Class: Hubtime::HubConfig
- Inherits:
-
Object
- Object
- Hubtime::HubConfig
- Defined in:
- lib/hubtime/hub_config.rb
Defined Under Namespace
Classes: Stuff
Instance Attribute Summary collapse
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
- .add_ignore(repo_name) ⇒ Object
- .auth(user, password) ⇒ Object
- .display_password ⇒ Object
- .ignore ⇒ Object
- .instance ⇒ Object
- .password ⇒ Object
- .store(user, password) ⇒ Object
- .threads ⇒ Object
- .user ⇒ Object
Instance Method Summary collapse
- #add_ignore(repo_name) ⇒ Object
- #file ⇒ Object
-
#initialize ⇒ HubConfig
constructor
A new instance of HubConfig.
- #read_file ⇒ Object
- #store(user, password) ⇒ Object
- #write_file! ⇒ Object
Constructor Details
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
44 45 46 |
# File 'lib/hubtime/hub_config.rb', line 44 def ignore @ignore end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
44 45 46 |
# File 'lib/hubtime/hub_config.rb', line 44 def password @password end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
44 45 46 |
# File 'lib/hubtime/hub_config.rb', line 44 def user @user end |
Class Method Details
.add_ignore(repo_name) ⇒ Object
36 37 38 |
# File 'lib/hubtime/hub_config.rb', line 36 def self.add_ignore(repo_name) instance.add_ignore(repo_name) end |
.auth(user, password) ⇒ Object
12 13 14 |
# File 'lib/hubtime/hub_config.rb', line 12 def self.auth(user, password) store(user, password) end |
.display_password ⇒ Object
28 29 30 |
# File 'lib/hubtime/hub_config.rb', line 28 def self.display_password '*' * password.size end |
.ignore ⇒ Object
32 33 34 |
# File 'lib/hubtime/hub_config.rb', line 32 def self.ignore instance.ignore end |
.instance ⇒ Object
8 9 10 |
# File 'lib/hubtime/hub_config.rb', line 8 def self.instance @config ||= HubConfig.new end |
.password ⇒ Object
24 25 26 |
# File 'lib/hubtime/hub_config.rb', line 24 def self.password instance.password end |
.store(user, password) ⇒ Object
16 17 18 |
# File 'lib/hubtime/hub_config.rb', line 16 def self.store(user, password) instance.store(user, password) end |
.threads ⇒ Object
40 41 42 |
# File 'lib/hubtime/hub_config.rb', line 40 def self.threads 8 end |
.user ⇒ Object
20 21 22 |
# File 'lib/hubtime/hub_config.rb', line 20 def self.user instance.user end |
Instance Method Details
#add_ignore(repo_name) ⇒ Object
81 82 83 84 85 |
# File 'lib/hubtime/hub_config.rb', line 81 def add_ignore(repo_name) @ignore << repo_name @ignore.uniq! write_file! end |
#file ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hubtime/hub_config.rb', line 70 def file file = File.join(File.("."), "hubtime_config.yml") unless File.exists?(file) File.open(file, 'w' ) do |out| YAML.dump({}, out ) end end file end |
#read_file ⇒ Object
53 54 55 |
# File 'lib/hubtime/hub_config.rb', line 53 def read_file YAML.load_file(file) end |
#store(user, password) ⇒ Object
87 88 89 90 91 |
# File 'lib/hubtime/hub_config.rb', line 87 def store(user, password) @user = user @password = password write_file! end |
#write_file! ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hubtime/hub_config.rb', line 57 def write_file! hash = {} ["user", "password", "ignore"].each do |key| hash[key] = instance_variable_get("@#{key}") end hash["password"] = Stuff.encrypt(hash["password"]) File.open(file, 'w' ) do |out| YAML.dump(hash, out) end end |