wdd-ruby-ext 0.2.2 → 0.2.3
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/Gemfile +1 -0
- data/Gemfile.lock +13 -0
- data/VERSION +1 -1
- data/lib/wdd-ruby-ext/string.rb +3 -5
- data/wdd-ruby-ext.gemspec +3 -1
- metadata +5 -3
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gem 'wdd-ruby-ext', :path=>"."
|
data/Gemfile.lock
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/lib/wdd-ruby-ext/string.rb
CHANGED
@@ -51,14 +51,12 @@ class String
|
|
51
51
|
# >> "this is that".mgpsub( [ [/(that)/, 'really $1!'], [/this/, 'that'] ] )
|
52
52
|
# => that is really that!"
|
53
53
|
#
|
54
|
-
def mgpsub(
|
54
|
+
def mgpsub(key_value_pairs=[].freeze)
|
55
55
|
regexp_fragments = key_value_pairs.collect { |k,v| k }
|
56
|
-
|
56
|
+
gsub(Regexp.union(*regexp_fragments)) do |match|
|
57
57
|
replacement_term = key_value_pairs.detect{|k,v| k=~match}[1]
|
58
|
-
vars =
|
58
|
+
vars = ["$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$`", "$&", "$'"]
|
59
59
|
vars.each do |var|
|
60
|
-
tm_safe_log var
|
61
|
-
tm_safe_log eval(var)||''
|
62
60
|
replacement_term.gsub!( Regexp.compile("\\"+var), eval(var)||'' )
|
63
61
|
end
|
64
62
|
replacement_term
|
data/wdd-ruby-ext.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wdd-ruby-ext}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["shock"]
|
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
22
24
|
"LICENSE",
|
23
25
|
"README.rdoc",
|
24
26
|
"Rakefile",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wdd-ruby-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- shock
|
@@ -46,6 +46,8 @@ extra_rdoc_files:
|
|
46
46
|
files:
|
47
47
|
- .document
|
48
48
|
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
49
51
|
- LICENSE
|
50
52
|
- README.rdoc
|
51
53
|
- Rakefile
|