custom_configuration 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 David Heinemeier Hansson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Custom Configuration
2
+
3
+ Makes it easy to use the Rails.configuration point as your central configuration store, even for things not included in Rails.
4
+
5
+ ``` ruby
6
+ # config/environments/production.rb
7
+ BCX::Application.configure do
8
+ config.x.resque.jobs_inline = true
9
+ end
10
+
11
+ # config/initializers/resque.rb
12
+ if Rails.configuration.x.resque.jobs_inline
13
+ Resque.inline = true
14
+ end
15
+ ```
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ require 'bundler/gem_tasks'
5
+ rescue LoadError
6
+ raise 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ require 'rake/testtask'
10
+
11
+ Rake::TestTask.new(:test) do |t|
12
+ t.libs << 'lib'
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task :default => :test
@@ -0,0 +1,2 @@
1
+ require 'custom_configuration/configuration'
2
+ require 'custom_configuration/railtie'
@@ -0,0 +1,11 @@
1
+ module CustomConfiguration
2
+ class Configuration
3
+ def initialize
4
+ @configurations = Hash.new
5
+ end
6
+
7
+ def method_missing(method, *args)
8
+ @configurations[method] ||= ActiveSupport::OrderedOptions.new
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails/railtie'
2
+
3
+ module CustomConfiguration
4
+ class Railtie < ::Rails::Railtie
5
+ config.x = CustomConfiguration::Configuration.new
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module CustomConfiguration
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+ require 'custom_configuration/configuration'
3
+
4
+ class CustomConfigurationTest < ActiveSupport::TestCase
5
+ setup do
6
+ @config = Rails.configuration.x
7
+ end
8
+
9
+ test 'any top level configuration point is accessible' do
10
+ @config.resque.inline_jobs = :always
11
+ assert_equal :always, @config.resque.inline_jobs
12
+ end
13
+
14
+ test 'you can set multiple points and they are remembered' do
15
+ @config.resque.inline_jobs = :always
16
+ @config.resque.timeout = 60
17
+
18
+ assert_equal :always, @config.resque.inline_jobs
19
+ assert_equal 60, @config.resque.timeout
20
+ end
21
+
22
+ test 'unset points are nil' do
23
+ assert_nil @config.resque.nothing_here
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require 'test/unit'
5
+ require 'rails'
6
+
7
+ class FakeApplication < Rails::Application; end
8
+ Rails.application = FakeApplication
9
+
10
+ require 'custom_configuration'
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: custom_configuration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Heinemeier Hansson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description:
47
+ email:
48
+ - david@heinemeierhansson.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/custom_configuration/configuration.rb
54
+ - lib/custom_configuration/railtie.rb
55
+ - lib/custom_configuration/version.rb
56
+ - lib/custom_configuration.rb
57
+ - MIT-LICENSE
58
+ - Rakefile
59
+ - README.md
60
+ - test/custom_configuration_test.rb
61
+ - test/test_helper.rb
62
+ homepage: https://github.com/rails/custom_configuration
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.23
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Custom configuration storage for Rails
86
+ test_files:
87
+ - test/custom_configuration_test.rb
88
+ - test/test_helper.rb