Class: Crackin::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/crackin/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/crackin/config.rb', line 6

def source
  @source
end

Class Method Details

.defaultsObject



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

.instanceObject



23
24
25
# File 'lib/crackin/config.rb', line 23

def instance
  @config || load
end

.load(file = "./.crackin.yml") ⇒ Object



19
20
21
# File 'lib/crackin/config.rb', line 19

def load(file="./.crackin.yml")
  @config = Crackin::Config.new(file)
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
# File 'lib/crackin/config.rb', line 14

def [](key)
  @config[key]
end