Class: LockJar::Bundler
- Inherits:
-
Object
- Object
- LockJar::Bundler
- Defined in:
- lib/lock_jar/bundler.rb
Class Method Summary collapse
-
.lock!(*opts) ⇒ Object
Create a lock file from bundled gems.
Class Method Details
.lock!(*opts) ⇒ Object
Create a lock file from bundled gems
rubocop:disable Metrics/PerceivedComplexity
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lock_jar/bundler.rb', line 16 def lock!(*opts) # check if Bundler has already run return unless ::Bundler.instance_variable_get('@setup').nil? dsl = nil jarfile_opt = opts.find { |option| option.is_a? String } jarfile = File.(jarfile_opt || 'Jarfile') # load local Jarfile dsl = if File.exist?(jarfile) LockJar::Domain::JarfileDsl.create(jarfile) # Create new Dsl else LockJar::Domain::Dsl.new end gems_with_jars = [] ::Bundler.definition.groups.each do |group| puts "[LockJar] Group #{group}:" if ENV['DEBUG'] ::Bundler.definition.specs_for([group]).each do |spec| next unless File.exist? File.join(spec.gem_dir, 'Jarfile') merged_dsl = merge_gem_dsl(dsl, spec, group) if merged_dsl gems_with_jars << "gem:#{spec.name}" dsl = merged_dsl end end end puts "[LockJar] Locking Jars for: #{gems_with_jars.inspect}" unless gems_with_jars.empty? LockJar.lock(*([dsl] + opts)) end |