lock_jar 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +16 -0
  3. data/.rubocop.yml +28 -0
  4. data/.travis.yml +12 -1
  5. data/Gemfile +6 -3
  6. data/Guardfile +2 -3
  7. data/README.md +17 -16
  8. data/Rakefile +11 -7
  9. data/lib/lock_jar/buildr.rb +95 -89
  10. data/lib/lock_jar/bundler.rb +85 -84
  11. data/lib/lock_jar/class_loader.rb +19 -21
  12. data/lib/lock_jar/cli.rb +32 -25
  13. data/lib/lock_jar/domain/artifact.rb +39 -45
  14. data/lib/lock_jar/domain/dsl.rb +50 -79
  15. data/lib/lock_jar/domain/dsl_merger.rb +76 -0
  16. data/lib/lock_jar/domain/gem_dsl.rb +10 -12
  17. data/lib/lock_jar/domain/jarfile_dsl.rb +6 -18
  18. data/lib/lock_jar/domain/lockfile.rb +17 -24
  19. data/lib/lock_jar/logging.rb +4 -3
  20. data/lib/lock_jar/maven.rb +29 -29
  21. data/lib/lock_jar/registry.rb +52 -60
  22. data/lib/lock_jar/resolver.rb +17 -20
  23. data/lib/lock_jar/runtime/install.rb +28 -0
  24. data/lib/lock_jar/runtime/list.rb +55 -0
  25. data/lib/lock_jar/runtime/load.rb +54 -0
  26. data/lib/lock_jar/runtime/lock.rb +152 -0
  27. data/lib/lock_jar/runtime.rb +30 -302
  28. data/lib/lock_jar/version.rb +2 -1
  29. data/lib/lock_jar.rb +137 -105
  30. data/lock_jar.gemspec +7 -4
  31. data/spec/fixtures/jarfile_gem/Gemfile +4 -0
  32. data/spec/fixtures/jarfile_gem/Jarfile +1 -0
  33. data/spec/fixtures/jarfile_gem/jarfile_gem.gemspec +23 -0
  34. data/spec/fixtures/jarfile_gem/lib/jarfile_gem/version.rb +3 -0
  35. data/spec/fixtures/jarfile_gem/lib/jarfile_gem.rb +5 -0
  36. data/spec/lock_jar/bundler_spec.rb +27 -0
  37. data/spec/lock_jar/class_loader_spec.rb +34 -36
  38. data/spec/lock_jar/cli_spec.rb +39 -46
  39. data/spec/lock_jar/domain/dsl_merger_spec.rb +49 -0
  40. data/spec/lock_jar/domain/dsl_spec.rb +35 -37
  41. data/spec/lock_jar/domain/gem_dsl_spec.rb +18 -0
  42. data/spec/lock_jar/maven_spec.rb +9 -11
  43. data/spec/lock_jar/resolver_spec.rb +16 -17
  44. data/spec/lock_jar/runtime_spec.rb +17 -13
  45. data/spec/lock_jar_spec.rb +255 -195
  46. data/spec/spec_helper.rb +13 -8
  47. data/spec/support/helper.rb +13 -5
  48. data/spec/support/shared_examples/lockfile.rb +4 -6
  49. metadata +43 -19
  50. data/bundler/Gemfile +0 -21
  51. data/bundler/LICENSE.txt +0 -22
  52. data/bundler/README.md +0 -29
  53. data/bundler/Rakefile +0 -2
  54. data/bundler/lib/lock_jar_bundler/bundler.rb +0 -35
  55. data/bundler/lib/lock_jar_bundler/piggy_back.rb +0 -98
  56. data/bundler/lib/lock_jar_bundler/version.rb +0 -5
  57. data/bundler/lib/lock_jar_bundler.rb +0 -5
  58. data/bundler/lock_jar_bundler.gemspec +0 -24
  59. data/bundler/spec/Jarfile +0 -3
  60. data/bundler/spec/dummy_gem/Jarfile +0 -1
  61. data/bundler/spec/dummy_gem/dummy_gem.gemspec +0 -19
  62. data/bundler/spec/lock_jar_bundler_spec.rb +0 -49
  63. data/bundler/spec/spec_helper.rb +0 -88
  64. data/lib/lock_jar/domain/dsl_helper.rb +0 -84
  65. data/spec/lock_jar/domain/dsl_helper_spec.rb +0 -52
data/lock_jar.gemspec CHANGED
@@ -9,7 +9,10 @@ Gem::Specification.new do |s|
9
9
  s.version = LockJar::VERSION
10
10
  s.authors = ['Michael Guymon']
11
11
  s.date = '2014-03-06'
12
- s.description = 'Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test. The Jarfile.lock can be used to populate the classpath'
12
+ s.description = 'Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile
13
+ is used to generate a Jarfile.lock that contains all the resolved jar dependencies
14
+ for scopes runtime, compile, and test. The Jarfile.lock can be used to populate the
15
+ classpath'
13
16
  s.email = 'michael@tobedevoured.com'
14
17
  s.files = `git ls-files -z`.split("\x0")
15
18
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -20,8 +23,8 @@ Gem::Specification.new do |s|
20
23
  s.require_paths = %w(lib)
21
24
  s.summary = 'Manage Jar files for Ruby'
22
25
 
23
- s.add_dependency(%q<naether>, ['~> 0.15.0'])
24
- s.add_dependency(%q<thor>, ['>= 0.18.1'])
25
-
26
+ s.add_dependency('naether', ['~> 0.15.0'])
27
+ s.add_dependency('thor', ['>= 0.18.1'])
28
+ s.add_development_dependency('rspec', '~> 2.14.1')
26
29
  s.add_development_dependency('rake')
27
30
  end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jarfile_gem.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ jar 'commons-lang:commons-lang:jar:2.4'
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jarfile_gem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jarfile_gem"
8
+ spec.version = JarfileGem::VERSION
9
+ spec.authors = ["Michael Guymon"]
10
+ spec.email = ["michael@tobedevoured.com"]
11
+ spec.summary = %q{a short summary.}
12
+ spec.description = %q{a longer description.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,3 @@
1
+ module JarfileGem
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "jarfile_gem/version"
2
+
3
+ module JarfileGem
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require 'lock_jar/bundler'
3
+
4
+ describe LockJar::Bundler do
5
+ include Spec::Helpers
6
+
7
+ before do
8
+ remove_file('Jarfile.lock')
9
+ LockJar::Bundler.lock!('spec/fixtures/Jarfile')
10
+ end
11
+
12
+ describe '.lock!' do
13
+ it 'should create Jarfile.lock' do
14
+ expect(File).to exist('Jarfile.lock')
15
+ end
16
+ end
17
+
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)
25
+ end
26
+ end
27
+ end
@@ -1,56 +1,54 @@
1
1
  require 'spec_helper'
2
2
  require 'lock_jar/class_loader'
3
3
 
4
-
5
- describe LockJar::ClassLoader, "#isolate" do
6
-
4
+ describe LockJar::ClassLoader, '#isolate' do
7
5
  if Naether.platform != 'java'
8
- pending "need tests for RJB backed classloader"
6
+ pending 'need tests for RJB backed classloader'
9
7
  else
10
- it "should create a SimpleEmail" do
11
- # Generate the IsolateJarfile.lock
12
- LockJar.lock( :lockfile => "#{TEMP_DIR}/IsolateJarfile.lock" ) do
13
- jar 'org.apache.commons:commons-email:1.2'
8
+ it 'should create a SimpleEmail' do
9
+ # Generate the IsolateJarfile.lock
10
+ LockJar.lock(lockfile: "#{TEMP_DIR}/IsolateJarfile.lock") do
11
+ jar 'org.apache.commons:commons-email:1.2'
14
12
  end
15
-
16
- email = LockJar::ClassLoader.new( "#{TEMP_DIR}/IsolateJarfile.lock" ).isolate do
17
- email = new_instance( 'org.apache.commons.mail.SimpleEmail' )
18
- email.setSubject( 'test subject' )
19
-
20
- email
13
+
14
+ email = LockJar::ClassLoader.new("#{TEMP_DIR}/IsolateJarfile.lock").isolate do
15
+ email = new_instance('org.apache.commons.mail.SimpleEmail')
16
+ email.setSubject('test subject')
17
+
18
+ email
21
19
  end
22
-
23
- email.getSubject().should eql 'test subject'
24
-
20
+
21
+ email.getSubject.should eql 'test subject'
22
+
25
23
  unless $CLASSPATH.nil?
26
24
  $CLASSPATH.to_a.join(' ').should_not =~ /commons-email-1\.2\.jar/
27
25
  end
28
-
26
+
29
27
  expect { org.apache.commons.mail.SimpleEmail.new }.to raise_error
30
28
  end
31
-
32
- it "should create a JsonFactory and ObjectMapper" do
33
- # Generate the IsolateJarfile.lock
34
- LockJar.lock( :lockfile => "#{TEMP_DIR}/IsolateJarfile.lock" ) do
35
- jar 'com.fasterxml.jackson.core:jackson-core:2.0.6'
36
- jar 'com.fasterxml.jackson.core:jackson-databind:2.0.6'
29
+
30
+ it 'should create a JsonFactory and ObjectMapper' do
31
+ # Generate the IsolateJarfile.lock
32
+ LockJar.lock(lockfile: "#{TEMP_DIR}/IsolateJarfile.lock") do
33
+ jar 'com.fasterxml.jackson.core:jackson-core:2.0.6'
34
+ jar 'com.fasterxml.jackson.core:jackson-databind:2.0.6'
37
35
  end
38
-
39
- json = '{ "test1": "1test1", "test2": "2test2"}'
40
-
41
- map = LockJar::ClassLoader.new( "#{TEMP_DIR}/IsolateJarfile.lock" ).isolate do
42
- factory = new_instance( 'com.fasterxml.jackson.core.JsonFactory' )
43
- mapper = new_instance( 'com.fasterxml.jackson.databind.ObjectMapper', factory)
44
- mapper.readValue(json, java.util.Map.java_class)
36
+
37
+ json = '{ "test1": "1test1", "test2": "2test2" }'
38
+
39
+ map = LockJar::ClassLoader.new("#{TEMP_DIR}/IsolateJarfile.lock").isolate do
40
+ factory = new_instance('com.fasterxml.jackson.core.JsonFactory')
41
+ mapper = new_instance('com.fasterxml.jackson.databind.ObjectMapper', factory)
42
+ mapper.readValue(json, java.util.Map.java_class)
45
43
  end
46
-
47
- map.get('test1').should eql "1test1"
48
- map.get('test2').should eql "2test2"
49
-
44
+
45
+ map.get('test1').should eql '1test1'
46
+ map.get('test2').should eql '2test2'
47
+
50
48
  unless $CLASSPATH.nil?
51
49
  $CLASSPATH.to_a.join(' ').should_not =~ /jackson-databind-2\.0\.6\.jar/
52
50
  end
53
-
51
+
54
52
  expect { com.fasterxml.jackson.core.JsonFactory.new }.to raise_error
55
53
  end
56
54
  end
@@ -1,69 +1,64 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "lockjar" do
4
-
3
+ describe 'lockjar' do
5
4
  include Spec::Helpers
6
5
 
7
- before(:all) do
6
+ before do
8
7
  install_jarfile <<-J
9
- jar "com.google.guava:guava:14.0.1"
8
+ jar 'com.google.guava:guava:14.0.1'
10
9
  J
11
10
  end
12
11
 
13
- after(:all) do
14
- FileUtils.rm("Jarfile")
15
- FileUtils.rm("Jarfile.lock") rescue nil
12
+ after do
13
+ remove_file('Jarfile')
14
+ remove_file('Jarfile.lock')
16
15
  end
17
16
 
18
- context "version" do
19
-
20
- it "should return correct version" do
21
- lockjar "version"
17
+ context 'version' do
18
+ it 'should return correct version' do
19
+ lockjar 'version'
22
20
  expect(@out).to eq(LockJar::VERSION)
23
21
  end
24
22
  end
25
23
 
26
- context "lock" do
27
- it "should create lock file with default path" do
28
- FileUtils.rm("Jarfile.lock") rescue nil
29
- lockjar "lock"
24
+ context 'lock' do
25
+ it 'should create lock file with default path' do
26
+ lockjar 'lock'
30
27
  expect(@out).to match(/^Locking Jarfile to Jarfile.lock.*/)
31
- expect(File.exists?("Jarfile.lock")).to be_true
28
+ expect(File).to exist('Jarfile.lock')
32
29
  end
33
30
 
34
- it "should create lock file with specific path" do
35
- jarfile_path = File.join("spec", "support", "Jarfile")
36
- jarfile_lock_path = File.join("spec", "support", "Jarfile.lock")
37
- FileUtils.rm(jarfile_lock_path) rescue nil
31
+ it 'should create lock file with specific path' do
32
+ jarfile_path = File.join('spec', 'support', 'Jarfile')
33
+ jarfile_lock_path = File.join('spec', 'support', 'Jarfile.lock')
34
+ remove_file(jarfile_lock_path)
38
35
 
39
36
  lockjar "lock -j #{jarfile_path} -l #{jarfile_lock_path}"
40
37
  expect(@out).to eq("Locking #{jarfile_path} to #{jarfile_lock_path}")
41
- expect(File.exists?(jarfile_lock_path)).to be_true
38
+ expect(File).to exist(jarfile_lock_path)
42
39
  end
43
40
  end
44
41
 
45
- context "list" do
46
-
47
- it "should list with default path" do
48
- FileUtils.rm("Jarfile.lock") rescue nil
49
- lockjar "lock"
42
+ context 'list' do
43
+ it 'should list with default path' do
44
+ lockjar 'lock'
50
45
 
51
- expect_output =<<-EOM.strip
46
+ expect_output = %(
52
47
  Listing Jars from Jarfile.lock for ["default"]
53
48
  ["com.google.guava:guava:jar:14.0.1"]
54
- EOM
49
+ ).strip
55
50
 
56
- lockjar "list"
51
+ lockjar 'list'
57
52
  expect(@out).to eq(expect_output)
58
53
  end
59
54
 
60
- it "should list with specific path" do
61
- jarfile_path = File.join("spec", "support", "Jarfile")
62
- jarfile_lock_path = File.join("spec", "support", "Jarfile.lock")
63
- FileUtils.rm(jarfile_lock_path) rescue nil
55
+ it 'should list with specific path' do
56
+ jarfile_path = File.join('spec', 'support', 'Jarfile')
57
+ jarfile_lock_path = File.join('spec', 'support', 'Jarfile.lock')
58
+ remove_file(jarfile_lock_path)
64
59
  lockjar "lock -j #{jarfile_path} -l #{jarfile_lock_path}"
65
60
 
66
- expect_expr = Regexp.new(<<-'EOM'.strip)
61
+ expect_expr = Regexp.new(<<-'EOM'.strip)
67
62
  Listing Jars from .*Jarfile.lock for \["default"\]
68
63
  \["com.google.guava:guava:jar:14.0.1"\]
69
64
  EOM
@@ -73,28 +68,26 @@ EOM
73
68
  end
74
69
  end
75
70
 
76
- context "install" do
77
- it "should install jar archives with default path" do
78
- FileUtils.rm("Jarfile.lock") rescue nil
79
- lockjar "lock"
71
+ context 'install' do
72
+ it 'should install jar archives with default path' do
73
+ lockjar 'lock'
80
74
 
81
- lockjar "install"
82
- expect(@out).to eq("Installing Jars from Jarfile.lock for [\"default\"]")
75
+ lockjar 'install'
76
+ expect(@out).to eq(%(Installing Jars from Jarfile.lock for ["default"]))
83
77
  LockJar.load
84
78
  expect(Java::ComGoogleCommonCollect::Multimap).to be_kind_of(Module) if is_jruby?
85
79
  end
86
80
 
87
- it "should install jar archives with specific path" do
88
- jarfile_path = File.join("spec", "support", "Jarfile")
89
- jarfile_lock_path = File.join("spec", "support", "Jarfile.lock")
90
- FileUtils.rm(jarfile_lock_path) rescue nil
81
+ it 'should install jar archives with specific path' do
82
+ jarfile_path = File.join('spec', 'support', 'Jarfile')
83
+ jarfile_lock_path = File.join('spec', 'support', 'Jarfile.lock')
84
+ remove_file(jarfile_lock_path)
91
85
  lockjar "lock -j #{jarfile_path} -l #{jarfile_lock_path}"
92
86
 
93
87
  lockjar "install -l #{jarfile_lock_path}"
94
- expect(@out).to eq("Installing Jars from #{jarfile_lock_path} for [\"default\"]")
88
+ expect(@out).to eq(%(Installing Jars from #{jarfile_lock_path} for ["default"]))
95
89
  LockJar.load(jarfile_lock_path)
96
90
  expect(Java::ComGoogleCommonCollect::Multimap).to be_kind_of(Module) if is_jruby?
97
91
  end
98
92
  end
99
-
100
93
  end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ require 'lock_jar/domain/dsl_merger'
4
+
5
+ describe LockJar::Domain::DslMerger do
6
+ it 'should merge dsl' do
7
+ block1 = LockJar::Domain::Dsl.create do
8
+ repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
9
+
10
+ jar 'org.apache.mina:mina-core:2.0.4'
11
+ pom 'spec/pom.xml'
12
+
13
+ group 'runtime' do
14
+ jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
15
+ end
16
+
17
+ group 'test' do
18
+ jar 'junit:junit:jar:4.10'
19
+ end
20
+ end
21
+
22
+ block2 = LockJar::Domain::Dsl.create do
23
+ repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
24
+ repository 'http://new-repo'
25
+
26
+ jar 'org.apache.mina:mina-core:2.0.4'
27
+ jar 'compile-jar'
28
+
29
+ group 'runtime' do
30
+ jar 'runtime-jar'
31
+ pom 'runtime-pom.xml'
32
+ end
33
+
34
+ group 'test' do
35
+ jar 'test-jar'
36
+ pom 'test-pom.xml'
37
+ end
38
+ end
39
+
40
+ dsl = LockJar::Domain::DslMerger.new(block1, block2).merge
41
+
42
+ expect(dsl.artifacts['default']).to eq([
43
+ LockJar::Domain::Jar.new('org.apache.mina:mina-core:2.0.4'),
44
+ LockJar::Domain::Pom.new('spec/pom.xml', %w(runtime compile)),
45
+ LockJar::Domain::Jar.new('compile-jar')
46
+ ])
47
+ dsl.remote_repositories.should eql(['http://repository.jboss.org/nexus/content/groups/public-jboss', 'http://new-repo'])
48
+ end
49
+ end
@@ -2,56 +2,54 @@ require 'spec_helper'
2
2
  require 'lock_jar/domain/artifact'
3
3
 
4
4
  describe LockJar::Domain::Dsl do
5
- context "Instance" do
6
- it "should load a Jarfile" do
7
- jarfile = LockJar::Domain::Dsl.create( "spec/fixtures/Jarfile" )
8
-
5
+ describe '.create' do
6
+ it 'should load a Jarfile' do
7
+ jarfile = LockJar::Domain::Dsl.create('spec/fixtures/Jarfile')
8
+
9
9
  jarfile.local_repository.should eql '~/.m2/repository'
10
- jarfile.artifacts["default"][0].should == LockJar::Domain::Jar.new("org.apache.mina:mina-core:2.0.4")
11
- jarfile.artifacts["default"][1].should == LockJar::Domain::Local.new("spec/fixtures/naether-0.13.0.jar")
12
- jarfile.artifacts["default"][2].path.should eql "spec/pom.xml"
13
- jarfile.artifacts["default"][3].should be_nil
14
-
15
- jarfile.artifacts["development"][0].should == LockJar::Domain::Jar.new("com.typesafe:config:jar:0.5.0")
16
- jarfile.artifacts["development"][1].should be_nil
17
-
18
- jarfile.artifacts["test"][0].should == LockJar::Domain::Jar.new("junit:junit:jar:4.10")
19
- jarfile.artifacts["test"][1].should be_nil
20
-
21
- jarfile.remote_repositories.should eql( ['http://mirrors.ibiblio.org/pub/mirrors/maven2'] )
10
+ expect(jarfile.artifacts['default'][0]).to eq LockJar::Domain::Jar.new('org.apache.mina:mina-core:2.0.4')
11
+ expect(jarfile.artifacts['default'][1]).to eq LockJar::Domain::Local.new('spec/fixtures/naether-0.13.0.jar')
12
+ jarfile.artifacts['default'][2].path.should eql 'spec/pom.xml'
13
+ jarfile.artifacts['default'][3].should be_nil
14
+
15
+ expect(jarfile.artifacts['development'][0]).to eq LockJar::Domain::Jar.new('com.typesafe:config:jar:0.5.0')
16
+ jarfile.artifacts['development'][1].should be_nil
17
+
18
+ expect(jarfile.artifacts['test'][0]).to eq LockJar::Domain::Jar.new('junit:junit:jar:4.10')
19
+ jarfile.artifacts['test'][1].should be_nil
20
+
21
+ jarfile.remote_repositories.should eql(['http://mirrors.ibiblio.org/pub/mirrors/maven2'])
22
22
  end
23
-
24
- it "should load a block" do
25
- block = LockJar::Domain::Dsl.create do
23
+
24
+ it 'should load a block' do
25
+ block = LockJar::Domain::Dsl.create do
26
26
  local_repo '~/.m2'
27
27
  repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
28
-
29
- jar "org.apache.mina:mina-core:2.0.4"
30
- local "spec/fixtures/naether-0.13.0.jar"
28
+
29
+ jar 'org.apache.mina:mina-core:2.0.4'
30
+ local 'spec/fixtures/naether-0.13.0.jar'
31
31
  pom 'spec/pom.xml'
32
-
32
+
33
33
  group 'pirate' do
34
- jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
34
+ jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
35
35
  end
36
-
36
+
37
37
  group 'test' do
38
- jar 'junit:junit:jar:4.10'
38
+ jar 'junit:junit:jar:4.10'
39
39
  end
40
40
  end
41
-
41
+
42
42
  block.local_repository.should eql '~/.m2'
43
- block.artifacts.should == {
44
- "default" => [LockJar::Domain::Jar.new("org.apache.mina:mina-core:2.0.4"), LockJar::Domain::Local.new("spec/fixtures/naether-0.13.0.jar"), LockJar::Domain::Pom.new("spec/pom.xml")],
45
- "pirate" => [LockJar::Domain::Jar.new("org.apache.tomcat:servlet-api:jar:6.0.35")],
46
- "test" => [LockJar::Domain::Jar.new("junit:junit:jar:4.10")]
47
- }
48
- block.remote_repositories.should eql( ["http://repository.jboss.org/nexus/content/groups/public-jboss"] )
49
-
43
+ expect(block.artifacts).to eq(
44
+ 'default' => [LockJar::Domain::Jar.new('org.apache.mina:mina-core:2.0.4'), LockJar::Domain::Local.new('spec/fixtures/naether-0.13.0.jar'), LockJar::Domain::Pom.new('spec/pom.xml')],
45
+ 'pirate' => [LockJar::Domain::Jar.new('org.apache.tomcat:servlet-api:jar:6.0.35')],
46
+ 'test' => [LockJar::Domain::Jar.new('junit:junit:jar:4.10')]
47
+ )
48
+ block.remote_repositories.should eql(['http://repository.jboss.org/nexus/content/groups/public-jboss'])
50
49
  end
51
-
52
- it "should raise an error without arguments" do
50
+
51
+ it 'should raise an error without arguments' do
53
52
  lambda { LockJar::Domain::Dsl.create }.should raise_error
54
53
  end
55
-
56
54
  end
57
55
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'lock_jar/domain/gem_dsl'
3
+
4
+ describe LockJar::Domain::GemDsl do
5
+ describe '.create' do
6
+ let(:spec) do
7
+ double(:spec, gem_dir: 'spec/fixtures', name: 'test')
8
+ end
9
+
10
+ it 'should create from a block' do
11
+ jarfile = LockJar::Domain::GemDsl.create(spec, File.join(spec.gem_dir, 'Jarfile')) do
12
+ pom 'pom.xml'
13
+ end
14
+
15
+ expect(jarfile.gem_dir).to eql 'spec/fixtures'
16
+ end
17
+ end
18
+ end
@@ -8,16 +8,14 @@ describe LockJar::Maven do
8
8
  # Bootstrap Naether
9
9
  Naether::Bootstrap.bootstrap_local_repo
10
10
  end
11
-
12
- context "Class" do
13
- it "should get pom version" do
14
- LockJar::Maven.pom_version( "spec/pom.xml" ).should eql( "3" )
15
- end
16
-
17
- it "should install artifact" do
18
- LockJar::Maven.install( "maven_spec:install:7", "spec/pom.xml", nil, :local_repo => "#{TEMP_DIR}/test-repo" )
19
-
20
- File.exists?( "#{TEMP_DIR}/test-repo/maven_spec/install/7/install-7.pom" ).should be_true
21
- end
11
+
12
+ it 'should get pom version' do
13
+ LockJar::Maven.pom_version('spec/pom.xml').should eql('3')
14
+ end
15
+
16
+ it 'should install artifact' do
17
+ LockJar::Maven.install('maven_spec:install:7', 'spec/pom.xml', nil, local_repo: "#{TEMP_DIR}/test-repo")
18
+
19
+ File.exist?("#{TEMP_DIR}/test-repo/maven_spec/install/7/install-7.pom").should be_true
22
20
  end
23
21
  end
@@ -4,23 +4,22 @@ require 'fileutils'
4
4
  require 'naether'
5
5
 
6
6
  describe LockJar::Resolver do
7
- context "Instance" do
8
- before(:each) do
9
- FileUtils.mkdir_p( "#{TEMP_DIR}/test-repo" )
10
- @resolver = LockJar::Resolver.new( :local_repo => "#{TEMP_DIR}/test-repo" )
11
- end
12
-
13
- it "should bootstrap naether" do
14
- deps = Naether::Bootstrap.check_local_repo_for_deps( "#{TEMP_DIR}/test-repo" )
15
- deps[:missing].should eql([])
16
- deps[:exists].each do |dep|
17
- dep.values[0].should match /#{TEMP_DIR}#{File::SEPARATOR}test-repo#{File::SEPARATOR}.+/
18
- end
19
- end
20
-
21
- it "should return local paths for notations" do
22
- @resolver.to_local_paths( ["junit:junit:jar:4.10"] ).should
23
- eql( [File.expand_path("#{TEMP_DIR}/test-repo/junit/junit/4.10/junit-4.10.jar")] )
7
+ before(:each) do
8
+ FileUtils.mkdir_p("#{TEMP_DIR}/test-repo")
9
+ @resolver = LockJar::Resolver.new(local_repo: "#{TEMP_DIR}/test-repo")
10
+ end
11
+
12
+ it 'should bootstrap naether' do
13
+ deps = Naether::Bootstrap.check_local_repo_for_deps("#{TEMP_DIR}/test-repo")
14
+ deps[:missing].should eql([])
15
+ deps[:exists].each do |dep|
16
+ expect(dep.values[0]).to match(/#{TEMP_DIR}#{File::SEPARATOR}test-repo#{File::SEPARATOR}.+/)
24
17
  end
25
18
  end
19
+
20
+ it 'should return local paths for notations' do
21
+ expect(@resolver.to_local_paths(['junit:junit:jar:4.10'])).to(
22
+ eql([File.expand_path("#{TEMP_DIR}/test-repo/junit/junit/4.10/junit-4.10.jar")])
23
+ )
24
+ end
26
25
  end
@@ -2,25 +2,29 @@ require 'spec_helper'
2
2
  require 'lock_jar/runtime'
3
3
 
4
4
  describe LockJar::Runtime do
5
- context "Singleton" do
6
- it "should set local repo" do
7
- LockJar::Runtime.instance.load( nil, [], :resolve => true, :local_repo => TEST_REPO ) do
5
+ describe '#load' do
6
+ it 'should set local repo' do
7
+ LockJar::Runtime.instance.load(nil, [], resolve: true, local_repo: TEST_REPO) do
8
8
  jar 'junit:junit:4.10'
9
9
  end
10
-
10
+
11
11
  LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql TEST_REPO
12
-
13
- LockJar::Runtime.instance.load( nil, [], :local_repo => PARAM_CONFIG ) do
14
- local_repo 'dsl_config'
15
- end
16
-
17
- LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql PARAM_CONFIG
18
-
19
- LockJar::Runtime.instance.load( nil ) do
12
+ end
13
+
14
+ it 'should use the local repo from the dsl' do
15
+ LockJar::Runtime.instance.load(nil) do
20
16
  local_repo DSL_CONFIG
21
17
  end
22
-
18
+
23
19
  LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql DSL_CONFIG
24
20
  end
21
+
22
+ it 'should use the local repo from param' do
23
+ LockJar::Runtime.instance.load(nil, [], local_repo: PARAM_CONFIG) do
24
+ local_repo 'dsl_config'
25
+ end
26
+
27
+ LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql PARAM_CONFIG
28
+ end
25
29
  end
26
30
  end