lock_jar 0.14.2 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lock_jar/bundler.rb +8 -90
- data/lib/lock_jar/version.rb +1 -1
- data/spec/lock_jar/bundler_spec.rb +12 -12
- data/spec/lock_jar_spec.rb +4 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 795a7aedb78dcc0d8913b25fb263617d4018e707
|
4
|
+
data.tar.gz: f09a029a84c9a0123292473cde5110ec502299c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 833e4bda38e0332690a916ea0641463f589ccab70a245f0f4bf56e2757ae15fe604f8757463d94238cb3f63703ba3f8f2d1398ac3841f9d04d25376ab37e8fb1
|
7
|
+
data.tar.gz: 09b4ca6624b2f03b173309d2dd2e630e1f744b29050163671e6db0ab1a2e137b6788779df2fd4063ecb9da35d5ad6d95b554a6fb2cccc4ce2fc3dc70d917577f
|
data/lib/lock_jar/bundler.rb
CHANGED
@@ -10,41 +10,18 @@ module LockJar
|
|
10
10
|
#
|
11
11
|
class Bundler
|
12
12
|
class << self
|
13
|
-
|
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
|
-
|
16
|
-
return if groups.empty? || !File.exist?('Jarfile.lock')
|
20
|
+
LockJar::Bundler.lock!(opts)
|
17
21
|
|
18
|
-
|
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
|
data/lib/lock_jar/version.rb
CHANGED
@@ -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 '.
|
19
|
-
it 'should
|
20
|
-
LockJar::Bundler.
|
21
|
-
|
22
|
-
|
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
|
data/spec/lock_jar_spec.rb
CHANGED
@@ -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
|
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
|
|