Class: MrF::Project
- Inherits:
-
Object
- Object
- MrF::Project
- Defined in:
- lib/mrf/project.rb
Instance Attribute Summary collapse
-
#gpg_passphrase ⇒ Object
Returns the value of attribute gpg_passphrase.
-
#secrets_path ⇒ Object
Returns the value of attribute secrets_path.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Project
constructor
A new instance of Project.
- #unpack_secrets ⇒ Object
- #yaml_file?(path) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Project
Returns a new instance of Project.
7 8 9 10 |
# File 'lib/mrf/project.rb', line 7 def initialize (opts={}) @secrets_path = opts.fetch(:secrets_path) @gpg_passphrase = opts.fetch(:gpg_passphrase, nil) end |
Instance Attribute Details
#gpg_passphrase ⇒ Object
Returns the value of attribute gpg_passphrase.
4 5 6 |
# File 'lib/mrf/project.rb', line 4 def gpg_passphrase @gpg_passphrase end |
#secrets_path ⇒ Object
Returns the value of attribute secrets_path.
5 6 7 |
# File 'lib/mrf/project.rb', line 5 def secrets_path @secrets_path end |
Instance Method Details
#unpack_secrets ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mrf/project.rb', line 12 def unpack_secrets raise "File not found: #{secrets_path}" unless File.exists?(secrets_path) keyring = Keyring.new( path: secrets_path, gpg_passphrase: gpg_passphrase ) keyring.data.reduce({}) do |acc, (filename, data)| content = StringIO.new(yaml_file?(filename) ? YAML.dump(data) : data) acc.merge(filename => content) end end |
#yaml_file?(path) ⇒ Boolean
25 26 27 |
# File 'lib/mrf/project.rb', line 25 def yaml_file? (path) path =~ /\A.*\.yml\Z/ end |