Class: JBundler::Config
- Inherits:
-
Object
- Object
- JBundler::Config
- Defined in:
- lib/jbundler/config.rb
Overview
allow yaml config in $HOME/.jbundlerrc and $PWD/.jbundlerrc
Constant Summary collapse
- RC_FILE =
'.jbundlerrc'
Instance Attribute Summary collapse
-
#basedir ⇒ Object
Returns the value of attribute basedir.
-
#gemfile ⇒ Object
Returns the value of attribute gemfile.
-
#jarfile ⇒ Object
Returns the value of attribute jarfile.
-
#local_repository ⇒ Object
Returns the value of attribute local_repository.
-
#offline ⇒ Object
Returns the value of attribute offline.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#skip ⇒ Object
Returns the value of attribute skip.
-
#vendor_dir ⇒ Object
Returns the value of attribute vendor_dir.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#work_dir ⇒ Object
Returns the value of attribute work_dir.
Instance Method Summary collapse
- #absolute(file) ⇒ Object
- #classpath_file ⇒ Object
- #find_basedir(dir) ⇒ Object
- #gemfile_lock ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #jarfile_lock ⇒ Object
- #join_basedir(path) ⇒ Object
- #mirror ⇒ Object
- #proxy ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jbundler/config.rb', line 33 def initialize if ENV.has_key? 'HOME' homefile = File.join(ENV['HOME'], RC_FILE) home_config = YAML.load_file(homefile) if File.exists?(homefile) else home_config = nil end @config = (home_config || {}) @basedir = find_basedir( File.( '.' ) ) @basedir ||= File.( '.' ) file = join_basedir( RC_FILE ) pwd_config = YAML.load_file(file) if File.exists?(file) @config.merge!(pwd_config || {}) end |
Instance Attribute Details
#basedir ⇒ Object
Returns the value of attribute basedir.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def basedir @basedir end |
#gemfile ⇒ Object
Returns the value of attribute gemfile.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def gemfile @gemfile end |
#jarfile ⇒ Object
Returns the value of attribute jarfile.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def jarfile @jarfile end |
#local_repository ⇒ Object
Returns the value of attribute local_repository.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def local_repository @local_repository end |
#offline ⇒ Object
Returns the value of attribute offline.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def offline @offline end |
#settings ⇒ Object
Returns the value of attribute settings.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def settings @settings end |
#skip ⇒ Object
Returns the value of attribute skip.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def skip @skip end |
#vendor_dir ⇒ Object
Returns the value of attribute vendor_dir.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def vendor_dir @vendor_dir end |
#verbose ⇒ Object
Returns the value of attribute verbose.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def verbose @verbose end |
#work_dir ⇒ Object
Returns the value of attribute work_dir.
31 32 33 |
# File 'lib/jbundler/config.rb', line 31 def work_dir @work_dir end |
Instance Method Details
#absolute(file) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/jbundler/config.rb', line 69 def absolute( file ) if file.nil? || file == File.( file ) file else File.join( @basedir, file ) end end |
#classpath_file ⇒ Object
131 132 133 134 |
# File 'lib/jbundler/config.rb', line 131 def classpath_file absolute( jbundler_env('JBUNDLE_CLASSPATH_FILE') || '.jbundler/classpath.rb' ) end |
#find_basedir(dir) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/jbundler/config.rb', line 56 def find_basedir( dir ) f = File.join( dir, RC_FILE ) return dir if File.exists?( f ) f = File.join( dir, _jarfile ) return dir if File.exists?( f ) f = File.join( dir, _gemfile ) return dir if File.exists?( f ) parent = File.dirname( dir ) if dir != ENV['HOME'] && dir != parent find_basedir( parent ) end end |
#gemfile_lock ⇒ Object
127 128 129 |
# File 'lib/jbundler/config.rb', line 127 def gemfile_lock "#{gemfile}.lock" end |
#jarfile_lock ⇒ Object
114 115 116 |
# File 'lib/jbundler/config.rb', line 114 def jarfile_lock "#{jarfile}.lock" end |
#join_basedir(path) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/jbundler/config.rb', line 48 def join_basedir( path ) if @basedir File.join( @basedir, path ) else path end end |
#mirror ⇒ Object
171 172 173 174 175 176 177 178 179 |
# File 'lib/jbundler/config.rb', line 171 def mirror @mirror ||= jbundler_env('JBUNDLE_MIRROR') # nice to have no leading slash @mirror = @mirror.sub( /\/$/, '' ) if @mirror if @mirror warn 'mirror config is deprecated, use settings.xml instead' end @mirror end |
#proxy ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/jbundler/config.rb', line 163 def proxy @proxy ||= jbundler_env('JBUNDLE_PROXY') if @proxy warn 'proxy config is deprecated, use settings.xml instead' end @proxy end |