Class: Stickler::Client::ConfigFile
- Inherits:
-
Object
- Object
- Stickler::Client::ConfigFile
- Defined in:
- lib/stickler/client/config_file.rb
Instance Method Summary collapse
- #config_path ⇒ Object
- #configuration ⇒ Object
- #initalize ⇒ Object
- #save_config(config) ⇒ Object
- #server ⇒ Object
- #server=(server) ⇒ Object
- #update(opts) ⇒ Object
- #updated? ⇒ Boolean
- #upstream ⇒ Object
- #upstream=(upstream) ⇒ Object
Instance Method Details
#config_path ⇒ Object
11 12 13 |
# File 'lib/stickler/client/config_file.rb', line 11 def config_path File.join(Gem.user_home, '.gem', 'stickler') end |
#configuration ⇒ Object
15 16 17 |
# File 'lib/stickler/client/config_file.rb', line 15 def configuration Gem.configuration.load_file(config_path) end |
#initalize ⇒ Object
7 8 9 |
# File 'lib/stickler/client/config_file.rb', line 7 def initalize @updated = false end |
#save_config(config) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/stickler/client/config_file.rb', line 47 def save_config( config ) dirname = File.dirname(config_path) Dir.mkdir(dirname) unless File.exists?(dirname) File.open(config_path, "w") do |f| f.write config.to_yaml end @updated = true end |
#server ⇒ Object
29 30 31 |
# File 'lib/stickler/client/config_file.rb', line 29 def server configuration[:server] end |
#server=(server) ⇒ Object
33 34 35 36 |
# File 'lib/stickler/client/config_file.rb', line 33 def server=( server ) config = configuration.merge( :server => server ) save_config( config ) end |
#update(opts) ⇒ Object
19 20 21 22 23 |
# File 'lib/stickler/client/config_file.rb', line 19 def update( opts ) self.server = opts[:server] if opts[:server] self.upstream = opts[:upstream] if opts[:upstream] return updated? end |
#updated? ⇒ Boolean
25 26 27 |
# File 'lib/stickler/client/config_file.rb', line 25 def updated? return @updated end |
#upstream ⇒ Object
38 39 40 |
# File 'lib/stickler/client/config_file.rb', line 38 def upstream configuration[:upstream] || ::Stickler::Repository::RubygemsAuthenticator.rubygems_uri.to_s end |
#upstream=(upstream) ⇒ Object
42 43 44 45 |
# File 'lib/stickler/client/config_file.rb', line 42 def upstream=( upstream ) config = configuration.merge( :upstream => upstream ) save_config( config ) end |