Module: GitBlur::Conf

Defined in:
lib/git-blur/conf.rb

Defined Under Namespace

Classes: MissingConfiguration

Class Method Summary collapse

Class Method Details

.ciphersObject



25
26
27
# File 'lib/git-blur/conf.rb', line 25

def ciphers
  config[ :ciphers ]
end

.ciphers=(cipher_list) ⇒ Object



21
22
23
# File 'lib/git-blur/conf.rb', line 21

def ciphers=( cipher_list )
  config[:ciphers] = cipher_list
end

.configObject



12
13
14
# File 'lib/git-blur/conf.rb', line 12

def config
  @config ||= {}
end

.config=(conf_hash) ⇒ Object



8
9
10
# File 'lib/git-blur/conf.rb', line 8

def config=( conf_hash )
  @config = conf_hash
end

.keysObject



29
30
31
# File 'lib/git-blur/conf.rb', line 29

def keys
  config[ :keys ]
end

.read_configuration(config_file) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/git-blur/conf.rb', line 33

def read_configuration( config_file )
  config_file = File.expand_path( config_file )
  config_hash = YAML.load( File.read( config_file ) )
  if config_hash.include? :keys
    config_hash[ :keys ].each_key do |k|
      config_hash[ :keys ][k] = Base64.strict_decode64( config_hash[ :keys ][k] )
    end
  end
  self.config = config_hash || {}
rescue Errno::ENOENT
  raise GitBlur::MissingConfiguration.new(config_file)
end

.store_keys_from_gen(keygen) ⇒ Object



16
17
18
19
# File 'lib/git-blur/conf.rb', line 16

def store_keys_from_gen( keygen )
  ciphers = keygen.cipher_list
  config[ :keys ] = keygen.cipher_keys
end

.write_configuration(config_file) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/git-blur/conf.rb', line 46

def write_configuration( config_file )
  config_file = File.expand_path( config_file )
  txt_config = self.config.clone
  if txt_config.include? :keys
    txt_config[ :keys ].each_key do |k|
      txt_config[ :keys ][k] = Base64.strict_encode64( txt_config[ :keys ][k] )
    end
  end
  File.open( config_file, "wb" ) do |f| 
    f.write( YAML.dump( self.config ) )
  end
rescue Errno::ENOENT
  raise GitBlur::MissingConfiguration.new(config_file)
end