user_preferences 0.0.3 → 1.0.0

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: 79eae692bdc8ae7a55e3d051e1a1410d107f2e40
4
- data.tar.gz: 2ddb651befe78053081eb5f38c6676f2e1e0d926
3
+ metadata.gz: 15615015e9ccb0efd6e0db7e176c1d13c8699d71
4
+ data.tar.gz: 9d62fe5e9b60512492121e22f93e0fa892ed1344
5
5
  SHA512:
6
- metadata.gz: 6249b2348c71609f89f107716a7c54a77f6d3ee40c137418514c389f3e4d9a29f43c56c9fadb9dd849f1afd4a1413f539d445b865d6d99afd50571eb848fcf19
7
- data.tar.gz: e4d8f5ce0240d47ddc78c6c40ab7c1828fd30107b19fd4446b9aca45127d46dea37fce97fc61197118dd9a8c1a9cbd9b51ffb8cdd737a28ac5d8fdc138b75373
6
+ metadata.gz: da8293ea1bbfd7cef25c5aa5ca68f77e3789f7e65e04651792f37a0a2e894dbb5c6f99962eaba85689c8be3437169628fc3f1bfd3e900459f6f347845431bb4c
7
+ data.tar.gz: e0017a948a1eafaad7e20f80fe9eadcf6d3ec1e81c11f610e661dcc9c011a172aa908bfd8dc0275d00492b190ad61b2fb3913d36b21db2aa3a1cea0c49f8c05d
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.1.3
4
+ - 2.2.6
5
5
  gemfile:
6
- - gemfiles/rails_3.gemfile
7
6
  - gemfiles/rails_4.gemfile
7
+ - gemfiles/rails_5.gemfile
data/Appraisals CHANGED
@@ -1,7 +1,7 @@
1
- appraise "rails-3" do
2
- gem "rails", "~> 3.2.0"
1
+ appraise "rails-4" do
2
+ gem "rails", "~> 4"
3
3
  end
4
4
 
5
- appraise "rails-4" do
6
- gem "rails", "~> 4.0.0"
5
+ appraise "rails-5" do
6
+ gem "rails", "~> 5.0"
7
7
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0 2017-02-13
4
+
5
+ * Fix compatibility with Rails 5
6
+ * Drop compatibility with Rails 3
7
+
3
8
  ## 0.0.3 2015-06-15
4
9
 
5
10
  * Fix Rails 4 deprecation of ActiveRecord::Relation#all
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.0.0"
5
+ gem "rails", "~> 4"
6
6
 
7
7
  gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 3.2.0"
5
+ gem "rails", "~> 5.0"
6
6
 
7
7
  gemspec :path => "../"
@@ -18,6 +18,7 @@ module UserPreferences
18
18
  hash.each do |name, value|
19
19
  find_or_init_preference(name).update_value!(value)
20
20
  end
21
+ reload
21
22
  end
22
23
  end
23
24
 
@@ -41,11 +42,7 @@ module UserPreferences
41
42
  end
42
43
 
43
44
  def find_or_init_preference(name)
44
- unless preference = saved_preferences.detect { |p| p.name == name }
45
- preference = @scope.find_by_name(name) || @scope.build(name: name, category: @category)
46
- saved_preferences << preference
47
- end
48
- preference
45
+ @scope.find_or_initialize_by(name: name, category: @category)
49
46
  end
50
47
 
51
48
  def hash_setter(&block)
@@ -8,14 +8,18 @@ class UserPreferences::Preference < ActiveRecord::Base
8
8
  delegate :binary?, :default, :permitted_values, :lookup, :to_db, to: :definition
9
9
 
10
10
  def update_value!(v)
11
- update_attributes!(value: to_db(v))
11
+ update_attributes!(value: v)
12
12
  end
13
13
 
14
14
  def value
15
15
  lookup(attributes['value'])
16
16
  end
17
17
 
18
+ def value=(v)
19
+ super(to_db(v))
20
+ end
21
+
18
22
  def definition
19
23
  UserPreferences[category, name]
20
24
  end
21
- end
25
+ end
@@ -44,4 +44,4 @@ module UserPreferences
44
44
  raise ArgumentError.new("invalid value for Boolean: \"#{value}\"")
45
45
  end
46
46
  end
47
- end
47
+ end
@@ -1,3 +1,3 @@
1
1
  module UserPreferences
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -78,4 +78,4 @@ describe UserPreferences::API do
78
78
  })
79
79
  end
80
80
  end
81
- end
81
+ end
@@ -76,4 +76,4 @@ describe UserPreferences::Preference do
76
76
  preference.stub(:value).and_return('white')
77
77
  preference.stub(:permitted_values).and_return(['white'])
78
78
  end
79
- end
79
+ end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'activerecord', '>= 3.0'
22
+ spec.add_dependency 'activerecord', '>= 4.0'
23
23
 
24
24
  spec.add_development_dependency "appraisal"
25
25
  spec.add_development_dependency "bundler", "~> 1.7"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_preferences
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Dust
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: appraisal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -111,8 +111,8 @@ files:
111
111
  - LICENSE.txt
112
112
  - README.md
113
113
  - Rakefile
114
- - gemfiles/rails_3.gemfile
115
114
  - gemfiles/rails_4.gemfile
115
+ - gemfiles/rails_5.gemfile
116
116
  - lib/generators/user_preferences/install_generator.rb
117
117
  - lib/generators/user_preferences/templates/migration.rb
118
118
  - lib/generators/user_preferences/templates/user_preferences.yml
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.4.6
158
+ rubygems_version: 2.4.5.1
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: User preferences gem for Rails.