lock_jar 0.14.2 → 0.14.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89e8000e6eabfa436d403adf58c2df66c89f2939
4
- data.tar.gz: de15e6014fadc83bee21a403ca80cb25d595849d
3
+ metadata.gz: 795a7aedb78dcc0d8913b25fb263617d4018e707
4
+ data.tar.gz: f09a029a84c9a0123292473cde5110ec502299c9
5
5
  SHA512:
6
- metadata.gz: f6a3d83e53fa5759b2b0099e9325e87a183f46e37047d6b92741f169f2f46fadc5890c481014da4a7140f4a8555d9c55ca4d941728e3a4f45c1415fd549ceda7
7
- data.tar.gz: 65d1ea5290e981d89f32066d37fbac6a91626744d130e58c1cb1ca96d9e7227555130ceca93927b3a06c58615599a98010a21fdbcb7605fe6ddb31c6364df1c2
6
+ metadata.gz: 833e4bda38e0332690a916ea0641463f589ccab70a245f0f4bf56e2757ae15fe604f8757463d94238cb3f63703ba3f8f2d1398ac3841f9d04d25376ab37e8fb1
7
+ data.tar.gz: 09b4ca6624b2f03b173309d2dd2e630e1f744b29050163671e6db0ab1a2e137b6788779df2fd4063ecb9da35d5ad6d95b554a6fb2cccc4ce2fc3dc70d917577f
@@ -10,41 +10,18 @@ module LockJar
10
10
  #
11
11
  class Bundler
12
12
  class << self
13
- attr_accessor :skip_lock
13
+ # Patch Bundler::Definition.to_lock to run LockJar::Bundler.lock!
14
+ def lock_with_bundler(*opts)
15
+ ::Bundler::Definition.class_eval do
16
+ alias_method :_lockjar_extended_to_lock, :to_lock
17
+ define_method(:to_lock) do
18
+ result = _lockjar_extended_to_lock
14
19
 
15
- def load(*groups)
16
- return if groups.empty? || !File.exist?('Jarfile.lock')
20
+ LockJar::Bundler.lock!(opts)
17
21
 
18
- lockfile = LockJar::Domain::Lockfile.read('Jarfile.lock')
19
-
20
- # expand merged paths to include gem base path
21
- unless lockfile.merged.empty?
22
- lockfile.merged = LockJar::Bundler.expand_gem_paths(lockfile.merged)
23
- end
24
-
25
- LockJar.load(lockfile, groups)
26
-
27
- puts(
28
- '[LockJar] Loaded Jars for #{groups.inspect}: '\
29
- "#{LockJar::Registry.instance.loaded_jars.inspect}"
30
- ) if ENV['DEBUG']
31
- end
32
-
33
- def expand_gem_paths(merged)
34
- merged_gem_paths = []
35
- Gem.path.each do |gem_root|
36
- merged.each do |merge|
37
- next unless merge.start_with? 'gem:'
38
-
39
- # merged gems follow the notation: gem:gemname:path
40
- gem_path = merge.gsub(/^gem:.+:/, '')
41
- gem_path = File.join(gem_root, gem_path)
42
-
43
- merged_gem_paths << gem_path if File.exist? gem_path
22
+ result
44
23
  end
45
24
  end
46
-
47
- merged_gem_paths
48
25
  end
49
26
 
50
27
  # Create a lock file from bundled gems
@@ -99,62 +76,3 @@ module LockJar
99
76
  end
100
77
  end
101
78
  end
102
-
103
- # Patch Bundler module to allow LockJar to lock and load when Bundler is run
104
- module Bundler
105
- class << self
106
- alias_method :_lockjar_extended_require, :require
107
- def require(*groups)
108
- LockJar::Bundler.load(*groups)
109
-
110
- LockJar::Bundler.skip_lock = true
111
-
112
- _lockjar_extended_require
113
- end
114
-
115
- alias_method :_lockjar_extended_setup, :setup
116
- def setup(*groups)
117
- LockJar::Bundler.load(*groups)
118
-
119
- LockJar::Bundler.skip_lock = true
120
-
121
- _lockjar_extended_setup
122
- end
123
- end
124
-
125
- # Patch Bundler::Runtime.require and Bundler::Runtime.setup to execute
126
- # Lockjar::Bundler.load
127
- class Runtime
128
- alias_method :_lockjar_extended_require, :require
129
- def require(*groups)
130
- LockJar::Bundler.load(*groups)
131
-
132
- LockJar::Bundler.skip_lock = true
133
-
134
- _lockjar_extended_require
135
- end
136
-
137
- alias_method :_lockjar_extended_setup, :setup
138
- def setup(*groups)
139
- LockJar::Bundler.load(*groups)
140
-
141
- LockJar::Bundler.skip_lock = true
142
-
143
- _lockjar_extended_setup
144
- end
145
- end
146
-
147
- # Patch Bundler::Definition.to_lock to run LockJar::Bundler.lock!
148
- class Definition
149
- alias_method :_lockjar_extended_to_lock, :to_lock
150
- def to_lock
151
- result = _lockjar_extended_to_lock
152
-
153
- return result if LockJar::Bundler.skip_lock
154
-
155
- LockJar::Bundler.lock!
156
-
157
- result
158
- end
159
- end
160
- end
@@ -1,4 +1,4 @@
1
1
  # the version
2
2
  module LockJar
3
- VERSION = '0.14.2'
3
+ VERSION = '0.14.3'
4
4
  end
@@ -1,27 +1,27 @@
1
1
  require 'spec_helper'
2
2
  require 'lock_jar/bundler'
3
+ require 'bundler/cli'
4
+ require 'bundler/cli/install'
3
5
 
4
6
  describe LockJar::Bundler do
5
7
  include Spec::Helpers
6
8
 
7
- before do
8
- remove_file('Jarfile.lock')
9
- LockJar::Bundler.lock!('spec/fixtures/Jarfile')
10
- end
11
-
12
9
  describe '.lock!' do
10
+ before do
11
+ remove_file('Jarfile.lock')
12
+ LockJar::Bundler.lock!('spec/fixtures/Jarfile')
13
+ end
14
+
13
15
  it 'should create Jarfile.lock' do
14
16
  expect(File).to exist('Jarfile.lock')
15
17
  end
16
18
  end
17
19
 
18
- describe '.load' do
19
- it 'should load jars' do
20
- LockJar::Bundler.load('test')
21
-
22
- expected_jars = %w(junit:junit:jar:4.10 org.hamcrest:hamcrest-core:jar:1.1)
23
-
24
- expect(LockJar::Registry.instance.loaded_jars).to eql(expected_jars)
20
+ describe '.lock_with_bundler' do
21
+ it 'should call lock! from Bundler' do
22
+ LockJar::Bundler.lock_with_bundler(test: :arg)
23
+ expect(LockJar::Bundler).to receive(:lock!).with([{ test: :arg }])
24
+ ::Bundler::CLI::Install.new({}).run
25
25
  end
26
26
  end
27
27
  end
@@ -287,15 +287,14 @@ describe LockJar do
287
287
  end
288
288
 
289
289
  describe '#lock_registered_jarfiles' do
290
+ let(:lockfile) { "#{TEMP_DIR}/Jarfile.lock" }
291
+ let(:lock_registered_jarfiles) { LockJar.lock_registered_jarfiles lockfile: lockfile }
292
+
290
293
  after do
291
294
  LockJar.reset_registered_jarfiles
292
295
  end
293
296
 
294
- let(:lock_registered_jarfiles) { LockJar.lock_registered_jarfiles lockfile: lockfile }
295
-
296
297
  context 'with LRJJarfile1.lock' do
297
- let(:lockfile) { "#{TEMP_DIR}/LRJJarfile1.lock" }
298
-
299
298
  before do
300
299
  File.unlink lockfile if File.exist? lockfile
301
300
  end
@@ -307,8 +306,6 @@ describe LockJar do
307
306
  end
308
307
 
309
308
  context 'with multiple lockfiles' do
310
- let(:lockfile) { "#{TEMP_DIR}/LRJJarfile2.lock" }
311
-
312
309
  before do
313
310
  LockJar.register_jarfile 'spec/fixtures/Jarfile'
314
311
  LockJar.register_jarfile 'spec/fixtures/Jarfile2'
@@ -327,12 +324,11 @@ describe LockJar do
327
324
  end
328
325
 
329
326
  context 'with gem lockfiles' do
330
- let(:lockfile) { "#{TEMP_DIR}/Jarfile.lock" }
331
327
  let(:gem_spec) { Gem::Specification.find_by_name('jarfile_gem') }
332
328
  let(:lock_registered_jarfiles) { LockJar.lock_registered_jarfiles lockfile: lockfile }
333
329
 
334
330
  before do
335
- LockJar.register_jarfile File.join(gem_spec.full_gem_path, 'Jarfile'), gem_spec
331
+ LockJar.register_jarfile 'spec/fixtures/jarfile_gem/Jarfile', gem_spec
336
332
  File.unlink lockfile if File.exist? lockfile
337
333
  end
338
334
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lock_jar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Guymon