secros 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 83b5b33c6b33d2f3ca71aabd4e2123c2821bbae3
4
+ data.tar.gz: 4fdbc4c6a8324efc6caa1b223b515a7d4c6c47be
5
+ SHA512:
6
+ metadata.gz: 80c30e3aa82f1cdb83119f936cd17aa7fc5b27a5ac5fe82474476e37227ce129b4219d61a0ccdba955ea506b173ce0dcf1cfad6178d2c551b64e68eb0a1f0b0f
7
+ data.tar.gz: bf0511adc2964a4aa2b8109aa9efa214e78dc951fadc6e4c78e04209bb0b7f32e4bdd9135c38da7355747caf60c99314241e14b85465b12163a21e3749bf30a0
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ /*.gem
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'activesupport'
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ secros (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.1.4)
10
+ i18n (~> 0.6, >= 0.6.9)
11
+ json (~> 1.7, >= 1.7.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.1)
14
+ tzinfo (~> 1.1)
15
+ diff-lcs (1.2.5)
16
+ i18n (0.6.9)
17
+ json (1.8.1)
18
+ minitest (5.3.5)
19
+ rspec (2.14.1)
20
+ rspec-core (~> 2.14.0)
21
+ rspec-expectations (~> 2.14.0)
22
+ rspec-mocks (~> 2.14.0)
23
+ rspec-core (2.14.8)
24
+ rspec-expectations (2.14.5)
25
+ diff-lcs (>= 1.1.3, < 2.0)
26
+ rspec-mocks (2.14.6)
27
+ thread_safe (0.3.4)
28
+ tzinfo (1.2.1)
29
+ thread_safe (~> 0.1)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ activesupport
36
+ rspec
37
+ secros!
data/bin/secros ADDED
@@ -0,0 +1,3 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require_relative '../lib/generate'
@@ -0,0 +1,4 @@
1
+ values:
2
+ hoge: piyo
3
+ files:
4
+ mage: meg.pem
data/lib/generate.rb ADDED
@@ -0,0 +1,11 @@
1
+ require_relative 'initialize'
2
+
3
+ def failed(message)
4
+ puts message
5
+ exit 1
6
+ end
7
+
8
+ failed('Please specify directory path.') if ARGV.length == 0
9
+ dir = ARGV[0]
10
+ failed("Directory #{dir} already exists.") if File.directory?(dir)
11
+ `cp -r #{File.expand_path('../../template', __FILE__)} #{dir}`
data/lib/initialize.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'active_support/all'
5
+ require 'yaml'
6
+
7
+ ActiveSupport::Dependencies.autoload_paths << File.expand_path('../../lib', __FILE__)
@@ -0,0 +1,13 @@
1
+ module Secros::Paths
2
+ def root_path
3
+ @root_path
4
+ end
5
+
6
+ def secrets_path
7
+ File.join(root_path, 'secrets.yml')
8
+ end
9
+
10
+ def secret_files_path
11
+ File.join(root_path, 'files')
12
+ end
13
+ end
data/lib/secros.rb ADDED
@@ -0,0 +1,27 @@
1
+ require_relative 'initialize'
2
+
3
+ class Secros
4
+ include Paths
5
+
6
+ def initialize(path)
7
+ @root_path = path
8
+ end
9
+
10
+ def value(key)
11
+ secrets[:values][normalized_key(key)]
12
+ end
13
+
14
+ def file(key)
15
+ File.join(secret_files_path, secrets[:files][normalized_key(key)])
16
+ end
17
+
18
+ private
19
+
20
+ def secrets
21
+ @secrets ||= YAML.load(File.read(secrets_path)).deep_symbolize_keys
22
+ end
23
+
24
+ def normalized_key(key)
25
+ key.to_s.to_sym
26
+ end
27
+ end
data/secros.gemspec ADDED
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'secros'
3
+ s.version = '0.1.0'
4
+ s.authors = ['Tetsuri Moriya']
5
+ s.email = ['tetsuri.moriya@gmail.com']
6
+ s.summary = 'Secrets management gem'
7
+ s.description = 'You can manage all your secrets in one place.'
8
+ s.homepage = 'https://bitbucket.org/pandora2000/secros'
9
+ s.license = 'MIT'
10
+ s.files = `git ls-files`.split("\n")
11
+ s.add_development_dependency 'rspec', '~> 0'
12
+ end
data/spec/secrets.yml ADDED
@@ -0,0 +1,4 @@
1
+ values:
2
+ test_key: test_value
3
+ files:
4
+ test_file_key: test_file_value
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'secros'
5
+
6
+ def root_path
7
+ File.expand_path('../..', __FILE__)
8
+ end
data/spec/test_spec.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'test' do
4
+ it 'should succeed' do
5
+ generate_path = "#{root_path}/tmp/secros_generate_spec_dummy#{SecureRandom.uuid}"
6
+ `mkdir -p #{File.dirname(generate_path)}`
7
+ `rm -rf #{generate_path}`
8
+ `ruby #{File.join(root_path, 'lib', 'generate.rb')} #{generate_path}`
9
+ `cp #{File.join(root_path, 'spec', 'secrets.yml')} #{generate_path}/secrets.yml`
10
+ secros = Secros.new(generate_path)
11
+ secros.value(:test_key).should eq('test_value')
12
+ secros.file(:test_file_key).should eq("#{generate_path}/files/test_file_value")
13
+ `rm -rf #{generate_path}`
14
+ end
15
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ values: {}
2
+ files: {}
@@ -0,0 +1,4 @@
1
+ values:
2
+ test_key: test_value
3
+ files:
4
+ test_file_key: test_file_value
@@ -0,0 +1,4 @@
1
+ values:
2
+ test_key: test_value
3
+ files:
4
+ test_file_key: test_file_value
@@ -0,0 +1,4 @@
1
+ values:
2
+ test_key: test_value
3
+ files:
4
+ test_file_key: test_file_value
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: secros
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tetsuri Moriya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: You can manage all your secrets in one place.
28
+ email:
29
+ - tetsuri.moriya@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - bin/secros
38
+ - config/secrets.yml
39
+ - lib/generate.rb
40
+ - lib/initialize.rb
41
+ - lib/secros.rb
42
+ - lib/secros/paths.rb
43
+ - secros.gemspec
44
+ - spec/secrets.yml
45
+ - spec/spec_helper.rb
46
+ - spec/test_spec.rb
47
+ - template/files/.gitkeep
48
+ - template/secrets.yml
49
+ - tmp/secros_generate_spec_dummy3a25bbd0-c885-4831-ace8-65c8ed442278/files/.gitkeep
50
+ - tmp/secros_generate_spec_dummy3a25bbd0-c885-4831-ace8-65c8ed442278/secrets.yml
51
+ - tmp/secros_generate_spec_dummy8ed8ff34-0c8d-464a-88e3-54e1f92fe3c7/files/.gitkeep
52
+ - tmp/secros_generate_spec_dummy8ed8ff34-0c8d-464a-88e3-54e1f92fe3c7/secrets.yml
53
+ - tmp/secros_generate_spec_dummy94e40a74-69ed-4242-9bf5-15a6454e0401/files/.gitkeep
54
+ - tmp/secros_generate_spec_dummy94e40a74-69ed-4242-9bf5-15a6454e0401/secrets.yml
55
+ homepage: https://bitbucket.org/pandora2000/secros
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.2.2
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Secrets management gem
79
+ test_files: []
80
+ has_rdoc: