preference_fu 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -0
- data/Gemfile.lock +67 -0
- data/VERSION +1 -1
- data/lib/preference_fu.rb +7 -0
- data/preference_fu.gemspec +7 -1
- data/test/abstract_unit.rb +0 -1
- data/test/preference_fu_test.rb +8 -2
- metadata +31 -3
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,15 +2,82 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
remote: http://gems.github.com/
|
4
4
|
specs:
|
5
|
+
abstract (1.0.0)
|
6
|
+
actionmailer (3.0.2)
|
7
|
+
actionpack (= 3.0.2)
|
8
|
+
mail (~> 2.2.9)
|
9
|
+
actionpack (3.0.2)
|
10
|
+
activemodel (= 3.0.2)
|
11
|
+
activesupport (= 3.0.2)
|
12
|
+
builder (~> 2.1.2)
|
13
|
+
erubis (~> 2.6.6)
|
14
|
+
i18n (~> 0.4.1)
|
15
|
+
rack (~> 1.2.1)
|
16
|
+
rack-mount (~> 0.6.13)
|
17
|
+
rack-test (~> 0.5.6)
|
18
|
+
tzinfo (~> 0.3.23)
|
19
|
+
activemodel (3.0.2)
|
20
|
+
activesupport (= 3.0.2)
|
21
|
+
builder (~> 2.1.2)
|
22
|
+
i18n (~> 0.4.1)
|
23
|
+
activerecord (3.0.2)
|
24
|
+
activemodel (= 3.0.2)
|
25
|
+
activesupport (= 3.0.2)
|
26
|
+
arel (~> 2.0.2)
|
27
|
+
tzinfo (~> 0.3.23)
|
28
|
+
activeresource (3.0.2)
|
29
|
+
activemodel (= 3.0.2)
|
30
|
+
activesupport (= 3.0.2)
|
31
|
+
activesupport (3.0.2)
|
32
|
+
arel (2.0.2)
|
33
|
+
builder (2.1.2)
|
34
|
+
erubis (2.6.6)
|
35
|
+
abstract (>= 1.0.0)
|
36
|
+
ffi (0.6.3)
|
37
|
+
rake (>= 0.8.7)
|
5
38
|
git (1.2.5)
|
39
|
+
i18n (0.4.2)
|
6
40
|
jeweler (1.5.1)
|
7
41
|
bundler (~> 1.0.0)
|
8
42
|
git (>= 1.2.5)
|
9
43
|
rake
|
44
|
+
mail (2.2.9.1)
|
45
|
+
activesupport (>= 2.3.6)
|
46
|
+
i18n (>= 0.4.1)
|
47
|
+
mime-types (~> 1.16)
|
48
|
+
treetop (~> 1.4.8)
|
49
|
+
mime-types (1.16)
|
50
|
+
polyglot (0.3.1)
|
51
|
+
rack (1.2.1)
|
52
|
+
rack-mount (0.6.13)
|
53
|
+
rack (>= 1.0.0)
|
54
|
+
rack-test (0.5.6)
|
55
|
+
rack (>= 1.0)
|
56
|
+
rails (3.0.2)
|
57
|
+
actionmailer (= 3.0.2)
|
58
|
+
actionpack (= 3.0.2)
|
59
|
+
activerecord (= 3.0.2)
|
60
|
+
activeresource (= 3.0.2)
|
61
|
+
activesupport (= 3.0.2)
|
62
|
+
bundler (~> 1.0.0)
|
63
|
+
railties (= 3.0.2)
|
64
|
+
railties (3.0.2)
|
65
|
+
actionpack (= 3.0.2)
|
66
|
+
activesupport (= 3.0.2)
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (~> 0.14.4)
|
10
69
|
rake (0.8.7)
|
70
|
+
sqlite3 (0.1.1)
|
71
|
+
ffi (>= 0.6.3)
|
72
|
+
thor (0.14.4)
|
73
|
+
treetop (1.4.8)
|
74
|
+
polyglot (>= 0.3.1)
|
75
|
+
tzinfo (0.3.23)
|
11
76
|
|
12
77
|
PLATFORMS
|
13
78
|
ruby
|
14
79
|
|
15
80
|
DEPENDENCIES
|
16
81
|
jeweler (~> 1.5)
|
82
|
+
rails (~> 3.0.1)
|
83
|
+
sqlite3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/preference_fu.rb
CHANGED
@@ -18,6 +18,7 @@ module PreferenceFu
|
|
18
18
|
end
|
19
19
|
|
20
20
|
options = prefs.extract_options!
|
21
|
+
preference_names=prefs-options.keys
|
21
22
|
@config = { :column => 'preferences' }.merge(options)
|
22
23
|
|
23
24
|
self.preference_options = {}
|
@@ -25,6 +26,12 @@ module PreferenceFu
|
|
25
26
|
self.preference_options[2**idx] = { :key => pref.to_sym, :default => false }
|
26
27
|
end
|
27
28
|
|
29
|
+
preference_names.each do |pref|
|
30
|
+
define_method(pref.to_sym) {self.prefs[pref.to_sym]}
|
31
|
+
define_method((pref.to_s+'?').to_sym) {send pref.to_sym}
|
32
|
+
define_method((pref.to_s+'=').to_sym) {|a| self.prefs[pref.to_sym]=a}
|
33
|
+
end
|
34
|
+
|
28
35
|
class << self
|
29
36
|
define_method(:preferences_column) { @config[:column] }
|
30
37
|
end
|
data/preference_fu.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{preference_fu}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brennan Dunn"]
|
@@ -49,11 +49,17 @@ Gem::Specification.new do |s|
|
|
49
49
|
|
50
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
51
|
s.add_runtime_dependency(%q<jeweler>, ["~> 1.5"])
|
52
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0.1"])
|
53
|
+
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
52
54
|
else
|
53
55
|
s.add_dependency(%q<jeweler>, ["~> 1.5"])
|
56
|
+
s.add_dependency(%q<rails>, ["~> 3.0.1"])
|
57
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
54
58
|
end
|
55
59
|
else
|
56
60
|
s.add_dependency(%q<jeweler>, ["~> 1.5"])
|
61
|
+
s.add_dependency(%q<rails>, ["~> 3.0.1"])
|
62
|
+
s.add_dependency(%q<sqlite3>, [">= 0"])
|
57
63
|
end
|
58
64
|
end
|
59
65
|
|
data/test/abstract_unit.rb
CHANGED
data/test/preference_fu_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require File.join(File.dirname(__FILE__), 'abstract_unit')
|
3
|
-
require File.join(File.dirname(__FILE__), 'person')
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'abstract_unit'))
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'person'))
|
4
4
|
|
5
5
|
|
6
6
|
class PreferenceFuTest < Test::Unit::TestCase
|
@@ -62,4 +62,10 @@ class PreferenceFuTest < Test::Unit::TestCase
|
|
62
62
|
assert_equal 4, @person.prefs.index(:delete_user)
|
63
63
|
end
|
64
64
|
|
65
|
+
def test_instance_preference_method
|
66
|
+
@person.prefs[:change_theme]=true
|
67
|
+
@person.save
|
68
|
+
assert_equal true,Person.find(@person.id).change_theme
|
69
|
+
end
|
70
|
+
|
65
71
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brennan Dunn
|
@@ -31,6 +31,34 @@ dependencies:
|
|
31
31
|
type: :runtime
|
32
32
|
prerelease: false
|
33
33
|
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rails
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 3
|
43
|
+
- 0
|
44
|
+
- 1
|
45
|
+
version: 3.0.1
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: sqlite3
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
type: :development
|
60
|
+
prerelease: false
|
61
|
+
version_requirements: *id003
|
34
62
|
description: This plugin, greatly inspired by Jim Morris' blog post (http://blog.wolfman.com/articles/2007/08/07/bit-vector-preferences), aims to make it easy and flexible to store boolean preferences for an ActiveRecord model.This can be also used as a very quick way to setup an ACL. Because the values are stored within a bit vector, a virtually unlimited number of preferences can be created without additional migrations.
|
35
63
|
email: ""
|
36
64
|
executables: []
|
@@ -70,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
98
|
requirements:
|
71
99
|
- - ">="
|
72
100
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
101
|
+
hash: -3753918124169257309
|
74
102
|
segments:
|
75
103
|
- 0
|
76
104
|
version: "0"
|