Class: ConfigKit::DeployData

Inherits:
SlashedHash show all
Defined in:
lib/config_kit/deploy_data.rb

Defined Under Namespace

Classes: DeployDataOptsError

Instance Method Summary collapse

Methods inherited from SlashedHash

#inspect, symbolize, #to_hash

Methods inherited from Hash

#deep_merge

Constructor Details

#initialize(name, version, opts) ⇒ DeployData

Returns a new instance of DeployData.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/config_kit/deploy_data.rb', line 5

def initialize(name, version, opts)
  @name = name 
  @version = version[0] == 'v' ? version : "v#{version}"
  @api_version = opts.fetch(:api_version, '1.0')
  @kind = opts.fetch(:kind, 'config_kit')
  @extra = opts.fetch(:extra, :no_default)
  @cs = opts.fetch(:cs, "no_cs") if @extra != :default_only
  
  ConfigKit.logger.debug "Deploy in #{@extra} options"
  check_extra(@extra)
  @binded_data = binding_data
  super(@binded_data)
end

Instance Method Details

#binding_dataObject



35
36
37
38
39
40
41
42
43
# File 'lib/config_kit/deploy_data.rb', line 35

def binding_data
  if @extra == :no_default
    binding_kind
  elsif @extra == :set_default
    binding_default.deep_merge(binding_kind)
  elsif @extra == :default_only
    binding_default
  end
end

#binding_defaultObject



27
28
29
30
31
32
33
# File 'lib/config_kit/deploy_data.rb', line 27

def binding_default
  { 
    @kind => {
      'deploy' => deploy_default_data
    }
  }
end

#binding_deployObject



19
20
21
# File 'lib/config_kit/deploy_data.rb', line 19

def binding_deploy
  {'deploy' => data}
end

#binding_kindObject



23
24
25
# File 'lib/config_kit/deploy_data.rb', line 23

def binding_kind
  { @kind => binding_deploy}
end

#dataObject



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/config_kit/deploy_data.rb', line 45

def data
  { 
    @name => { 
      @version => 
            {
              "ts" => ts,
              "cs" => @cs
            }
            }
  }
end

#deploy_default_dataObject



57
58
59
60
61
62
63
# File 'lib/config_kit/deploy_data.rb', line 57

def deploy_default_data
  {
    @name => {
      'default' => @version
    }
  }
end