yml-secrets 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f97b7b3ec8c5b6f88990bc94b7b2045a3b3a3125
4
+ data.tar.gz: 3ccce0fee5065c1403622d0c5c0086dd2696d47d
5
+ SHA512:
6
+ metadata.gz: 889b8fc301741293c5b5b4b7ba76c708d02b3def49c90295c1a7bc69697baa409255b64075522bf5d1f0681cb2ae7eff7ce0da92861635b7754f853f42ba1e2f
7
+ data.tar.gz: 91699e94e3353ee7e133df9c4c4f59454421ba613f3f80ca02e1d1b00ebed2ac8b642ea8fc7d79a94b7bd0b46f1526397d3cdc4c84361048eb0e519d4eca224b
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ config
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in secrets.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Matteo Abis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Secrets
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Credits
6
+ inspired by https://github.com/collin/secrets
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'secrets', :git => 'https://github.com/Enucatl/secrets.git'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install secrets
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it ( https://github.com/Enucatl/secrets/fork )
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/lib/secrets.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "secrets/version"
2
+
3
+ module Secrets
4
+ # Your code goes here...
5
+ end
6
+
7
+ require "secrets/secret"
@@ -0,0 +1,27 @@
1
+ require "ostruct"
2
+ require "yaml"
3
+
4
+ module Secrets
5
+
6
+ class Secret
7
+
8
+ def initialize path
9
+ if File.exist?(path)
10
+ YAML.load_file(path).each do |(key, value)|
11
+ instance_variable_set "@#{key}", OpenStruct.new(value)
12
+ define_singleton_method key do
13
+ instance_variable_get "@#{key}"
14
+ end
15
+ define_singleton_method "#{key}=" do |v|
16
+ instance_variable_set "@#{key}", OpenStruct.new(v)
17
+ data = YAML.load_file path
18
+ data[key] = v
19
+ File.open(path, 'w') { |f| YAML.dump(data, f) }
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,3 @@
1
+ module Secrets
2
+ VERSION = "0.0.1"
3
+ end
data/secrets.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'secrets/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yml-secrets"
8
+ spec.version = Secrets::VERSION
9
+ spec.authors = ["Matteo Abis"]
10
+ spec.email = ["gmatteo..abis@gmail.com"]
11
+ spec.summary = "read and write from a secret yml file"
12
+ spec.description = "read and write from a secret yml file"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,30 @@
1
+ require 'secrets'
2
+
3
+ secrets_file = "config/secrets.yml"
4
+
5
+ describe Secrets::Secret do
6
+
7
+ before :all do
8
+ # setup a standard secrets file with an example server address
9
+ unless Dir.exist? "config"
10
+ Dir.mkdir "config"
11
+ end
12
+ secrets = {server: {address: "100.100.100.100"}}
13
+ File.open(secrets_file, "w") {|f| f.write secrets.to_yaml}
14
+ end
15
+
16
+ it "reads a secret" do
17
+ secrets = Secrets::Secret.new secrets_file
18
+ expect(secrets.server.address).to eql("100.100.100.100")
19
+ end
20
+
21
+ it "updates a secret" do
22
+ secrets = Secrets::Secret.new secrets_file
23
+ secrets.server.address = "100.100.200.200"
24
+ expect(secrets.server.address).to eql("100.100.200.200")
25
+ end
26
+
27
+ after :all do
28
+ File.delete "config/secrets.yml"
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yml-secrets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matteo Abis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: read and write from a secret yml file
56
+ email:
57
+ - gmatteo..abis@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/secrets.rb
68
+ - lib/secrets/secret.rb
69
+ - lib/secrets/version.rb
70
+ - secrets.gemspec
71
+ - spec/secrets_spec.rb
72
+ homepage: ''
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: read and write from a secret yml file
96
+ test_files:
97
+ - spec/secrets_spec.rb