rails-creds 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
+ SHA256:
3
+ metadata.gz: 497fb39a0aa27697fe83d1d9e67072e4ec36810bfd3eed590ddad0ffc53b7d79
4
+ data.tar.gz: befd5d2e8f5edde45600a541fd7295460ec2f3ca59963f4c825249c0f45f957f
5
+ SHA512:
6
+ metadata.gz: 5859ffeb2a62357f628370ffc511fd6323d6cbda3ee912512feadae76dfa6468c80e9747ee243bd165a3afba53fe0fd42465485b00cf4ec6bd81508599532dc0
7
+ data.tar.gz: 366f49854ac673e5ac2ed9249fc296076ba923ba6b6b1184c4888a5d6a9654a2d26656a7d08f57dcb980d8fe697d1a4925bc7ad025515a6914c40eed4dc24777
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ config/credentials.yml.enc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'creds.gemspec'
4
+
5
+ Metrics/BlockLength:
6
+ Exclude:
7
+ - 'spec/**/*.rb'
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mikkel@brnbw.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in creds.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,158 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ creds (0.1.0)
5
+ rails (~> 5.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.2.0)
11
+ actionpack (= 5.2.0)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailer (5.2.0)
15
+ actionpack (= 5.2.0)
16
+ actionview (= 5.2.0)
17
+ activejob (= 5.2.0)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.2.0)
21
+ actionview (= 5.2.0)
22
+ activesupport (= 5.2.0)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.2.0)
28
+ activesupport (= 5.2.0)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.2.0)
34
+ activesupport (= 5.2.0)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.2.0)
37
+ activesupport (= 5.2.0)
38
+ activerecord (5.2.0)
39
+ activemodel (= 5.2.0)
40
+ activesupport (= 5.2.0)
41
+ arel (>= 9.0)
42
+ activestorage (5.2.0)
43
+ actionpack (= 5.2.0)
44
+ activerecord (= 5.2.0)
45
+ marcel (~> 0.3.1)
46
+ activesupport (5.2.0)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (>= 0.7, < 2)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ arel (9.0.0)
52
+ ast (2.4.0)
53
+ builder (3.2.3)
54
+ concurrent-ruby (1.0.5)
55
+ crass (1.0.4)
56
+ diff-lcs (1.3)
57
+ erubi (1.7.1)
58
+ globalid (0.4.1)
59
+ activesupport (>= 4.2.0)
60
+ i18n (1.0.0)
61
+ concurrent-ruby (~> 1.0)
62
+ loofah (2.2.2)
63
+ crass (~> 1.0.2)
64
+ nokogiri (>= 1.5.9)
65
+ mail (2.7.0)
66
+ mini_mime (>= 0.1.1)
67
+ marcel (0.3.2)
68
+ mimemagic (~> 0.3.2)
69
+ method_source (0.9.0)
70
+ mimemagic (0.3.2)
71
+ mini_mime (1.0.0)
72
+ mini_portile2 (2.3.0)
73
+ minitest (5.11.3)
74
+ nio4r (2.3.0)
75
+ nokogiri (1.8.2)
76
+ mini_portile2 (~> 2.3.0)
77
+ parallel (1.12.1)
78
+ parser (2.5.0.5)
79
+ ast (~> 2.4.0)
80
+ powerpack (0.1.1)
81
+ rack (2.0.4)
82
+ rack-test (1.0.0)
83
+ rack (>= 1.0, < 3)
84
+ rails (5.2.0)
85
+ actioncable (= 5.2.0)
86
+ actionmailer (= 5.2.0)
87
+ actionpack (= 5.2.0)
88
+ actionview (= 5.2.0)
89
+ activejob (= 5.2.0)
90
+ activemodel (= 5.2.0)
91
+ activerecord (= 5.2.0)
92
+ activestorage (= 5.2.0)
93
+ activesupport (= 5.2.0)
94
+ bundler (>= 1.3.0)
95
+ railties (= 5.2.0)
96
+ sprockets-rails (>= 2.0.0)
97
+ rails-dom-testing (2.0.3)
98
+ activesupport (>= 4.2.0)
99
+ nokogiri (>= 1.6)
100
+ rails-html-sanitizer (1.0.4)
101
+ loofah (~> 2.2, >= 2.2.2)
102
+ railties (5.2.0)
103
+ actionpack (= 5.2.0)
104
+ activesupport (= 5.2.0)
105
+ method_source
106
+ rake (>= 0.8.7)
107
+ thor (>= 0.18.1, < 2.0)
108
+ rainbow (3.0.0)
109
+ rake (10.5.0)
110
+ rspec (3.7.0)
111
+ rspec-core (~> 3.7.0)
112
+ rspec-expectations (~> 3.7.0)
113
+ rspec-mocks (~> 3.7.0)
114
+ rspec-core (3.7.1)
115
+ rspec-support (~> 3.7.0)
116
+ rspec-expectations (3.7.0)
117
+ diff-lcs (>= 1.2.0, < 2.0)
118
+ rspec-support (~> 3.7.0)
119
+ rspec-mocks (3.7.0)
120
+ diff-lcs (>= 1.2.0, < 2.0)
121
+ rspec-support (~> 3.7.0)
122
+ rspec-support (3.7.1)
123
+ rubocop (0.54.0)
124
+ parallel (~> 1.10)
125
+ parser (>= 2.5)
126
+ powerpack (~> 0.1)
127
+ rainbow (>= 2.2.2, < 4.0)
128
+ ruby-progressbar (~> 1.7)
129
+ unicode-display_width (~> 1.0, >= 1.0.1)
130
+ ruby-progressbar (1.9.0)
131
+ sprockets (3.7.1)
132
+ concurrent-ruby (~> 1.0)
133
+ rack (> 1, < 3)
134
+ sprockets-rails (3.2.1)
135
+ actionpack (>= 4.0)
136
+ activesupport (>= 4.0)
137
+ sprockets (>= 3.0.0)
138
+ thor (0.20.0)
139
+ thread_safe (0.3.6)
140
+ tzinfo (1.2.5)
141
+ thread_safe (~> 0.1)
142
+ unicode-display_width (1.3.0)
143
+ websocket-driver (0.7.0)
144
+ websocket-extensions (>= 0.1.0)
145
+ websocket-extensions (0.1.3)
146
+
147
+ PLATFORMS
148
+ ruby
149
+
150
+ DEPENDENCIES
151
+ bundler (~> 1.16)
152
+ creds!
153
+ rake (~> 10.0)
154
+ rspec (~> 3.0)
155
+ rubocop (~> 0.54)
156
+
157
+ BUNDLED WITH
158
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Mikkel Malmberg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ <h1><img src='https://s3.brnbw.com/logo-2x-SiurkO6hTL.png' alt='' width='220' /></h1>
2
+
3
+ `Creds` is both **a)** a shortcut for the dreadfully long `Rails.application.credentials` and **b)** bringing environment scoping back (from when it was called _secrets_).
4
+
5
+ ## Usage
6
+
7
+ Given encrypted credentials looking like:
8
+
9
+ ```yaml
10
+ ---
11
+ default: &default
12
+ super_secret: 'shared between environments'
13
+
14
+ development:
15
+ <<: *default
16
+
17
+ test:
18
+ <<: *default
19
+
20
+ production:
21
+ <<: *default
22
+ super_secret: 'you can override defaults for individual environments'
23
+ ```
24
+
25
+ You can access those super secret things like:
26
+
27
+ ```ruby
28
+ Creds.super_secret # => "shared between environments"
29
+ # or, of course, the other when in production
30
+ ```
31
+
32
+ ## Installation
33
+
34
+ ```ruby
35
+ gem 'rails-creds'
36
+ ```
37
+
38
+ That's it.
39
+
40
+ ## License
41
+
42
+ MIT
43
+
44
+
45
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/config/master.key ADDED
@@ -0,0 +1 @@
1
+ 69104fb1cb0f1be6b0a0019f1311bb00
data/creds.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'creds/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'rails-creds'
7
+ spec.version = Creds::VERSION
8
+ spec.authors = ['Mikkel Malmberg']
9
+ spec.email = ['mikkel@brnbw.com']
10
+
11
+ spec.summary = "Shorter, env-scoped version of Rails' credentials"
12
+ spec.description = ''
13
+ spec.homepage = 'https://github.com/mikker/rails-creds'
14
+ spec.metadata = { 'source_code_uri' => 'https://github.com/mikker/rails-creds' }
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'rails', '~> 5.2'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'rubocop', '~> 0.54'
30
+ end
@@ -0,0 +1,3 @@
1
+ class Creds
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/lib/creds.rb ADDED
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'creds/version'
4
+ require 'ostruct'
5
+ require 'singleton'
6
+
7
+ require 'rails'
8
+
9
+ # The main module
10
+ class Creds
11
+ class MissingKeyError < StandardError
12
+ MESSAGE = 'Key :%<key>s missing from credentials in "%<env>s" env'.freeze
13
+ end
14
+
15
+ class MissingEnvError < StandardError
16
+ # rubocop:disable Layout/TrailingWhitespace
17
+ MESSAGE = <<-MSG
18
+ Creds scopes credentials to the current Rails environment.
19
+ It seems you are missing a scope for the environment "%<env>s".
20
+
21
+ Here's an example of how your credentials could look:
22
+
23
+ ---
24
+ default: &default
25
+ aws_key: 'shared between environments'
26
+
27
+ development:
28
+ <<: *default
29
+
30
+ test:
31
+ <<: *default
32
+
33
+ production:
34
+ <<: *default
35
+ aws_key: 'you can override defaults for individual environments'
36
+ MSG
37
+ .strip_heredoc.freeze
38
+ # rubocop:enable Layout/TrailingWhitespace
39
+ end
40
+
41
+ include Singleton
42
+
43
+ # rubocop:disable Style/MethodMissing
44
+ def self.method_missing(name, *_args)
45
+ instance.credentials.fetch(name)
46
+ rescue KeyError
47
+ raise(
48
+ MissingKeyError,
49
+ format(MissingKeyError::MESSAGE, key: name, env: Rails.env)
50
+ )
51
+ end
52
+ # rubocop:enable Style/MethodMissing
53
+
54
+ def self.to_h
55
+ instance.credentials
56
+ end
57
+
58
+ def credentials
59
+ Rails.application.credentials.fetch(Rails.env.to_sym)
60
+ rescue KeyError
61
+ raise(
62
+ MissingEnvError,
63
+ format(MissingEnvError::MESSAGE, env: Rails.env)
64
+ )
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ # rubocop:disable Naming/FileName
2
+ # rubocop:enable Naming/FileName
3
+ require 'creds'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-creds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mikkel Malmberg
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.54'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.54'
83
+ description: ''
84
+ email:
85
+ - mikkel@brnbw.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - config/master.key
101
+ - creds.gemspec
102
+ - lib/creds.rb
103
+ - lib/creds/version.rb
104
+ - lib/rails-creds.rb
105
+ homepage: https://github.com/mikker/rails-creds
106
+ licenses:
107
+ - MIT
108
+ metadata:
109
+ source_code_uri: https://github.com/mikker/rails-creds
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.7.6
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Shorter, env-scoped version of Rails' credentials
130
+ test_files: []