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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d08e416bc459776d37657d008c179166f451c196
4
- data.tar.gz: 4e74d4eef712368c163114a5f10871820dff7125
3
+ metadata.gz: 60b5fda411ade202d896d087b4104e4db35c3429
4
+ data.tar.gz: 4bffbff9d0590beb514ace34ab9bf5c1728b6f81
5
5
  SHA512:
6
- metadata.gz: 347c9989f03c843dec1db86153e2850be3c404879dd08cd68eca284433773609d24442cb0001939f49fdc6bdac2bee531cddb31bee4cdbdb307b0f728cab6f10
7
- data.tar.gz: 5e235a6b41d0956cfd3bed4c56425a70a65abbe1163ffff02d14b922c234c25100a37100977b2567d1a1e797ac5a1fde32c368a32ce8a5206dee343ce8980c81
6
+ metadata.gz: 0e4a2812bce9c3614664ca89da4145e1fdf01cc4db396095a964af7f9c4a95576dd1b28e209063484aea690b97b011b6e26461dbe3646dcb5907e823615def01
7
+ data.tar.gz: 03a78326ea5c2dbd4789513cdcd3b2bf3d94b0b9e6c6b9e3391f61f644a5c155769ea024ca2cc8074998900059719444eaa7bd671ae114c7783c1edd885cd4e7
@@ -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.fetch sym
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
@@ -1,3 +1,3 @@
1
1
  module Cmds
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser