app_settings 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -8
- data/lib/app_settings.rb +2 -1
- data/lib/app_settings/railtie.rb +3 -19
- data/lib/app_settings/settings.rb +15 -0
- data/lib/app_settings/version.rb +3 -0
- data/test/app_settings_test.rb +24 -0
- data/test/test_helper.rb +11 -0
- metadata +18 -19
- data/.gitignore +0 -18
- data/.travis.yml +0 -9
- data/Gemfile +0 -4
- data/app_settings.gemspec +0 -22
- data/test/railtie_test.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80ef1d7b12243f96b63a2d6715370f0105523c22
|
4
|
+
data.tar.gz: 5b6fe9a9a333df5fcb7571a568c003f2b264aa40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76fbff0d6d69760eec0410730420424cf958df2920907d90035411a4780838a07928ec000a37421c267eb8f1ea9f246a78cedffef39a76be3c97576ae0f2154a
|
7
|
+
data.tar.gz: 5ecd4cf6d75d4c36c5e31cbf86c3c9db0ea73d6aa6e26296b43c5295c30dddb366e805255234989925842f3c2011394fa672de7c239b73e4f92c7c6f2f5be83d
|
data/README.md
CHANGED
@@ -35,10 +35,10 @@ gem 'app_settings'
|
|
35
35
|
|
36
36
|
You can use the following files to declare your application settings:
|
37
37
|
|
38
|
-
* config/application.rb
|
39
|
-
* config/environemnts/development.rb
|
40
|
-
* config/environemnts/test.rb
|
41
|
-
* config/environemnts/production.rb
|
38
|
+
* config/application.rb (for all environments)
|
39
|
+
* config/environemnts/development.rb (for just dev env)
|
40
|
+
* config/environemnts/test.rb (for just the test env)
|
41
|
+
* config/environemnts/production.rb (for just the production env)
|
42
42
|
|
43
43
|
The settings will work in the same way that Rails' environment config, where the application.rb is for all environments, but can be overridden by the environment specific files (development.rb, test.rb, production.rb).
|
44
44
|
|
@@ -52,8 +52,8 @@ config.settings.company_name = 'Fancy Pants LLC'
|
|
52
52
|
Then, anywhere in your app, you can access those by doing:
|
53
53
|
|
54
54
|
````
|
55
|
-
Rails.
|
56
|
-
Rails.
|
55
|
+
Rails.configuration.settings.appname # => 'My Rails Application'
|
56
|
+
Rails.configuration.settings.company_name # => 'Fancy Pants LLC'
|
57
57
|
````
|
58
58
|
|
59
59
|
OR
|
@@ -68,5 +68,3 @@ From there, you could put those into the app/controllers/application_controller.
|
|
68
68
|
file and shorten the name and then make it also a helper method. You could also
|
69
69
|
put it into your models as a method or use [Rails'
|
70
70
|
config_accessor](http://api.rubyonrails.org/classes/ActiveSupport/Configurable/ClassMethods.html#method-i-config_accessor). You'll get the benefit of having your app settings all in one place.
|
71
|
-
|
72
|
-
|
data/lib/app_settings.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require 'app_settings/
|
1
|
+
require 'app_settings/settings'
|
2
|
+
require 'app_settings/railtie'
|
data/lib/app_settings/railtie.rb
CHANGED
@@ -1,23 +1,7 @@
|
|
1
|
-
require 'rails'
|
2
|
-
require 'active_support/core_ext/module/remove_method'
|
3
|
-
|
4
|
-
module Rails
|
5
|
-
class Application
|
6
|
-
|
7
|
-
class Configuration
|
8
|
-
remove_possible_method :settings
|
9
|
-
end
|
10
|
-
|
11
|
-
# Undefine settings, if it even exists
|
12
|
-
remove_possible_method :settings
|
13
|
-
remove_possible_method :settings=
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
1
|
+
require 'rails/railtie'
|
18
2
|
|
19
3
|
module AppSettings
|
20
|
-
class Railtie < Rails::Railtie
|
21
|
-
config.settings =
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
config.settings = AppSettings::Settings.configuration
|
22
6
|
end
|
23
7
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'app_settings/settings'
|
3
|
+
|
4
|
+
class AppSettingsTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@config = Rails.configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def test_defaults
|
12
|
+
assert_empty @config.settings
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def test_storing_info_in_settings
|
17
|
+
assert_empty @config.settings
|
18
|
+
@config.settings.app_name = 'Test Name'
|
19
|
+
|
20
|
+
refute_empty @config.settings
|
21
|
+
assert_equal 'Test Name', @config.settings.app_name
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,26 +38,24 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email:
|
43
43
|
- robert@codewranglers.org
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- ".gitignore"
|
49
|
-
- ".travis.yml"
|
50
|
-
- Gemfile
|
51
48
|
- LICENSE.txt
|
52
49
|
- README.md
|
53
50
|
- Rakefile
|
54
|
-
- app_settings.gemspec
|
55
51
|
- lib/app_settings.rb
|
56
52
|
- lib/app_settings/railtie.rb
|
57
|
-
-
|
58
|
-
|
59
|
-
|
60
|
-
-
|
53
|
+
- lib/app_settings/settings.rb
|
54
|
+
- lib/app_settings/version.rb
|
55
|
+
- test/app_settings_test.rb
|
56
|
+
- test/test_helper.rb
|
57
|
+
homepage: https://github.com/revans/app_settings
|
58
|
+
licenses: []
|
61
59
|
metadata: {}
|
62
60
|
post_install_message:
|
63
61
|
rdoc_options: []
|
@@ -78,6 +76,7 @@ rubyforge_project:
|
|
78
76
|
rubygems_version: 2.2.2
|
79
77
|
signing_key:
|
80
78
|
specification_version: 4
|
81
|
-
summary: Application
|
79
|
+
summary: Application Settings for Rails
|
82
80
|
test_files:
|
83
|
-
- test/
|
81
|
+
- test/app_settings_test.rb
|
82
|
+
- test/test_helper.rb
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/app_settings.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "app_settings"
|
7
|
-
spec.version = "0.0.2"
|
8
|
-
spec.authors = ["Robert Evans"]
|
9
|
-
spec.email = ["robert@codewranglers.org"]
|
10
|
-
spec.summary = %q{Application wide settings}
|
11
|
-
spec.description = %q{Application wide settings}
|
12
|
-
spec.homepage = ""
|
13
|
-
spec.license = "MIT"
|
14
|
-
|
15
|
-
spec.files = `git ls-files -z`.split("\x0")
|
16
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_development_dependency "bundler"
|
21
|
-
spec.add_development_dependency "rake"
|
22
|
-
end
|
data/test/railtie_test.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'minitest/pride'
|
3
|
-
|
4
|
-
require 'active_support'
|
5
|
-
require 'active_support/testing/isolation'
|
6
|
-
require 'pathname'
|
7
|
-
|
8
|
-
class TestBoot < Minitest::Test
|
9
|
-
include ::ActiveSupport::Testing::Isolation
|
10
|
-
|
11
|
-
ROOT = File.expand_path("../../tmp/app", __FILE__)
|
12
|
-
|
13
|
-
attr_reader :app
|
14
|
-
|
15
|
-
def setup
|
16
|
-
require 'rails'
|
17
|
-
|
18
|
-
require 'active_support/dependencies'
|
19
|
-
require 'tzinfo'
|
20
|
-
|
21
|
-
ENV['RAILS_ENV'] = 'test'
|
22
|
-
|
23
|
-
FileUtils.mkdir_p ROOT
|
24
|
-
Dir.chdir ROOT
|
25
|
-
|
26
|
-
@app = Class.new(Rails::Application)
|
27
|
-
|
28
|
-
# Get bitched at if you don't set these
|
29
|
-
@app.config.eager_load = false
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_initialize
|
34
|
-
app.initialize!
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class TestRailtie < TestBoot
|
39
|
-
|
40
|
-
def setup
|
41
|
-
require ::Pathname.new(__dir__).join('../lib/app_settings/railtie').to_s
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def test_defaults
|
47
|
-
app.initialize!
|
48
|
-
|
49
|
-
assert_empty app.config.settings
|
50
|
-
assert_instance_of ActiveSupport::OrderedOptions, app.config.settings
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
def test_storing_info_in_settings
|
55
|
-
assert_empty app.config.settings
|
56
|
-
app.config.settings.app_name = 'Test Name'
|
57
|
-
|
58
|
-
app.initialize!
|
59
|
-
|
60
|
-
refute_empty app.config.settings
|
61
|
-
assert_equal 'Test Name', app.config.settings.app_name
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|