cmds 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cmds/erb_context.rb +11 -2
- data/lib/cmds/version.rb +1 -1
- data/spec/cmds/prepare_spec.rb +20 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60b5fda411ade202d896d087b4104e4db35c3429
|
4
|
+
data.tar.gz: 4bffbff9d0590beb514ace34ab9bf5c1728b6f81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e4a2812bce9c3614664ca89da4145e1fdf01cc4db396095a964af7f9c4a95576dd1b28e209063484aea690b97b011b6e26461dbe3646dcb5907e823615def01
|
7
|
+
data.tar.gz: 03a78326ea5c2dbd4789513cdcd3b2bf3d94b0b9e6c6b9e3391f61f644a5c155769ea024ca2cc8074998900059719444eaa7bd671ae114c7783c1edd885cd4e7
|
data/lib/cmds/erb_context.rb
CHANGED
@@ -14,10 +14,19 @@ module Cmds
|
|
14
14
|
# by returning `nil` if the value is "false-y"
|
15
15
|
@kwds[key] if @kwds[key]
|
16
16
|
else
|
17
|
-
@kwds.
|
17
|
+
if @kwds.key? sym
|
18
|
+
@kwds[sym]
|
19
|
+
elsif @kwds.key? sym.to_s
|
20
|
+
@kwds[sym.to_s]
|
21
|
+
else
|
22
|
+
::Kernel.raise ::KeyError.new ::NRSER.squish <<-END
|
23
|
+
couldn't find keys #{ sym.inspect } or #{ sym.to_s.inspect }
|
24
|
+
in keywords #{ @kwds.inspect }
|
25
|
+
END
|
26
|
+
end
|
18
27
|
end
|
19
28
|
else
|
20
|
-
super
|
29
|
+
super sym, *args, &block
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
data/lib/cmds/version.rb
CHANGED
data/spec/cmds/prepare_spec.rb
CHANGED
@@ -4,7 +4,6 @@ describe "Cmds.prepare" do
|
|
4
4
|
it "should work with a keyword substitutions" do
|
5
5
|
expect(
|
6
6
|
Cmds.prepare "psql <%= opts %> <%= database %> < <%= filepath %>",
|
7
|
-
[],
|
8
7
|
database: "blah",
|
9
8
|
filepath: "/where ever/it/is.psql",
|
10
9
|
opts: {
|
@@ -14,6 +13,26 @@ describe "Cmds.prepare" do
|
|
14
13
|
}
|
15
14
|
).to eq 'psql --host=localhost --port=12345 --username=bingo\ bob blah < /where\ ever/it/is.psql'
|
16
15
|
end
|
16
|
+
|
17
|
+
it "should work with a keyword substitutions with String keys" do
|
18
|
+
expect(
|
19
|
+
# NOTE since we use **kwds in #prepare which only accepts symbol keys,
|
20
|
+
# have to load kwds with string keys in through Cmd.new
|
21
|
+
Cmds::Cmd.new(
|
22
|
+
"psql <%= opts %> <%= database %> < <%= filepath %>", {
|
23
|
+
kwds: {
|
24
|
+
'database' => "blah",
|
25
|
+
'filepath' => "/where ever/it/is.psql",
|
26
|
+
'opts' => {
|
27
|
+
username: "bingo bob",
|
28
|
+
host: "localhost",
|
29
|
+
port: 12345,
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
).prepare
|
34
|
+
).to eq 'psql --host=localhost --port=12345 --username=bingo\ bob blah < /where\ ever/it/is.psql'
|
35
|
+
end
|
17
36
|
|
18
37
|
it "should work with positional substitutions" do
|
19
38
|
expect(
|