safe_attributes 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +12 -1
- data/NEWS.rdoc +10 -0
- data/README.rdoc +8 -0
- data/VERSION +1 -1
- data/lib/safe_attributes.rb +5 -7
- data/safe_attributes.gemspec +4 -6
- data/spec/safe_attributes/safe_attributes_spec.rb +0 -11
- metadata +23 -33
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use ruby-1.9.3-p0@safe_attributes
|
data/Gemfile
CHANGED
@@ -4,17 +4,24 @@ source "http://rubygems.org"
|
|
4
4
|
if ENV.has_key?('SA_WITH_3_0')
|
5
5
|
gem 'activesupport', '~> 3.0.0'
|
6
6
|
gem 'activerecord', '~> 3.0.0'
|
7
|
+
elsif ENV.has_key?('SA_WITH_3_1')
|
8
|
+
gem 'activesupport', '~> 3.1.0'
|
9
|
+
gem 'activerecord', '~> 3.1.0'
|
7
10
|
else
|
8
11
|
gem 'activesupport', '>= 3.0.0'
|
9
12
|
gem 'activerecord', '>= 3.0.0'
|
10
13
|
end
|
11
14
|
|
15
|
+
platform :mri do
|
16
|
+
gem 'simplecov', :require => false, :group => :test
|
17
|
+
end
|
18
|
+
|
12
19
|
group :development do
|
13
20
|
gem 'jeweler', '>= 1.5.2'
|
14
21
|
gem 'rake', '>= 0.8.7'
|
15
22
|
gem 'rdoc'
|
16
23
|
gem 'rspec', '>= 2.3.0'
|
17
|
-
|
24
|
+
|
18
25
|
platform :ruby do
|
19
26
|
gem 'sqlite3', '>= 1.3.4'
|
20
27
|
end
|
@@ -22,4 +29,8 @@ group :development do
|
|
22
29
|
gem 'activerecord-jdbcsqlite3-adapter'
|
23
30
|
gem 'jruby-openssl'
|
24
31
|
end
|
32
|
+
# For debugging under ruby 1.9 special gems are needed
|
33
|
+
# gem 'ruby-debug19', :platform => :mri
|
34
|
+
# gem 'ruby-debug-base19', '>=0.11.26'
|
35
|
+
# gem 'linecache19', '>=0.5.13'
|
25
36
|
end
|
data/NEWS.rdoc
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
= Version 1.0.8
|
2
|
+
|
3
|
+
* Tested against Rails 3.2
|
4
|
+
* No longer uses InstanceMethods, avoids deprecation warning under Rails 3.2
|
5
|
+
* Updated README noting column named 'attribute' will never work
|
6
|
+
|
7
|
+
= Version 1.0.7
|
8
|
+
|
9
|
+
* Resolved validation issue when using Devise
|
10
|
+
|
1
11
|
= Version 1.0.6
|
2
12
|
|
3
13
|
* Updated gemspec after verifying gem works with ActiveRecord 3.1.
|
data/README.rdoc
CHANGED
@@ -95,6 +95,14 @@ not to generate.
|
|
95
95
|
include SafeAttributes
|
96
96
|
end
|
97
97
|
|
98
|
+
== Caveats
|
99
|
+
|
100
|
+
It is virtually impossible to have a column named 'attribute' in your
|
101
|
+
schema when using ActiveRecord. After spending some time trying to
|
102
|
+
make it work I've come to the conclusion the only way to support this
|
103
|
+
will be to change the tactic I'm using entirely, and likely to
|
104
|
+
get the developers of ActiveRecord to agree to a patch.
|
105
|
+
|
98
106
|
== Note on Patches/Pull Requests
|
99
107
|
|
100
108
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
data/lib/safe_attributes.rb
CHANGED
@@ -52,13 +52,11 @@ module SafeAttributes
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
self.send(attr.to_s) if (self.respond_to?(attr.to_sym))
|
61
|
-
end
|
55
|
+
def read_attribute_for_validation(attr)
|
56
|
+
if (self.attributes.include?(attr.to_s))
|
57
|
+
self[attr.to_sym]
|
58
|
+
else
|
59
|
+
self.send(attr.to_s) if (self.respond_to?(attr.to_sym))
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
data/safe_attributes.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "safe_attributes"
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Jones"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2012-02-04"
|
13
13
|
s.description = "Better support for legacy database schemas for ActiveRecord, such as columns named class, or any other name that conflicts with an instance method of ActiveRecord."
|
14
14
|
s.email = "cbj@gnu.org"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".rspec",
|
22
|
+
".rvmrc",
|
22
23
|
"Gemfile",
|
23
24
|
"LICENSE",
|
24
25
|
"NEWS.rdoc",
|
@@ -34,7 +35,7 @@ Gem::Specification.new do |s|
|
|
34
35
|
s.homepage = "http://github.com/bjones/safe_attributes"
|
35
36
|
s.licenses = ["MIT"]
|
36
37
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = "1.8.
|
38
|
+
s.rubygems_version = "1.8.10"
|
38
39
|
s.summary = "Useful for legacy database support, adds support for reserved word column names with ActiveRecord"
|
39
40
|
|
40
41
|
if s.respond_to? :specification_version then
|
@@ -47,7 +48,6 @@ Gem::Specification.new do |s|
|
|
47
48
|
s.add_development_dependency(%q<rake>, [">= 0.8.7"])
|
48
49
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
49
50
|
s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
|
50
|
-
s.add_development_dependency(%q<rcov>, [">= 0"])
|
51
51
|
s.add_development_dependency(%q<sqlite3>, [">= 1.3.4"])
|
52
52
|
s.add_development_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 0"])
|
53
53
|
s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
|
@@ -58,7 +58,6 @@ Gem::Specification.new do |s|
|
|
58
58
|
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
59
59
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
60
60
|
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
61
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
62
61
|
s.add_dependency(%q<sqlite3>, [">= 1.3.4"])
|
63
62
|
s.add_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 0"])
|
64
63
|
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
@@ -70,7 +69,6 @@ Gem::Specification.new do |s|
|
|
70
69
|
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
71
70
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
72
71
|
s.add_dependency(%q<rspec>, [">= 2.3.0"])
|
73
|
-
s.add_dependency(%q<rcov>, [">= 0"])
|
74
72
|
s.add_dependency(%q<sqlite3>, [">= 1.3.4"])
|
75
73
|
s.add_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 0"])
|
76
74
|
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
@@ -12,7 +12,6 @@ ActiveRecord::Base.connection.create_table(:my_models) do |t|
|
|
12
12
|
t.string :errors
|
13
13
|
# support hyphenated column names
|
14
14
|
t.string :"comment-frequency"
|
15
|
-
t.string :attribute
|
16
15
|
end
|
17
16
|
|
18
17
|
class MyModel < ActiveRecord::Base
|
@@ -92,16 +91,6 @@ describe "models" do
|
|
92
91
|
(@model.methods.include?('id') || @model.methods.include?(:id)).should be_true
|
93
92
|
end
|
94
93
|
|
95
|
-
it "does not defined attribute()" do
|
96
|
-
@model.respond_to?(:attribute) # to force method generation
|
97
|
-
(@model.methods.include?('attribute') || @model.methods.include?(:attribute)).should be_false
|
98
|
-
end
|
99
|
-
|
100
|
-
it "does not defined attribute=()" do
|
101
|
-
@model.respond_to?(:attribute=) # to force method generation
|
102
|
-
(@model.methods.include?('attribute=') || @model.methods.include?(:attribute=)).should be_false
|
103
|
-
end
|
104
|
-
|
105
94
|
it "can create instance in database with special attribute name" do
|
106
95
|
m = MyModel.create!(:class => 'Foo')
|
107
96
|
m = MyModel.find(m.id)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70237043376580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70237043376580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &70237043374880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70237043374880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70237043374180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.5.2
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70237043374180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &70237043373200 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.8.7
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70237043373200
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &70237043403360 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70237043403360
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70237043400620 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,21 +76,10 @@ dependencies:
|
|
76
76
|
version: 2.3.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: rcov
|
82
|
-
requirement: &70339699363840 !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ! '>='
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0'
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *70339699363840
|
79
|
+
version_requirements: *70237043400620
|
91
80
|
- !ruby/object:Gem::Dependency
|
92
81
|
name: sqlite3
|
93
|
-
requirement: &
|
82
|
+
requirement: &70237043398180 !ruby/object:Gem::Requirement
|
94
83
|
none: false
|
95
84
|
requirements:
|
96
85
|
- - ! '>='
|
@@ -98,10 +87,10 @@ dependencies:
|
|
98
87
|
version: 1.3.4
|
99
88
|
type: :development
|
100
89
|
prerelease: false
|
101
|
-
version_requirements: *
|
90
|
+
version_requirements: *70237043398180
|
102
91
|
- !ruby/object:Gem::Dependency
|
103
92
|
name: activerecord-jdbcsqlite3-adapter
|
104
|
-
requirement: &
|
93
|
+
requirement: &70237043431700 !ruby/object:Gem::Requirement
|
105
94
|
none: false
|
106
95
|
requirements:
|
107
96
|
- - ! '>='
|
@@ -109,10 +98,10 @@ dependencies:
|
|
109
98
|
version: '0'
|
110
99
|
type: :development
|
111
100
|
prerelease: false
|
112
|
-
version_requirements: *
|
101
|
+
version_requirements: *70237043431700
|
113
102
|
- !ruby/object:Gem::Dependency
|
114
103
|
name: jruby-openssl
|
115
|
-
requirement: &
|
104
|
+
requirement: &70237043427660 !ruby/object:Gem::Requirement
|
116
105
|
none: false
|
117
106
|
requirements:
|
118
107
|
- - ! '>='
|
@@ -120,7 +109,7 @@ dependencies:
|
|
120
109
|
version: '0'
|
121
110
|
type: :development
|
122
111
|
prerelease: false
|
123
|
-
version_requirements: *
|
112
|
+
version_requirements: *70237043427660
|
124
113
|
description: Better support for legacy database schemas for ActiveRecord, such as
|
125
114
|
columns named class, or any other name that conflicts with an instance method of
|
126
115
|
ActiveRecord.
|
@@ -133,6 +122,7 @@ extra_rdoc_files:
|
|
133
122
|
files:
|
134
123
|
- .document
|
135
124
|
- .rspec
|
125
|
+
- .rvmrc
|
136
126
|
- Gemfile
|
137
127
|
- LICENSE
|
138
128
|
- NEWS.rdoc
|
@@ -159,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
149
|
version: '0'
|
160
150
|
segments:
|
161
151
|
- 0
|
162
|
-
hash:
|
152
|
+
hash: 2760352587887080071
|
163
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
154
|
none: false
|
165
155
|
requirements:
|
@@ -168,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
158
|
version: '0'
|
169
159
|
requirements: []
|
170
160
|
rubyforge_project:
|
171
|
-
rubygems_version: 1.8.
|
161
|
+
rubygems_version: 1.8.10
|
172
162
|
signing_key:
|
173
163
|
specification_version: 3
|
174
164
|
summary: Useful for legacy database support, adds support for reserved word column
|