string-mapper 0.1.1 → 0.1.2

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 CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.1.2 2009-10-27
2
+ * 1 behaviour changed:
3
+ * Map of Regexp with captures to a Proc that receive them as an params. For
4
+ example:
5
+ my_mappings["(.+) and (.+)"] => lambda { |first, second|
6
+ "First #{first} and then #{second}" }
7
+
1
8
  == 0.1.1 2009-10-27
2
9
  * 1 major enhancement:
3
10
  * Map of Regexp with captures to a Proc that receive them as an array. For
data/lib/string-mapper.rb CHANGED
@@ -29,7 +29,7 @@ module StringMapper #:nodoc:
29
29
  class VERSION #:nodoc:
30
30
  MAJOR = 0
31
31
  MINOR = 1
32
- TINY = 1
32
+ TINY = 2
33
33
  PATCH = nil # Set to nil for official release
34
34
 
35
35
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
@@ -53,11 +53,7 @@ class String
53
53
  mapping = if value.is_a?(String)
54
54
  eval('"'+value+'"')
55
55
  elsif value.is_a?(Proc)
56
- if $~.captures.any?
57
- value.call $~.captures
58
- else
59
- value.call
60
- end
56
+ value.call *$~.captures
61
57
  else
62
58
  value
63
59
  end
@@ -51,8 +51,8 @@ describe "String.add_mapper(:target)" do
51
51
  end
52
52
 
53
53
  it 'should pass matched captures as arguments to the proc object' do
54
- String.target_mappings["(.+) new (.+)"] = lambda {|captures|
55
- "This is a #{captures[0]} new #{captures[1]}"
54
+ String.target_mappings["(.+) new (.+)"] = lambda {|adjective, thing|
55
+ "This is a #{adjective} new #{thing}"
56
56
  }
57
57
  'brand new world'.to_target.should == "This is a brand new world"
58
58
 
@@ -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.1"
5
+ s.version = "0.1.2"
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-10-27}
9
+ s.date = %q{2009-11-20}
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.1
4
+ version: 0.1.2
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-10-27 00:00:00 +01:00
12
+ date: 2009-11-20 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency