prospectus 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.prospectus +11 -0
- data/README.md +41 -0
- data/bin/prospectus +13 -1
- data/lib/prospectus.rb +2 -2
- data/lib/prospectus/item.rb +5 -5
- data/lib/prospectus/modules/github_hash.rb +33 -0
- data/lib/prospectus/modules/homebrew_cask.rb +24 -0
- data/lib/prospectus/modules/homebrew_formula.rb +24 -0
- data/lib/prospectus/state.rb +8 -0
- data/lib/prospectus/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16466b7521140177eec3581756cc3b92b6e07f53
|
4
|
+
data.tar.gz: b8046e6ac337e4f0170164b154cfbb58818c3b12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a143cbe9d1dd69249004647139c2b8aad22e457f090556e253f9e62c99d777700f60b4ab553614d7a0f73d4d162a4a8cfc03ee615e8ba37ddac813d55072af0
|
7
|
+
data.tar.gz: 67e8d2ab89810914376aaea950addf7dc1ccc65730bdad3397aafe2adc53c0eb93b78f84dc8a2b0996a0ab46d7559c55b38549ee2ca39b21c3edfc5db00dab05
|
data/.prospectus
ADDED
data/README.md
CHANGED
@@ -117,6 +117,47 @@ expected do
|
|
117
117
|
end
|
118
118
|
```
|
119
119
|
|
120
|
+
### github_hash
|
121
|
+
|
122
|
+
This checks the latest commit hash on GitHub. Uses the github_api helper, which requires octoauth. Designed to be used alongside the git_hash module for comparing local submodules with upstream commits.
|
123
|
+
|
124
|
+
Will give the 7 character short hash unless "long" is specified.
|
125
|
+
|
126
|
+
```
|
127
|
+
expected do
|
128
|
+
github_hash
|
129
|
+
repo 'akerl/keys'
|
130
|
+
end
|
131
|
+
|
132
|
+
expected do
|
133
|
+
github_hash
|
134
|
+
repo 'akerl/keys'
|
135
|
+
long
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
139
|
+
### homebrew_formula
|
140
|
+
|
141
|
+
Checks a Formula file for the current version. This uses the grep module, and expects the formula to be in ./Formula/$NAME.rb.
|
142
|
+
|
143
|
+
```
|
144
|
+
actual do
|
145
|
+
homebrew_formula
|
146
|
+
name 'openssh'
|
147
|
+
end
|
148
|
+
```
|
149
|
+
|
150
|
+
### homebrew_cask
|
151
|
+
|
152
|
+
Checks a Cask file for the current version. This uses the grep module, and expects the cask to be in ./Casks/$NAME.rb.
|
153
|
+
|
154
|
+
```
|
155
|
+
actual do
|
156
|
+
homebrew_cask
|
157
|
+
name 'alfred'
|
158
|
+
end
|
159
|
+
```
|
160
|
+
|
120
161
|
### grep
|
121
162
|
|
122
163
|
This checks a local file's contents. Supports the Regex helper, and uses the provided regex pattern to match which line of the file to use. If no regex is specified, it will use the full first line of the file.
|
data/bin/prospectus
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
require 'prospectus'
|
4
4
|
require 'mercenary'
|
5
5
|
|
6
|
+
def load_list(params)
|
7
|
+
return Prospectus.load_from_file(params).check if File.exist? '.prospectus'
|
8
|
+
fail('No .prospectus/.prospectus.d found') unless Dir.exist? '.prospectus.d'
|
9
|
+
files = Dir.glob('.prospectus.d/*')
|
10
|
+
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
|
15
|
+
end
|
16
|
+
|
6
17
|
Mercenary.program(:prospectus) do |p|
|
7
18
|
p.version Prospectus::VERSION
|
8
19
|
p.description 'Tool and DSL for checking expected vs actual state'
|
@@ -17,7 +28,8 @@ Mercenary.program(:prospectus) do |p|
|
|
17
28
|
p.action do |_, options|
|
18
29
|
options[:directory] ||= '.'
|
19
30
|
Dir.chdir(options[:directory]) do
|
20
|
-
|
31
|
+
results = load_list(options)
|
32
|
+
results.each do |x|
|
21
33
|
puts "#{x.name}: #{x.actual} / #{x.expected}"
|
22
34
|
end
|
23
35
|
end
|
data/lib/prospectus.rb
CHANGED
@@ -15,10 +15,10 @@ module Prospectus
|
|
15
15
|
##
|
16
16
|
# Method for loading list from DSL
|
17
17
|
def load_from_file(params = {})
|
18
|
-
params[:file]
|
18
|
+
file = params[:file] || DEFAULT_FILE
|
19
19
|
list = List.new(params)
|
20
20
|
dsl = ListDSL.new(list, params)
|
21
|
-
dsl.instance_eval(File.read(
|
21
|
+
dsl.instance_eval(File.read(file), file)
|
22
22
|
list
|
23
23
|
end
|
24
24
|
|
data/lib/prospectus/item.rb
CHANGED
@@ -10,7 +10,10 @@ module Prospectus
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def name
|
13
|
-
@name
|
13
|
+
return @name if @name
|
14
|
+
@name = File.basename Dir.pwd
|
15
|
+
@name << "::#{File.basename @options[:file]}" if @options[:file]
|
16
|
+
@name
|
14
17
|
end
|
15
18
|
|
16
19
|
def expected
|
@@ -53,10 +56,7 @@ module Prospectus
|
|
53
56
|
private
|
54
57
|
|
55
58
|
def state(name, &block)
|
56
|
-
state = State.
|
57
|
-
dsl = StateDSL.new(state, @options)
|
58
|
-
dsl.instance_eval(&block)
|
59
|
-
dsl.load!
|
59
|
+
state = Prospectus::State.from_block(@options, &block)
|
60
60
|
@item.instance_variable_set(name, state.value)
|
61
61
|
end
|
62
62
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module LogCabin
|
2
|
+
module Modules
|
3
|
+
##
|
4
|
+
# Pull state from the latest GitHub commit
|
5
|
+
module GithubHash
|
6
|
+
include Prospectus.helpers.find(:github_api)
|
7
|
+
|
8
|
+
def load!
|
9
|
+
fail('No repo specified') unless @repo
|
10
|
+
@branch ||= 'master'
|
11
|
+
@state.value = @long ? hash : hash.slice(0, 7)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def hash
|
17
|
+
@hash ||= github_api.branch(@repo, @branch).commit.sha
|
18
|
+
end
|
19
|
+
|
20
|
+
def repo(value)
|
21
|
+
@repo = value
|
22
|
+
end
|
23
|
+
|
24
|
+
def branch(value)
|
25
|
+
@branch = value
|
26
|
+
end
|
27
|
+
|
28
|
+
def long
|
29
|
+
@long = true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module LogCabin
|
2
|
+
module Modules
|
3
|
+
##
|
4
|
+
# Pull state from a homebrew cask file
|
5
|
+
module HomebrewCask
|
6
|
+
def load!
|
7
|
+
fail('No name specified') unless @name
|
8
|
+
cask_file = "Casks/#{@name}.rb"
|
9
|
+
version_regex = /^\s+version ['"](.+)['"]$/
|
10
|
+
Prospectus::State.from_block(@option, @state) do
|
11
|
+
grep
|
12
|
+
file cask_file
|
13
|
+
regex version_regex
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def name(value)
|
20
|
+
@name = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module LogCabin
|
2
|
+
module Modules
|
3
|
+
##
|
4
|
+
# Pull state from a homebrew formula file
|
5
|
+
module HomebrewFormula
|
6
|
+
def load!
|
7
|
+
fail('No name specified') unless @name
|
8
|
+
cask_file = "Formula/#{@name}.rb"
|
9
|
+
version_regex = /^\s+version ['"](.+)['"]$/
|
10
|
+
Prospectus::State.from_block(@option, @state) do
|
11
|
+
grep
|
12
|
+
file cask_file
|
13
|
+
regex version_regex
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def name(value)
|
20
|
+
@name = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/prospectus/state.rb
CHANGED
@@ -7,6 +7,14 @@ module Prospectus
|
|
7
7
|
def initialize(params = {})
|
8
8
|
@options = params
|
9
9
|
end
|
10
|
+
|
11
|
+
def self.from_block(params = {}, state = nil, &block)
|
12
|
+
state ||= State.new(params)
|
13
|
+
dsl = StateDSL.new(state, params)
|
14
|
+
dsl.instance_eval(&block)
|
15
|
+
dsl.load!
|
16
|
+
state
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
##
|
data/lib/prospectus/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.6
|
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-
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -116,6 +116,7 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
|
+
- ".prospectus"
|
119
120
|
- ".rspec"
|
120
121
|
- ".rubocop.yml"
|
121
122
|
- Gemfile
|
@@ -133,9 +134,12 @@ files:
|
|
133
134
|
- lib/prospectus/modules/gemnasium.rb
|
134
135
|
- lib/prospectus/modules/git_hash.rb
|
135
136
|
- lib/prospectus/modules/git_tag.rb
|
137
|
+
- lib/prospectus/modules/github_hash.rb
|
136
138
|
- lib/prospectus/modules/github_release.rb
|
137
139
|
- lib/prospectus/modules/github_tag.rb
|
138
140
|
- lib/prospectus/modules/grep.rb
|
141
|
+
- lib/prospectus/modules/homebrew_cask.rb
|
142
|
+
- lib/prospectus/modules/homebrew_formula.rb
|
139
143
|
- lib/prospectus/modules/static.rb
|
140
144
|
- lib/prospectus/modules/url_xpath.rb
|
141
145
|
- lib/prospectus/state.rb
|