Class: Bundler::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/lock_jar/bundler.rb

Instance Method Summary collapse

Instance Method Details

#_lockjar_extended_to_lockObject



101
# File 'lib/lock_jar/bundler.rb', line 101

alias :_lockjar_extended_to_lock :to_lock

#to_lockObject



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/lock_jar/bundler.rb', line 102

def to_lock
  to_lock = _lockjar_extended_to_lock

  if LockJar::Bundler.skip_lock != true
    definition = Bundler.definition
    #if !definition.send( :nothing_changed? )
      gems_with_jars = []

      # load local Jarfile
      if File.exists?( 'Jarfile' )
        dsl = LockJar::Domain::JarfileDsl.create( File.expand_path( 'Jarfile' ) )
        gems_with_jars << 'jarfile:Jarfile'
      # Create new Dsl
      else
        dsl = LockJar::Domain::Dsl.new
      end

      definition.groups.each do |group|
        if ENV["DEBUG"]
          puts "[LockJar] Group #{group}:"
        end

        definition.specs_for( [group] ).each do |spec|
          gem_dir = spec.gem_dir

          jarfile = File.join( gem_dir, "Jarfile" )

          if File.exists?( jarfile )
            gems_with_jars << "gem:#{spec.name}"

            if ENV["DEBUG"]
              puts "[LockJar]   #{spec.name} has Jarfile"
            end

            spec_dsl = LockJar::Domain::GemDsl.create( spec, "Jarfile" )

            dsl = LockJar::Domain::DslHelper.merge( dsl, spec_dsl, group.to_s )
          end
        end

      end

      puts "[LockJar] Locking Jars for: #{gems_with_jars.inspect}"
      LockJar.lock( dsl )
    #elsif ENV["DEBUG"]
    #  puts "[LockJar] Locking skiped, Gemfile has not changed"
    #end
  end

  to_lock
end