jar-dependencies 0.3.11 → 0.3.12

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: 21c3aa63524ec5c3364e055712810d559e4e5cf4
4
- data.tar.gz: 6d4d4532738f38c7f10b5c1997edc11854bc6a21
3
+ metadata.gz: f4108689beca71246730298b652ff1f257b632c9
4
+ data.tar.gz: 9ce8d4bbd9b198e10b7071d02a796ce7076f436c
5
5
  SHA512:
6
- metadata.gz: 42f48de83b2c779e9b7c4b6597ccf0ea4759a44b3071f644cec82635863ff14f62bd63cb54762f561972c4bd9b6901fb2fbb4c319bfd6b4ee050b70210935636
7
- data.tar.gz: 0d6b8b37fdf3332cac18da6aaf39af048f3ce3c2b5aca0051e2088c54b7ebe2a1d7efe71c5c02d928a78707685dc78f61f24e83f0616b6509ccd11e61d9f7cf5
6
+ metadata.gz: 2f72239c3d9d03f10841d27023b54c1dd55f04242ba9162eb7c362c412b014cc167ad231d359ffe5b57be3218c85b5e258c50cb3e224ddb41f006ba1ab3b7c0e
7
+ data.tar.gz: f2225f1fd6d20a70ebc7ea9835b56c84307554d177df49d5751b99ebd2f5ecb26d2abca5b1aa7ee3baea4330393811c0e78ef36548aa79ba52853238039bb852
data/Mavenfile CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  gemfile
4
4
 
5
- plugin_repository :id => :maven_gems, :url => 'mavengem:https://rubygems.org'
5
+ plugin_repository id: :maven_gems, url: 'mavengem:https://rubygems.org'
6
6
 
7
- jruby_plugin( :minitest, :minispecDirectory => "specs/*_spec.rb" ) do
7
+ jruby_plugin(:minitest, minispecDirectory: 'specs/*_spec.rb') do
8
8
  execute_goals(:spec)
9
9
  gem 'ruby-maven', '${ruby-maven.version}'
10
10
  end
@@ -17,51 +17,47 @@ ruby_maven = gemfile_profile.dependencies.detect do |d|
17
17
  d.artifact_id == 'ruby-maven'
18
18
  end
19
19
 
20
- properties( 'jruby.versions' => ['1.7.12', '1.7.25', '9.0.5.0', '${jruby.version}'
21
- ].join(','),
22
- 'jruby.modes' => ['1.9', '2.0', '2.2'].join(','),
23
- # just lock the version
24
- 'bundler.version' => '1.10.6',
25
- 'ruby-maven.version' => ruby_maven.version,
26
- 'jruby.version' => '9.1.8.0',
27
- 'jruby.plugins.version' => '1.1.3',
28
- 'push.skip' => true )
20
+ properties('jruby.versions' => ['1.7.12', '1.7.25', '${jruby.version}'].join(','),
21
+ 'jruby.modes' => ['1.9', '2.0', '2.2'].join(','),
22
+ # just lock the version
23
+ 'bundler.version' => '1.10.6',
24
+ 'ruby-maven.version' => ruby_maven.version,
25
+ 'jruby.version' => '9.0.5.0',
26
+ 'jruby.plugins.version' => '1.1.3',
27
+ 'push.skip' => true)
29
28
 
30
29
  plugin :invoker, '1.8' do
31
- execute_goals( :install, :run,
32
- :id => 'integration-tests',
33
- :projectsDirectory => 'integration',
34
- :streamLogs => true,
35
- :goals => ['install'],
36
- :preBuildHookScript => 'setup.bsh',
37
- :postBuildHookScript => 'verify.bsh',
38
- :cloneProjectsTo => '${project.build.directory}',
39
- :properties => { 'jar-dependencies.version' => '${project.version}',
40
- # use an old jruby with old ruby-maven here
41
- 'jruby.old-version' => '1.7.20',
42
- 'jruby.version' => '${jruby.version}',
43
- 'jruby.plugins.version' => '${jruby.plugins.version}',
44
- 'bundler.version' => '${bundler.version}',
45
- 'ruby-maven.version' => '${ruby-maven.version}' })
30
+ execute_goals(:install, :run,
31
+ id: 'integration-tests',
32
+ projectsDirectory: 'integration',
33
+ streamLogs: true,
34
+ goals: ['install'],
35
+ preBuildHookScript: 'setup.bsh',
36
+ postBuildHookScript: 'verify.bsh',
37
+ cloneProjectsTo: '${project.build.directory}',
38
+ properties: { 'jar-dependencies.version' => '${project.version}',
39
+ # use an old jruby with old ruby-maven here
40
+ 'jruby.old-version' => '1.7.20',
41
+ 'jruby.version' => '${jruby.version}',
42
+ 'jruby.plugins.version' => '${jruby.plugins.version}',
43
+ 'bundler.version' => '${bundler.version}',
44
+ 'ruby-maven.version' => '${ruby-maven.version}' })
46
45
  end
47
46
 
48
47
  distribution_management do
49
- repository :id => :ossrh, :url => 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
48
+ repository id: :ossrh, url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
50
49
  end
51
50
 
52
- profile :id => :skip do
53
-
54
- properties 'maven.test.skip' => true, 'invoker.skip' => true
55
-
51
+ profile id: :skip do
52
+ properties 'maven.test.skip' => true, 'invoker.skip' => true
56
53
  end
57
54
 
58
- profile :id => :release do
55
+ profile id: :release do
59
56
  properties 'maven.test.skip' => true, 'invoker.skip' => true, 'push.skip' => false
60
57
 
61
58
  build do
62
59
  default_goal :deploy
63
60
  end
64
-
65
61
  end
66
62
 
67
63
  # vim: syntax=Ruby
data/Rakefile CHANGED
@@ -1,32 +1,32 @@
1
1
  #-*- mode: ruby -*-
2
2
 
3
- task :default => [ :specs ]
3
+ task default: [:specs]
4
4
 
5
5
  desc 'run specs'
6
6
  task :specs do
7
- $LOAD_PATH << "specs"
7
+ $LOAD_PATH << 'specs'
8
8
 
9
- Dir['specs/*_spec.rb'].each do |f|
10
- require File.basename( f.sub(/.rb$/, '' ) )
9
+ Dir['specs/*_spec.rb'].each do |f|
10
+ require File.basename(f.sub(/.rb$/, ''))
11
11
  end
12
12
  end
13
13
 
14
14
  task :headers do
15
15
  require 'copyright_header'
16
16
 
17
- s = Gem::Specification.load( Dir["*gemspec"].first )
17
+ s = Gem::Specification.load(Dir['*gemspec'].first)
18
18
 
19
19
  args = {
20
- :license => s.license,
21
- :copyright_software => s.name,
22
- :copyright_software_description => s.description,
23
- :copyright_holders => s.authors,
24
- :copyright_years => [Time.now.year],
25
- :add_path => "lib",
26
- :output_dir => './'
20
+ license: s.license,
21
+ copyright_software: s.name,
22
+ copyright_software_description: s.description,
23
+ copyright_holders: s.authors,
24
+ copyright_years: [Time.now.year],
25
+ add_path: 'lib',
26
+ output_dir: './'
27
27
  }
28
28
 
29
- command_line = CopyrightHeader::CommandLine.new( args )
29
+ command_line = CopyrightHeader::CommandLine.new(args)
30
30
  command_line.execute
31
31
  end
32
32
 
data/Readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # jar-dependencies #
2
2
 
3
- * [![Build Status](https://secure.travis-ci.org/mkristian/jar-dependencies.png)](http://travis-ci.org/mkristian/jar-dependencies)
4
- * [![Code Climate](https://codeclimate.com/github/mkristian/jar-dependencies.png)](https://codeclimate.com/github/mkristian/jar-dependencies)
3
+ * [![Build Status](https://secure.travis-ci.org/mkristian/jar-dependencies.svg)](http://travis-ci.org/mkristian/jar-dependencies)
4
+ * [![Code Climate](https://codeclimate.com/github/mkristian/jar-dependencies.svg)](https://codeclimate.com/github/mkristian/jar-dependencies)
5
5
 
6
6
  add gem dependencies for jar files to ruby gems.
7
7
 
@@ -185,22 +185,22 @@ your current directory.
185
185
  <td>ENV</td><td>java system property</td><td>default</td><td>description</td>
186
186
  </tr>
187
187
  <tr>
188
- <td>`JARS_DEBUG`</td><td>jars.debug</td><td>false</td><td>if set to true it will produce lots of debug out (maven -X switch)</td>
188
+ <td><tt>JARS_DEBUG</tt></td><td>jars.debug</td><td>false</td><td>if set to true it will produce lots of debug out (maven -X switch)</td>
189
189
  </tr>
190
190
  <tr>
191
- <td>`JARS_VERBOSE`</td><td>jars.verbose</td><td>false</td><td>if set to true it will produce some extra output</td>
191
+ <td><tt>JARS_VERBOSE</tt></td><td>jars.verbose</td><td>false</td><td>if set to true it will produce some extra output</td>
192
192
  </tr>
193
193
  <tr>
194
- <td>`JARS_HOME`</td><td>jars.home</td><td>$HOME/.m2/repository</td><td>filesystem location where to store the jar files and some metadata</td>
194
+ <td><tt>JARS_HOME</tt></td><td>jars.home</td><td>$HOME/.m2/repository</td><td>filesystem location where to store the jar files and some metadata</td>
195
195
  </tr>
196
196
  <tr>
197
- <td>`JARS_MAVEN_SETTINGS`</td><td>jars.maven.settings</td><td>$HOME/.m2/settings.xml</td><td>setting.xml for maven to use</td>
197
+ <td><tt>JARS_MAVEN_SETTINGS</tt></td><td>jars.maven.settings</td><td>$HOME/.m2/settings.xml</td><td>setting.xml for maven to use</td>
198
198
  </tr>
199
199
  <tr>
200
- <td>`JARS_VENDOR`</td><td>jars.vendor</td><td>true</td><td>set to true means that the jars will be stored in JARS_HOME only</td>
200
+ <td><tt>JARS_VENDOR</tt></td><td>jars.vendor</td><td>true</td><td>set to true means that the jars will be stored in JARS_HOME only</td>
201
201
  </tr>
202
202
  <tr>
203
- <td>`JARS_SKIP`</td><td>jars.skip</td><td>true</td><td>do **NOT** install jar dependencies at all</td>
203
+ <td><tt>JARS_SKIP</tt></td><td>jars.skip</td><td>true</td><td>do **NOT** install jar dependencies at all</td>
204
204
  </tr>
205
205
  </table>
206
206
 
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'jar_dependencies'
3
- require 'optparse'
4
- options = {}
5
- optparse = OptionParser.new do|opts|
6
-
3
+ require 'optparse'
4
+ options = {}
5
+ optparse = OptionParser.new do |opts|
7
6
  opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
8
7
 
9
8
  opts.separator ''
@@ -15,35 +14,35 @@ optparse = OptionParser.new do|opts|
15
14
  opts.separator 'Options:'
16
15
  opts.separator ''
17
16
 
18
- opts.on( '-v', '--verbose', 'Output more information' ) do |t|
17
+ opts.on('-v', '--verbose', 'Output more information') do |t|
19
18
  options[:verbose] = t
20
19
  end
21
20
 
22
- opts.on( '-d', '--debug', 'Output debug information' ) do |t|
21
+ opts.on('-d', '--debug', 'Output debug information') do |t|
23
22
  options[:debug] = t
24
23
  end
25
24
 
26
- opts.on( '-f', '--force', 'Force creation of Jars.lock' ) do |t|
25
+ opts.on('-f', '--force', 'Force creation of Jars.lock') do |t|
27
26
  options[:force] = t
28
27
  end
29
28
 
30
- opts.on( '-t', '--tree', 'Show dependency tree' ) do |t|
29
+ opts.on('-t', '--tree', 'Show dependency tree') do |t|
31
30
  options[:tree] = t
32
31
  end
33
32
 
34
- opts.on( '-u', '--update JAR_COORDINATE', 'Resolves given dependency and use latest version. JAR_COORDINATE is either artifact_id or group_id:artifact_id' ) do |u|
33
+ opts.on('-u', '--update JAR_COORDINATE', 'Resolves given dependency and use latest version. JAR_COORDINATE is either artifact_id or group_id:artifact_id') do |u|
35
34
  options[:update] = u
36
35
  end
37
36
 
38
- opts.on( '--vendor-dir DIRECTORY', 'Vendor directory where to copy the installed jars.', 'add this directory to $LOAD_PATH or set JARS_HOME respectively.' ) do |dir|
37
+ opts.on('--vendor-dir DIRECTORY', 'Vendor directory where to copy the installed jars.', 'add this directory to $LOAD_PATH or set JARS_HOME respectively.') do |dir|
39
38
  options[:vendor_dir] = dir
40
39
  end
41
40
 
42
- opts.on( '-h', '--help', 'Display this screen' ) do
41
+ opts.on('-h', '--help', 'Display this screen') do
43
42
  puts opts
44
43
  exit
45
44
  end
46
45
  end
47
46
  optparse.parse!
48
47
 
49
- Jars.lock_down( options[:debug], options[:verbose], options )
48
+ Jars.lock_down(options[:debug], options[:verbose], options)
@@ -4,37 +4,37 @@ Gem::Specification.new do |s|
4
4
  s.name = 'jar-dependencies'
5
5
 
6
6
  path = File.expand_path('lib/jars/version.rb', File.dirname(__FILE__))
7
- s.version = File.read(path).match( /\s*VERSION\s*=\s*['"](.*)['"]/ )[1]
8
-
7
+ s.version = File.read(path).match(/\s*VERSION\s*=\s*['"](.*)['"]/)[1]
8
+
9
9
  s.author = 'christian meier'
10
- s.email = [ 'mkristian@web.de' ]
10
+ s.email = ['mkristian@web.de']
11
11
  s.summary = 'manage jar dependencies for gems'
12
12
  s.homepage = 'https://github.com/mkristian/jar-dependencies'
13
13
 
14
- s.bindir = "bin"
15
- LOCK_JARS = 'lock_jars'
14
+ s.bindir = 'bin'
15
+ LOCK_JARS = 'lock_jars'.freeze
16
16
  s.executables = [LOCK_JARS]
17
17
 
18
18
  s.license = 'MIT'
19
19
 
20
- s.files = `git ls-files`.split($/).select do |file|
20
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR).select do |file|
21
21
  file =~ /^lib\// ||
22
- [ 'Mavenfile', 'Rakefile' ].include?(file) ||
23
- [ 'Readme.md', 'jar-dependencies.gemspec', 'MIT-LICENSE' ].include?(file)
22
+ %w[Mavenfile Rakefile].include?(file) ||
23
+ ['Readme.md', 'jar-dependencies.gemspec', 'MIT-LICENSE'].include?(file)
24
24
  end
25
25
 
26
26
  s.description = 'manage jar dependencies for gems and keep track which jar was already loaded using maven artifact coordinates. it warns on version conflicts and loads only ONE jar assuming the first one is compatible to the second one otherwise your project needs to lock down the right version by providing a Jars.lock file.'
27
27
 
28
28
  s.add_development_dependency 'minitest', '~> 5.3'
29
29
  s.add_development_dependency 'rake', '~> 10.2'
30
- RUBY_MAVEN_VERSION = '~> 3.3.11'
30
+ RUBY_MAVEN_VERSION = '~> 3.3.11'.freeze
31
31
  s.add_development_dependency 'ruby-maven', RUBY_MAVEN_VERSION
32
32
 
33
33
  s.post_install_message = <<EOF
34
34
 
35
- if you want to use the executable #{LOCK_JARS} then install ruby-maven gem before using #{LOCK_JARS}
35
+ if you want to use the executable #{LOCK_JARS} then install ruby-maven gem before using #{LOCK_JARS}
36
36
 
37
- $ gem install ruby-maven -v '#{RUBY_MAVEN_VERSION}'
37
+ $ gem install ruby-maven -v '#{RUBY_MAVEN_VERSION}'
38
38
 
39
39
  or add it as a development dependency to your Gemfile
40
40
 
@@ -50,42 +50,41 @@ module Jars
50
50
  autoload :MavenSettings, 'jars/maven_settings'
51
51
 
52
52
  class << self
53
-
54
- def lock_down( debug = false, verbose = false, options = {} )
55
- ENV[ SKIP_LOCK ] = 'true'
53
+ def lock_down(debug = false, verbose = false, options = {})
54
+ ENV[SKIP_LOCK] = 'true'
56
55
  require 'jars/lock_down' # do this lazy to keep things clean
57
- Jars::LockDown.new( debug, verbose ).lock_down( options )
56
+ Jars::LockDown.new(debug, verbose).lock_down(options)
58
57
  ensure
59
- ENV[ SKIP_LOCK ] = nil
58
+ ENV[SKIP_LOCK] = nil
60
59
  end
61
60
 
62
61
  if defined? JRUBY_VERSION
63
- def to_prop( key )
64
- key = key.gsub( '_', '.' )
65
- ENV_JAVA[ ( key.downcase!; key ) ] ||
66
- ENV[ ( key.gsub!( '.', '_' ); key.upcase!; key ) ]
62
+ def to_prop(key)
63
+ key = key.tr('_', '.')
64
+ ENV_JAVA[(key.downcase!; key)] ||
65
+ ENV[(key.tr!('.', '_'); key.upcase!; key)]
67
66
  end
68
67
  else
69
- def to_prop( key )
70
- ENV[ key.gsub( '.', '_' ).upcase ]
68
+ def to_prop(key)
69
+ ENV[key.tr('.', '_').upcase]
71
70
  end
72
71
  end
73
72
 
74
- def to_boolean( key )
75
- return nil if ( prop = to_prop( key ) ).nil?
73
+ def to_boolean(key)
74
+ return nil if (prop = to_prop(key)).nil?
76
75
  prop.empty? || prop.eql?('true')
77
76
  end
78
77
 
79
78
  def skip?
80
- to_boolean( SKIP )
79
+ to_boolean(SKIP)
81
80
  end
82
81
 
83
82
  def require?
84
83
  @require = nil unless instance_variable_defined?(:@require)
85
84
  if @require.nil?
86
- if ( require = to_boolean( REQUIRE ) ).nil?
87
- no_require = to_boolean( NO_REQUIRE )
88
- @require = no_require.nil? ? true : ! no_require
85
+ if (require = to_boolean(REQUIRE)).nil?
86
+ no_require = to_boolean(NO_REQUIRE)
87
+ @require = no_require.nil? ? true : !no_require
89
88
  else
90
89
  @require = require
91
90
  end
@@ -95,26 +94,28 @@ module Jars
95
94
  attr_writer :require
96
95
 
97
96
  def quiet?
98
- ( @silent ||= false ) || to_boolean( QUIET )
97
+ (@silent ||= false) || to_boolean(QUIET)
99
98
  end
100
99
 
101
100
  def jarfile
102
- ENV[ 'JARFILE' ] || ENV_JAVA[ 'jarfile' ] || ENV[ 'JBUNDLER_JARFILE' ] || ENV_JAVA[ 'jbundler.jarfile' ] || 'Jarfile'
101
+ ENV['JARFILE'] || ENV_JAVA['jarfile'] || ENV['JBUNDLER_JARFILE'] || ENV_JAVA['jbundler.jarfile'] || 'Jarfile'
103
102
  end
104
103
 
105
104
  # @deprecated
106
- def no_require?; ! require? end
105
+ def no_require?
106
+ !require?
107
+ end
107
108
 
108
109
  def verbose?
109
- to_boolean( VERBOSE )
110
+ to_boolean(VERBOSE)
110
111
  end
111
112
 
112
113
  def debug?
113
- to_boolean( DEBUG )
114
+ to_boolean(DEBUG)
114
115
  end
115
116
 
116
117
  def vendor?
117
- to_boolean( VENDOR )
118
+ to_boolean(VENDOR)
118
119
  end
119
120
 
120
121
  def no_more_warnings
@@ -126,28 +127,26 @@ module Jars
126
127
  end
127
128
 
128
129
  def skip_lock?
129
- to_prop( SKIP_LOCK ) || false
130
+ to_prop(SKIP_LOCK) || false
130
131
  end
131
132
 
132
133
  def lock
133
- to_prop( LOCK ) || 'Jars.lock'
134
+ to_prop(LOCK) || 'Jars.lock'
134
135
  end
135
136
 
136
137
  def jars_lock_from_class_loader
137
- if to_prop( LOCK ).nil? && defined?(JRUBY_VERSION)
138
- JRuby.runtime.jruby_class_loader.get_resources( 'Jars.lock' ).collect do |url|
139
- url.to_s
140
- end
138
+ if to_prop(LOCK).nil? && defined?(JRUBY_VERSION)
139
+ JRuby.runtime.jruby_class_loader.get_resources('Jars.lock').collect(&:to_s)
141
140
  end
142
141
  end
143
142
 
144
- def lock_path( basedir = nil )
145
- deps = self.lock
146
- return deps if File.exists?( deps )
143
+ def lock_path(basedir = nil)
144
+ deps = lock
145
+ return deps if File.exist?(deps)
147
146
  basedir ||= '.'
148
- [ '.', 'jars', 'vendor/jars' ].each do |dir|
149
- file = File.join( basedir, dir, self.lock )
150
- return file if File.exists?( file )
147
+ ['.', 'jars', 'vendor/jars'].each do |dir|
148
+ file = File.join(basedir, dir, lock)
149
+ return file if File.exist?(file)
151
150
  end
152
151
  nil
153
152
  end
@@ -155,7 +154,7 @@ module Jars
155
154
  def reset
156
155
  instance_variables.each { |var| instance_variable_set(var, nil) }
157
156
  Jars::MavenSettings.reset
158
- ( @@jars ||= {} ).clear
157
+ (@@jars ||= {}).clear
159
158
  end
160
159
 
161
160
  def maven_local_settings
@@ -179,29 +178,28 @@ module Jars
179
178
  detect_local_repository(maven_local_settings) ||
180
179
  detect_local_repository(maven_user_settings) ||
181
180
  detect_local_repository(maven_global_settings) ||
182
- File.join( user_home, '.m2', 'repository' )
181
+ File.join(user_home, '.m2', 'repository')
183
182
  end
184
183
 
185
184
  def home
186
185
  absolute(to_prop(HOME)) || local_maven_repo
187
186
  end
188
187
 
189
- def require_jars_lock!( scope = :runtime )
188
+ def require_jars_lock!(scope = :runtime)
190
189
  urls = jars_lock_from_class_loader
191
- if urls and urls.size > 0
190
+ if urls && !urls.empty?
192
191
  @@jars_lock = true
193
192
  # funny error during spec where it tries to load it again
194
193
  # and finds it as gem instead of the LOAD_PATH
195
194
  require 'jars/classpath' unless defined? Jars::Classpath
196
195
  done = []
197
- while done != urls do
196
+ while done != urls
198
197
  urls.each do |url|
199
- unless done.member?( url )
200
- Jars.debug { "--- load jars from uri #{url}" }
201
- classpath = Jars::Classpath.new( nil, "uri:#{url}" )
202
- classpath.require( scope )
203
- done << url
204
- end
198
+ next if done.member?(url)
199
+ Jars.debug { "--- load jars from uri #{url}" }
200
+ classpath = Jars::Classpath.new(nil, "uri:#{url}")
201
+ classpath.require(scope)
202
+ done << url
205
203
  end
206
204
  urls = jars_lock_from_class_loader
207
205
  end
@@ -212,25 +210,25 @@ module Jars
212
210
  # funny error during spec where it tries to load it again
213
211
  # and finds it as gem instead of the LOAD_PATH
214
212
  require 'jars/classpath' unless defined? Jars::Classpath
215
- classpath = Jars::Classpath.new( nil, jars_lock )
216
- classpath.require( scope )
213
+ classpath = Jars::Classpath.new(nil, jars_lock)
214
+ classpath.require(scope)
217
215
  no_more_warnings
218
216
  end
219
- Jars.debug {
217
+ Jars.debug do
220
218
  @@jars ||= {}
221
- loaded = @@jars.collect{ |k,v| "#{k}:#{v}" }
219
+ loaded = @@jars.collect { |k, v| "#{k}:#{v}" }
222
220
  "--- loaded jars ---\n\t#{loaded.join("\n\t")}"
223
- }
221
+ end
224
222
  end
225
223
 
226
- def setup( options = nil )
224
+ def setup(options = nil)
227
225
  case options
228
226
  when Symbol
229
- require_jars_lock!( options )
227
+ require_jars_lock!(options)
230
228
  when Hash
231
229
  @_jars_home = options[:jars_home]
232
230
  @_jars_lock = options[:jars_lock]
233
- require_jars_lock!( options[:scope] || :runtime )
231
+ require_jars_lock!(options[:scope] || :runtime)
234
232
  else
235
233
  require_jars_lock!
236
234
  end
@@ -244,35 +242,35 @@ module Jars
244
242
  end
245
243
  end
246
244
 
247
- def mark_as_required( group_id, artifact_id, *classifier_version )
248
- require_jar_with_block( group_id, artifact_id, *classifier_version ) do
245
+ def mark_as_required(group_id, artifact_id, *classifier_version)
246
+ require_jar_with_block(group_id, artifact_id, *classifier_version) do
249
247
  end
250
248
  end
251
249
 
252
- def require_jar( group_id, artifact_id, *classifier_version )
250
+ def require_jar(group_id, artifact_id, *classifier_version)
253
251
  require_jars_lock unless skip_lock?
254
- require_jar_with_block( group_id, artifact_id, *classifier_version ) do |gid, aid, version, classifier|
255
- do_require( gid, aid, version, classifier )
252
+ require_jar_with_block(group_id, artifact_id, *classifier_version) do |gid, aid, version, classifier|
253
+ do_require(gid, aid, version, classifier)
256
254
  end
257
255
  end
258
256
 
259
- def warn(msg = nil, &block)
260
- Kernel.warn(msg || block.call) unless quiet? and not verbose?
257
+ def warn(msg = nil)
258
+ Kernel.warn(msg || yield) unless quiet? && !verbose?
261
259
  end
262
260
 
263
- def debug(msg = nil, &block)
264
- Kernel.warn(msg || block.call) if verbose?
261
+ def debug(msg = nil)
262
+ Kernel.warn(msg || yield) if verbose?
265
263
  end
266
264
 
267
- def absolute( file )
268
- File.expand_path( file ) if file
265
+ def absolute(file)
266
+ File.expand_path(file) if file
269
267
  end
270
268
 
271
269
  def user_home
272
- ENV[ 'HOME' ] || begin
270
+ ENV['HOME'] || begin
273
271
  user_home = Dir.home if Dir.respond_to?(:home)
274
272
  unless user_home
275
- user_home = ENV_JAVA[ 'user.home' ] if Object.const_defined?(:ENV_JAVA)
273
+ user_home = ENV_JAVA['user.home'] if Object.const_defined?(:ENV_JAVA)
276
274
  end
277
275
  user_home
278
276
  end
@@ -280,22 +278,22 @@ module Jars
280
278
 
281
279
  private
282
280
 
283
- def require_jar_with_block( group_id, artifact_id, *classifier_version )
284
- version = classifier_version[ -1 ]
285
- classifier = classifier_version[ -2 ]
281
+ def require_jar_with_block(group_id, artifact_id, *classifier_version)
282
+ version = classifier_version[-1]
283
+ classifier = classifier_version[-2]
286
284
 
287
285
  @@jars ||= {}
288
286
  coordinate = "#{group_id}:#{artifact_id}"
289
287
  coordinate << ":#{classifier}" if classifier
290
288
  if @@jars.key? coordinate
291
- if @@jars[ coordinate ] == version
289
+ if @@jars[coordinate] == version
292
290
  false
293
291
  else
294
- @@jars[ coordinate ] # version of already registered jar
292
+ @@jars[coordinate] # version of already registered jar
295
293
  end
296
294
  else
297
295
  yield group_id, artifact_id, version, classifier
298
- @@jars[ coordinate ] = version
296
+ @@jars[coordinate] = version
299
297
  return true
300
298
  end
301
299
  end
@@ -303,60 +301,56 @@ module Jars
303
301
  def detect_local_repository(settings)
304
302
  return nil unless settings
305
303
 
306
- doc = File.read( settings )
307
- # TODO filter out xml comments
308
- local_repo = doc.sub( /<\/localRepository>.*/m, '' ).sub( /.*<localRepository>/m, '' )
304
+ doc = File.read(settings)
305
+ # TODO: filter out xml comments
306
+ local_repo = doc.sub(/<\/localRepository>.*/m, '').sub(/.*<localRepository>/m, '')
309
307
  # replace maven like system properties embedded into the string
310
- local_repo.gsub!( /\$\{[a-zA-Z.]+\}/ ) do |a|
311
- ENV_JAVA[ a[2..-2] ] || a
312
- end
313
- if local_repo.empty? or not File.exists?( local_repo )
314
- local_repo = nil
308
+ local_repo.gsub!(/\$\{[a-zA-Z.]+\}/) do |a|
309
+ ENV_JAVA[a[2..-2]] || a
315
310
  end
311
+ local_repo = nil if local_repo.empty? || !File.exist?(local_repo)
316
312
  local_repo
317
313
  rescue
318
314
  Jars.warn { "error reading or parsing #{settings}" }
319
315
  nil
320
316
  end
321
317
 
322
- def to_jar( group_id, artifact_id, version, classifier = nil )
323
- file = String.new("#{group_id.gsub( '.', '/' )}/#{artifact_id}/#{version}/#{artifact_id}-#{version}")
318
+ def to_jar(group_id, artifact_id, version, classifier = nil)
319
+ file = String.new("#{group_id.tr('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}")
324
320
  file << "-#{classifier}" if classifier
325
321
  file << '.jar'
326
322
  file
327
323
  end
328
324
 
329
- def do_require( *args )
330
- jar = to_jar( *args )
331
- local = File.join( Dir.pwd, 'jars', jar )
332
- vendor = File.join( Dir.pwd, 'vendor', 'jars', jar )
333
- file = File.join( home, jar )
325
+ def do_require(*args)
326
+ jar = to_jar(*args)
327
+ local = File.join(Dir.pwd, 'jars', jar)
328
+ vendor = File.join(Dir.pwd, 'vendor', 'jars', jar)
329
+ file = File.join(home, jar)
334
330
  # use jar from local repository if exists
335
- if File.exists?( file )
331
+ if File.exist?(file)
336
332
  require file
337
333
  # use jar from PWD/jars if exists
338
- elsif File.exists?( local )
334
+ elsif File.exist?(local)
339
335
  require local
340
336
  # use jar from PWD/vendor/jars if exists
341
- elsif File.exists?( vendor )
337
+ elsif File.exist?(vendor)
342
338
  require vendor
343
339
  else
344
340
  # otherwise try to find it on the load path
345
341
  require jar
346
342
  end
347
343
  rescue LoadError => e
348
- raise "\n\n\tyou might need to reinstall the gem which depends on the missing jar or in case there is Jars.lock then resolve the jars with `lock_jars` command\n\n" + e.message + " (LoadError)"
344
+ raise "\n\n\tyou might need to reinstall the gem which depends on the missing jar or in case there is Jars.lock then resolve the jars with `lock_jars` command\n\n" + e.message + ' (LoadError)'
349
345
  end
350
-
351
346
  end # class << self
352
-
353
347
  end
354
348
 
355
- def require_jar( *args )
349
+ def require_jar(*args)
356
350
  return nil unless Jars.require?
357
- result = Jars.require_jar( *args )
351
+ result = Jars.require_jar(*args)
358
352
  if result.is_a? String
359
- Jars.warn { "--- jar coordinate #{args[0..-2].join( ':' )} already loaded with version #{result} - omit version #{args[-1]}" }
353
+ Jars.warn { "--- jar coordinate #{args[0..-2].join(':')} already loaded with version #{result} - omit version #{args[-1]}" }
360
354
  Jars.debug { " try to load from #{caller.join("\n\t")}" }
361
355
  return false
362
356
  end