setting_accessors 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +17 -0
- data/README.md +3 -0
- data/Rakefile +28 -0
- data/lib/generators/setting_accessors/install_generator.rb +4 -8
- data/lib/generators/setting_accessors/templates/settings.yml +3 -3
- data/lib/setting_accessors/internal.rb +2 -2
- data/lib/setting_accessors/version.rb +1 -1
- data/test/dummy/config/environments/test.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3114ad72cb4a99f7e984b750a81bb1ea4acff3d3
|
4
|
+
data.tar.gz: 04bd6c11d031bca8467190cd32fa47010aa1af27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bbfb279bb02f9e4ac1235a5200c56100607ca2b27797974635732999399bd832e190ea3fd4c70ae9616ae9dd34c77b1a2450d204b657c3cca39b2c9686a54e9
|
7
|
+
data.tar.gz: 0fd5e574b4687d9054c8e0983c9b8d455eebd441be70d43a7dacc50bb4f3bc556532b3d10d22024199e3d8fd10dd465326def7d245c9f914ab44ab7ac8295cd0
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
SettingAccessors
|
2
2
|
================
|
3
3
|
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/setting_accessors.svg)](http://badge.fury.io/rb/setting_accessors)
|
5
|
+
[![Build Status](https://travis-ci.org/Stex/setting_accessors.svg?branch=master)](https://travis-ci.org/Stex/setting_accessors)
|
6
|
+
|
4
7
|
Sometimes it's handy to keep track of various settings or attributes in ActiveRecord instances and persist them through various requests (and sessions). An example would be to store a items-per-page value for multiple tables in the application per user or probably also set default sorting directions.
|
5
8
|
|
6
9
|
The only problem is, that it would be necessary to either keep hundreds of columns in the corresponding table or create a serialized attribute which would grow over time and generally be hard to manage.
|
data/Rakefile
CHANGED
@@ -1,2 +1,30 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rdoc/task'
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = 'ArMailerRevised'
|
14
|
+
rdoc.options << '--line-numbers'
|
15
|
+
rdoc.rdoc_files.include('README.rdoc')
|
16
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
|
+
end
|
18
|
+
|
19
|
+
Bundler::GemHelper.install_tasks
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
|
23
|
+
Rake::TestTask.new(:test) do |t|
|
24
|
+
t.libs << 'lib'
|
25
|
+
t.libs << 'test'
|
26
|
+
t.pattern = 'test/**/*_test.rb'
|
27
|
+
t.verbose = false
|
28
|
+
end
|
29
|
+
|
30
|
+
task default: :test
|
@@ -23,14 +23,10 @@ module SettingAccessors
|
|
23
23
|
migration_template 'migration.rb.erb', "db/migrate/create_#{model_name.classify.underscore.pluralize}.rb"
|
24
24
|
|
25
25
|
initializer 'setting_accessors.rb', <<INIT
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
#model name below should already be correct.
|
31
|
-
config.setting_class = #{model_name}
|
32
|
-
|
33
|
-
end
|
26
|
+
#The model your application is using for settings.
|
27
|
+
#If you created it using the SettingAccessors generator, the
|
28
|
+
#model name below should already be correct.
|
29
|
+
SettingAccessors.setting_class = #{model_name}
|
34
30
|
INIT
|
35
31
|
end
|
36
32
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# This file specifies all settings used in the application
|
3
|
-
# (be it record specific or global).
|
2
|
+
# This file specifies all globally defined settings used in the application.
|
4
3
|
#
|
5
4
|
# The keys are the setting names, the values are a hash
|
6
5
|
# containing validation options, type and default value
|
@@ -21,4 +20,5 @@
|
|
21
20
|
# type: boolean
|
22
21
|
# default: true
|
23
22
|
# validations:
|
24
|
-
# boolean: true
|
23
|
+
# boolean: true
|
24
|
+
|
@@ -32,9 +32,9 @@ module SettingAccessors
|
|
32
32
|
#
|
33
33
|
def self.global_config
|
34
34
|
if Rails.env.test? || Rails.env.development?
|
35
|
-
YAML.load(File.open(Rails.root.join('config/settings.yml'))).deep_stringify_keys
|
35
|
+
(YAML.load(File.open(Rails.root.join('config/settings.yml'))) || {}).deep_stringify_keys
|
36
36
|
else
|
37
|
-
@@config ||= YAML.load(File.open(Rails.root.join('config/settings.yml'))).deep_stringify_keys
|
37
|
+
@@config ||= (YAML.load(File.open(Rails.root.join('config/settings.yml'))) || {}).deep_stringify_keys
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
16
|
+
config.serve_static_files = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setting_accessors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Exner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- ".gitignore"
|
121
121
|
- ".ruby-gemset"
|
122
122
|
- ".ruby-version"
|
123
|
+
- ".travis.yml"
|
123
124
|
- Gemfile
|
124
125
|
- LICENSE.txt
|
125
126
|
- README.md
|