normalizr 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +7 -0
- data/gemfiles/activerecord-3.2.x.gemfile +1 -0
- data/gemfiles/activerecord-4.1.x.gemfile +1 -0
- data/lib/normalizr.rb +1 -0
- data/lib/normalizr/concern.rb +4 -8
- data/lib/normalizr/integrations/mongoid.rb +1 -0
- data/lib/normalizr/version.rb +1 -1
- data/normalizr.gemspec +1 -0
- data/spec/models/document_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/models/document.rb +6 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35d0bdb1fb701098a4ba14fcc771bac72ccebfc1
|
4
|
+
data.tar.gz: aef77413b158952855f197d55bcda23f20ceaac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df5b1e87b4532ec83d9dab7f5c6c6ae98e1926a4938348e42ac2d971d9d937d292e30dae277d5192008903aaa896a1b83c3ce2c63580f874df310b5dbaeb0e65
|
7
|
+
data.tar.gz: 63226dd5fc98126dc36a7db9812be4333bcaa51bbd7600b9e51b4f27122febc1c390e0f47600654c5e8fa38e30f3a4b33e1c748d853c81cf373a16ce7720774c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -130,6 +130,13 @@ Normalizr.normalize(value, :strip, :blank)
|
|
130
130
|
Normalizr.normalize(value, :strip, truncate: { length: 20 })
|
131
131
|
```
|
132
132
|
|
133
|
+
### ORMs
|
134
|
+
|
135
|
+
Normalizr automatically loads into:
|
136
|
+
|
137
|
+
* ActiveRecord
|
138
|
+
* Mongoid
|
139
|
+
|
133
140
|
### RSpec matcher
|
134
141
|
|
135
142
|
```ruby
|
data/lib/normalizr.rb
CHANGED
data/lib/normalizr/concern.rb
CHANGED
@@ -2,14 +2,6 @@ module Normalizr
|
|
2
2
|
module Concern
|
3
3
|
def self.included(base)
|
4
4
|
base.extend(ClassMethods)
|
5
|
-
|
6
|
-
base.instance_eval do
|
7
|
-
class << self
|
8
|
-
# attribute normalizer replacement
|
9
|
-
alias_method :normalize_attribute, :normalize
|
10
|
-
alias_method :normalize_attributes, :normalize
|
11
|
-
end
|
12
|
-
end
|
13
5
|
end
|
14
6
|
|
15
7
|
module ClassMethods
|
@@ -26,6 +18,10 @@ module Normalizr
|
|
26
18
|
end
|
27
19
|
}
|
28
20
|
end
|
21
|
+
|
22
|
+
# attribute normalizer compatibility
|
23
|
+
alias_method :normalize_attribute, :normalize
|
24
|
+
alias_method :normalize_attributes, :normalize
|
29
25
|
end
|
30
26
|
end
|
31
27
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Mongoid::Document::ClassMethods.send(:include, Normalizr::Concern::ClassMethods)
|
data/lib/normalizr/version.rb
CHANGED
data/normalizr.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
25
25
|
spec.add_development_dependency 'rspec-its'
|
26
26
|
spec.add_development_dependency 'fuubar'
|
27
|
+
spec.add_development_dependency 'mongoid', '>= 3.0'
|
27
28
|
spec.add_development_dependency 'activerecord', '>= 3.0'
|
28
29
|
spec.add_development_dependency 'sqlite3'
|
29
30
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ require 'support/codeclimate'
|
|
2
2
|
require 'pry'
|
3
3
|
require 'rspec'
|
4
4
|
require 'rspec/its'
|
5
|
+
require 'mongoid'
|
5
6
|
require 'active_record'
|
6
7
|
require 'normalizr'
|
7
8
|
|
@@ -13,6 +14,7 @@ end
|
|
13
14
|
require 'support/models/article'
|
14
15
|
require 'support/models/author'
|
15
16
|
require 'support/models/book'
|
17
|
+
require 'support/models/document'
|
16
18
|
require 'support/models/journal'
|
17
19
|
require 'support/models/magazine'
|
18
20
|
require 'support/models/person'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: normalizr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mongoid
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: activerecord
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,6 +158,7 @@ files:
|
|
144
158
|
- lib/normalizr/configuration.rb
|
145
159
|
- lib/normalizr/exceptions.rb
|
146
160
|
- lib/normalizr/integrations/active_record.rb
|
161
|
+
- lib/normalizr/integrations/mongoid.rb
|
147
162
|
- lib/normalizr/integrations/rspec.rb
|
148
163
|
- lib/normalizr/normalizers.rb
|
149
164
|
- lib/normalizr/options_parser.rb
|
@@ -156,6 +171,7 @@ files:
|
|
156
171
|
- spec/models/article_spec.rb
|
157
172
|
- spec/models/author_spec.rb
|
158
173
|
- spec/models/book_spec.rb
|
174
|
+
- spec/models/document_spec.rb
|
159
175
|
- spec/models/journal_spec.rb
|
160
176
|
- spec/models/magazine_spec.rb
|
161
177
|
- spec/models/phone_spec.rb
|
@@ -167,6 +183,7 @@ files:
|
|
167
183
|
- spec/support/models/article.rb
|
168
184
|
- spec/support/models/author.rb
|
169
185
|
- spec/support/models/book.rb
|
186
|
+
- spec/support/models/document.rb
|
170
187
|
- spec/support/models/journal.rb
|
171
188
|
- spec/support/models/magazine.rb
|
172
189
|
- spec/support/models/person.rb
|
@@ -205,6 +222,7 @@ test_files:
|
|
205
222
|
- spec/models/article_spec.rb
|
206
223
|
- spec/models/author_spec.rb
|
207
224
|
- spec/models/book_spec.rb
|
225
|
+
- spec/models/document_spec.rb
|
208
226
|
- spec/models/journal_spec.rb
|
209
227
|
- spec/models/magazine_spec.rb
|
210
228
|
- spec/models/phone_spec.rb
|
@@ -216,6 +234,7 @@ test_files:
|
|
216
234
|
- spec/support/models/article.rb
|
217
235
|
- spec/support/models/author.rb
|
218
236
|
- spec/support/models/book.rb
|
237
|
+
- spec/support/models/document.rb
|
219
238
|
- spec/support/models/journal.rb
|
220
239
|
- spec/support/models/magazine.rb
|
221
240
|
- spec/support/models/person.rb
|