settler 1.2.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +14 -0
- data/Appraisals +15 -0
- data/CHANGELOG +7 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +81 -0
- data/LICENSE +1 -1
- data/README.rdoc +14 -20
- data/Rakefile +2 -19
- data/VERSION +1 -1
- data/gemfiles/3.0.gemfile +10 -0
- data/gemfiles/3.0.gemfile.lock +73 -0
- data/gemfiles/3.2.gemfile +10 -0
- data/gemfiles/3.2.gemfile.lock +73 -0
- data/gemfiles/4.0.gemfile +10 -0
- data/gemfiles/4.0.gemfile.lock +81 -0
- data/lib/generators/settler/templates/migration.rb +1 -1
- data/lib/generators/settler/templates/settler.yml +4 -4
- data/lib/setting.rb +17 -32
- data/lib/settler.rb +4 -5
- data/settler.gemspec +22 -17
- data/test/schema.rb +1 -1
- data/test/settler.yml +8 -8
- data/test/{helper.rb → test_helper.rb} +2 -1
- data/test/test_settler.rb +9 -21
- metadata +28 -36
- data/generators/settler/settler_generator.rb +0 -13
- data/generators/settler/templates/migration.rb +0 -19
- data/generators/settler/templates/settler.yml +0 -30
- data/lib/default_scope_patch.rb +0 -17
- data/lib/hash_extension.rb +0 -9
- data/test/debug.log +0 -59876
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWIzMzYxNTI2ZTE3NmNjOTlhZmZkZDEwMzU0Mzg4NjlmNDU1MTZkNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZmY5MGY5YTkzZjg4NDdmOWM5MjJlZWRkZTdkY2RlNmNiMDM3NDJhOA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTM5YTU4NDE5N2ZlMThiY2MyODA5MGQ3M2UwNDliNDNlZWE1MDE1MGVhOGJj
|
10
|
+
M2JlZDc1YTZkM2IzNGUyMTM3MzJiOGIzZDcxYzNlZWU2Y2FiY2MzN2ZhYTc5
|
11
|
+
MzViNzZkMmVkMmRkYzUyNjJiNDUxZWRmZWQxNGUxY2RlNGU1M2Q=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Mjc3NDA4MWZhMTBmMzAwNmQzODhlMjExYzkxMzQ4ZjU1ZmMwNjdhYTkxZjVi
|
14
|
+
ZTA0NThiMDM2NzZkNGM2Mzg4NzNlODA3MjY2YzgzZDJlYzU2ZTg4Y2EwYThk
|
15
|
+
OWU4YzU4OGJlZWIzZDIxY2RjYjVhY2VkMjhiYzAzOGU2NjU1ZGU=
|
data/.travis.yml
ADDED
data/Appraisals
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
appraise '3.0' do
|
2
|
+
gem 'activerecord', '~> 3.0'
|
3
|
+
gem 'activesupport', '~> 3.0'
|
4
|
+
end
|
5
|
+
|
6
|
+
appraise '3.2' do
|
7
|
+
gem 'activerecord', '~> 3.2'
|
8
|
+
gem 'activesupport', '~> 3.2'
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise '4.0' do
|
12
|
+
gem 'activerecord', '~> 4.0'
|
13
|
+
gem 'activesupport', '~> 4.0'
|
14
|
+
end
|
15
|
+
|
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (4.0.0)
|
5
|
+
activesupport (= 4.0.0)
|
6
|
+
builder (~> 3.1.0)
|
7
|
+
activerecord (4.0.0)
|
8
|
+
activemodel (= 4.0.0)
|
9
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
10
|
+
activesupport (= 4.0.0)
|
11
|
+
arel (~> 4.0.0)
|
12
|
+
activerecord-deprecated_finders (1.0.3)
|
13
|
+
activesupport (4.0.0)
|
14
|
+
i18n (~> 0.6, >= 0.6.4)
|
15
|
+
minitest (~> 4.2)
|
16
|
+
multi_json (~> 1.3)
|
17
|
+
thread_safe (~> 0.1)
|
18
|
+
tzinfo (~> 0.3.37)
|
19
|
+
addressable (2.3.5)
|
20
|
+
appraisal (0.5.2)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
arel (4.0.0)
|
24
|
+
atomic (1.1.12)
|
25
|
+
builder (3.1.4)
|
26
|
+
faraday (0.8.8)
|
27
|
+
multipart-post (~> 1.2.0)
|
28
|
+
git (1.2.5)
|
29
|
+
github_api (0.10.1)
|
30
|
+
addressable
|
31
|
+
faraday (~> 0.8.1)
|
32
|
+
hashie (>= 1.2)
|
33
|
+
multi_json (~> 1.4)
|
34
|
+
nokogiri (~> 1.5.2)
|
35
|
+
oauth2
|
36
|
+
hashie (2.0.5)
|
37
|
+
highline (1.6.19)
|
38
|
+
httpauth (0.2.0)
|
39
|
+
i18n (0.6.4)
|
40
|
+
jeweler (1.8.6)
|
41
|
+
builder
|
42
|
+
bundler (~> 1.0)
|
43
|
+
git (>= 1.2.5)
|
44
|
+
github_api (= 0.10.1)
|
45
|
+
highline (>= 1.6.15)
|
46
|
+
nokogiri (= 1.5.10)
|
47
|
+
rake
|
48
|
+
rdoc
|
49
|
+
json (1.8.0)
|
50
|
+
jwt (0.1.8)
|
51
|
+
multi_json (>= 1.5)
|
52
|
+
minitest (4.7.5)
|
53
|
+
multi_json (1.7.8)
|
54
|
+
multi_xml (0.5.5)
|
55
|
+
multipart-post (1.2.0)
|
56
|
+
nokogiri (1.5.10)
|
57
|
+
oauth2 (0.9.2)
|
58
|
+
faraday (~> 0.8)
|
59
|
+
httpauth (~> 0.2)
|
60
|
+
jwt (~> 0.1.4)
|
61
|
+
multi_json (~> 1.0)
|
62
|
+
multi_xml (~> 0.5)
|
63
|
+
rack (~> 1.2)
|
64
|
+
rack (1.5.2)
|
65
|
+
rake (10.1.0)
|
66
|
+
rdoc (4.0.1)
|
67
|
+
json (~> 1.4)
|
68
|
+
sqlite3 (1.3.7)
|
69
|
+
thread_safe (0.1.2)
|
70
|
+
atomic
|
71
|
+
tzinfo (0.3.37)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
ruby
|
75
|
+
|
76
|
+
DEPENDENCIES
|
77
|
+
activerecord (>= 3.2)
|
78
|
+
activesupport (>= 3.2)
|
79
|
+
appraisal
|
80
|
+
jeweler
|
81
|
+
sqlite3
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,31 +1,25 @@
|
|
1
1
|
= Settler
|
2
2
|
|
3
|
+
{<img src="https://travis-ci.org/moiristo/settler.png?branch=master" alt="Build Status" />}[https://travis-ci.org/moiristo/settler]
|
4
|
+
|
3
5
|
Settler can be used for defining application wide settings in Rails. Settings are loaded from a YAML file and stored in the database using ActiveRecord to allow users to update settings on the fly. The YAML configuration allows you to not only specify defaults, but setting value validations and typecasts as well!
|
4
6
|
|
5
7
|
== Requirements
|
6
8
|
|
7
|
-
*
|
9
|
+
* Ruby >= 1.9 (tested with Rails 1.9.2, 1.9.3 and 2.0.0)
|
10
|
+
* Activerecord >= 3.0 (tested with Rails 3.0, 3.2 and 4.0)
|
8
11
|
|
9
12
|
== Installation
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
gem install settler
|
14
|
-
|
15
|
-
And include the gem in your apps config
|
16
|
-
|
17
|
-
config.gem 'settler'
|
18
|
-
|
19
|
-
Or install as a plugin if you must. But gems are cooler.
|
14
|
+
Add the gem to your Gemfile:
|
20
15
|
|
21
|
-
|
16
|
+
gem 'settler'
|
22
17
|
|
23
18
|
== Setup
|
24
19
|
|
25
20
|
* You must create the table used by the Setting model and install an initial configuration file. Simply run this command:
|
26
21
|
|
27
|
-
|
28
|
-
rails3: rails g settler
|
22
|
+
rails g settler
|
29
23
|
|
30
24
|
* This will create a migration and will add a settler.yml configuration file in your config directory. Now just migrate the database:
|
31
25
|
|
@@ -48,7 +42,7 @@ Or install as a plugin if you must. But gems are cooler.
|
|
48
42
|
The initial version of settler.yml contains example settings for every default Rails environment. A setting consists of at least a key and a value. Consider the following example:
|
49
43
|
|
50
44
|
google_analytics_key:
|
51
|
-
|
45
|
+
label: Google analytics key
|
52
46
|
value: 'UA-xxxxxx-x'
|
53
47
|
editable: true
|
54
48
|
deletable: false
|
@@ -71,7 +65,7 @@ will evaluate the GOOGLE_ANALYTICS_KEY constant.
|
|
71
65
|
>> Settler.google_analytics_key
|
72
66
|
Setting Load (0.7ms) SELECT * FROM "settings" WHERE ("settings"."key" = 'google_analytics_key') LIMIT 1
|
73
67
|
+----+----------------------+----------------------+------------+----------+-----------+
|
74
|
-
| id | key |
|
68
|
+
| id | key | label | value | editable | deletable |
|
75
69
|
+----+----------------------+----------------------+------------+----------+-----------+
|
76
70
|
| 6 | google_analytics_key | Google analytics key | UA-xxxxx-x | true | false |
|
77
71
|
+----+----------------------+----------------------+------------+----------+-----------+
|
@@ -92,7 +86,7 @@ will evaluate the GOOGLE_ANALYTICS_KEY constant.
|
|
92
86
|
* Setting values can be typecasted to several types. This can easily be done by adding a 'typecast' property to the settler.yml. For example:
|
93
87
|
|
94
88
|
float_value:
|
95
|
-
|
89
|
+
label: A float that should be typecasted
|
96
90
|
value: '0.25'
|
97
91
|
typecast: float
|
98
92
|
|
@@ -118,7 +112,7 @@ will evaluate the GOOGLE_ANALYTICS_KEY constant.
|
|
118
112
|
When you require this class in your application, you can easily use your typecaster by specifying its class name in the settler configuration:
|
119
113
|
|
120
114
|
custom_value:
|
121
|
-
|
115
|
+
label: An integer that should be custom typecasted
|
122
116
|
value: 1
|
123
117
|
typecast: CustomTypecaster
|
124
118
|
|
@@ -168,14 +162,14 @@ When you require this class in your application, you can easily use your typecas
|
|
168
162
|
|
169
163
|
settings: &settings
|
170
164
|
google_analytics_key: &google
|
171
|
-
|
165
|
+
label: Google analytics key
|
172
166
|
value: 'UA-xxxxxx-x'
|
173
167
|
|
174
168
|
development:
|
175
169
|
<<: *settings
|
176
170
|
google_analytics_key:
|
177
171
|
<<: *google
|
178
|
-
|
172
|
+
label: Development Google analytics key
|
179
173
|
value: 'UA-xxxxxx-1'
|
180
174
|
|
181
175
|
* Report missing / raise missing
|
@@ -202,4 +196,4 @@ When you require this class in your application, you can easily use your typecas
|
|
202
196
|
|
203
197
|
== Copyright
|
204
198
|
|
205
|
-
Copyright (c)
|
199
|
+
Copyright (c) 2013 Reinier de Lange. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'appraisal'
|
3
4
|
|
4
5
|
begin
|
5
6
|
require 'jeweler'
|
@@ -10,9 +11,6 @@ begin
|
|
10
11
|
gem.email = "r.j.delange@nedforce.nl"
|
11
12
|
gem.homepage = "http://github.com/moiristo/settler"
|
12
13
|
gem.authors = ["Reinier de Lange"]
|
13
|
-
gem.test_files = Dir["test/**/*"]
|
14
|
-
gem.add_development_dependency 'sqlite3'
|
15
|
-
gem.add_dependency 'rails'
|
16
14
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
15
|
end
|
18
16
|
Jeweler::GemcutterTasks.new
|
@@ -27,21 +25,6 @@ Rake::TestTask.new(:test) do |test|
|
|
27
25
|
test.verbose = true
|
28
26
|
end
|
29
27
|
|
30
|
-
begin
|
31
|
-
require 'rcov/rcovtask'
|
32
|
-
Rcov::RcovTask.new do |test|
|
33
|
-
test.libs << 'test'
|
34
|
-
test.pattern = 'test/**/test_*.rb'
|
35
|
-
test.verbose = true
|
36
|
-
end
|
37
|
-
rescue LoadError
|
38
|
-
task :rcov do
|
39
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
task :test => :check_dependencies
|
44
|
-
|
45
28
|
task :default => :test
|
46
29
|
|
47
30
|
require 'rdoc/task'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
@@ -0,0 +1,73 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (3.2.14)
|
5
|
+
activesupport (= 3.2.14)
|
6
|
+
builder (~> 3.0.0)
|
7
|
+
activerecord (3.2.14)
|
8
|
+
activemodel (= 3.2.14)
|
9
|
+
activesupport (= 3.2.14)
|
10
|
+
arel (~> 3.0.2)
|
11
|
+
tzinfo (~> 0.3.29)
|
12
|
+
activesupport (3.2.14)
|
13
|
+
i18n (~> 0.6, >= 0.6.4)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
addressable (2.3.5)
|
16
|
+
appraisal (0.5.2)
|
17
|
+
bundler
|
18
|
+
rake
|
19
|
+
arel (3.0.2)
|
20
|
+
builder (3.0.4)
|
21
|
+
faraday (0.8.8)
|
22
|
+
multipart-post (~> 1.2.0)
|
23
|
+
git (1.2.5)
|
24
|
+
github_api (0.10.1)
|
25
|
+
addressable
|
26
|
+
faraday (~> 0.8.1)
|
27
|
+
hashie (>= 1.2)
|
28
|
+
multi_json (~> 1.4)
|
29
|
+
nokogiri (~> 1.5.2)
|
30
|
+
oauth2
|
31
|
+
hashie (2.0.5)
|
32
|
+
highline (1.6.19)
|
33
|
+
httpauth (0.2.0)
|
34
|
+
i18n (0.6.4)
|
35
|
+
jeweler (1.8.6)
|
36
|
+
builder
|
37
|
+
bundler (~> 1.0)
|
38
|
+
git (>= 1.2.5)
|
39
|
+
github_api (= 0.10.1)
|
40
|
+
highline (>= 1.6.15)
|
41
|
+
nokogiri (= 1.5.10)
|
42
|
+
rake
|
43
|
+
rdoc
|
44
|
+
json (1.8.0)
|
45
|
+
jwt (0.1.8)
|
46
|
+
multi_json (>= 1.5)
|
47
|
+
multi_json (1.7.8)
|
48
|
+
multi_xml (0.5.5)
|
49
|
+
multipart-post (1.2.0)
|
50
|
+
nokogiri (1.5.10)
|
51
|
+
oauth2 (0.9.2)
|
52
|
+
faraday (~> 0.8)
|
53
|
+
httpauth (~> 0.2)
|
54
|
+
jwt (~> 0.1.4)
|
55
|
+
multi_json (~> 1.0)
|
56
|
+
multi_xml (~> 0.5)
|
57
|
+
rack (~> 1.2)
|
58
|
+
rack (1.5.2)
|
59
|
+
rake (10.1.0)
|
60
|
+
rdoc (4.0.1)
|
61
|
+
json (~> 1.4)
|
62
|
+
sqlite3 (1.3.7)
|
63
|
+
tzinfo (0.3.37)
|
64
|
+
|
65
|
+
PLATFORMS
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
activerecord (~> 3.0)
|
70
|
+
activesupport (~> 3.0)
|
71
|
+
appraisal
|
72
|
+
jeweler
|
73
|
+
sqlite3
|
@@ -0,0 +1,73 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (3.2.14)
|
5
|
+
activesupport (= 3.2.14)
|
6
|
+
builder (~> 3.0.0)
|
7
|
+
activerecord (3.2.14)
|
8
|
+
activemodel (= 3.2.14)
|
9
|
+
activesupport (= 3.2.14)
|
10
|
+
arel (~> 3.0.2)
|
11
|
+
tzinfo (~> 0.3.29)
|
12
|
+
activesupport (3.2.14)
|
13
|
+
i18n (~> 0.6, >= 0.6.4)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
addressable (2.3.5)
|
16
|
+
appraisal (0.5.2)
|
17
|
+
bundler
|
18
|
+
rake
|
19
|
+
arel (3.0.2)
|
20
|
+
builder (3.0.4)
|
21
|
+
faraday (0.8.8)
|
22
|
+
multipart-post (~> 1.2.0)
|
23
|
+
git (1.2.5)
|
24
|
+
github_api (0.10.1)
|
25
|
+
addressable
|
26
|
+
faraday (~> 0.8.1)
|
27
|
+
hashie (>= 1.2)
|
28
|
+
multi_json (~> 1.4)
|
29
|
+
nokogiri (~> 1.5.2)
|
30
|
+
oauth2
|
31
|
+
hashie (2.0.5)
|
32
|
+
highline (1.6.19)
|
33
|
+
httpauth (0.2.0)
|
34
|
+
i18n (0.6.4)
|
35
|
+
jeweler (1.8.6)
|
36
|
+
builder
|
37
|
+
bundler (~> 1.0)
|
38
|
+
git (>= 1.2.5)
|
39
|
+
github_api (= 0.10.1)
|
40
|
+
highline (>= 1.6.15)
|
41
|
+
nokogiri (= 1.5.10)
|
42
|
+
rake
|
43
|
+
rdoc
|
44
|
+
json (1.8.0)
|
45
|
+
jwt (0.1.8)
|
46
|
+
multi_json (>= 1.5)
|
47
|
+
multi_json (1.7.8)
|
48
|
+
multi_xml (0.5.5)
|
49
|
+
multipart-post (1.2.0)
|
50
|
+
nokogiri (1.5.10)
|
51
|
+
oauth2 (0.9.2)
|
52
|
+
faraday (~> 0.8)
|
53
|
+
httpauth (~> 0.2)
|
54
|
+
jwt (~> 0.1.4)
|
55
|
+
multi_json (~> 1.0)
|
56
|
+
multi_xml (~> 0.5)
|
57
|
+
rack (~> 1.2)
|
58
|
+
rack (1.5.2)
|
59
|
+
rake (10.1.0)
|
60
|
+
rdoc (4.0.1)
|
61
|
+
json (~> 1.4)
|
62
|
+
sqlite3 (1.3.7)
|
63
|
+
tzinfo (0.3.37)
|
64
|
+
|
65
|
+
PLATFORMS
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
activerecord (~> 3.2)
|
70
|
+
activesupport (~> 3.2)
|
71
|
+
appraisal
|
72
|
+
jeweler
|
73
|
+
sqlite3
|