configurable_engine 0.3.2 → 0.3.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: 1811d51a74023fce2888c443a4e18b484e03e64d
4
- data.tar.gz: a513bf6396dbb4edda39ab28a29bf2e6579478cb
3
+ metadata.gz: 990bdf66a3b906927e53869aa049a82638b13791
4
+ data.tar.gz: 1107460d5c031cc5b143b950966cb8548b5a5529
5
5
  SHA512:
6
- metadata.gz: 9d6083ff4f21055b7c6c03074ec1348b405e6a2928119fe26529ea03a8118af35b067060bec2c0f5a24a89c9f71afbba3e963b0ae97117fd8f182acdfaa3d620
7
- data.tar.gz: ca72a610057f1b1370f84a6ec0e1afa4ff93230f460f782c6e09aa3a70a31f1ea31d91299ebcd6a9ebcabdf0d25c9b528f62193046bab3508f7d9f03b432e7b1
6
+ metadata.gz: 204972e4fc0157f654f0900e3156dba911c11d5fd45878d2c3ec3d6cc115c25ac4b8e4d131d10b8d0a43cd000d0aeec431cb29dc9f0faf90199be5fbba50b6d4
7
+ data.tar.gz: 9422ce1965bd055dc95fc0597f7945433011548172b73b144fdd39ab38aa90ff2d7f66766725f107134d6ecc20038059ad3210af49b257dd0391e4ea9c0c5153
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### v0.3.3 - May 21, 2014
2
+ **bug fixes**
3
+ No longer uses mass assignment internally.
4
+
1
5
  ### v0.3.2 - Mar 12, 2014
2
6
  **features**
3
7
  re-releasing gem without test files included to shrink it. Should have no code changes.
data/README.md CHANGED
@@ -12,11 +12,15 @@ If you or your app users need to change these variables, Configurable stores new
12
12
 
13
13
  Configurable is available as a Ruby gem. Simply add it to your Rails 3 app's `Gemfile`:
14
14
 
15
- gem 'configurable_engine'
15
+ ```ruby
16
+ gem 'configurable_engine'
17
+ ```
16
18
 
17
19
  Then run the `configurable_engine:install` generator:
18
20
 
19
- rails generate configurable_engine:install
21
+ ```bash
22
+ $ rails generate configurable_engine:install
23
+ ```
20
24
 
21
25
  ## Usage ##
22
26
 
@@ -24,68 +28,79 @@ There are two parts to how configurable_engine works. First of all there is a co
24
28
 
25
29
  For example, if you wanted to have access to a config variable "site_title", put this in configurable.yml:
26
30
 
27
- site_title:
28
- name: Site Title
29
- default: My Site
30
-
31
+ ```yaml
32
+ site_title:
33
+ name: Site Title
34
+ default: My Site
35
+ # type: String is the default
36
+ ```
31
37
  Now, within your app, you can access `Configurable[:site_title]` (or `Configurable.site_title` if you prefer).
32
38
 
33
39
  Since Configurable is an ActiveRecord model, if you want to update the config, create a Configurable record in the database:
34
40
 
35
- Configurable.create!(:name => 'site_title', :value => 'My New Site')
36
-
41
+ ```ruby
42
+ Configurable.create!(:name => 'site_title', :value => 'My New Site')
43
+ ```
44
+ You can set the `type` attribute to `boolean`, `decimal`,`integer`, or `list` and it will treat those fields as those types. Lists are comma and/or newline delimeted arrays of strings.
45
+
37
46
  ## Web Interface ##
38
47
 
39
48
  Configurable comes with a web interface that is available to your app straight away at `http://localhost:3000/admin/configurable`.
40
49
 
41
50
  If you want to add a layout, or protect the configurable controller, create `app/controllers/admin/configurables_controller.rb` as such:
42
51
 
43
- bundle exec rails generate controller admin/configurables
52
+ ```bash
53
+ $ bundle exec rails generate controller admin/configurables
54
+ ```
44
55
 
45
56
  and include `ConfigurableEngine::ConfigurablesController`, eg.
46
57
 
47
- class Admin::ConfigurablesController < ApplicationController
48
- # include the engine controller actions
49
- include ConfigurableEngine::ConfigurablesController
58
+ ```ruby
59
+ class Admin::ConfigurablesController < ApplicationController
60
+ # include the engine controller actions
61
+ include ConfigurableEngine::ConfigurablesController
50
62
 
51
- # add your own filter(s) / layout
52
- before_filter :protect_my_code
53
- layout 'admin'
54
- end
63
+ # add your own filter(s) / layout
64
+ before_filter :protect_my_code
65
+ layout 'admin'
66
+ end
67
+ ```
55
68
 
56
69
  If you want to control how the fields in the admin interface appear, you can add additional params in your configurable.yml file:
57
70
 
58
- site_title:
59
- name: Name of Your Site # sets the edit label
60
- default: My Site # sets the default value
61
- type: string # uses input type="text"
62
-
63
- site_description:
64
- name: Describe Your Site # sets the edit label
65
- default: My Site # sets the default value
66
- type: text # uses textarea
67
-
68
- secret:
69
- name: A Secret Passphrase # sets the edit label
70
- default: passpass # sets the default value
71
- type: password # uses input type="password"
72
-
73
- Value:
74
- name: A number # sets the edit label
75
- default: 10 # sets the default value
76
- type: integer # coerces the value to an integer
77
-
78
- Price:
79
- name: A price # sets the edit label
80
- default: "10.00" # sets the default value
81
- type: decimal # coerces the value to a decimal
82
-
71
+ ```yaml
72
+ site_title:
73
+ name: Name of Your Site # sets the edit label
74
+ default: My Site # sets the default value
75
+ type: string # uses input type="text"
76
+ site_description:
77
+ name: Describe Your Site # sets the edit label
78
+ default: My Site # sets the default value
79
+ type: text # uses textarea
80
+ secret:
81
+ name: A Secret Passphrase # sets the edit label
82
+ default: passpass # sets the default value
83
+ type: password # uses input type="password"
84
+
85
+ Value:
86
+ name: A number # sets the edit label
87
+ default: 10 # sets the default value
88
+ type: integer # coerces the value to an integer
89
+
90
+ Price:
91
+ name: A price # sets the edit label
92
+ default: "10.00" # sets the default value
93
+ type: decimal # coerces the value to a decimal
94
+ ```
95
+
83
96
  ## Cacheing ##
84
97
 
85
98
  If you want to use rails caching of Configurable updates, simply set
86
99
 
87
- config.use_cache = true
88
-
100
+
101
+ ```ruby
102
+ config.use_cache = true
103
+ ```
89
104
  in your `config/application.rb` (or `config/production.rb`)
90
105
 
91
106
  ## Running the Tests ##
@@ -94,9 +109,11 @@ The tests for this rails engine are in the `spec` and `features` directories. T
94
109
 
95
110
  From the top level run:
96
111
 
97
- $ bundle exec rake app:db:schema:load app:db:test:prepare
98
- $ bundle exec rake
99
-
112
+ ```bash
113
+ $ bundle exec rake app:db:schema:load app:db:test:prepare
114
+ $ bundle exec rake
115
+ ```
116
+
100
117
  ## Contributing ##
101
118
 
102
119
  All contributions are welcome. Just fork the code, ensure your changes include a test, ensure all the current tests pass and send a pull request.
@@ -24,7 +24,7 @@ class Configurable < ActiveRecord::Base
24
24
  if exisiting
25
25
  exisiting.update_attribute(:value, value)
26
26
  else
27
- create(:name => key.to_s, :value => value)
27
+ create {|c| c.name = key.to_s; c.value = value}
28
28
  end
29
29
  end
30
30
 
@@ -1,3 +1,3 @@
1
1
  module ConfigurableEngine
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configurable_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Campbell
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.2.0
71
+ rubygems_version: 2.2.2
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: Database-backed configuration for Rails 3, with defaults from config file.