configurable_engine 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem 'rake'
5
4
  gem 'jeweler'
5
+ gem 'rake'
6
6
  gem 'rspec'
7
7
  gem 'cucumber'
8
8
  end
data/Gemfile.lock CHANGED
@@ -9,14 +9,16 @@ GEM
9
9
  json (~> 1.4.6)
10
10
  term-ansicolor (~> 1.0.5)
11
11
  diff-lcs (1.1.2)
12
+ gemcutter (0.6.1)
12
13
  gherkin (2.3.3)
13
14
  json (~> 1.4.6)
14
15
  git (1.2.5)
15
- jeweler (1.5.2)
16
- bundler (~> 1.0.0)
16
+ jeweler (1.4.0)
17
+ gemcutter (>= 0.1.0)
17
18
  git (>= 1.2.5)
18
- rake
19
+ rubyforge (>= 2.0.0)
19
20
  json (1.4.6)
21
+ json_pure (1.5.3)
20
22
  rake (0.8.7)
21
23
  rspec (2.4.0)
22
24
  rspec-core (~> 2.4.0)
@@ -26,6 +28,8 @@ GEM
26
28
  rspec-expectations (2.4.0)
27
29
  diff-lcs (~> 1.1.2)
28
30
  rspec-mocks (2.4.0)
31
+ rubyforge (2.0.4)
32
+ json_pure (>= 1.1.7)
29
33
  term-ansicolor (1.0.5)
30
34
 
31
35
  PLATFORMS
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ Jeweler::Tasks.new do |gem|
25
25
  gem.add_runtime_dependency 'activerecord', '~>3'
26
26
  gem.files = FileList["[A-Za-z]*", "lib/**/*", "app/**/*", "config/*"]
27
27
  end
28
- Jeweler::RubygemsDotOrgTasks.new
28
+ # Jeweler::RubygemsDotOrgTasks.new
29
29
 
30
30
  require 'rspec/core'
31
31
  require 'rspec/core/rake_task'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.2.9
@@ -1,5 +1,8 @@
1
1
  class Configurable < ActiveRecord::Base
2
-
2
+
3
+ validates_presence_of :name
4
+ validates_uniqueness_of :name
5
+
3
6
  def self.defaults
4
7
  HashWithIndifferentAccess.new(
5
8
  YAML.load_file(
@@ -7,12 +10,23 @@ class Configurable < ActiveRecord::Base
7
10
  )
8
11
  )
9
12
  end
10
-
13
+
11
14
  def self.keys
12
15
  self.defaults.collect { |k,v| k.to_s }.sort
13
16
  end
14
-
17
+
18
+ def self.[]=(key, value)
19
+ exisiting = find_by_name(key)
20
+ if exisiting
21
+ exisiting.update_attribute(:value, value)
22
+ else
23
+ create(:name => key.to_s, :value => value)
24
+ end
25
+ end
26
+
15
27
  def self.[](key)
28
+ return self.defaults[key][:default] unless table_exists?
29
+
16
30
  value = find_by_name(key).try(:value) || self.defaults[key][:default]
17
31
  case self.defaults[key][:type]
18
32
  when 'boolean'
@@ -28,14 +42,18 @@ class Configurable < ActiveRecord::Base
28
42
  value
29
43
  end
30
44
  end
31
-
45
+
32
46
  def self.method_missing(name, *args)
33
- name_stripped = name.to_s.gsub('?', '')
47
+ name_stripped = name.to_s.sub(/[\?=]$/, '')
34
48
  if self.keys.include?(name_stripped)
35
- self[name_stripped]
49
+ if name.to_s.end_with?('=')
50
+ self[name_stripped] = args.first
51
+ else
52
+ self[name_stripped]
53
+ end
36
54
  else
37
55
  super
38
56
  end
39
57
  end
40
-
58
+
41
59
  end
@@ -1,70 +1,59 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{configurable_engine}
8
- s.version = "0.2.8"
8
+ s.version = "0.2.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Paul Campbell}]
12
- s.date = %q{2011-07-11}
12
+ s.date = %q{2011-08-29}
13
13
  s.description = %q{Configurable is a Rails 3 engine that allows you to set up config variables in a config file, specifying default values for all environments. These variables can then be set on a per-app basis using a user facing configuration screen. }
14
14
  s.email = %q{paul@rslw.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.md"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  "CHANGELOG",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.md",
25
- "Rakefile",
26
- "VERSION",
27
- "app/controllers/admin/configurables_controller.rb",
28
- "app/models/configurable.rb",
29
- "app/views/admin/configurables/show.html.erb",
30
- "config/routes.rb",
31
- "configurable_engine.gemspec",
32
- "lib/configurable_engine.rb",
33
- "lib/configurable_engine/configurables_controller.rb",
34
- "lib/configurable_engine/engine.rb",
35
- "lib/generators/configurable_engine/install_generator.rb",
36
- "lib/generators/configurable_engine/templates/configurable.yml",
37
- "lib/generators/configurable_engine/templates/migration.rb"
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "app/controllers/admin/configurables_controller.rb",
28
+ "app/models/configurable.rb",
29
+ "app/views/admin/configurables/show.html.erb",
30
+ "config/routes.rb",
31
+ "configurable_engine.gemspec",
32
+ "lib/configurable_engine.rb",
33
+ "lib/configurable_engine/configurables_controller.rb",
34
+ "lib/configurable_engine/engine.rb",
35
+ "lib/generators/configurable_engine/install_generator.rb",
36
+ "lib/generators/configurable_engine/templates/configurable.yml",
37
+ "lib/generators/configurable_engine/templates/migration.rb"
38
38
  ]
39
39
  s.homepage = %q{http://github.com/paulca/configurable_engine}
40
40
  s.licenses = [%q{MIT}]
41
+ s.rdoc_options = [%q{--charset=UTF-8}]
41
42
  s.require_paths = [%q{lib}]
42
- s.rubygems_version = %q{1.8.5}
43
+ s.rubygems_version = %q{1.8.6}
43
44
  s.summary = %q{Database-backed configuration for Rails 3, with defaults from config file.}
44
45
 
45
46
  if s.respond_to? :specification_version then
46
47
  s.specification_version = 3
47
48
 
48
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_development_dependency(%q<rake>, [">= 0"])
50
- s.add_development_dependency(%q<jeweler>, [">= 0"])
51
- s.add_development_dependency(%q<rspec>, [">= 0"])
52
- s.add_development_dependency(%q<cucumber>, [">= 0"])
53
50
  s.add_runtime_dependency(%q<rails>, ["~> 3"])
54
51
  s.add_runtime_dependency(%q<activerecord>, ["~> 3"])
55
52
  else
56
- s.add_dependency(%q<rake>, [">= 0"])
57
- s.add_dependency(%q<jeweler>, [">= 0"])
58
- s.add_dependency(%q<rspec>, [">= 0"])
59
- s.add_dependency(%q<cucumber>, [">= 0"])
60
53
  s.add_dependency(%q<rails>, ["~> 3"])
61
54
  s.add_dependency(%q<activerecord>, ["~> 3"])
62
55
  end
63
56
  else
64
- s.add_dependency(%q<rake>, [">= 0"])
65
- s.add_dependency(%q<jeweler>, [">= 0"])
66
- s.add_dependency(%q<rspec>, [">= 0"])
67
- s.add_dependency(%q<cucumber>, [">= 0"])
68
57
  s.add_dependency(%q<rails>, ["~> 3"])
69
58
  s.add_dependency(%q<activerecord>, ["~> 3"])
70
59
  end
metadata CHANGED
@@ -1,116 +1,48 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: configurable_engine
3
- version: !ruby/object:Gem::Version
4
- hash: 7
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.9
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 8
10
- version: 0.2.8
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Paul Campbell
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-11 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- requirement: &id001 !ruby/object:Gem::Requirement
22
- none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 0
29
- version: "0"
30
- name: rake
31
- prerelease: false
32
- version_requirements: *id001
33
- type: :development
34
- - !ruby/object:Gem::Dependency
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- none: false
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- hash: 3
41
- segments:
42
- - 0
43
- version: "0"
44
- name: jeweler
45
- prerelease: false
46
- version_requirements: *id002
47
- type: :development
48
- - !ruby/object:Gem::Dependency
49
- requirement: &id003 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- hash: 3
55
- segments:
56
- - 0
57
- version: "0"
58
- name: rspec
59
- prerelease: false
60
- version_requirements: *id003
61
- type: :development
62
- - !ruby/object:Gem::Dependency
63
- requirement: &id004 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
- version: "0"
72
- name: cucumber
73
- prerelease: false
74
- version_requirements: *id004
75
- type: :development
76
- - !ruby/object:Gem::Dependency
77
- requirement: &id005 !ruby/object:Gem::Requirement
12
+ date: 2011-08-29 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70297958263040 !ruby/object:Gem::Requirement
78
17
  none: false
79
- requirements:
18
+ requirements:
80
19
  - - ~>
81
- - !ruby/object:Gem::Version
82
- hash: 5
83
- segments:
84
- - 3
85
- version: "3"
86
- name: rails
87
- prerelease: false
88
- version_requirements: *id005
20
+ - !ruby/object:Gem::Version
21
+ version: '3'
89
22
  type: :runtime
90
- - !ruby/object:Gem::Dependency
91
- requirement: &id006 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: *70297958263040
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ requirement: &70297958251220 !ruby/object:Gem::Requirement
92
28
  none: false
93
- requirements:
29
+ requirements:
94
30
  - - ~>
95
- - !ruby/object:Gem::Version
96
- hash: 5
97
- segments:
98
- - 3
99
- version: "3"
100
- name: activerecord
101
- prerelease: false
102
- version_requirements: *id006
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
103
33
  type: :runtime
104
- description: "Configurable is a Rails 3 engine that allows you to set up config variables in a config file, specifying default values for all environments. These variables can then be set on a per-app basis using a user facing configuration screen. "
34
+ prerelease: false
35
+ version_requirements: *70297958251220
36
+ description: ! 'Configurable is a Rails 3 engine that allows you to set up config
37
+ variables in a config file, specifying default values for all environments. These
38
+ variables can then be set on a per-app basis using a user facing configuration screen. '
105
39
  email: paul@rslw.com
106
40
  executables: []
107
-
108
41
  extensions: []
109
-
110
- extra_rdoc_files:
42
+ extra_rdoc_files:
111
43
  - LICENSE.txt
112
44
  - README.md
113
- files:
45
+ files:
114
46
  - CHANGELOG
115
47
  - Gemfile
116
48
  - Gemfile.lock
@@ -130,37 +62,32 @@ files:
130
62
  - lib/generators/configurable_engine/templates/configurable.yml
131
63
  - lib/generators/configurable_engine/templates/migration.rb
132
64
  homepage: http://github.com/paulca/configurable_engine
133
- licenses:
65
+ licenses:
134
66
  - MIT
135
67
  post_install_message:
136
- rdoc_options: []
137
-
138
- require_paths:
68
+ rdoc_options:
69
+ - --charset=UTF-8
70
+ require_paths:
139
71
  - lib
140
- required_ruby_version: !ruby/object:Gem::Requirement
72
+ required_ruby_version: !ruby/object:Gem::Requirement
141
73
  none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- hash: 3
146
- segments:
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ segments:
147
79
  - 0
148
- version: "0"
149
- required_rubygems_version: !ruby/object:Gem::Requirement
80
+ hash: 4438324471680151781
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
82
  none: false
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- hash: 3
155
- segments:
156
- - 0
157
- version: "0"
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
158
87
  requirements: []
159
-
160
88
  rubyforge_project:
161
- rubygems_version: 1.8.5
89
+ rubygems_version: 1.8.6
162
90
  signing_key:
163
91
  specification_version: 3
164
92
  summary: Database-backed configuration for Rails 3, with defaults from config file.
165
93
  test_files: []
166
-