Class: ConfConf::Project::Developer
- Inherits:
-
Struct
- Object
- Struct
- ConfConf::Project::Developer
- Defined in:
- lib/conf_conf/project/developer.rb
Instance Attribute Summary collapse
-
#pretty_private_key ⇒ Object
Returns the value of attribute pretty_private_key.
-
#pretty_public_key ⇒ Object
Returns the value of attribute pretty_public_key.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#pretty_private_key ⇒ Object
Returns the value of attribute pretty_private_key
6 7 8 |
# File 'lib/conf_conf/project/developer.rb', line 6 def pretty_private_key @pretty_private_key end |
#pretty_public_key ⇒ Object
Returns the value of attribute pretty_public_key
6 7 8 |
# File 'lib/conf_conf/project/developer.rb', line 6 def pretty_public_key @pretty_public_key end |
Class Method Details
.current ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/conf_conf/project/developer.rb', line 7 def self.current user_config_path = File.join(File.('~'), '.conf_conf.json') if File.exists?(user_config_path) user_config = MultiJson.load(File.read(user_config_path)) else private_key = RbNaCl::PrivateKey.generate pretty_private_key = private_key.to_s.unpack('H*') pretty_public_key = private_key.public_key.to_s.unpack('H*') user_config = { 'public_key' => pretty_public_key, 'private_key' => pretty_private_key } File.write(user_config_path, MultiJson.dump(user_config)) end Developer.new(user_config['public_key'], user_config['private_key']) end |
Instance Method Details
#private_key ⇒ Object
29 30 31 |
# File 'lib/conf_conf/project/developer.rb', line 29 def private_key [pretty_private_key].pack('H*') end |
#public_key ⇒ Object
33 34 35 |
# File 'lib/conf_conf/project/developer.rb', line 33 def public_key [pretty_public_key].pack('H*') end |