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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 272c37e0192010c875187bd6de75748d301c3d53
4
- data.tar.gz: 7aa0645bdcb88d8249c520c80c73caf86ed2c2cb
3
+ metadata.gz: 80ef1d7b12243f96b63a2d6715370f0105523c22
4
+ data.tar.gz: 5b6fe9a9a333df5fcb7571a568c003f2b264aa40
5
5
  SHA512:
6
- metadata.gz: b3c0c17ceb421b60d6f02bdd8fe73a5c638cdd9c2655b832b95a08f67a7cb752531c3774004b78c3752bddd9e4ad947f1a0a0dbc1c148ffe56b1c3fc4f1e62f3
7
- data.tar.gz: c1c8c065c4c05cdd7d1fe0bdb1b04184e8d99033ee7fff4212c88c92142fb7a0ba2b1dff85643320172379a85e789adb33d4481f70f374a80166a76208b097f9
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 (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)
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.application.config.settings.appname # => 'My Rails Application'
56
- Rails.application.config.settings.company_name # => 'Fancy Pants LLC'
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
-
@@ -1 +1,2 @@
1
- require 'app_settings/railtie' if defined? Rails
1
+ require 'app_settings/settings'
2
+ require 'app_settings/railtie'
@@ -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 = ActiveSupport::OrderedOptions.new
4
+ class Railtie < ::Rails::Railtie
5
+ config.settings = AppSettings::Settings.configuration
22
6
  end
23
7
  end
@@ -0,0 +1,15 @@
1
+ module AppSettings
2
+ class Settings
3
+
4
+ def self.configuration
5
+ new.settings
6
+ end
7
+
8
+ attr_accessor :settings
9
+
10
+ def initialize
11
+ @settings = ::ActiveSupport::OrderedOptions.new
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module AppSettings
2
+ VERSION = "0.0.3"
3
+ 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
@@ -0,0 +1,11 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require 'test/unit'
4
+ require 'pathname'
5
+
6
+ require 'rails'
7
+
8
+ class FakeApplication < Rails::Application; end
9
+ Rails.application = FakeApplication
10
+
11
+ require 'app_settings'
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.2
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-04 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
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: :development
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: Application wide settings
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
- - test/railtie_test.rb
58
- homepage: ''
59
- licenses:
60
- - MIT
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 wide settings
79
+ summary: Application Settings for Rails
82
80
  test_files:
83
- - test/railtie_test.rb
81
+ - test/app_settings_test.rb
82
+ - test/test_helper.rb
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- .DS_Store
@@ -1,9 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1.1
5
- before_install:
6
- - gem install bundler
7
- notifications:
8
- recipients:
9
- - robert@codewranglers.org
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'rails', github: 'rails/rails', branch: '4-1-stable'
@@ -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
@@ -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