rufus-dollar 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +5 -0
- data/Rakefile +1 -1
- data/lib/rufus/dollar.rb +10 -2
- data/spec/dollar_spec.rb +14 -2
- metadata +53 -53
data/CHANGELOG.txt
CHANGED
data/Rakefile
CHANGED
data/lib/rufus/dollar.rb
CHANGED
@@ -36,7 +36,7 @@ module Rufus
|
|
36
36
|
|
37
37
|
module Dollar
|
38
38
|
|
39
|
-
VERSION = '1.0.
|
39
|
+
VERSION = '1.0.4'
|
40
40
|
|
41
41
|
# Performs 'dollar substitution' on a piece of text with a given
|
42
42
|
# dictionary.
|
@@ -92,7 +92,15 @@ module Rufus
|
|
92
92
|
end
|
93
93
|
|
94
94
|
value = dict[key]
|
95
|
-
|
95
|
+
|
96
|
+
value = if value.nil?
|
97
|
+
''
|
98
|
+
elsif value.is_a?(String)
|
99
|
+
value
|
100
|
+
else
|
101
|
+
value.inspect
|
102
|
+
end
|
103
|
+
|
96
104
|
value = value.inspect if quote
|
97
105
|
|
98
106
|
pre = (i > 0) ? text[0..i-1] : ''
|
data/spec/dollar_spec.rb
CHANGED
@@ -17,7 +17,9 @@ describe Rufus::Dollar do
|
|
17
17
|
'renard' => 'goupil',
|
18
18
|
'cane' => 'oie',
|
19
19
|
'oie blanche' => 'poule',
|
20
|
-
'x' => 'y'
|
20
|
+
'x' => 'y',
|
21
|
+
'customers' => %w[ alice bob ],
|
22
|
+
'table' => { 2011 => 2, 2012 => 7 }
|
21
23
|
}
|
22
24
|
end
|
23
25
|
|
@@ -63,6 +65,16 @@ describe Rufus::Dollar do
|
|
63
65
|
|
64
66
|
dsub("le petit ${chien} suisse").should == "le petit suisse"
|
65
67
|
end
|
68
|
+
|
69
|
+
it "'inspects' arrays" do
|
70
|
+
|
71
|
+
dsub("the ${customers}").should == 'the ["alice", "bob"]'
|
72
|
+
end
|
73
|
+
|
74
|
+
it "'inspects' hashes" do
|
75
|
+
|
76
|
+
dsub("${table}").should == '{2011=>2, 2012=>7}'
|
77
|
+
end
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
@@ -97,7 +109,7 @@ describe Rufus::Dollar do
|
|
97
109
|
|
98
110
|
let(:dict) do
|
99
111
|
{
|
100
|
-
'renard' => 'goupil'
|
112
|
+
'renard' => 'goupil'
|
101
113
|
}
|
102
114
|
end
|
103
115
|
|
metadata
CHANGED
@@ -3,49 +3,49 @@ name: rufus-dollar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
version: 1.0.
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
version: 1.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
-
|
12
|
+
- John Mettraux
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-24 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rspec
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 2
|
41
|
+
- 0
|
42
|
+
version: "2.0"
|
43
|
+
type: :development
|
44
|
+
version_requirements: *id002
|
45
45
|
description: "\n\
|
46
46
|
${xxx} substitutions\n "
|
47
47
|
email:
|
48
|
-
|
48
|
+
- jmettraux@gmail.com
|
49
49
|
executables: []
|
50
50
|
|
51
51
|
extensions: []
|
@@ -53,16 +53,16 @@ extensions: []
|
|
53
53
|
extra_rdoc_files: []
|
54
54
|
|
55
55
|
files:
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
- Rakefile
|
57
|
+
- lib/rufus/dollar.rb
|
58
|
+
- lib/rufus-dollar.rb
|
59
|
+
- spec/dollar_spec.rb
|
60
|
+
- spec/spec_base.rb
|
61
|
+
- spec/support/dollar_helper.rb
|
62
|
+
- rufus-dollar.gemspec
|
63
|
+
- CHANGELOG.txt
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.txt
|
66
66
|
has_rdoc: true
|
67
67
|
homepage: http://rufus.rubyforge.org
|
68
68
|
licenses: []
|
@@ -71,21 +71,21 @@ post_install_message:
|
|
71
71
|
rdoc_options: []
|
72
72
|
|
73
73
|
require_paths:
|
74
|
-
|
74
|
+
- lib
|
75
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
89
|
requirements: []
|
90
90
|
|
91
91
|
rubyforge_project: rufus
|