ruby-nuggets 0.4.2 → 0.4.4

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/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.4.2
5
+ This documentation refers to ruby-nuggets version 0.4.4
6
6
 
7
7
 
8
8
  == DESCRIPTION
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ Hen.lay! {{
21
21
 
22
22
  desc "Run all examples"
23
23
  task :examples do
24
- ruby = "#{Config::CONFIG['RUBY_INSTALL_NAME']}#{Config::CONFIG['EXEEXT']}"
24
+ ruby = Config::CONFIG.values_at('RUBY_INSTALL_NAME', 'EXEEXT').join
25
25
 
26
26
  Dir['lib/nuggets/*/**/*.rb'].each { |file|
27
27
  puts ">>>>> #{file} <<<<<"
@@ -39,7 +39,7 @@ class File
39
39
 
40
40
  if path = ENV['PATH']
41
41
  path.split(PATH_SEPARATOR).each { |dir|
42
- candidate = join(dir, executable)
42
+ candidate = join(expand_path(dir), executable)
43
43
  return candidate if executable?(candidate)
44
44
  }
45
45
  end
@@ -35,7 +35,7 @@ class String
35
35
  # substitution expressions ("#{...}") that can get evaluated in a different
36
36
  # environment (= +binding+) at a later point.
37
37
  def evaluate(binding = TOPLEVEL_BINDING)
38
- eval(%Q{"#{self}"}, binding)
38
+ eval(%Q{%Q{#{self}}}, binding)
39
39
  end
40
40
 
41
41
  end
@@ -50,4 +50,6 @@ if $0 == __FILE__
50
50
  end
51
51
 
52
52
  p foo(s)
53
+
54
+ p 'a"b"c'.evaluate(binding)
53
55
  end
@@ -52,6 +52,11 @@ class String
52
52
  # Destructive version of #msub.
53
53
  def msub!(*substitutions)
54
54
  substitutions = substitutions.first if substitutions.first.is_a?(Hash)
55
+
56
+ binding = substitutions.is_a?(Hash) ? substitutions.delete(:__binding__) :
57
+ substitutions.last.is_a?(Hash) ? substitutions.pop[:__binding__] : nil
58
+ binding ||= Kernel.binding
59
+
55
60
  keys, subs, cache = [], [], {}
56
61
 
57
62
  substitutions.each { |key, value|
@@ -62,9 +67,7 @@ class String
62
67
  }
63
68
 
64
69
  gsub!(Regexp.union(*keys)) { |match|
65
- cache[match] ||= subs.find { |key, _|
66
- key =~ match
67
- }.last.evaluate(binding)
70
+ cache[match] ||= subs.find { |key, _| key =~ match }.last.evaluate(binding)
68
71
  }
69
72
  end
70
73
 
@@ -79,4 +82,12 @@ if $0 == __FILE__
79
82
 
80
83
  s.msub!('a' => 'o', 'o' => 'a')
81
84
  p s
85
+
86
+ t = '!!!'
87
+ begin
88
+ p s.msub('r' => '???', 'z' => '#{t}')
89
+ rescue NameError => err
90
+ warn err
91
+ end
92
+ p s.msub('r' => '???', 'z' => '#{t}', :__binding__ => binding)
82
93
  end
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 4
7
- TINY = 2
7
+ TINY = 4
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nuggets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-22 00:00:00 +01:00
12
+ date: 2009-01-26 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15