app_constants 1.0.0 → 1.0.1
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.
- data/VERSION +1 -1
- data/app_constants.gemspec +73 -0
- data/lib/app_constants.rb +2 -2
- data/lib/generators/app_constants_generator.rb +5 -1
- data/lib/generators/templates/README +15 -0
- data/test/app_constants_spec.rb +10 -0
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{app_constants}
|
8
|
+
s.version = "1.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Leonardo Borges"]
|
12
|
+
s.date = %q{2011-02-02}
|
13
|
+
s.description = %q{A clean and simple way to manage your application's per-environment constants}
|
14
|
+
s.email = %q{leonardoborges.rj@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"Gemfile",
|
20
|
+
"Gemfile.lock",
|
21
|
+
"MIT-LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"app_constants.gemspec",
|
26
|
+
"init.rb",
|
27
|
+
"install.rb",
|
28
|
+
"lib/app_constants.rb",
|
29
|
+
"lib/generators/USAGE",
|
30
|
+
"lib/generators/app_constants_generator.rb",
|
31
|
+
"lib/generators/templates/README",
|
32
|
+
"lib/generators/templates/constants.yml",
|
33
|
+
"lib/generators/templates/load_app_constants.rb",
|
34
|
+
"test/app_constants_spec.rb",
|
35
|
+
"test/fixtures/constants.yml",
|
36
|
+
"test/fixtures/nested_constants.yml",
|
37
|
+
"test/fixtures/template_constants.yml",
|
38
|
+
"test/test_helper.rb",
|
39
|
+
"uninstall.rb"
|
40
|
+
]
|
41
|
+
s.homepage = %q{http://github.com/leonardoborges/app_constants}
|
42
|
+
s.licenses = ["MIT"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = %q{1.3.7}
|
45
|
+
s.summary = %q{A clean and simple way to manage your application's per-environment constants}
|
46
|
+
s.test_files = [
|
47
|
+
"test/app_constants_spec.rb",
|
48
|
+
"test/test_helper.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
+
s.specification_version = 3
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
62
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
68
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
69
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
70
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/lib/app_constants.rb
CHANGED
@@ -16,9 +16,9 @@ class AppConstants
|
|
16
16
|
def self.method_missing(method, *args)
|
17
17
|
@@instance.send(method).is_a?(Hash) ? AppConstants.new(@@instance.constants_hash[method.to_s]) : @@instance.send(method)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def method_missing(method, *args)
|
21
|
-
constants_hash[method.to_s].nil? ? "" : constants_hash[method.to_s]
|
21
|
+
constants_hash[method.to_s].nil? ? "" : constants_hash[method.to_s].freeze
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.load!
|
@@ -1,10 +1,14 @@
|
|
1
1
|
class AppConstantsGenerator < Rails::Generators::Base
|
2
2
|
def self.source_root
|
3
3
|
@source_root ||= File.expand_path('../templates', __FILE__)
|
4
|
-
end
|
4
|
+
end
|
5
|
+
|
6
|
+
desc "Generates the constants.yml file under Rails.root/config" <<
|
7
|
+
"and the corresponding initializer under Rails.root/config/initializers"
|
5
8
|
|
6
9
|
def copy_config_files
|
7
10
|
copy_file('constants.yml', 'config/constants.yml')
|
8
11
|
copy_file('load_app_constants.rb', 'config/initializers/load_app_constants.rb')
|
12
|
+
readme("README")
|
9
13
|
end
|
10
14
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
AppConstants is now installed! A couple of things you should know:
|
4
|
+
|
5
|
+
1. You now have a file under Rails.root/config called constants.yml
|
6
|
+
|
7
|
+
Use this file to add you environment specific constants
|
8
|
+
|
9
|
+
2. The initializer lives under Rails.root/config/initializers and is called load_app_constants.rb
|
10
|
+
|
11
|
+
This is where the gem gets set up and where you can customize the location of the constants.yml file
|
12
|
+
|
13
|
+
3. Enjoy!
|
14
|
+
|
15
|
+
===============================================================================
|
data/test/app_constants_spec.rb
CHANGED
@@ -10,6 +10,16 @@ describe "AppConstants" do
|
|
10
10
|
AppConstants.app_name.should == "Master of awesomeness"
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should raise a RuntiemError if trying to modify constants" do
|
14
|
+
AppConstants.config_path = "#{File.dirname(__FILE__)}/fixtures/constants.yml"
|
15
|
+
AppConstants.environment = "development"
|
16
|
+
AppConstants.load!
|
17
|
+
|
18
|
+
AppConstants.public_url.should == "development.myawesomeapp.com"
|
19
|
+
|
20
|
+
expect { AppConstants.public_url << "trying something nasty" }.to raise_error(RuntimeError)
|
21
|
+
end
|
22
|
+
|
13
23
|
it "should return nil for non-existing environments" do
|
14
24
|
AppConstants.config_path = "#{File.dirname(__FILE__)}/fixtures/constants.yml"
|
15
25
|
AppConstants.environment = "invalid"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Leonardo Borges
|
@@ -84,11 +84,13 @@ files:
|
|
84
84
|
- README.rdoc
|
85
85
|
- Rakefile
|
86
86
|
- VERSION
|
87
|
+
- app_constants.gemspec
|
87
88
|
- init.rb
|
88
89
|
- install.rb
|
89
90
|
- lib/app_constants.rb
|
90
91
|
- lib/generators/USAGE
|
91
92
|
- lib/generators/app_constants_generator.rb
|
93
|
+
- lib/generators/templates/README
|
92
94
|
- lib/generators/templates/constants.yml
|
93
95
|
- lib/generators/templates/load_app_constants.rb
|
94
96
|
- test/app_constants_spec.rb
|
@@ -111,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
113
|
requirements:
|
112
114
|
- - ">="
|
113
115
|
- !ruby/object:Gem::Version
|
114
|
-
hash: -
|
116
|
+
hash: -3393428465027735857
|
115
117
|
segments:
|
116
118
|
- 0
|
117
119
|
version: "0"
|