prospectus 0.0.6 → 0.0.8

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: 16466b7521140177eec3581756cc3b92b6e07f53
4
- data.tar.gz: b8046e6ac337e4f0170164b154cfbb58818c3b12
3
+ metadata.gz: 6a83caa1e8c5df11f5a75a0504dd2ee30bff50b1
4
+ data.tar.gz: a8f7968847301c55278e5166c83ba2ccce6d41cb
5
5
  SHA512:
6
- metadata.gz: 4a143cbe9d1dd69249004647139c2b8aad22e457f090556e253f9e62c99d777700f60b4ab553614d7a0f73d4d162a4a8cfc03ee615e8ba37ddac813d55072af0
7
- data.tar.gz: 67e8d2ab89810914376aaea950addf7dc1ccc65730bdad3397aafe2adc53c0eb93b78f84dc8a2b0996a0ab46d7559c55b38549ee2ca39b21c3edfc5db00dab05
6
+ metadata.gz: 4335beb6154e75c29497c1926c32f21e12828f88710513e60d3be891c24707ef5b4199b4f1d3d3b02687cdc2fd55de0783e618c608f9d32d69b7b09efee2cfbf
7
+ data.tar.gz: 0143bab868fe7240835782fbfb8358107cde332afcd20c639584f866bbbd586dccaf439f0af75e6a2d35619011f3e32ffd57f8a31615466616ffa00839d0d5c3
data/README.md CHANGED
@@ -39,6 +39,10 @@ The expected/actual blocks first define the module to be used, and then define a
39
39
 
40
40
  To run the check, just run `prospectus` in the directory with the .prospectus file, or use `prospectus -d /path/to/directory`.
41
41
 
42
+ ### Parsing output
43
+
44
+ If you're looking to parse the output with something else, consider using -j to get JSON output.
45
+
42
46
  ## Included Modules
43
47
 
44
48
  The following modules are included with Prospectus.
data/bin/prospectus CHANGED
@@ -3,15 +3,19 @@
3
3
  require 'prospectus'
4
4
  require 'mercenary'
5
5
 
6
+ def run_file(params, file = nil)
7
+ Prospectus.load_from_file({ file: file }.merge(params)).check
8
+ rescue RuntimeError
9
+ puts "Failed parsing #{Dir.pwd}/#{file}"
10
+ raise
11
+ end
12
+
6
13
  def load_list(params)
7
- return Prospectus.load_from_file(params).check if File.exist? '.prospectus'
14
+ return run_file(params) if File.exist? '.prospectus'
8
15
  fail('No .prospectus/.prospectus.d found') unless Dir.exist? '.prospectus.d'
9
16
  files = Dir.glob('.prospectus.d/*')
10
17
  fail('No files in .prospectus.d') if files.empty?
11
- results = files.map do |x|
12
- Prospectus.load_from_file({ file: x }.merge(params)).check
13
- end
14
- results.flatten
18
+ files.map { |x| run_file(params, x) }.flatten
15
19
  end
16
20
 
17
21
  Mercenary.program(:prospectus) do |p|
@@ -23,14 +27,17 @@ Mercenary.program(:prospectus) do |p|
23
27
  p.option :directory, '-d DIR', '--directory DIR', 'Change to directory before loading'
24
28
  p.option :good_only, '-g', '--good', 'Show only items with good state'
25
29
  p.option :all, '-a', '--all', 'Show all items'
30
+ p.option :json, '-j', '--json', 'Output results as json'
26
31
  # rubocop:enable Metrics/LineLength
27
32
 
28
33
  p.action do |_, options|
29
34
  options[:directory] ||= '.'
30
35
  Dir.chdir(options[:directory]) do
31
36
  results = load_list(options)
32
- results.each do |x|
33
- puts "#{x.name}: #{x.actual} / #{x.expected}"
37
+ if options[:json]
38
+ puts results.to_json
39
+ else
40
+ results.each { |x| puts "#{x.name}: #{x.actual} / #{x.expected}" }
34
41
  end
35
42
  end
36
43
  end
data/lib/prospectus.rb CHANGED
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  require 'logcabin'
2
3
 
3
4
  ##
4
5
  # Tool and DSL for checking expected vs actual state
5
6
  module Prospectus
6
- DEFAULT_FILE = './.prospectus'
7
+ DEFAULT_FILE = './.prospectus'.freeze
7
8
 
8
9
  class << self
9
10
  ##
@@ -3,9 +3,9 @@ module LogCabin
3
3
  ##
4
4
  # Change directory before running module
5
5
  module Chdir
6
- def chdir_helper(&block)
6
+ def chdir_helper
7
7
  @dir ||= '.'
8
- Dir.chdir(@dir) { block.call }
8
+ Dir.chdir(@dir) { yield }
9
9
  end
10
10
 
11
11
  private
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Prospectus
2
4
  ##
3
5
  # Define item objects that defined expected vs actual state
@@ -23,6 +25,10 @@ module Prospectus
23
25
  def actual
24
26
  @actual || fail("No actual state was loaded for #{name}")
25
27
  end
28
+
29
+ def to_json(_ = {})
30
+ { name: name, expected: expected, actual: actual }.to_json
31
+ end
26
32
  end
27
33
 
28
34
  ##
@@ -1,5 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # Declare package version
3
4
  module Prospectus
4
- VERSION = '0.0.6'
5
+ VERSION = '0.0.8'.freeze
5
6
  end
data/prospectus.gemspec CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'mercenary', '~> 0.3.4'
21
21
  s.add_dependency 'logcabin', '~> 0.0.1'
22
22
 
23
- s.add_development_dependency 'rubocop', '~> 0.35.0'
24
- s.add_development_dependency 'rake', '~> 10.4.0'
23
+ s.add_development_dependency 'rubocop', '~> 0.36.0'
24
+ s.add_development_dependency 'rake', '~> 10.5.0'
25
25
  s.add_development_dependency 'codecov', '~> 0.1.1'
26
26
  s.add_development_dependency 'rspec', '~> 3.4.0'
27
27
  s.add_development_dependency 'fuubar', '~> 2.0.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prospectus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-30 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.35.0
47
+ version: 0.36.0
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
- version: 0.35.0
54
+ version: 0.36.0
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
- version: 10.4.0
61
+ version: 10.5.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
- version: 10.4.0
68
+ version: 10.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: codecov
71
71
  requirement: !ruby/object:Gem::Requirement