pack_rb 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: 9fa9a2e4e584f27505b9c844749b682d7ec2d735
4
- data.tar.gz: 10ca1ecf02e460a16ed096aeae8cd5bcf56dd9f1
3
+ metadata.gz: 58c2f1887fec78272487e04cded1d2ff9e60dab6
4
+ data.tar.gz: b3b8206993ae86eec8bc1f9b45f6ed97d175cd0c
5
5
  SHA512:
6
- metadata.gz: 85d6ca9698e520df0ae4a1e365fa621dcdb2884c1aa8cc25f7ff2af1e6fca45da1a239720085484bf2238c510594e3b6e147074a9f081b029890b49cfaa838b7
7
- data.tar.gz: d801cb47c6f6f96b0dfa23a378709e20ac9e910cb152709bd311e5a7ddcc7b8648518e71e61ba2009724547391ff793245f2d6116c5ae233e4720c8a8092144a
6
+ metadata.gz: e6b0e781d943eb7bfd9ee241d2f732c1e2eec42070bd626a9380f7b2e08a86c33b12f560f0949c2cf34db82c807c67254fa908887117473f803f96cf74a9a0d7
7
+ data.tar.gz: 642c0b78b67c15aa953b09b5144fbf5ad25d1aea2f7ac5fb83cb132396867fbad9f7d2e564e6c7d6a07e9ff7f0221dbf2b00fb744a4a1017d0769213e09550e3
data/README.md CHANGED
@@ -65,6 +65,16 @@ packer = PackRb::Packer.new(tpl: 'config/template.json', machine_readable: true)
65
65
  packer.build(debug: true)
66
66
  ```
67
67
 
68
+ ### Streaming Output
69
+
70
+ If you wish to have STDOUT and STDERR from the Packer command stream to the console as it runs,
71
+ you will need to enable streaming by setting ``stream_output: true``:
72
+
73
+ ```ruby
74
+ PackRb::Packer.new(tpl: 'config/template.json', machine_readable: true, stream_output: true)
75
+ packer.build(debug :true)
76
+ ```
77
+
68
78
  ## Development
69
79
 
70
80
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec pack_rb` to use the gem in this directory, ignoring other installed copies of this gem.
@@ -1,5 +1,24 @@
1
1
  require 'json'
2
2
  require 'pack_rb/sub_commands'
3
+ require 'mkmf'
4
+
5
+ # MakeMakefile::find_executable provides a built-in, native Ruby
6
+ # implementation of the Unix ``which`` command. Modify some variables
7
+ # to make it suppress writing log files or echoing.
8
+ begin
9
+ const_get 'MakeMakefile'
10
+ # this will fail with NameError on older rubies
11
+ module MakeMakefile::Logging
12
+ @logfile = File::NULL
13
+ @quiet = true
14
+ end
15
+ rescue NameError
16
+ # module on older rubies
17
+ module Logging
18
+ @logfile = File::NULL
19
+ @quiet = true
20
+ end
21
+ end
3
22
 
4
23
  module PackRb
5
24
  class Packer
@@ -7,6 +26,7 @@ module PackRb
7
26
  @machine_readable = opts[:machine_readable]
8
27
  @bin_path = opts[:bin_path]
9
28
  @tpl = opts[:tpl]
29
+ @stream_output = opts.fetch(:stream_output, false)
10
30
  end
11
31
 
12
32
  def command
@@ -18,7 +38,16 @@ module PackRb
18
38
  end
19
39
 
20
40
  def bin
21
- bin_path || 'packer'
41
+ return bin_path if bin_path
42
+ # some distros, such as Arch Linux, package the Packer
43
+ # binary as ``packer-io``
44
+ ['packer', 'packer-io'].each do |bin_name|
45
+ p = find_executable(bin_name)
46
+ return p if p
47
+ end
48
+ raise RuntimeError, "Could not find packer or packer-io binary on path." \
49
+ " Please specify the full binary path with the " \
50
+ "'bin_path' option."
22
51
  end
23
52
 
24
53
  def template
@@ -27,7 +56,7 @@ module PackRb
27
56
  end
28
57
 
29
58
  def commander
30
- @commander ||= PackRb::SubCommands.new
59
+ @commander ||= PackRb::SubCommands.new(stream_output: @stream_output)
31
60
  end
32
61
 
33
62
  def method_missing(name, *args, &block)
@@ -9,6 +9,13 @@ module PackRb
9
9
  include PackRb::SubCommands::Inspect
10
10
  include PackRb::SubCommands::Validate
11
11
 
12
+ def initialize(opts = {})
13
+ if opts[:stream_output]
14
+ STDOUT.sync = true
15
+ STDERR.sync = true
16
+ end
17
+ end
18
+
12
19
  # Execute a Packer command via {PackRb::Executor.run_cmd_stream_output}
13
20
  #
14
21
  # @param opts [Hash] options passed to the Packer class
@@ -1,3 +1,3 @@
1
1
  module PackRb
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pack_rb
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
  - Jonathan Niesen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.13'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: guard-bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
83
  description: A gem for driving the Packer command line tool from within your Ruby
@@ -88,9 +88,9 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - ".gitignore"
92
- - ".rspec"
93
- - ".travis.yml"
91
+ - .gitignore
92
+ - .rspec
93
+ - .travis.yml
94
94
  - Gemfile
95
95
  - Guardfile
96
96
  - LICENSE.txt
@@ -119,17 +119,17 @@ require_paths:
119
119
  - lib
120
120
  required_ruby_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
127
+ - - '>='
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.4.5
132
+ rubygems_version: 2.0.14
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: A Packer CLI wrapper.