console-mux 2.0.2 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,7 +58,7 @@ module Console
58
58
  end
59
59
 
60
60
  def self.run(options)
61
- Console.new(options)
61
+ Console.new(options).startup
62
62
  end
63
63
  end
64
- end
64
+ end
@@ -74,6 +74,10 @@ module Console
74
74
  # `[new_command, new_opts]`.
75
75
  def initialize(opts)
76
76
  @opts = opts.dup
77
+ # one-level-deep dup, required to properly dup :env, possibly others
78
+ opts.each do |k,v|
79
+ @opts[k] = v.dup if v.kind_of?(Hash)
80
+ end
77
81
 
78
82
  self.env ||= {}
79
83
  self.run_with ||= []
@@ -131,4 +135,4 @@ module Console
131
135
  end
132
136
  end
133
137
  end
134
- end
138
+ end
@@ -40,9 +40,10 @@ module Console
40
40
 
41
41
  BUFFER_LINES = 10000
42
42
 
43
- attr_reader :commands, :default_options, :formatter, :buffer, :logger
43
+ attr_reader :commands, :options, :default_options, :formatter, :buffer, :logger
44
44
 
45
45
  def initialize(options={})
46
+ @options = options
46
47
  @commands = CommandSet.new
47
48
  @default_options = Hash.new
48
49
  @base_dir = '.'
@@ -58,7 +59,9 @@ module Console
58
59
  BUFFER_LINES,
59
60
  :formatter => formatter)
60
61
  logger.add @buffer
62
+ end
61
63
 
64
+ def startup
62
65
  EventMachine.run do
63
66
  logger.info { 'Initializing' }
64
67
 
@@ -149,16 +152,20 @@ module Console
149
152
  # {:command => 'ls'})
150
153
  #
151
154
  # @param [Hash] *opts one or more option hashes passed to +Command.new+.
152
- def run(*optses)
153
- names = optses.map do |opts|
155
+ def run(*opts_hashes)
156
+ names = add(*opts_hashes).compact
157
+ seq_names(names)
158
+ end
159
+
160
+ # Like #run, but does not start any processes.
161
+ def add(*opts_hashes)
162
+ opts_hashes.map do |opts|
154
163
  if opts.kind_of? Array
155
164
  opts.map { |o| make_command_and_add(o) }
156
165
  else
157
166
  make_command_and_add(opts)
158
167
  end
159
168
  end
160
-
161
- seq_names(names.compact)
162
169
  end
163
170
 
164
171
  def make_command(opts)
@@ -188,6 +195,13 @@ module Console
188
195
  end
189
196
  private :make_command_and_add
190
197
 
198
+ # Run a sequence of names where each name is the name of a
199
+ # process that may be started. Each process identified by
200
+ # +names+ will be started, and only after it exits will the
201
+ # remaining processes be started.
202
+ #
203
+ # Each element of +names+ may be a single name or an array of
204
+ # names, in which case all are started in parallel.
191
205
  def seq_names(names)
192
206
  return unless names.size > 0
193
207
 
@@ -285,4 +299,4 @@ module Console
285
299
  end
286
300
  end
287
301
  end
288
- end
302
+ end
@@ -71,4 +71,4 @@ module Console
71
71
  end
72
72
  end
73
73
  end
74
- end
74
+ end
@@ -62,6 +62,7 @@ module Console
62
62
  :status,
63
63
  :lastlog,
64
64
  :run,
65
+ :add,
65
66
  :start,
66
67
  :stop,
67
68
  :restart,
@@ -82,4 +83,4 @@ module Console
82
83
  end
83
84
  end
84
85
  end
85
- end
86
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console-mux
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-21 00:00:00.000000000 Z
12
+ date: 2013-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -99,21 +99,21 @@ executables:
99
99
  extensions: []
100
100
  extra_rdoc_files: []
101
101
  files:
102
- - lib/console/mux/events.rb
103
- - lib/console/mux/console.rb
104
- - lib/console/mux/pty_handler.rb
105
- - lib/console/mux/command.rb
106
- - lib/console/mux/rolling_array.rb
107
- - lib/console/mux/env_with_merged.rb
108
102
  - lib/console/mux/buffer_outputter.rb
109
- - lib/console/mux/console_outputter.rb
103
+ - lib/console/mux/color_formatter.rb
104
+ - lib/console/mux/command.rb
110
105
  - lib/console/mux/command_set.rb
111
- - lib/console/mux/util.rb
112
- - lib/console/mux/run_with.rb
106
+ - lib/console/mux/console.rb
107
+ - lib/console/mux/console_outputter.rb
108
+ - lib/console/mux/env_with_merged.rb
109
+ - lib/console/mux/events.rb
113
110
  - lib/console/mux/object_compose.rb
114
111
  - lib/console/mux/process.rb
115
- - lib/console/mux/color_formatter.rb
112
+ - lib/console/mux/pty_handler.rb
113
+ - lib/console/mux/rolling_array.rb
114
+ - lib/console/mux/run_with.rb
116
115
  - lib/console/mux/shell.rb
116
+ - lib/console/mux/util.rb
117
117
  - lib/console/mux.rb
118
118
  - lib/console/mux/bundle_exec.sh
119
119
  - bin/console-mux
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: 2589698380893334747
134
+ hash: -1687027767931669956
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  none: false
137
137
  requirements:
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: 2589698380893334747
143
+ hash: -1687027767931669956
144
144
  requirements: []
145
145
  rubyforge_project:
146
146
  rubygems_version: 1.8.23