string-mapper 0.1.2 → 0.1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -1
- data/lib/string-mapper.rb +2 -2
- data/spec/string-mapper_spec.rb +4 -0
- data/string-mapper.gemspec +2 -2
- metadata +2 -2
data/History.txt
CHANGED
data/lib/string-mapper.rb
CHANGED
@@ -30,7 +30,7 @@ module StringMapper #:nodoc:
|
|
30
30
|
MAJOR = 0
|
31
31
|
MINOR = 1
|
32
32
|
TINY = 2
|
33
|
-
PATCH =
|
33
|
+
PATCH = 1 # Set to nil for official release
|
34
34
|
|
35
35
|
STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
|
36
36
|
end
|
@@ -47,7 +47,7 @@ class String
|
|
47
47
|
regexp = if key.is_a?(Regexp)
|
48
48
|
key
|
49
49
|
else
|
50
|
-
Regexp.new(key
|
50
|
+
Regexp.new("^#{key}$", Regexp::IGNORECASE)
|
51
51
|
end
|
52
52
|
if self =~ regexp
|
53
53
|
mapping = if value.is_a?(String)
|
data/spec/string-mapper_spec.rb
CHANGED
@@ -27,11 +27,15 @@ describe "String.add_mapper(:target)" do
|
|
27
27
|
|
28
28
|
it 'should convert from a String ignoring case' do
|
29
29
|
String.target_mappings['one million'] = 1000000
|
30
|
+
'Thirty or one million'.to_target.should be_nil
|
31
|
+
'one million dollars'.to_target.should be_nil
|
30
32
|
'One million'.to_target.should be(1000000)
|
31
33
|
end
|
32
34
|
|
33
35
|
it 'should convert from a Symbol ignoring case' do
|
34
36
|
String.target_mappings[:four] = 4
|
37
|
+
'Twenty four'.to_target.should be_nil
|
38
|
+
'fourty five'.to_target.should be_nil
|
35
39
|
'FOUR'.to_target.should be(4)
|
36
40
|
end
|
37
41
|
|
data/string-mapper.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{string-mapper}
|
5
|
-
s.version = "0.1.2"
|
5
|
+
s.version = "0.1.2.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Fernando Garc\303\255a Samblas"]
|
9
|
-
s.date = %q{2009-11-
|
9
|
+
s.date = %q{2009-11-23}
|
10
10
|
s.description = %q{}
|
11
11
|
s.email = ["fernando.garcia@the-cocktail.com"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.2
|
4
|
+
version: 0.1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Fernando Garc\xC3\xADa Samblas"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-23 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|