preferences 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  == master
2
2
 
3
+ == 0.4.2 / 2010-04-17
4
+
5
+ * Fix #preferences lookup not typecasting values
6
+
3
7
  == 0.4.1 / 2010-03-07
4
8
 
5
9
  * Add support for per-group default preferences
@@ -6,7 +6,7 @@
6
6
 
7
7
  API
8
8
 
9
- * http://api.pluginaweek.org/preferences
9
+ * http://rdoc.info/projects/pluginaweek/preferences
10
10
 
11
11
  Bugs
12
12
 
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.1'
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 => [:gem, :package] do
70
+ task :release => :package do
86
71
  require 'rake/gemcutter'
87
72
 
88
73
  Rake::Gemcutter::Tasks.new(spec)
@@ -317,7 +317,10 @@ module Preferences
317
317
  end
318
318
  end
319
319
 
320
- preferences.dup
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.1
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-03-07 00:00:00 -05:00
12
+ date: 2010-04-17 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15