# Packaging common code with gems

**URL:** <https://www.ruby-forum.com/t/packaging-common-code-with-gems/189727>\
**Category:** Ruby\
**Created:** [June 6, 2010, 10:45am UTC](https://www.ruby-forum.com/t/packaging-common-code-with-gems/189727 "2010-06-06T10:45:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sentinel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sentinel](https://www.ruby-forum.com/u/sentinel)\
**Post date:** [June 6, 2010, 10:45am UTC](https://www.ruby-forum.com/t/packaging-common-code-with-gems/189727/1 "2010-06-06T10:45:20Z")

</div>

Let’s say I have some common code, I use in various scripts or ruby  
apps. I’ve got it in a common folder which I’ve put in my RUBYLIB  
environment variable.

In the old days (Java), I’d put this in (say) commons.jar, and  
distribute such jars with my apps. Now if i decide to put these apps on  
github or create gems, how would i distribute the common code.

1. Should I keep copies with each app (more maintenance)
2. Should i create a common gem ?
3. Include these files in the gemspec (pointing to a folder outside the  
tree)

thx.

---

<div class="post-metadata">

**Author:** ![sentinel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sentinel](https://www.ruby-forum.com/u/sentinel)\
**Post date:** [June 6, 2010, 12:56pm UTC](https://www.ruby-forum.com/t/packaging-common-code-with-gems/189727/2 "2010-06-06T12:56:18Z")

</div>

On Jun 6, 4:45 am, “R… Kumar” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 1. Include these files in the gemspec (pointing to a folder outside the  
> tree)

#1 might not be so bad if you vendor them. That way there is no  
dependency but there is central management.

Otherwise #2 is a good option. #3 sounds like a very bad idea.

You might also consider, how common is common? Are these libs common  
enough that you might already find their equivalent in a support  
library like ActiveSupport or Facets? Where your common libs do not  
appear you mght even be able to contribute to those projects.

```
trans.

```

---

<div class="post-metadata">

**Author:** ![sentinel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sentinel](https://www.ruby-forum.com/u/sentinel)\
**Post date:** [June 7, 2010, 3:31am UTC](https://www.ruby-forum.com/t/packaging-common-code-with-gems/189727/3 "2010-06-07T03:31:53Z")

</div>

On 2010-06-06 01:45:23 -0700, R… Kumar said:

> 1. Include these files in the gemspec (pointing to a folder outside the  
> tree)
> 
> thx.

I would write a gem. You can create your own gem server very easily if  
you don’t want to publish it.

Rein H.

> **[Puppet Infrastructure & IT Automation at Scale | Puppet by Perforce](https://www.puppet.com/)**
>
> Puppet is the industry-leading automation solution for configuration management, compliance, CI/CD, patch management, IT automation, and more.

[http://reinh.com](http://reinh.com)

---

<div class="post-metadata">

**Author:** ![sentinel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sentinel](https://www.ruby-forum.com/u/sentinel)\
**Post date:** [June 6, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/packaging-common-code-with-gems/189727/4 "2010-06-06T13:10:39Z")

</div>

Thomas S. wrote:

> On Jun 6, 4:45ï¿½am, “R… Kumar” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > 1. Include these files in the gemspec (pointing to a folder outside the  
> > tree)
> 
> #1 might not be so bad if you vendor them. That way there is no  
> dependency but there is central management.
> 
> Otherwise #2 is a good option. #3 sounds like a very bad idea.
> 
> You might also consider, how common is common? Are these libs common  
> enough that you might already find their equivalent in a support  
> library like ActiveSupport or Facets? Where your common libs do not  
> appear you mght even be able to contribute to those projects.
> 
> ```
> trans.
> 
> ```

I haven’t looked at ActiveSupport. These are command line apps (not web  
stuff). These are not so common enough that Facets might have them.

I used Facets a few years back but lost touch with it. Is it 1.9  
compliant ?
