cmds 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +18 -0
- data/README.md +6 -0
- data/cmds.gemspec +1 -1
- data/lib/cmds/version.rb +1 -1
- data/spec/cmds/erb_context_spec.rb +22 -5
- data/spec/cmds/prepare_spec.rb +14 -6
- data/spec/cmds/stream_spec.rb +3 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c155b3a2266b44990db163f49efec7a59044a3b
|
4
|
+
data.tar.gz: f5fa951737f8b51a0a95aee8f49d3ec7344f3a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d879ac96441d732374252beea066e84f2a1fc771ee21cea94374266b02ea02fdb8b47d8fd4771e8aaaed77d6176fb750d8ace803584fe65ebd5469394d8575be
|
7
|
+
data.tar.gz: cf7e0c8d02f586e8353b494baaf5a0d9171236708243d694ea50a80eadf96d8f4f975bd152345d834bcb39747eaae5e94fc5981d74944f8ff6f4cd5848a1e3f2
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
Cmds
|
2
2
|
=============================================================================
|
3
3
|
|
4
|
+
[![Gem Version](http://img.shields.io/gem/v/cmds.svg)][gem]
|
5
|
+
[![Build Status](http://img.shields.io/travis/nrser/cmds.svg)][travis]
|
6
|
+
|
7
|
+
[gem]: https://rubygems.org/gems/cmds
|
8
|
+
[travis]: http://travis-ci.org/nrser/cmds
|
9
|
+
|
4
10
|
`Cmds` tries to make it easier to read, write and remember using shell commands in Ruby.
|
5
11
|
|
6
12
|
It treats generating shell the in a similar fashion to generating SQL or HTML.
|
data/cmds.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
# ----------------------------------------------------------------------------
|
29
29
|
|
30
30
|
# Mu guns
|
31
|
-
spec.add_dependency "nrser", ">= 0.2.0.pre.
|
31
|
+
spec.add_dependency "nrser", ">= 0.2.0.pre.3"
|
32
32
|
|
33
33
|
# ERB replacement with more features
|
34
34
|
#
|
data/lib/cmds/version.rb
CHANGED
@@ -11,13 +11,30 @@ describe Cmds::ERBContext do
|
|
11
11
|
BLOCK
|
12
12
|
}
|
13
13
|
|
14
|
-
def get_result tpl,
|
15
|
-
|
14
|
+
def get_result tpl, context
|
15
|
+
# NOTE This *used* to use {ERB.new}, but that stopped working in Ruby
|
16
|
+
# 2.4+ with a weird
|
17
|
+
#
|
18
|
+
# uninitialized constant Cmds::ERBContext::String
|
19
|
+
#
|
20
|
+
# message... https://travis-ci.org/nrser/cmds/jobs/347910522
|
21
|
+
#
|
22
|
+
# This doesn't matter, because we use {ERubis}, and that still works,
|
23
|
+
# so switched to that here...
|
24
|
+
#
|
25
|
+
NRSER.squish Cmds::ShellEruby.new( tpl ).result( context.get_binding )
|
16
26
|
end
|
17
27
|
|
18
28
|
it "should work" do
|
19
|
-
|
29
|
+
context = Cmds::ERBContext.new(
|
30
|
+
[],
|
31
|
+
current_host: 'xyz',
|
32
|
+
domain: 'com.nrser.blah',
|
33
|
+
filepath: '/tmp/export.plist',
|
34
|
+
)
|
20
35
|
|
21
|
-
expect(
|
36
|
+
expect(
|
37
|
+
get_result tpl, context
|
38
|
+
).to eq "defaults -currentHost xyz export com.nrser.blah /tmp/export.plist"
|
22
39
|
end
|
23
|
-
end
|
40
|
+
end
|
data/spec/cmds/prepare_spec.rb
CHANGED
@@ -221,8 +221,10 @@ describe "Cmds.prepare" do
|
|
221
221
|
context "specify :repeat behavior" do
|
222
222
|
it "outputs repeated options" do
|
223
223
|
expect(
|
224
|
-
Cmds.prepare
|
225
|
-
|
224
|
+
Cmds.prepare(
|
225
|
+
'blah <%= opts %>',
|
226
|
+
opts: { list: ['a', 'b', 'see'] }
|
227
|
+
) {
|
226
228
|
{ array_mode: :repeat }
|
227
229
|
}
|
228
230
|
).to eq 'blah --list=a --list=b --list=see'
|
@@ -232,15 +234,21 @@ describe "Cmds.prepare" do
|
|
232
234
|
context "specify :json behavior" do
|
233
235
|
it "outputs JSON-encoded options" do
|
234
236
|
expect(
|
235
|
-
Cmds.prepare
|
236
|
-
|
237
|
+
Cmds.prepare(
|
238
|
+
'blah <%= opts %>',
|
239
|
+
opts: { list: ['a', 'b', 'see'] }
|
240
|
+
) {
|
241
|
+
{ array_mode: :json }
|
242
|
+
}
|
237
243
|
).to eq %{blah --list='["a","b","see"]'}
|
238
244
|
end
|
239
245
|
|
240
246
|
it "handles single quotes in the string" do
|
241
247
|
expect(
|
242
|
-
Cmds.prepare
|
243
|
-
|
248
|
+
Cmds.prepare(
|
249
|
+
'blah <%= opts %>',
|
250
|
+
opts: { list: ["you're the best"] }
|
251
|
+
) {{ array_mode: :json }}
|
244
252
|
).to eq %{blah --list='["you'"'"'re the best"]'}
|
245
253
|
|
246
254
|
|
data/spec/cmds/stream_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe 'Cmds#stream' do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
expect(out).to match /^\s
|
44
|
+
expect(out).to match /^\s*3\n$/
|
45
45
|
expect(err).to eq ''
|
46
46
|
end
|
47
47
|
|
@@ -52,7 +52,7 @@ describe 'Cmds#stream' do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
expect(out).to match /^\s
|
55
|
+
expect(out).to match /^\s*3\n$/
|
56
56
|
end
|
57
57
|
end # input
|
58
58
|
|
@@ -66,4 +66,4 @@ describe 'Cmds#stream!' do
|
|
66
66
|
it "raises when exit code is not 0" do
|
67
67
|
expect { Cmds.new('false').stream! }.to raise_error SystemCallError
|
68
68
|
end
|
69
|
-
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nrser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.0.pre.
|
19
|
+
version: 0.2.0.pre.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.0.pre.
|
26
|
+
version: 0.2.0.pre.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: erubis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +159,7 @@ extra_rdoc_files: []
|
|
159
159
|
files:
|
160
160
|
- ".gitignore"
|
161
161
|
- ".rspec"
|
162
|
+
- ".travis.yml"
|
162
163
|
- ".yardopts"
|
163
164
|
- Gemfile
|
164
165
|
- LICENSE.txt
|