nilify_blanks 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Appraisals +1 -1
- data/CHANGELOG.rdoc +4 -0
- data/Gemfile.lock +27 -19
- data/lib/nilify_blanks.rb +29 -21
- data/lib/nilify_blanks/version.rb +1 -1
- data/spec/db/test.sqlite3 +0 -0
- metadata +42 -26
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzNlZTg1MTRiOGE2OTllOTYyZWNkYTU5NGJlMDJiOTQ5Mjg2MTQ0MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWY2MDA4NzljZjVhN2VkNDlmMzIyOTMyYTljYzZhMDFlY2E5MTUwZg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YmIyZTQzNzllM2YzMzJiNGUyNzI3OGM5MDlhM2Q1N2QwMjE2YzkxNDhhN2Qx
|
10
|
+
ZWNiZWIzMDM4ZDc4ZGIyYzY1YjY1MDA0NmEwZDk1OGEwZTc1OTI1YmI0Njkz
|
11
|
+
YzAwMDY2ZjczZGM4NTYzNDQ4ZmE4YmYxYWQ2NjRhNDlkOWQ2ZTc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OGI4Y2VhMzkwMDFlZjdmMDM2ODMwM2Q0YmM1ZDhlYTM5NWMxNWQwNzVhZjMx
|
14
|
+
ODFlNjQzNTg0MjAzN2UxOTI2NTIzYzlmMjI4NDVkZjQyMWFkNDc3MWNkYThj
|
15
|
+
ZmY1NThjOWU3YjIwNWU1MjQ5NWJiNzk5YWRlNzlkYThhNDc1MGU=
|
data/Appraisals
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nilify_blanks (1.0.
|
4
|
+
nilify_blanks (1.0.2)
|
5
5
|
activerecord (>= 3.0.0)
|
6
6
|
activesupport (>= 3.0.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (
|
12
|
-
activesupport (=
|
13
|
-
builder (~> 3.
|
14
|
-
activerecord (
|
15
|
-
activemodel (=
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
11
|
+
activemodel (4.0.0)
|
12
|
+
activesupport (= 4.0.0)
|
13
|
+
builder (~> 3.1.0)
|
14
|
+
activerecord (4.0.0)
|
15
|
+
activemodel (= 4.0.0)
|
16
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
17
|
+
activesupport (= 4.0.0)
|
18
|
+
arel (~> 4.0.0)
|
19
|
+
activerecord-deprecated_finders (1.0.3)
|
20
|
+
activesupport (4.0.0)
|
21
|
+
i18n (~> 0.6, >= 0.6.4)
|
22
|
+
minitest (~> 4.2)
|
23
|
+
multi_json (~> 1.3)
|
24
|
+
thread_safe (~> 0.1)
|
25
|
+
tzinfo (~> 0.3.37)
|
26
|
+
appraisal (0.5.2)
|
23
27
|
bundler
|
24
28
|
rake
|
25
|
-
arel (
|
26
|
-
|
29
|
+
arel (4.0.0)
|
30
|
+
atomic (1.0.1)
|
31
|
+
builder (3.1.4)
|
27
32
|
diff-lcs (1.2.1)
|
28
|
-
i18n (0.6.
|
29
|
-
|
33
|
+
i18n (0.6.5)
|
34
|
+
minitest (4.7.5)
|
35
|
+
multi_json (1.7.9)
|
30
36
|
rake (10.0.3)
|
31
37
|
rspec (2.13.0)
|
32
38
|
rspec-core (~> 2.13.0)
|
@@ -37,13 +43,15 @@ GEM
|
|
37
43
|
diff-lcs (>= 1.1.3, < 2.0)
|
38
44
|
rspec-mocks (2.13.0)
|
39
45
|
sqlite3 (1.3.7)
|
40
|
-
|
46
|
+
thread_safe (0.1.0)
|
47
|
+
atomic
|
48
|
+
tzinfo (0.3.37)
|
41
49
|
|
42
50
|
PLATFORMS
|
43
51
|
ruby
|
44
52
|
|
45
53
|
DEPENDENCIES
|
46
|
-
appraisal (~> 0.5.
|
54
|
+
appraisal (~> 0.5.2)
|
47
55
|
nilify_blanks!
|
48
56
|
rake (~> 10.0.3)
|
49
57
|
rspec (~> 2.13)
|
data/lib/nilify_blanks.rb
CHANGED
@@ -2,46 +2,54 @@ module NilifyBlanks
|
|
2
2
|
def self.included(base)
|
3
3
|
base.extend ClassMethods
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
module ClassMethods
|
7
|
+
|
8
|
+
def define_attribute_methods
|
9
|
+
super
|
10
|
+
define_nilify_blank_methods
|
11
|
+
end
|
12
|
+
|
7
13
|
def nilify_blanks(options = {})
|
8
14
|
return if self.included_modules.include?(NilifyBlanks::InstanceMethods)
|
9
|
-
|
10
|
-
|
15
|
+
|
11
16
|
include NilifyBlanks::InstanceMethods
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
|
18
|
+
@_nilify_blanks_options = options
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def define_nilify_blank_methods
|
24
|
+
return unless @_nilify_blanks_options
|
25
|
+
|
26
|
+
options = @_nilify_blanks_options
|
27
|
+
options[:only] = Array.wrap(options[:only]).map(&:to_s) if options[:only]
|
28
|
+
options[:except] = Array.wrap(options[:except]).map(&:to_s) if options[:except]
|
29
|
+
|
23
30
|
cattr_accessor :nilify_blanks_columns
|
24
|
-
|
31
|
+
|
25
32
|
if options[:only]
|
26
33
|
self.nilify_blanks_columns = options[:only].clone
|
27
34
|
else
|
28
|
-
self.nilify_blanks_columns = self.content_columns.
|
35
|
+
self.nilify_blanks_columns = self.content_columns.select(&:null).map(&:name).map(&:to_s)
|
29
36
|
end
|
30
37
|
self.nilify_blanks_columns -= options[:except] if options[:except]
|
31
38
|
self.nilify_blanks_columns = self.nilify_blanks_columns.map(&:to_s)
|
32
|
-
|
39
|
+
|
33
40
|
options[:before] ||= :save
|
34
|
-
|
41
|
+
send("before_#{options[:before]}", :nilify_blanks)
|
35
42
|
end
|
43
|
+
|
36
44
|
end
|
37
|
-
|
45
|
+
|
38
46
|
module InstanceMethods
|
39
47
|
def nilify_blanks
|
40
48
|
(self.nilify_blanks_columns || []).each do |column|
|
41
49
|
value = read_attribute(column)
|
42
50
|
next unless value.is_a?(String)
|
43
|
-
next unless value.
|
44
|
-
|
51
|
+
next unless value.respond_to?(:blank?)
|
52
|
+
|
45
53
|
write_attribute(column, nil) if value.blank?
|
46
54
|
end
|
47
55
|
end
|
data/spec/db/test.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,82 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nilify_blanks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ben Hughes
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: activerecord
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ! '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 3.0.0
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rake
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
45
|
- - ~>
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: 10.0.3
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 10.0.3
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: rspec
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '2.13'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.13'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: appraisal
|
60
|
-
requirement:
|
61
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
62
72
|
requirements:
|
63
73
|
- - ~>
|
64
74
|
- !ruby/object:Gem::Version
|
65
|
-
version: 0.5.
|
75
|
+
version: 0.5.2
|
66
76
|
type: :development
|
67
77
|
prerelease: false
|
68
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.5.2
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: sqlite3
|
71
|
-
requirement:
|
72
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
73
86
|
requirements:
|
74
87
|
- - ~>
|
75
88
|
- !ruby/object:Gem::Version
|
76
89
|
version: 1.3.6
|
77
90
|
type: :development
|
78
91
|
prerelease: false
|
79
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.6
|
80
97
|
description: Often times you'll end up with empty strings where you really want nil
|
81
98
|
at the database level. This plugin automatically converts blanks to nil and is
|
82
99
|
configurable.
|
@@ -103,27 +120,26 @@ files:
|
|
103
120
|
- init.rb
|
104
121
|
homepage: http://github.com/rubiety/nilify_blanks
|
105
122
|
licenses: []
|
123
|
+
metadata: {}
|
106
124
|
post_install_message:
|
107
125
|
rdoc_options: []
|
108
126
|
require_paths:
|
109
127
|
- lib
|
110
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
129
|
requirements:
|
113
130
|
- - ! '>='
|
114
131
|
- !ruby/object:Gem::Version
|
115
132
|
version: '0'
|
116
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
134
|
requirements:
|
119
135
|
- - ! '>='
|
120
136
|
- !ruby/object:Gem::Version
|
121
137
|
version: 1.3.4
|
122
138
|
requirements: []
|
123
139
|
rubyforge_project: nilify_blanks
|
124
|
-
rubygems_version:
|
140
|
+
rubygems_version: 2.0.6
|
125
141
|
signing_key:
|
126
|
-
specification_version:
|
142
|
+
specification_version: 4
|
127
143
|
summary: Auto-convert blank fields to nil.
|
128
144
|
test_files: []
|
129
145
|
has_rdoc:
|