Class: ZdHire::Config
- Inherits:
-
Object
- Object
- ZdHire::Config
- Defined in:
- lib/zd_hire/config.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#github_token ⇒ Object
Returns the value of attribute github_token.
-
#local_path ⇒ Object
Returns the value of attribute local_path.
-
#origin_repo ⇒ Object
Returns the value of attribute origin_repo.
Instance Method Summary collapse
- #attributes ⇒ Object
- #attributes=(options) ⇒ Object
- #config_file ⇒ Object
- #deserialize_from_file ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #serialize_to_file ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 |
# File 'lib/zd_hire/config.rb', line 8 def initialize if File.exist?(config_file) begin deserialize_from_file rescue FileUtils.rm(config_file) end end end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
6 7 8 |
# File 'lib/zd_hire/config.rb', line 6 def branch @branch end |
#github_token ⇒ Object
Returns the value of attribute github_token.
6 7 8 |
# File 'lib/zd_hire/config.rb', line 6 def github_token @github_token end |
#local_path ⇒ Object
Returns the value of attribute local_path.
6 7 8 |
# File 'lib/zd_hire/config.rb', line 6 def local_path @local_path end |
#origin_repo ⇒ Object
Returns the value of attribute origin_repo.
6 7 8 |
# File 'lib/zd_hire/config.rb', line 6 def origin_repo @origin_repo end |
Instance Method Details
#attributes ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/zd_hire/config.rb', line 30 def attributes { github_token: github_token, origin_repo: origin_repo, local_path: local_path, branch: branch, } end |
#attributes=(options) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/zd_hire/config.rb', line 43 def attributes=() self.github_token = [:github_token] self.origin_repo = [:origin_repo] self.local_path = [:local_path] self.branch = [:branch] end |
#config_file ⇒ Object
18 19 20 |
# File 'lib/zd_hire/config.rb', line 18 def config_file @config_file ||= File.join(File.('~'), '.zd_hire') end |
#deserialize_from_file ⇒ Object
22 23 24 |
# File 'lib/zd_hire/config.rb', line 22 def deserialize_from_file self.attributes = YAML.load_file(config_file) end |
#serialize_to_file ⇒ Object
26 27 28 |
# File 'lib/zd_hire/config.rb', line 26 def serialize_to_file File.write(config_file, attributes.to_yaml) end |
#valid? ⇒ Boolean
39 40 41 |
# File 'lib/zd_hire/config.rb', line 39 def valid? attributes.values.none?(&:nil?) end |