abstract_command 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/abstract_command.rb +7 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3706a839f7295878c06686c9c32c6c9cdac8e40e3d02a1abd81deb68db727818
4
- data.tar.gz: efc8aae7e852219c359f6ed21ca7a6709cd2609fbff88a1714d382a85861e88a
3
+ metadata.gz: 3e45a35935e9e0126e5e93e44656311a01ac2cf3b2f20c76b1b1179f9e24c3a9
4
+ data.tar.gz: 6743344c1ab9268d159286040382b36c979955e8dd020a3e85ee710bc5fe7dbb
5
5
  SHA512:
6
- metadata.gz: 09548c7b15fe58fa50a6ee67049f5865b95c78144f620bd10c97f7dda34faaeb9665b170f9c5be66638c16437c341059648154f4cb26d141687818d4818827f2
7
- data.tar.gz: 364a7426ec492d013e705e0bcd6f7f43926de54ce8497f46cdd32c772a8c36a576d84e00ee2d371041472d62e412f668b8259e104ac26c644e9306bf07137be8
6
+ metadata.gz: b66f0431990fc522e8534f6dcd0d294f970cc0a168caddc9aabd6684d199bd1d23fd700daa4ec67c30f0c64f4c3abebac5584597e8d65a4e69703e6a9856d378
7
+ data.tar.gz: fa588040bcc5551a8d1c6aeb90f32a176fbfbfe920ef6617361d1310326d55213dcf200f281faac1a9d902f83ff1e2b11b23b35da3e23bd3ca73c99e33054d11
@@ -1,3 +1,5 @@
1
+ require 'shellwords'
2
+
1
3
  # Shell Command Abstraction.
2
4
  #
3
5
  # Hides away all the details to generate a command.
@@ -9,7 +11,10 @@
9
11
  # 1. Stadardization.
10
12
  # 2. Simplicity of code.
11
13
  # 3. Reduces smells in methods that interpolate values.
14
+ # 4. Provides an elegant way to interact shell objects.
15
+ # 5. Secure ensures that shell commands are executed safely.
12
16
  class AbstractCommand
17
+
13
18
  # '%<name>s'.scan(/(%<)(\w+)(>)/)
14
19
  # => [["%<", "name", ">"]]
15
20
  VARIABLE_REGEX = /(%<)(\w+)(>)/
@@ -40,7 +45,7 @@ class AbstractCommand
40
45
  bindings = {}
41
46
  variables.each do |variable|
42
47
  value = instance_variable_get("@#{variable}")
43
- bindings[variable.to_sym] = value
48
+ bindings[variable.to_sym] = "#{value}".shellescape
44
49
  end
45
50
  format(template % bindings)
46
51
  end
@@ -52,4 +57,5 @@ class AbstractCommand
52
57
  def backtick
53
58
  `#{to_s}`
54
59
  end
60
+
55
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstract_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuyoshi Tlacaelel