Class: SignedConfig::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/signed_config/writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(private_key, config_hash, org_name = nil) ⇒ Writer

Returns a new instance of Writer.



3
4
5
6
7
8
9
# File 'lib/signed_config/writer.rb', line 3

def initialize(private_key, config_hash, org_name = nil)
  config_string = YAML::dump(config_hash)
  signature = Crypto.sign(private_key, config_string)
  @org_name = org_name
  @signed_config = YAML::dump({:config => config_string,
                               :signature => signature})
end

Instance Method Details

#signed_configObject



11
12
13
14
15
16
17
18
# File 'lib/signed_config/writer.rb', line 11

def signed_config
  dramatic = '=' * 25
  brand_txt = @org_name ? @org_name + " " : nil

  "#{dramatic}BEGIN #{brand_txt}LICENSE#{dramatic}\n" +
  @signed_config + "\n" +
  "#{dramatic}END #{brand_txt}LICENSE#{dramatic}"
end