caliph 0.2.0 → 0.3.0

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: d4a677cfc00224f91e1cddbfd66ecf9310071deb
4
- data.tar.gz: ba9069ed6aff7c72b2e1c5b9b40c00c694970a37
3
+ metadata.gz: 8bc37eb0ffecf0d003a9144cf99d8f9a1c939615
4
+ data.tar.gz: a01552b706ec5dd873175abe5d299716312bdcbc
5
5
  SHA512:
6
- metadata.gz: 995b6ad0b4898b4f51ac2ce098a7fe92558773a63747ccb28db6d8324305ca3c43dcaaddafddc0b60843e0cb22f95c7cb154d4a8c54c10906a8291990f7e64d6
7
- data.tar.gz: 125d12f8318ff484e2e74a67794dbf12569d66d5612fa62a8c9ccf3a800552d52ec0bf25be165fe5ff420258974789ebd7a8e19cfcb2bdf47675901bd632a667
6
+ metadata.gz: 69b432bb2de573c7694ec6191afbf3ec103bf3cfa027e9022cec0c2e9a201774081819e5a1c5d6bf1e774ce88fe08b364bce6418f4dc01a95466071f21e6a6fe
7
+ data.tar.gz: 72c5668ae540aee64b20db9eb55fcc7c19ed98ae9e96bb0938e83ae60f40bb390b8c307405058de795964a4a64e7543cd40084387c3127931441b53c290f4155
@@ -1,20 +1,12 @@
1
+ require 'caliph/describer'
1
2
  module Caliph
2
3
  module CommandLineDSL
3
- class Watcher
4
- attr_accessor :apex
5
-
6
- def inspect
7
- "Watcher@#{"%#0x" % apex.object_id}"
8
- end
9
- end
10
-
11
4
  def cmd(*args, &block)
12
- watcher = Watcher.new
13
5
  cmd = CommandLine.new(*args)
14
- cmd.definition_watcher = watcher
15
- watcher.apex = cmd
16
- yield cmd if block_given?
17
- watcher.apex
6
+ if block_given?
7
+ cmd = Describer.new(cmd).describe(&block)
8
+ end
9
+ return cmd
18
10
  end
19
11
 
20
12
  def escaped_command(*args, &block)
@@ -9,10 +9,9 @@ module Caliph
9
9
  attr_accessor :output_stream
10
10
  end
11
11
 
12
- def initialize(executable = nil, *options)
12
+ def initialize(*args)
13
13
  @output_stream = self.class.output_stream || $stderr
14
- @executable = executable.to_s unless executable.nil?
15
- @options = options
14
+ from(*args)
16
15
  @redirections = []
17
16
  @env = {}
18
17
  @verbose = false
@@ -25,6 +24,11 @@ module Caliph
25
24
 
26
25
  alias_method :command_environment, :env
27
26
 
27
+ def from(executable = nil, *options)
28
+ @executable = executable.to_s unless executable.nil?
29
+ @options = options
30
+ end
31
+
28
32
  def valid?
29
33
  !@executable.nil?
30
34
  end
@@ -0,0 +1,19 @@
1
+ module Caliph
2
+ class Describer
3
+ attr_accessor :apex
4
+
5
+ def initialize(apex)
6
+ @apex = apex
7
+ end
8
+
9
+ def describe(&block)
10
+ apex.definition_watcher = self
11
+ yield apex
12
+ return apex
13
+ end
14
+
15
+ def inspect
16
+ "Watcher@#{"%#0x" % apex.object_id}"
17
+ end
18
+ end
19
+ end
data/lib/caliph/shell.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'caliph/describer'
2
+
1
3
  module Caliph
2
4
  class Error < StandardError; end
3
5
  class IncompleteCommand < Error; end
@@ -49,7 +51,9 @@ module Caliph
49
51
  else
50
52
  command_line = args.first
51
53
  end
52
- yield command_line if block_given?
54
+ if block_given?
55
+ command_line = Describer.new(command_line).describe(&block)
56
+ end
53
57
  #raise InvalidCommand, "not a command line: #{command_line.inspect}"
54
58
  #unless command_line.is_a? CommandLine
55
59
  raise IncompleteCommand, "cannot run #{command_line}" unless command_line.valid?
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Dorn
@@ -53,6 +53,7 @@ files:
53
53
  - lib/caliph/command-line.rb
54
54
  - lib/caliph/command-run-result.rb
55
55
  - lib/caliph/define-op.rb
56
+ - lib/caliph/describer.rb
56
57
  - lib/caliph/shell-escaped.rb
57
58
  - lib/caliph/testing/mock-command-line.rb
58
59
  - lib/caliph/testing/record-commands.rb
@@ -101,7 +102,7 @@ rdoc_options:
101
102
  - --main
102
103
  - doc/README
103
104
  - --title
104
- - caliph-0.2.0 Documentation
105
+ - caliph-0.3.0 Documentation
105
106
  require_paths:
106
107
  - lib/
107
108
  required_ruby_version: !ruby/object:Gem::Requirement