caliph 0.1.2 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b5de06075953f9ad400bad3cc4332993b9bacd0
4
- data.tar.gz: 06aa83e94ac0995663cfb620b6ebdfc1ae0ad52f
3
+ metadata.gz: d4a677cfc00224f91e1cddbfd66ecf9310071deb
4
+ data.tar.gz: ba9069ed6aff7c72b2e1c5b9b40c00c694970a37
5
5
  SHA512:
6
- metadata.gz: 3d6102271b1792f2e61475a4d8fbfe90015a22285db7443c7c9fe0532bde556f514bcc4397b4e8c9c15c782171dbfdc470770e85e9282d24859c970a69395566
7
- data.tar.gz: b10807d66cff7e0660da4cc896b9cf48eff868617b4f82479a3101f81459eba831b8ed5b73ed8cdf4fe0294b0e6a0077f9aa7b543184ac3070c357a1271e1a1a
6
+ metadata.gz: 995b6ad0b4898b4f51ac2ce098a7fe92558773a63747ccb28db6d8324305ca3c43dcaaddafddc0b60843e0cb22f95c7cb154d4a8c54c10906a8291990f7e64d6
7
+ data.tar.gz: 125d12f8318ff484e2e74a67794dbf12569d66d5612fa62a8c9ccf3a800552d52ec0bf25be165fe5ff420258974789ebd7a8e19cfcb2bdf47675901bd632a667
@@ -30,6 +30,18 @@ module Caliph
30
30
  end
31
31
  end
32
32
 
33
+ def redirect_to(stream, path)
34
+ @commands.last.redirect_to(stream, path)
35
+ end
36
+
37
+ def redirect_from(path, stream)
38
+ @commands.last.redirect_from(path, stream)
39
+ end
40
+
41
+ def copy_stream_to(from, to)
42
+ @commands.last.copy_stream_to(from, to)
43
+ end
44
+
33
45
  def name
34
46
  @name || @commands.last.name
35
47
  end
@@ -1,7 +1,20 @@
1
1
  module Caliph
2
2
  module CommandLineDSL
3
+ class Watcher
4
+ attr_accessor :apex
5
+
6
+ def inspect
7
+ "Watcher@#{"%#0x" % apex.object_id}"
8
+ end
9
+ end
10
+
3
11
  def cmd(*args, &block)
4
- CommandLine.new(*args, &block)
12
+ watcher = Watcher.new
13
+ cmd = CommandLine.new(*args)
14
+ cmd.definition_watcher = watcher
15
+ watcher.apex = cmd
16
+ yield cmd if block_given?
17
+ watcher.apex
5
18
  end
6
19
 
7
20
  def escaped_command(*args, &block)
@@ -20,6 +20,7 @@ module Caliph
20
20
  end
21
21
 
22
22
  attr_accessor :name, :executable, :options, :env, :output_stream, :verbose
23
+ attr_accessor :definition_watcher
23
24
  attr_reader :redirections
24
25
 
25
26
  alias_method :command_environment, :env
@@ -59,8 +60,6 @@ module Caliph
59
60
  self
60
61
  end
61
62
 
62
- # Waits for the process to complete. If this takes longer that
63
- # {consume_timeout},
64
63
  def redirect_from(path, stream)
65
64
  @redirections << "#{stream}<#{path}"
66
65
  end
@@ -15,6 +15,10 @@ module Caliph
15
15
  chain = self
16
16
  else
17
17
  chain = klass.new
18
+ chain.definition_watcher = definition_watcher
19
+ unless definition_watcher.nil?
20
+ definition_watcher.apex = chain
21
+ end
18
22
  chain.add(self)
19
23
  end
20
24
  chain.add(other)
@@ -3,6 +3,24 @@ require 'caliph/command-line-dsl'
3
3
  describe Caliph::CommandLineDSL do
4
4
  include described_class
5
5
 
6
+ describe "complex commands in a block" do
7
+ let :command do
8
+ cmd("cd", "/tmp/trash") do |cmd|
9
+ cmd.redirect_stderr "file1"
10
+ cmd &= %w{rm -rf *}
11
+ cmd.redirect_stderr "file2"
12
+ end #=> returns whole chain
13
+ end
14
+
15
+ it "should define commands" do
16
+ expect(command).to be_a(Caliph::CommandChain)
17
+ expect(command.commands.size).to eq(2)
18
+ expect(command.commands[0]).to be_an_instance_of(Caliph::CommandLine)
19
+ expect(command.commands[1]).to be_an_instance_of(Caliph::CommandLine)
20
+ expect(command.command).to eq("cd /tmp/trash 2>file1 && rm -rf * 2>file2")
21
+ end
22
+ end
23
+
6
24
  describe "using the - operator" do
7
25
  let :command do
8
26
  cmd("sudo") - ["gem", "install", "bundler"]
@@ -33,7 +51,6 @@ describe Caliph::CommandLineDSL do
33
51
 
34
52
  describe "using the & operator" do
35
53
  let :command do
36
- p method(:cmd).source_location
37
54
  cmd("cd", "/tmp/trash") & %w{rm -rf *}
38
55
  end
39
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caliph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Dorn
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-15 00:00:00.000000000 Z
12
+ date: 2014-07-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |2
15
15
  TDD-suitable Ruby tool for generating command-line commands via an OOP interface.
@@ -101,7 +101,7 @@ rdoc_options:
101
101
  - --main
102
102
  - doc/README
103
103
  - --title
104
- - caliph-0.1.2 Documentation
104
+ - caliph-0.2.0 Documentation
105
105
  require_paths:
106
106
  - lib/
107
107
  required_ruby_version: !ruby/object:Gem::Requirement