Class: Crackin::Config
- Inherits:
-
Object
- Object
- Crackin::Config
- Defined in:
- lib/crackin/config.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(file = "./.crackin.yml") ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(file = "./.crackin.yml") ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 |
# File 'lib/crackin/config.rb', line 8 def initialize(file="./.crackin.yml") yaml = YAML.load_file(file) @config = self.class.defaults.deep_merge(yaml['crackin']||{}) @source = Crackin::Scm.open(@config) end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/crackin/config.rb', line 6 def source @source end |
Class Method Details
.defaults ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/crackin/config.rb', line 27 def defaults { name: '<app>', scm: 'git', changelog: 'CHANGELOG.md', branch: { production: 'master', development: 'develop' }, status: { verbose: true }, version: 'lib/<app>/version.rb', build: { command: 'rake build', # gem build :name.gemspec && mkdir -p pkg && mv :name.gem pkg after: [] } }.deep_stringify_keys end |
.instance ⇒ Object
23 24 25 |
# File 'lib/crackin/config.rb', line 23 def instance @config || load end |
Instance Method Details
#[](key) ⇒ Object
14 15 16 |
# File 'lib/crackin/config.rb', line 14 def [](key) @config[key] end |