lock_jar 0.3.0 → 0.3.1

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.
data/README.rdoc CHANGED
@@ -46,7 +46,11 @@ Example Jarfile
46
46
 
47
47
  ==== Resolving dependencies
48
48
 
49
- * LockJar.lock( jarfile = 'Jarfile', opts = {} ): Using a Jarfile, creates a lock file. Default jarfile lock is *Jarfile.lock*, can be changed by setting opts = { :lockfile => 'NewLockFile' }. The local repo defined in the Jarfile can be override by setting opts = { :local_repo => 'path/to/local/repo' }
49
+ * LockJar.lock( *args ): Using a Jarfile, creates a lock file. Default jarfile is *Jarfile* and default lockfile is *Jarfile.lock*.
50
+ * An arg of a String will set the Jarfile, e.g. 'Jarfile.different'
51
+ * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
52
+ * :local_repo sets the local repo path
53
+ * :lockfile sets the Jarfile.lock path
50
54
 
51
55
  When the Jarfile is locked, the transitive dependencies are resolved and saved to the Jarfile.lock file.
52
56
 
@@ -97,16 +101,17 @@ The Jarfile.lock
97
101
  ==== Accessing Jars
98
102
 
99
103
  * LockJar.list(*args): Lists all dependencies as notations for scopes from the Jarfile.lock. Defaults scopes are *compile* and *runtime*. Default lock file is *Jarfile.lock*.
100
- * args of a String will set the Jarfile, e.g. 'Jarfile.different'
101
- * args of an Array will set the scopes, e.g. ['compile','test']
102
- * args of a Hash will set the options, e.g. { :local_repo => 'path' }
104
+ * An arg of a String will set the Jarfile.lock, e.g. 'Better.lock'
105
+ * An arg of an Array will set the scopes, e.g. ['compile','test']
106
+ * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
103
107
  * :local_repo sets the local repo path
104
108
  * :local_paths converts the notations to paths to jars in the local repo path
109
+ * :resolve to true will make transitive dependences resolve before loading to classpath
105
110
 
106
111
  * LockJar.load(*args): Loads all dependencies to the classpath for scopes from the Jarfile.lock. Defaults scopes are *compile* and *runtime*. Default lock file is *Jarfile.lock*.
107
- * args of a String will set the Jarfile, e.g. 'Jarfile.different'
108
- * args of an Array will set the scopes, e.g. ['compile','test']
109
- * args of a Hash will set the options, e.g. { :local_repo => 'path' }
112
+ * An arg of a String will set the Jarfile.lock, e.g. 'Better.lock'
113
+ * An arg of an Array will set the scopes, e.g. ['compile','test']
114
+ * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
110
115
  * :local_repo sets the local repo path
111
116
  * :resolve to true will make transitive dependences resolve before loading to classpath
112
117
 
@@ -122,14 +127,28 @@ Do not forget, if you change your Jarfile, you have to re-generate the Jarfile.l
122
127
 
123
128
  ==== Skipping the Jarfile
124
129
 
125
- You can skip the Jarfile and Jarfile.lock to directly load dependencies by passing a block to LockJar.load
130
+ You can skip the Jarfile and Jarfile.lock to directly play with dependencies by passing a block to LockJar.lock, LockJar.list, LockJar.load
131
+
132
+ ===== Lock with a Jarfile
133
+
134
+ LockJar.lock do
135
+ jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
136
+ end
137
+
138
+ ===== List with a Jarfile
139
+
140
+ LockJar.list do
141
+ jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
142
+ end
143
+
144
+ ===== Load with a Jarfile
126
145
 
127
146
  LockJar.load do
128
147
  jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
129
148
  end
130
149
 
131
150
  Since you skipped the locking part, mostly likely you will need to resolve the dependences in the block, just pass the
132
- :resolve => true option to enable dependency resolution.
151
+ :resolve => true option to enable dependency resolution (also works for LockJar.list).
133
152
 
134
153
  LockJar.load( :resolve => true ) do
135
154
  jar 'org.eclipse.jetty:example-jetty-embedded:jar:8.1.2.v20120308'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -59,7 +59,7 @@ module LockJar
59
59
  @naether = Naether.create_from_jars( jars )
60
60
  end
61
61
 
62
- @naether.local_repo_path = opts[:local_repo] if opts[:local_repo]
62
+ @naether.local_repo_path = opts[:local_repo].to_s if opts[:local_repo]
63
63
 
64
64
 
65
65
  @naether.clear_remote_repositories if opts[:offline]
@@ -27,6 +27,10 @@ module LockJar
27
27
  attr_reader :current_resolver
28
28
 
29
29
  def resolver( opts = {} )
30
+ if opts[:local_repo]
31
+ opts[:local_repo] = File.expand_path(opts[:local_repo])
32
+ end
33
+
30
34
  # XXX: opts for a method will cause resolver to reload
31
35
  if @current_resolver.nil? || opts != @current_resolver.opts
32
36
  @current_resolver = LockJar::Resolver.new( opts )
@@ -169,6 +173,10 @@ module LockJar
169
173
  dependencies = mapped_dependencies
170
174
  end
171
175
 
176
+ if opts[:resolve]
177
+ dependencies = resolver(opts).resolve( dependencies )
178
+ end
179
+
172
180
  if opts[:local_paths]
173
181
  opts.delete( :local_paths ) # remove list opts so resolver is not reset
174
182
  resolver(opts).to_local_paths( dependencies.uniq )
@@ -196,11 +204,7 @@ module LockJar
196
204
  end
197
205
 
198
206
  dependencies = list( jarfile_lock, scopes, opts, &blk )
199
-
200
- if opts[:resolve]
201
- dependencies = resolver(opts).resolve( dependencies )
202
- end
203
-
207
+
204
208
  resolver(opts).load_to_classpath( dependencies )
205
209
  end
206
210
 
data/lock_jar.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "lock_jar"
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Guymon"]
@@ -30,7 +30,8 @@ describe Bundler do
30
30
  in_app_root
31
31
  end
32
32
 
33
- after(:each) do
33
+ after(:all) do
34
+ puts "Changing pwd back to #{root}"
34
35
  Dir.chdir(root)
35
36
  end
36
37
 
@@ -14,13 +14,13 @@ describe LockJar::Runtime do
14
14
  local 'dsl_config'
15
15
  end
16
16
 
17
- LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql 'tmp/param_config'
17
+ LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql File.expand_path('tmp/param_config')
18
18
 
19
19
  LockJar::Runtime.instance.load( nil ) do
20
20
  local 'tmp/dsl_config'
21
21
  end
22
22
 
23
- LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql 'tmp/dsl_config'
23
+ LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql File.expand_path('tmp/dsl_config')
24
24
 
25
25
  end
26
26
  end
@@ -104,7 +104,6 @@ describe LockJar, "#load" do
104
104
  LockJar.lock( "spec/Jarfile", :local_repo => 'tmp/test-repo', :lockfile => 'tmp/Jarfile.lock' )
105
105
 
106
106
  jars = LockJar.load( 'tmp/Jarfile.lock', ['compile', 'runtime'], :local_repo => 'tmp/test-repo' )
107
-
108
107
  jars.should eql( [File.expand_path("tmp/test-repo/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar"), File.expand_path("tmp/test-repo/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar"), File.expand_path("tmp/test-repo/com/slackworks/modelcitizen/0.2.2/modelcitizen-0.2.2.jar"), File.expand_path("tmp/test-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"), File.expand_path("tmp/test-repo/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"), File.expand_path("tmp/test-repo/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"), File.expand_path("tmp/test-repo/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar"), File.expand_path("tmp/test-repo/ch/qos/logback/logback-core/0.9.24/logback-core-0.9.24.jar"), File.expand_path("tmp/test-repo/com/metapossum/metapossum-scanner/1.0/metapossum-scanner-1.0.jar"), File.expand_path("tmp/test-repo/commons-io/commons-io/1.4/commons-io-1.4.jar"), File.expand_path("tmp/test-repo/junit/junit/4.7/junit-4.7.jar"), File.expand_path("tmp/test-repo/org/apache/tomcat/servlet-api/6.0.35/servlet-api-6.0.35.jar")] )
109
108
 
110
109
  if Naether.platform == 'java'
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.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: naether
16
- requirement: &6015220 !ruby/object:Gem::Requirement
16
+ requirement: &15583440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *6015220
24
+ version_requirements: *15583440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &6011880 !ruby/object:Gem::Requirement
27
+ requirement: &15580160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.9.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *6011880
35
+ version_requirements: *15580160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &6132000 !ruby/object:Gem::Requirement
38
+ requirement: &15700940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.1.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *6132000
46
+ version_requirements: *15700940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &6129360 !ruby/object:Gem::Requirement
49
+ requirement: &15697920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 1.6.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *6129360
57
+ version_requirements: *15697920
58
58
  description: ! "Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile\n is
59
59
  used to generate a Jarfile.lock that contains all the resolved jar dependencies
60
60
  for scopes runtime, compile, and test.\n The Jarfile.lock can be used to populate
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  segments:
107
107
  - 0
108
- hash: 122660553079972418
108
+ hash: -3207536742551290776
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  none: false
111
111
  requirements: