arduino_ci 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -150,10 +150,8 @@ module ArduinoCI
150
150
  end
151
151
  end
152
152
 
153
- # run a command in a display
154
- # @return [bool]
155
- def run(*args, **kwargs)
156
- ret = false
153
+ def wrap_run(work_fn, *args, **kwargs)
154
+ ret = nil
157
155
  # do some work to extract & merge environment variables if they exist
158
156
  has_env = !args.empty? && args[0].class == Hash
159
157
  with_display do |env_vars|
@@ -161,15 +159,21 @@ module ArduinoCI
161
159
  env_vars.merge!(args[0]) if has_env
162
160
  actual_args = has_env ? args[1..-1] : args # need to shift over if we extracted args
163
161
  full_cmd = env_vars.empty? ? actual_args : [env_vars] + actual_args
164
- ret = Host.run(*full_cmd, **kwargs)
162
+ ret = work_fn.call(*full_cmd, **kwargs)
165
163
  end
166
164
  ret
167
165
  end
168
166
 
169
- # run a command in a display with no output
167
+ # run a command in a display, outputting to stdout
168
+ # @return [bool]
169
+ def run_and_output(*args, **kwargs)
170
+ wrap_run((proc { |*a, **k| Host.run_and_output(*a, **k) }), *args, **kwargs)
171
+ end
172
+
173
+ # run a command in a display, capturing output
170
174
  # @return [bool]
171
- def run_silent(*args)
172
- run(*args, out: File::NULL, err: File::NULL)
175
+ def run_and_capture(*args, **kwargs)
176
+ wrap_run((proc { |*a, **k| Host.run_and_capture(*a, **k) }), *args, **kwargs)
173
177
  end
174
178
 
175
179
  # @return [Hash] the environment variables for the display
@@ -1,4 +1,5 @@
1
1
  require 'os'
2
+ require 'open3'
2
3
 
3
4
  module ArduinoCI
4
5
 
@@ -20,8 +21,12 @@ module ArduinoCI
20
21
  nil
21
22
  end
22
23
 
23
- # run a command in a display
24
- def self.run(*args, **kwargs)
24
+ def self.run_and_capture(*args, **kwargs)
25
+ stdout, stderr, status = Open3.capture3(*args, **kwargs)
26
+ { out: stdout, err: stderr, success: status.exitstatus.zero? }
27
+ end
28
+
29
+ def self.run_and_output(*args, **kwargs)
25
30
  system(*args, **kwargs)
26
31
  end
27
32
 
@@ -1,3 +1,3 @@
1
1
  module ArduinoCI
2
- VERSION = "0.1.5".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Katz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-05 00:00:00.000000000 Z
11
+ date: 2018-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -103,6 +103,7 @@ files:
103
103
  - cpp/arduino/Stream.h
104
104
  - cpp/arduino/WCharacter.h
105
105
  - cpp/arduino/WString.h
106
+ - cpp/arduino/WString.h.orig
106
107
  - cpp/arduino/avr/README.md
107
108
  - cpp/arduino/avr/common.h
108
109
  - cpp/arduino/avr/fuse.h
@@ -375,6 +376,7 @@ files:
375
376
  - cpp/arduino/avr/iox8e5.h
376
377
  - cpp/arduino/avr/lock.h
377
378
  - cpp/arduino/avr/pgmspace.h
379
+ - cpp/arduino/avr/pgmspace.h.orig
378
380
  - cpp/arduino/avr/portpins.h
379
381
  - cpp/arduino/avr/version.h
380
382
  - cpp/arduino/avr/xmega.h
@@ -397,6 +399,7 @@ files:
397
399
  - lib/arduino_ci/arduino_installation.rb
398
400
  - lib/arduino_ci/ci_config.rb
399
401
  - lib/arduino_ci/cpp_library.rb
402
+ - lib/arduino_ci/cpp_library.rb.orig
400
403
  - lib/arduino_ci/display_manager.rb
401
404
  - lib/arduino_ci/host.rb
402
405
  - lib/arduino_ci/version.rb