normalize 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/normalize.rb CHANGED
@@ -4,7 +4,11 @@ module Normalize
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def normalize_value(value, normalizer)
7
- normalizer.call(value)
7
+ if value.blank?
8
+ value
9
+ else
10
+ normalizer.call(value)
11
+ end
8
12
  end
9
13
 
10
14
  module ClassMethods
data/normalize.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'normalize'
5
- s.version = '0.0.1'
5
+ s.version = '0.0.2'
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ['Tom-Eric Gerritsen']
8
8
  s.email = 'ik@tom-eric.info'
@@ -16,6 +16,20 @@ describe Normalize do
16
16
  it 'normalizes the given value with the given normalizer' do
17
17
  normalizer.normalize_value("string", -> input { input.upcase }).should == "STRING"
18
18
  end
19
+
20
+ it 'does not normalize the value if it is empty' do
21
+ normalization = mock
22
+ normalization.should_not_receive(:call)
23
+
24
+ normalizer.normalize_value('', normalization)
25
+ end
26
+
27
+ it 'does not normalize the value if it is nil' do
28
+ normalization = mock
29
+ normalization.should_not_receive(:call)
30
+
31
+ normalizer.normalize_value(nil, normalization)
32
+ end
19
33
  end
20
34
  end
21
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70140813674080 !ruby/object:Gem::Requirement
16
+ requirement: &70204692924000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70140813674080
24
+ version_requirements: *70204692924000
25
25
  description: The attribute normalizer.
26
26
  email: ik@tom-eric.info
27
27
  executables: []