preferences 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +4 -0
- data/README.rdoc +1 -1
- data/Rakefile +2 -17
- data/lib/preferences.rb +4 -1
- data/test/functional/preferences_test.rb +10 -0
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
|
|
6
6
|
|
7
7
|
spec = Gem::Specification.new do |s|
|
8
8
|
s.name = 'preferences'
|
9
|
-
s.version = '0.4.
|
9
|
+
s.version = '0.4.2'
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.summary = 'Adds support for easily creating custom preferences for ActiveRecord models'
|
12
12
|
s.description = s.summary
|
@@ -66,23 +66,8 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
66
66
|
p.gem_spec = spec
|
67
67
|
end
|
68
68
|
|
69
|
-
desc 'Publish the beta gem.'
|
70
|
-
task :pgem => [:package] do
|
71
|
-
require 'rake/contrib/sshpublisher'
|
72
|
-
Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{spec.name}-#{spec.version}.gem").upload
|
73
|
-
end
|
74
|
-
|
75
|
-
desc 'Publish the API documentation.'
|
76
|
-
task :pdoc => [:rdoc] do
|
77
|
-
require 'rake/contrib/sshpublisher'
|
78
|
-
Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{spec.name}", 'rdoc').upload
|
79
|
-
end
|
80
|
-
|
81
|
-
desc 'Publish the API docs and gem'
|
82
|
-
task :publish => [:pgem, :pdoc, :release]
|
83
|
-
|
84
69
|
desc 'Publish the release files to RubyForge.'
|
85
|
-
task :release =>
|
70
|
+
task :release => :package do
|
86
71
|
require 'rake/gemcutter'
|
87
72
|
|
88
73
|
Rake::Gemcutter::Tasks.new(spec)
|
data/lib/preferences.rb
CHANGED
@@ -317,7 +317,10 @@ module Preferences
|
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
320
|
-
preferences.
|
320
|
+
preferences.inject({}) do |typed_preferences, (name, value)|
|
321
|
+
typed_preferences[name] = value.nil? ? value : preference_definitions[name].type_cast(value)
|
322
|
+
typed_preferences
|
323
|
+
end
|
321
324
|
end
|
322
325
|
|
323
326
|
# Queries whether or not a value is present for the given preference.
|
@@ -968,6 +968,11 @@ class PreferencesLookupTest < ModelPreferenceTest
|
|
968
968
|
assert_equal e = {'notifications' => false, 'language' => 'English'}, @user.preferences
|
969
969
|
end
|
970
970
|
|
971
|
+
def test_should_typecast_unsaved_changes
|
972
|
+
@user.write_preference(:notifications, 'true')
|
973
|
+
assert_equal e = {'notifications' => true, 'language' => 'English'}, @user.preferences
|
974
|
+
end
|
975
|
+
|
971
976
|
def test_should_cache_results
|
972
977
|
assert_queries(1) { @user.preferences }
|
973
978
|
assert_queries(0) { @user.preferences }
|
@@ -1019,6 +1024,11 @@ class PreferencesGroupLookupTest < ModelPreferenceTest
|
|
1019
1024
|
assert_equal e = {'notifications' => false, 'language' => 'Spanish'}, @user.preferences(:chat)
|
1020
1025
|
end
|
1021
1026
|
|
1027
|
+
def test_should_typecast_unsaved_changes
|
1028
|
+
@user.write_preference(:notifications, 'true', :chat)
|
1029
|
+
assert_equal e = {'notifications' => true, 'language' => 'English'}, @user.preferences
|
1030
|
+
end
|
1031
|
+
|
1022
1032
|
def test_should_cache_results
|
1023
1033
|
assert_queries(1) { @user.preferences(:chat) }
|
1024
1034
|
assert_queries(0) { @user.preferences(:chat) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: preferences
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Pfeifer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-17 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|