text-interpolator 1.0.1 → 1.0.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.
- checksums.yaml +8 -8
- data/CHANGES +4 -0
- data/lib/text_interpolator/text_interpolator.rb +14 -13
- data/lib/text_interpolator/version.rb +1 -1
- data/spec/text_interpolator_spec.rb +0 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDk5ZDBkYjAxZTRmNjAzNmY5NjgxNDI0Njc4Y2FhYjM0YTJkZDIzNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGZiNWZiNTExMjBjNWVhMGU3NTczNjYzZGMzZjk2YzgxMWQyMzMwYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTkyYmY5NmM0NmQ2NTQ3NDU5ZTRkZDFkOTM1ODg2MDA4MTIxNmJhNjM4NWEx
|
10
|
+
Njg5NWM1OWY4OTI0MzE1YTcwMTE2ZWQwMzc4NzUyOTBmNGUzZThkMjMxZjQ3
|
11
|
+
NzM2MGRkOTQ3YzI5YmY0NDZjNWNkYzBlZDFkODMyOGE1MDc0NzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmZkNGE5ZGU4Yjg4OWEwZmZlNTYwODg2MDUzMjQ1MzVkNGUwZDFjNTYzYWJj
|
14
|
+
N2Q5MGMyYWU5ZTU0YmQ5OWRhMzExODJkYjIwMzVhMjRhMGE3MDE0Y2Q2N2Yy
|
15
|
+
MWFkNzU3YWNiZmQ3ZmRlMjQwZWM5ZjAxNmJjZDFkN2RmY2Q3NzQ=
|
data/CHANGES
CHANGED
@@ -13,11 +13,9 @@ class TextInterpolator
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def interpolate_string string, env={}
|
16
|
-
|
16
|
+
new_string = replace_special_symbols(string)
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
StringIO.new(string).read % env
|
18
|
+
StringIO.new(new_string).read % env
|
21
19
|
end
|
22
20
|
|
23
21
|
def interpolate_io io, env={}
|
@@ -32,22 +30,16 @@ class TextInterpolator
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def interpolate_hash hash
|
35
|
-
|
33
|
+
env = hash.reduce({}) do |result, value|
|
36
34
|
result[value[0]] = value[1]
|
37
35
|
|
38
36
|
result
|
39
37
|
end
|
40
38
|
|
41
39
|
hash.each do |key, value|
|
42
|
-
|
43
|
-
|
44
|
-
hash[key] = StringIO.new(value).read % pairs
|
45
|
-
end
|
46
|
-
|
47
|
-
hash.each do |key, value|
|
48
|
-
new_value = interpolate_env_vars value
|
40
|
+
new_value = replace_special_symbols(value)
|
49
41
|
|
50
|
-
hash[key] = new_value
|
42
|
+
hash[key] = StringIO.new(new_value).read % env
|
51
43
|
end
|
52
44
|
|
53
45
|
hash
|
@@ -55,6 +47,15 @@ class TextInterpolator
|
|
55
47
|
|
56
48
|
private
|
57
49
|
|
50
|
+
def replace_special_symbols string
|
51
|
+
new_string = string
|
52
|
+
|
53
|
+
new_string = new_string.gsub(/\#{/, '%{') if new_string.index(/\#\{/)
|
54
|
+
new_string = interpolate_env_vars(new_string) if new_string.index('ENV[')
|
55
|
+
|
56
|
+
new_string
|
57
|
+
end
|
58
|
+
|
58
59
|
def interpolate_env_vars value
|
59
60
|
while value.index('ENV[')
|
60
61
|
value = interpolate_env_var value
|
@@ -75,15 +75,5 @@ describe TextInterpolator do
|
|
75
75
|
expect(result[:dest_dir]).to eq '/usr/local/oracle/instantclient_11_2'
|
76
76
|
expect(result[:basic_zip]).to eq 'downloads/instantclient-basic-macos.x64-11.2.0.4.0.zip'
|
77
77
|
end
|
78
|
-
|
79
|
-
it "test" do
|
80
|
-
env = {:host=>"localhost", :user=>"ashvets", :home=>"/Users/ashvets", :ruby_home=>"/Users/ashvets/.rvm/rubies/ruby-1.9.3-p545", :oracle_base=>"/usr/local/oracle", :oracle_version=>"11.2.0.4.0", :ruby_oci_version=>"2.1.7", :tns_admin_dir=>"/usr/local/oracle/network/admin", :src_dir=>"downloads", :dest_dir=>"/usr/local/oracle/instantclient_11_2", :basic_zip=>"downloads/instantclient-basic-macos.x64-11.2.0.4.0.zip", :sdk_zip=>"downloads/instantclient-sdk-macos.x64-11.2.0.4.0.zip", :sqlplus_zip=>"downloads/instantclient-sqlplus-macos.x64-11.2.0.4.0.zip"}
|
81
|
-
|
82
|
-
s = "\necho \"Installing ruby-oci8 gem...\"\n\nORACLE_BASE=\"%{oracle_base}\"\nDYLD_LIBRARY_PATH=\"%{dest_dir}\"\nTNS_ADMIN=\"%{tns_admin_dir}\"\nNLS_LANG='.UTF8'\n\nENV_VARS=\"ORACLE_BASE=$ORACLE_BASE DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH TNS_ADMIN=$TNS_ADMIN NLS_LANG=$NLS_LANG\"\n\n%env $ENV_VARS bash -c 'gem install ruby-oci8 -v %{ruby_oci_version}'\n\n\n"
|
83
|
-
|
84
|
-
result = subject.interpolate s, env
|
85
|
-
|
86
|
-
p result
|
87
|
-
end
|
88
78
|
end
|
89
79
|
end
|