prospectus 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +166 -2
- data/lib/prospectus/helpers/chdir.rb +18 -0
- data/lib/prospectus/modules/git_hash.rb +24 -0
- data/lib/prospectus/modules/grep.rb +1 -0
- data/lib/prospectus/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67fdaf9d85016c56745670bc3950906d07288129
|
4
|
+
data.tar.gz: d764a11f127a12a2ecc22f43f27fd5270dbb792a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78411e2c4e76f03c02b7c0487b60289c3be11bf74d2b1de02e6071303632c728eb83e13a514ae34d257b46302862facd4fb2335753b85a2f2266550dac7babde
|
7
|
+
data.tar.gz: 1a396dd894814191fb051b1c188f50aca8c3ca51e78c8ec01c8c9903a01d3f0967c022cdc860ef67af0b8cf80f235b8db7708e2d8a18bee36b5c290bf56cf9bd
|
data/README.md
CHANGED
@@ -41,9 +41,134 @@ To run the check, just run `prospectus` in the directory with the .prospectus fi
|
|
41
41
|
|
42
42
|
## Included Modules
|
43
43
|
|
44
|
-
|
44
|
+
The following modules are included with Prospectus.
|
45
45
|
|
46
|
-
|
46
|
+
Most of the examples below will use either an expected or actual block, based on the most common use case, but any module can be used for either state.
|
47
|
+
|
48
|
+
### git_tag
|
49
|
+
|
50
|
+
This checks the git tag of the local repo. Supports the Regex helper
|
51
|
+
|
52
|
+
```
|
53
|
+
# This would use the current git tag directly
|
54
|
+
actual do
|
55
|
+
git_tag
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
```
|
60
|
+
# This would convert v1.0.0 into 1.0.0
|
61
|
+
actual do
|
62
|
+
git_tag
|
63
|
+
regex /^v([\d.]+)$/
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
```
|
68
|
+
# And this would convert v1_0_0 into 1.0.0
|
69
|
+
actual do
|
70
|
+
git_tag
|
71
|
+
regex /^v(\d+)_(\d+)_(\d+)$/, '\1.\2.\3'
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
### git_hash
|
76
|
+
|
77
|
+
Checks the git hash of a local repository. Supports the chdir helper.
|
78
|
+
|
79
|
+
Will return the short hash unless the `long` argument is provided.
|
80
|
+
|
81
|
+
Primarily used for checking git submodules.
|
82
|
+
|
83
|
+
```
|
84
|
+
# Returns the short hash
|
85
|
+
actual do
|
86
|
+
git_hash
|
87
|
+
dir 'submodules/my-important-other-repo'
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns the full hash
|
91
|
+
actual do
|
92
|
+
git_hash
|
93
|
+
long
|
94
|
+
dir 'submodules/other-repo'
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
### github_release
|
99
|
+
|
100
|
+
This checks the latest GitHub release for a repo (must be a real Release, not just a tag. Use github_tag if there isn't a Release). Supports the Regex helper and uses the GitHub API helper for API access.
|
101
|
+
|
102
|
+
```
|
103
|
+
expected do
|
104
|
+
github_release
|
105
|
+
repo 'amylum/s6'
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
### github_tag
|
110
|
+
|
111
|
+
This checks the latest GitHub tag for a repo. Supports the Regex helper and uses the GitHub API helper for API access.
|
112
|
+
|
113
|
+
```
|
114
|
+
expected do
|
115
|
+
github_tag
|
116
|
+
repo 'reubenhwk/radvd'
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
### grep
|
121
|
+
|
122
|
+
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.
|
123
|
+
|
124
|
+
```
|
125
|
+
# Searches file for OPENSSL_VERSION = 1.0.1e and returns 1.0.1e
|
126
|
+
actual do
|
127
|
+
grep
|
128
|
+
file 'Makefile'
|
129
|
+
regex /^OPENSSL_VERSION = ([\w.-]+)$/
|
130
|
+
end
|
131
|
+
```
|
132
|
+
|
133
|
+
### url_xpath
|
134
|
+
|
135
|
+
Used to parse an xpath inside a web page. Requires the nokogiri gem, and supports the Regex helper.
|
136
|
+
|
137
|
+
The easiest way to get an xpath is usually to use Chrome's Inspector to find the element you want and right click it -> Copy -> As XPath. There are some quirks, notably that nokogiri doesn't parse the tbody tag (just remove it from the xpath that Chrome provides).
|
138
|
+
|
139
|
+
```
|
140
|
+
# Parses the latest tag for procps-ng
|
141
|
+
expected do
|
142
|
+
url_xpath
|
143
|
+
url 'https://gitlab.com/procps-ng/procps/tags'
|
144
|
+
xpath '/html/body/div[1]/div[2]/div[2]/div/div/div[2]/ul/li[1]/div[1]/a/strong/text()'
|
145
|
+
regex /v([\d.]+)$/
|
146
|
+
end
|
147
|
+
```
|
148
|
+
|
149
|
+
### gemnasium
|
150
|
+
|
151
|
+
Parses the dep status on Gemnasium for a project. Will return the worst color from their dashboard (red, yellow, or green). Requires the netrc gem.
|
152
|
+
|
153
|
+
Due to the nature of the response, this is best used with a `static` expected block, like this:
|
154
|
+
|
155
|
+
```
|
156
|
+
item do
|
157
|
+
expected do
|
158
|
+
static
|
159
|
+
set 'green'
|
160
|
+
end
|
161
|
+
|
162
|
+
actual do
|
163
|
+
gemnasium
|
164
|
+
slug 'amylum/server'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
```
|
168
|
+
|
169
|
+
### static
|
170
|
+
|
171
|
+
Basic module for staticly defining a value. Useful for testing, and also for comparisons against a known state (like with the gemnasium module).
|
47
172
|
|
48
173
|
```
|
49
174
|
item do
|
@@ -58,6 +183,45 @@ item do
|
|
58
183
|
end
|
59
184
|
```
|
60
185
|
|
186
|
+
## Included Helpers
|
187
|
+
|
188
|
+
### regex
|
189
|
+
|
190
|
+
Allows modification of result using regex. Supported by most modules, per the above modules list.
|
191
|
+
|
192
|
+
The first argument should be a regex pattern to match against the value. Note that an error will be raised if the value does not match the provided regex. An optional second value specifies the replacement string to use; the default is '\1', which will use the first capture group from your regex.
|
193
|
+
|
194
|
+
```
|
195
|
+
# This would convert v1.0.0 into 1.0.0
|
196
|
+
actual do
|
197
|
+
git_tag
|
198
|
+
regex /^v([\d.]+)$/
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
202
|
+
```
|
203
|
+
# And this would convert v1_0_0 into 1.0.0
|
204
|
+
actual do
|
205
|
+
git_tag
|
206
|
+
regex /^v(\d+)_(\d+)_(\d+)$/, '\1.\2.\3'
|
207
|
+
end
|
208
|
+
```
|
209
|
+
|
210
|
+
### chdir
|
211
|
+
|
212
|
+
Used to chdir to a different directory before loading the state.
|
213
|
+
|
214
|
+
```
|
215
|
+
actual do
|
216
|
+
git_hash
|
217
|
+
dir 'submodules/important_repo'
|
218
|
+
end
|
219
|
+
```
|
220
|
+
|
221
|
+
### github_api
|
222
|
+
|
223
|
+
Used by modules to provide authenticated access to the GitHub API. Uses the [octoauth gem](https://github.com/akerl/octoauth)
|
224
|
+
|
61
225
|
## Installation
|
62
226
|
|
63
227
|
gem install prospectus
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module LogCabin
|
2
|
+
module Modules
|
3
|
+
##
|
4
|
+
# Change directory before running module
|
5
|
+
module Chdir
|
6
|
+
def chdir_helper(&block)
|
7
|
+
@dir ||= '.'
|
8
|
+
Dir.chdir(@dir) { block.call }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def dir(value)
|
14
|
+
@dir = value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module LogCabin
|
2
|
+
module Modules
|
3
|
+
##
|
4
|
+
# Pull state from a git hash
|
5
|
+
module GitHash
|
6
|
+
include Prospectus.helpers.find(:chdir)
|
7
|
+
|
8
|
+
def load!
|
9
|
+
chdir_helper do
|
10
|
+
short_arg = @long ? '' : '--short'
|
11
|
+
hash = `git rev-parse #{short_arg} HEAD 2>/dev/null`.chomp
|
12
|
+
fail('No hash found') if hash.empty?
|
13
|
+
@state.value = hash
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def long
|
20
|
+
@long = true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/prospectus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
@@ -125,11 +125,13 @@ files:
|
|
125
125
|
- bin/prospectus
|
126
126
|
- circle.yml
|
127
127
|
- lib/prospectus.rb
|
128
|
+
- lib/prospectus/helpers/chdir.rb
|
128
129
|
- lib/prospectus/helpers/github_api.rb
|
129
130
|
- lib/prospectus/helpers/regex.rb
|
130
131
|
- lib/prospectus/item.rb
|
131
132
|
- lib/prospectus/list.rb
|
132
133
|
- lib/prospectus/modules/gemnasium.rb
|
134
|
+
- lib/prospectus/modules/git_hash.rb
|
133
135
|
- lib/prospectus/modules/git_tag.rb
|
134
136
|
- lib/prospectus/modules/github_release.rb
|
135
137
|
- lib/prospectus/modules/github_tag.rb
|