basic_model 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,10 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1
4
5
  gemfile:
5
6
  - gemfiles/Gemfile.activemodel-3.0.x
6
7
  - gemfiles/Gemfile.activemodel-3.1.x
7
-
8
+ - gemfiles/Gemfile.activemodel-3.2.x
9
+ - gemfiles/Gemfile.activemodel-4.0.x
10
+
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = 'basic_model'
16
16
 
17
- s.add_dependency 'activemodel', '~> 3.0'
18
- s.add_dependency 'activesupport', '~> 3.0'
17
+ s.add_dependency 'activemodel', '>= 3.0', '< 5'
18
+ s.add_dependency 'activesupport', '>= 3.0', '< 5'
19
19
  s.add_development_dependency 'rake'
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'basic_model', :path => File.expand_path('../..', __FILE__)
4
4
 
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'basic_model', :path => File.expand_path('../..', __FILE__)
4
4
 
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'basic_model', :path => File.expand_path('../..', __FILE__)
4
+
5
+ gem 'activemodel', '~> 3.2.0'
6
+ gem 'activesupport', '~> 3.2.0'
7
+
8
+ gem 'rake', :group => :development
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'basic_model', :path => File.expand_path('../..', __FILE__)
4
+
5
+ gem 'activemodel', '~> 4.0.0'
6
+ gem 'activesupport', '~> 4.0.0'
7
+
8
+ gem 'rake', :group => :development
@@ -6,7 +6,7 @@ module BasicModel
6
6
  extend ActiveSupport::Concern
7
7
  include ActiveModel::Conversion
8
8
  include ActiveModel::Validations
9
-
9
+
10
10
  # Creates and optionally sets the attributes of the model with keys
11
11
  # matching the attribute names. If ActiveModel::MassSecurityAssignment
12
12
  # is included, attributes will be sanitized with the role given in the :as option.
@@ -15,23 +15,23 @@ module BasicModel
15
15
  unless attributes.nil?
16
16
  # Sanitize the attributes if we're using ActiveModel::MassSecurityAssignment
17
17
  # Also account for the different APIs between 3.0 and 3.1
18
- if respond_to? :sanitize_for_mass_assignment
18
+ if protected_methods.include? :sanitize_for_mass_assignment
19
19
  if method(:sanitize_for_mass_assignment).arity == 2
20
20
  attributes = sanitize_for_mass_assignment attributes, options[:as]
21
21
  else
22
22
  attributes = sanitize_for_mass_assignment attributes
23
23
  end
24
24
  end
25
-
25
+
26
26
  # Now set the attributes, ignoring any private methods
27
27
  attributes.each do |name, value|
28
28
  send "#{name}=", value if respond_to? "#{name}="
29
29
  end
30
30
  end
31
-
31
+
32
32
  yield self if block_given?
33
33
  end
34
-
34
+
35
35
  # By default, BasicModels are not persisted in any way.
36
36
  def persisted?
37
37
  false
@@ -1,3 +1,3 @@
1
1
  module BasicModel
2
- VERSION = "0.3.2"
2
+ VERSION = '0.4.0'
3
3
  end
@@ -6,9 +6,9 @@ require 'test/unit'
6
6
  class Post
7
7
  include BasicModel
8
8
  attr_accessor :title, :body
9
-
9
+
10
10
  private
11
-
11
+
12
12
  def not_allowed=(value)
13
13
  raise 'Not Allowed!'
14
14
  end
@@ -16,36 +16,40 @@ end
16
16
 
17
17
  class Comment
18
18
  include BasicModel
19
- include ActiveModel::MassAssignmentSecurity
20
19
  attr_accessor :name, :comment, :spam
21
-
22
- attr_accessible :name, :comment
20
+
21
+ if defined? ActiveModel::MassAssignmentSecurity
22
+ include ActiveModel::MassAssignmentSecurity
23
+ attr_accessible :name, :comment
24
+ end
23
25
  end
24
26
 
25
27
  class BasicModelTest < ActiveSupport::TestCase
26
28
  include ActiveModel::Lint::Tests
27
-
29
+
28
30
  def setup
29
31
  @model = Post.new
30
32
  end
31
-
33
+
32
34
  def test_initialize_with_attributes
33
35
  @model = Post.new(:title => 'Title', :body => 'Body')
34
36
  assert_equal 'Title', @model.title
35
37
  assert_equal 'Body', @model.body
36
38
  end
37
-
39
+
38
40
  def test_do_not_call_private_methods
39
41
  assert_nothing_raised do
40
42
  Post.new(:not_allowed => 'Oops')
41
43
  end
42
44
  end
43
-
44
- def test_mass_security_assignment
45
- @model = Comment.new(:name => 'Bob', :comment => 'Great post!', :spam => false)
46
- assert_nil @model.spam
45
+
46
+ if defined? ActiveModel::MassAssignmentSecurity
47
+ def test_mass_security_assignment
48
+ @model = Comment.new(:name => 'Bob', :comment => 'Great post!', :spam => false)
49
+ assert_nil @model.spam
50
+ end
47
51
  end
48
-
52
+
49
53
  def test_initialize_with_yield
50
54
  @model = Post.new do |post|
51
55
  post.title = 'Title'
metadata CHANGED
@@ -1,76 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: basic_model
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 2
10
- version: 0.3.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Pete Browne
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-09-06 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2014-03-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: activemodel
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70238234788220 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 7
29
- segments:
30
- - 3
31
- - 0
32
- version: "3.0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ - - <
23
+ - !ruby/object:Gem::Version
24
+ version: '5'
33
25
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: activesupport
37
26
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: *70238234788220
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: &70238234816100 !ruby/object:Gem::Requirement
39
31
  none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 7
44
- segments:
45
- - 3
46
- - 0
47
- version: "3.0"
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '3.0'
36
+ - - <
37
+ - !ruby/object:Gem::Version
38
+ version: '5'
48
39
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: rake
52
40
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ version_requirements: *70238234816100
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: &70238234813680 !ruby/object:Gem::Requirement
54
45
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
62
50
  type: :development
63
- version_requirements: *id003
64
- description: BasicModel is intended to be used in a tableless model in Rails >= 3.0. It complies with the ActiveModel API and includes valdiations, so it can be used in form helpers without a problem.
65
- email:
51
+ prerelease: false
52
+ version_requirements: *70238234813680
53
+ description: BasicModel is intended to be used in a tableless model in Rails >= 3.0.
54
+ It complies with the ActiveModel API and includes valdiations, so it can be used
55
+ in form helpers without a problem.
56
+ email:
66
57
  - me@petebrowne.com
67
58
  executables: []
68
-
69
59
  extensions: []
70
-
71
60
  extra_rdoc_files: []
72
-
73
- files:
61
+ files:
74
62
  - .gitignore
75
63
  - .travis.yml
76
64
  - Gemfile
@@ -80,41 +68,40 @@ files:
80
68
  - basic_model.gemspec
81
69
  - gemfiles/Gemfile.activemodel-3.0.x
82
70
  - gemfiles/Gemfile.activemodel-3.1.x
71
+ - gemfiles/Gemfile.activemodel-3.2.x
72
+ - gemfiles/Gemfile.activemodel-4.0.x
83
73
  - lib/basic_model.rb
84
74
  - lib/basic_model/version.rb
85
75
  - test/basic_model_test.rb
86
76
  homepage: http://github.com/petebrowne/basic_model
87
77
  licenses: []
88
-
89
78
  post_install_message:
90
79
  rdoc_options: []
91
-
92
- require_paths:
80
+ require_paths:
93
81
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
95
83
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ segments:
101
89
  - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
90
+ hash: 3744792226769240364
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
92
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ segments:
110
98
  - 0
111
- version: "0"
99
+ hash: 3744792226769240364
112
100
  requirements: []
113
-
114
101
  rubyforge_project: basic_model
115
- rubygems_version: 1.8.5
102
+ rubygems_version: 1.8.11
116
103
  signing_key:
117
104
  specification_version: 3
118
105
  summary: BasicModel is a tiny Module that complies with the ActiveModel API
119
- test_files:
106
+ test_files:
120
107
  - test/basic_model_test.rb