normalizr 0.0.1 → 0.0.2

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: 46e20b8bf0d6a0371b2d02e709f83f64f530febc
4
- data.tar.gz: 03815de2a257c27aa115e25601658eed6c6d76c6
3
+ metadata.gz: 1a1ea6ea124dcfb9150f5baa5014afd7c48d22a6
4
+ data.tar.gz: 8edcc27a488527db1fcee49f784011c4432f47f3
5
5
  SHA512:
6
- metadata.gz: 300fc2ccb51ad7808ebb8fd24baa6b9a9124d4a796df908d6a9d7653b386bec23a7f14ee44c44228b52c71ec55d48aac44b70331c58301996e3489491bdb7982
7
- data.tar.gz: 53347f657d9352371bea8b9d3d2025a51e819ddf8786fa70f4650e21313fbe84f90c7fe3b860e39027867207a01febd75e67d83eb46c5913592fb01756e9338e
6
+ metadata.gz: ea84b47043932b32f5fb5f23ec1c8cda39c20765e355ead63adda7d7eb462322c11c5a0b5bc12a22a72db0ce615c4d230949d3d47898fc084e794c2d8358506e
7
+ data.tar.gz: 97ae21ee80ba0b1bc824ca36e5005225736feab1341bb0648a1821052ccf9d605c1292c8d8a114ea5446b3467e9a620502eee31478a3096a0cc8c037628cabc0
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ### 0.0.2 / 2014-08-22
2
+
3
+ * Rename `#do` method to `#normalize`
4
+
5
+ ### 0.0.1 / 2014-08-22
6
+
7
+ * Initial release
data/README.md CHANGED
@@ -50,7 +50,7 @@ Normalizr.configure do
50
50
  end
51
51
  ```
52
52
 
53
- Add a custom normalizer:
53
+ Register custom normalizer:
54
54
 
55
55
  ```ruby
56
56
  Normalizr.configure do
@@ -93,12 +93,12 @@ class Currency
93
93
  end
94
94
  ```
95
95
 
96
- Normalize value outside class:
96
+ Normalize values outside of class:
97
97
 
98
98
  ```ruby
99
- Normalizr.do(value)
100
- Normalizr.do(value, :strip, :blank)
101
- Normalizr.do(value, :strip, truncate: { length: 20 })
99
+ Normalizr.normalize(value)
100
+ Normalizr.normalize(value, :strip, :blank)
101
+ Normalizr.normalize(value, :strip, truncate: { length: 20 })
102
102
  ```
103
103
 
104
104
  ### Built-in normalizers
@@ -19,8 +19,8 @@ module Normalizr
19
19
  prepend Module.new {
20
20
  options.attributes.each do |method|
21
21
  define_method :"#{method}=" do |value|
22
- value = Normalizr.do(value, *options.pre)
23
- value = Normalizr.do(value, *options.post) if options.post.any?
22
+ value = Normalizr.normalize(value, *options.pre)
23
+ value = Normalizr.normalize(value, *options.post) if options.post.any?
24
24
  super(value)
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module Normalizr
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/normalizr.rb CHANGED
@@ -27,7 +27,7 @@ module Normalizr
27
27
  end
28
28
  end
29
29
 
30
- def do(value, *normalizers)
30
+ def normalize(value, *normalizers)
31
31
  normalizers = configuration.default_normalizers if normalizers.empty?
32
32
  normalizers.each do |name|
33
33
  name, options = name.first if Hash === name
@@ -31,33 +31,9 @@ describe Normalizr do
31
31
  end
32
32
  end
33
33
 
34
- describe '#do' do
34
+ describe '#normalize' do
35
35
  before { configuration.default_normalizers = [:strip, :blank] }
36
- subject { described_class.do(value, *normalizers) }
37
-
38
- context 'normalizers is empty' do
39
- let(:normalizers) { [] }
40
- let(:value) { ' text ' }
41
- it { should == 'text' }
42
- end
43
-
44
- context 'normalizers is not empty' do
45
- let(:normalizers) { [truncate: { length: 8, omission: '...' }] }
46
- let(:value) { 'Lorem ipsum dolor sit amet' }
47
- it { should == 'Lorem...' }
48
- end
49
-
50
- context 'proc' do
51
- let(:normalizers) { [proc { |v| v.first(5) }] }
52
- let(:value) { 'Lorem ipsum dolor sit amet' }
53
- it { should == 'Lorem' }
54
- end
55
- end
56
-
57
-
58
- describe '#do' do
59
- before { configuration.default_normalizers = [:strip, :blank] }
60
- subject { described_class.do(value, *normalizers) }
36
+ subject { described_class.normalize(value, *normalizers) }
61
37
 
62
38
  context 'normalizers is empty' do
63
39
  let(:normalizers) { [] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalizr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimko
@@ -132,6 +132,7 @@ files:
132
132
  - ".gitignore"
133
133
  - ".rspec"
134
134
  - ".travis.yml"
135
+ - CHANGELOG.md
135
136
  - Gemfile
136
137
  - LICENSE.txt
137
138
  - README.md