prospectus 0.3.0 → 0.4.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: c4f1bb78a5ab3c1031f9a69e7089b858e1bec9a5
4
- data.tar.gz: ab0d4015eca705a6b6a47bbb774dd84519e47d69
3
+ metadata.gz: d6a7c68d906bd417f0f089b15566e1a577b9272a
4
+ data.tar.gz: 465c39908596caefa93c39b2a3f395eb3cdbb967
5
5
  SHA512:
6
- metadata.gz: 27edc960edbdfbae7683b0dadc3597a0585ab8d2c595f8ec3832629d49e990c326d728a21be2b84aa430fa19f75eb98793cb1e0e7ba94c84a59979fcefa9c88c
7
- data.tar.gz: b6fa22f4f0556981b7e0acc576f1209f5bcb361be0c538970a0b0d744585968820cbd29662698d5b98a5af9d608cfbad7b8aed60a894088ffaf40f4c03884d9b
6
+ metadata.gz: 0e1c5e5f7a5efbfeb296f2edda70750c599ff7a8af8c1d98b45c768f22ecab52e0411f2eae2805e1352d0d7927640dc3a6c5c8728f5f2f8e8a2ff07dc50d5aea
7
+ data.tar.gz: 57e611969ca62a66ba376116bdc1e3c40047e1e52d7f413afb425950424b146b358c26927c7c4461722b649e3c398b852891f236eea4979b2d62ddbae0d31709
data/.prospectus CHANGED
@@ -1,11 +1,25 @@
1
+ Prospectus.extra_dep('file', 'prospectus_circleci')
2
+
3
+ my_slug = 'akerl/prospectus'
4
+
1
5
  item do
2
- expected do
3
- static
4
- set 'green'
5
- end
6
+ noop
6
7
 
7
- actual do
8
- gemnasium
9
- slug 'akerl/prospectus'
8
+ deps do
9
+ item do
10
+ name 'gems'
11
+
12
+ expected do
13
+ static
14
+ set 'green'
15
+ end
16
+
17
+ actual do
18
+ gemnasium
19
+ slug my_slug
20
+ end
21
+ end
10
22
  end
23
+
24
+ extend ProspectusCircleci::Build.new(my_slug)
11
25
  end
data/bin/prospectus CHANGED
@@ -3,21 +3,6 @@
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
-
13
- def load_list(params)
14
- return run_file(params) if File.exist? '.prospectus'
15
- raise('No .prospectus/.prospectus.d found') unless Dir.exist? '.prospectus.d'
16
- files = Dir.glob('.prospectus.d/*')
17
- raise('No files in .prospectus.d') if files.empty?
18
- files.map { |x| run_file(params, x) }.flatten
19
- end
20
-
21
6
  Mercenary.program(:prospectus) do |p|
22
7
  p.version Prospectus::VERSION
23
8
  p.description 'Tool and DSL for checking expected vs actual state'
@@ -34,7 +19,7 @@ Mercenary.program(:prospectus) do |p|
34
19
  p.action do |_, options|
35
20
  options[:directory] ||= '.'
36
21
  Dir.chdir(options[:directory]) do
37
- results = load_list(options)
22
+ results = Prospectus.load(options)
38
23
  unless options[:quiet]
39
24
  if options[:json]
40
25
  puts results.to_json
data/lib/prospectus.rb CHANGED
@@ -5,8 +5,6 @@ require 'logcabin'
5
5
  ##
6
6
  # Tool and DSL for checking expected vs actual state
7
7
  module Prospectus
8
- DEFAULT_FILE = './.prospectus'.freeze
9
-
10
8
  class << self
11
9
  ##
12
10
  # Insert a helper .new() method for creating a new Cache object
@@ -14,13 +12,17 @@ module Prospectus
14
12
  self::List.new(*args)
15
13
  end
16
14
 
15
+ def load(*args)
16
+ self::Loader.new(*args).load
17
+ end
18
+
17
19
  ##
18
20
  # Method for loading list from DSL
19
21
  def load_from_file(params = {})
20
- file = params[:file] || DEFAULT_FILE
22
+ file = params[:file] || raise('File path required for load_from_file')
21
23
  list = List.new(params)
22
24
  dsl = ListDSL.new(list, params)
23
- dsl.instance_eval(File.read(file), file)
25
+ dsl.instance_eval(File.read(file), File.realpath(file, Dir.pwd))
24
26
  list
25
27
  end
26
28
 
@@ -51,6 +53,7 @@ module Prospectus
51
53
  end
52
54
 
53
55
  require 'prospectus/version'
56
+ require 'prospectus/loader'
54
57
  require 'prospectus/list'
55
58
  require 'prospectus/item'
56
59
  require 'prospectus/state'
@@ -14,7 +14,7 @@ module Prospectus
14
14
  def name
15
15
  return @name if @name
16
16
  @name = File.basename Dir.pwd
17
- @name << "::#{File.basename @options[:file]}" if @options[:file]
17
+ @name << "::#{File.basename @options[:file]}" if @options[:suffix_file]
18
18
  @name
19
19
  end
20
20
 
@@ -0,0 +1,31 @@
1
+ module Prospectus
2
+ DEFAULT_FILE = './.prospectus'.freeze
3
+
4
+ ##
5
+ # Helper for loading prospectus from the current directory
6
+ class Loader
7
+ def initialize(params = {})
8
+ @options = params
9
+ @file = params[:file] || DEFAULT_FILE
10
+ @dir = @file + '.d'
11
+ end
12
+
13
+ def load
14
+ return run_file(@options, @file) if File.exist? @file
15
+ raise("No #{@file}/#{@dir} found") unless Dir.exist? @dir
16
+ files = Dir.glob(@dir + '/*')
17
+ raise('No files in ' + @dir) if files.empty?
18
+ files.map { |x| run_file(@options, x, true) }.flatten
19
+ end
20
+
21
+ private
22
+
23
+ def run_file(params, file, suffix_file = false)
24
+ options = { file: file, suffix_file: suffix_file }.merge(params)
25
+ Prospectus.load_from_file(options).check
26
+ rescue RuntimeError
27
+ puts "Failed parsing #{Dir.pwd}/#{file}"
28
+ raise
29
+ end
30
+ end
31
+ end
@@ -3,5 +3,5 @@
3
3
  ##
4
4
  # Declare package version
5
5
  module Prospectus
6
- VERSION = '0.3.0'.freeze
6
+ VERSION = '0.4.0'.freeze
7
7
  end
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.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-09 00:00:00.000000000 Z
11
+ date: 2017-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -134,6 +134,7 @@ files:
134
134
  - lib/prospectus/helpers/regex.rb
135
135
  - lib/prospectus/item.rb
136
136
  - lib/prospectus/list.rb
137
+ - lib/prospectus/loader.rb
137
138
  - lib/prospectus/modules/gemnasium.rb
138
139
  - lib/prospectus/modules/git_hash.rb
139
140
  - lib/prospectus/modules/git_tag.rb