Unpacking / freezing precious stones in a ruby ​​application without rails

I am writing a ruby ​​non-Rails application (gasp!) And would like to be able to include all the dependencies that applications require in a vendor subdirectory. This will be similar to how http://gemsonrails.rubyforge.org/ works for Rails applications.

The goal is to avoid the situation that my team faces when adding a new dependency. Each developer on my team must manually install the gem, and then someone must manually update each test and intermediate and production machine. If we can freeze the dependencies in the most distributed application, then a simple svn update (or git pull for these hipsters in the crowd) will be all that is needed.

+3
source share
1 answer

UPDATE (new solution):

Try Yehuda Katz new bundler gem. gem install bundlerthen create Gemfilewith all your dependencies. See the documentation for more details.

Old Recommendation:

- vendor lib $LOAD_PATH.

:

$ cd vendor/gems
$ gem unpack active_support
Unpacked gem: '/path/to/myproject/vendor/gems/activesupport-2.3.2'

, ( ).

/ $LOAD_PATH, - :

Dir.glob(File.join("vendor", "gems", "*", "lib")).each do |lib|
  $LOAD_PATH.unshift(File.expand_path(lib))
end

: ( ) , GEM_PATH. :

require 'rubygems'
gem_paths = [File.expand_path(File.join("vendor", "gems")),  Gem.default_dir]
Gem.clear_paths
Gem.send :set_paths, gem_paths.join(":")

Rip (Rubys Intelligent Packaging) . , .

+4

Source: https://habr.com/ru/post/1712311/


All Articles