rails-secrets 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e369fbd416f9f930faa9a80e34de33e432d475f
4
+ data.tar.gz: 921fd05a350a4c7fdf8bb23a288c76534c457b6b
5
+ SHA512:
6
+ metadata.gz: 9d9fa32a479ccb9f8b09fe820b7c53b17b97ad50e80560b1c7231b9580cff312a1d99d2f15f2ae85a2856ad534a8d3274ec2ddf5d2d48774abb511824b13d15e
7
+ data.tar.gz: 906b461739d6b57d6b91cf8616ffadea1274e3a1c521afa1025071ae19698a8504d5e274116482bcc82ed019800273491eb2fe7be66c84e7be9714d030d7db2a
@@ -0,0 +1,6 @@
1
+ pkg/*
2
+ rdoc/*
3
+ *.gem
4
+ .bundle
5
+ Gemfile.lock
6
+ gemfiles/*.lock
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Andrew White
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.
@@ -0,0 +1,52 @@
1
+ # Rails Secrets
2
+
3
+ This gem backports the `config/secrets.yml` from Rails 4.1 to Rails 4.0 applications.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rails-secrets'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rails-secrets
18
+
19
+ ## Usage
20
+
21
+ Add this gem to your Gemfile, remove `config/initializers/secret_token.rb` and configure `config/secrets.yml` [as you would for Rails 4.1][1].
22
+
23
+ ## Changelog
24
+
25
+ ### 1.0.0
26
+
27
+ Initial version.
28
+
29
+ ## License (MIT)
30
+
31
+ Copyright (c) 2014 Andrew White <andyw@pixeltrix.co.uk>
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining
34
+ a copy of this software and associated documentation files (the
35
+ "Software"), to deal in the Software without restriction, including
36
+ without limitation the rights to use, copy, modify, merge, publish,
37
+ distribute, sublicense, and/or sell copies of the Software, and to
38
+ permit persons to whom the Software is furnished to do so, subject to
39
+ the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be
42
+ included in all copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
45
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
46
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
47
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
48
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
49
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
50
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
51
+
52
+ [1]: http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#config-secrets-yml
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "rake/testtask"
3
+ require "bundler/gem_tasks"
4
+
5
+ desc "Default: run rails-secrets unit tests."
6
+ task :default => :test
7
+
8
+ Rake::TestTask.new do |t|
9
+ t.libs += %w[lib test]
10
+ t.pattern = "test/**/*_test.rb"
11
+ t.warning = true
12
+ end
@@ -0,0 +1 @@
1
+ require "rails/secrets"
@@ -0,0 +1,2 @@
1
+ require "rails/secrets/version"
2
+ require "rails/secrets/railtie"
@@ -0,0 +1,37 @@
1
+ module Rails
2
+ module Secrets
3
+ module InstanceMethods
4
+ def secrets
5
+ @secrets ||= ActiveSupport::OrderedOptions.new.tap do |secrets|
6
+ yaml = config.paths["config/secrets"].first
7
+
8
+ if File.exist?(yaml)
9
+ require "erb"
10
+ all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {}
11
+ env_secrets = all_secrets[::Rails.env]
12
+ secrets.merge!(env_secrets.symbolize_keys) if env_secrets
13
+ end
14
+ end
15
+ end
16
+
17
+ def secrets=(secrets)
18
+ @secrets = secrets
19
+ end
20
+ end
21
+
22
+ class Railtie < ::Rails::Railtie
23
+ initializer 'rails.secrets' do |app|
24
+ app.paths.add "config/secrets", with: "config/secrets.yml"
25
+ app.extend(InstanceMethods)
26
+
27
+ ActiveSupport.on_load(:after_initialize) do
28
+ if app.secrets.secret_key_base.blank?
29
+ raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
30
+ else
31
+ app.config.secret_key_base = app.secrets.secret_key_base
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module Rails
2
+ module Secrets
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rails/secrets/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "rails-secrets"
7
+ gem.version = Rails::Secrets::VERSION
8
+ gem.platform = Gem::Platform::RUBY
9
+ gem.authors = ["Andrew White"]
10
+ gem.email = ["andyw@pixeltrix.co.uk"]
11
+ gem.homepage = "https://github.com/pixeltrix/rails-secrets"
12
+
13
+ gem.summary = %q{Rails 4.1 secrets.yml for Rails 4.0}
14
+ gem.description = %q{Rails::Secrets is a backport of Rails 4.1 secrets.yml to Rails 4.0}
15
+
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.required_ruby_version = '>= 1.9.3'
22
+ gem.required_rubygems_version = '>= 1.8.11'
23
+
24
+ gem.add_runtime_dependency 'rails', ['>= 4.0.0', '<= 4.1.0']
25
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "rails/all"
4
+
5
+ Bundler.require(*Rails.groups)
6
+
7
+ require 'rails/secrets'
8
+
9
+ module Dummy
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
+ # config.time_zone = 'Central Time (US & Canada)'
18
+
19
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
+ # config.i18n.default_locale = :de
22
+
23
+ # Ignore log output
24
+ config.logger = Logger.new('/dev/null')
25
+ Rails.logger = config.logger
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,29 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Eager load engine models
10
+ config.eager_load = true
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end
@@ -0,0 +1,80 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation can not be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+ end
@@ -0,0 +1,36 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = "public, max-age=3600"
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ secret_key_base: <%= SecureRandom.hex(64) %>
3
+ api_token: "9f4a992"
@@ -0,0 +1,21 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path('../dummy/config/environment', __FILE__)
3
+ require 'minitest/autorun'
4
+
5
+ class RailsSecretsTest < ActiveSupport::TestCase
6
+
7
+ test "secrets is loaded from config/secrets.yml" do
8
+ assert_equal "9f4a992", app.secrets.api_token
9
+ end
10
+
11
+ test "config.secret_key_base is copied from secrets.secret_key_base" do
12
+ assert_equal app.secrets.secret_key_base, app.config.secret_key_base
13
+ end
14
+
15
+ private
16
+
17
+ def app
18
+ Rails.application
19
+ end
20
+
21
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-secrets
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew White
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-18 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: 4.0.0
20
+ - - <=
21
+ - !ruby/object:Gem::Version
22
+ version: 4.1.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 4.0.0
30
+ - - <=
31
+ - !ruby/object:Gem::Version
32
+ version: 4.1.0
33
+ description: Rails::Secrets is a backport of Rails 4.1 secrets.yml to Rails 4.0
34
+ email:
35
+ - andyw@pixeltrix.co.uk
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - .gitignore
41
+ - .travis.yml
42
+ - Gemfile
43
+ - LICENSE
44
+ - README.md
45
+ - Rakefile
46
+ - lib/rails-secrets.rb
47
+ - lib/rails/secrets.rb
48
+ - lib/rails/secrets/railtie.rb
49
+ - lib/rails/secrets/version.rb
50
+ - rails-secrets.gemspec
51
+ - test/dummy/config.ru
52
+ - test/dummy/config/application.rb
53
+ - test/dummy/config/boot.rb
54
+ - test/dummy/config/environment.rb
55
+ - test/dummy/config/environments/development.rb
56
+ - test/dummy/config/environments/production.rb
57
+ - test/dummy/config/environments/test.rb
58
+ - test/dummy/config/secrets.yml
59
+ - test/rails_secrets_test.rb
60
+ homepage: https://github.com/pixeltrix/rails-secrets
61
+ licenses: []
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: 1.9.3
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: 1.8.11
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.2.1
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Rails 4.1 secrets.yml for Rails 4.0
83
+ test_files:
84
+ - test/dummy/config.ru
85
+ - test/dummy/config/application.rb
86
+ - test/dummy/config/boot.rb
87
+ - test/dummy/config/environment.rb
88
+ - test/dummy/config/environments/development.rb
89
+ - test/dummy/config/environments/production.rb
90
+ - test/dummy/config/environments/test.rb
91
+ - test/dummy/config/secrets.yml
92
+ - test/rails_secrets_test.rb