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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40309262aecfd58ad3c5e78f110c0e364e05aca1
4
- data.tar.gz: 41c13121f6be1657aec6f7c42261028464701a6d
3
+ metadata.gz: 35d0bdb1fb701098a4ba14fcc771bac72ccebfc1
4
+ data.tar.gz: aef77413b158952855f197d55bcda23f20ceaac9
5
5
  SHA512:
6
- metadata.gz: 9176eed415951ae139c7292fcecd1d9984c7fa5480c465172e192a72914add830d1de488201b0c7dedabae82098e2093e39a14f0bf7f91971513ca48c5ebd283
7
- data.tar.gz: f866ecbde412f110fb642e0ba90616885825fb1b7c2915af282ba02b53afb3167674a48377b20588156a6752837903cc6e7e0b121e27f5b779ce02b51cdc1fb0
6
+ metadata.gz: df5b1e87b4532ec83d9dab7f5c6c6ae98e1926a4938348e42ac2d971d9d937d292e30dae277d5192008903aaa896a1b83c3ce2c63580f874df310b5dbaeb0e65
7
+ data.tar.gz: 63226dd5fc98126dc36a7db9812be4333bcaa51bbd7600b9e51b4f27122febc1c390e0f47600654c5e8fa38e30f3a4b33e1c748d853c81cf373a16ce7720774c
@@ -1,3 +1,7 @@
1
+ ### 0.1.0 / 2014-08-30
2
+
3
+ * Add Mongoid integration
4
+
1
5
  ### 0.0.4 / 2014-08-30
2
6
 
3
7
  * Automatically include RSpec matcher
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
@@ -1,6 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 3.2.0'
4
+ gem 'mongoid', '~> 3.0'
4
5
  gem 'codeclimate-test-reporter', require: false
5
6
 
6
7
  gemspec path: '../'
@@ -1,6 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'activerecord', '~> 4.1.0'
4
+ gem 'mongoid', '~> 4.0'
4
5
  gem 'codeclimate-test-reporter', require: false
5
6
 
6
7
  gemspec path: '../'
@@ -39,4 +39,5 @@ end
39
39
 
40
40
  require 'normalizr/normalizers'
41
41
  require 'normalizr/integrations/active_record' if defined?(ActiveRecord)
42
+ require 'normalizr/integrations/mongoid' if defined?(Mongoid)
42
43
  require 'normalizr/integrations/rspec' if defined?(RSpec)
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Normalizr
2
- VERSION = '0.0.4'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -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
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Document do
4
+ it { should normalize(:name) }
5
+ it { should normalize(:name).from(' this ').to('this') }
6
+ it { should normalize(:name).from(' ').to(nil) }
7
+ end
@@ -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'
@@ -0,0 +1,6 @@
1
+ class Document
2
+ include Mongoid::Document
3
+
4
+ field :name, type: String
5
+ normalize_attribute :name
6
+ end
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
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-29 00:00:00.000000000 Z
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