File tree Expand file tree Collapse file tree 9 files changed +150
-5
lines changed Expand file tree Collapse file tree 9 files changed +150
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
7
7
## [ Unreleased]
8
8
9
+ ## [ 2.0.2] - 2020-03-10
10
+ ### Added
11
+ - Retrieve latest version for gem from rubygems.org
12
+
9
13
## [ 2.0.1] - 2020-02-19
10
14
### Added
11
15
- Github issue related functions via the ` hub ` cli
Original file line number Diff line number Diff line change @@ -194,6 +194,17 @@ files within it's directory.
194
194
</ol>
195
195
</td>
196
196
</tr>
197
+ <tr>
198
+ <td><a href="test-utils/ruby">Ruby</a></td>
199
+ <td>Helpers related to ruby infrastructure</td>
200
+ <td>
201
+ <ol>
202
+ <li><b>bl_gem_latest_version</b>: Return the latest version of a gem from rubygems.org</li>
203
+ <li><b>bl_jq_available</b>: Check jq binary is available</li>
204
+ <li><b>bl_curl_available</b>: Check curl binary is available</li>
205
+ </ol>
206
+ </td>
207
+ </tr>
197
208
<tr>
198
209
<td><a href="test-utils/lib">test-utils</a></td>
199
210
<td>Helpers for executing tests</td>
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ function bl_hub_download_latest(){
28
28
local download_url
29
29
local bin_path
30
30
31
+ bl_curl_available
32
+
31
33
if [[ -z " ${os_arch} " ]]; then
32
34
if [[ " ${OSTYPE} " =~ " darwin" ]]; then
33
35
os_arch=" darwin-amd64"
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ BASH_LIB_DIR="${BASH_LIB_DIR_RELATIVE}"
26
26
27
27
# Load the filehandling module for the abspath
28
28
# function
29
- for lib in helpers logging filehandling git github k8s test-utils; do
29
+ for lib in helpers logging filehandling git github k8s test-utils ruby ; do
30
30
. " ${BASH_LIB_DIR_RELATIVE} /${lib} /lib"
31
31
done
32
32
Original file line number Diff line number Diff line change @@ -68,4 +68,3 @@ function bl_error(){
68
68
function bl_fatal(){
69
69
bl_log fatal " ${* } "
70
70
}
71
-
Original file line number Diff line number Diff line change
1
+ : "${BASH_LIB_DIR:?BASH_LIB_DIR must be set. Please source bash-lib/init before other scripts from bash-lib.}"
2
+
3
+ function bl_jq_available(){
4
+ type jq >/dev/null || bl_fail "jq not found :("
5
+ }
6
+
7
+ function bl_curl_available(){
8
+ type curl >/dev/null || bl_fail "curl not found :("
9
+ }
10
+
11
+ function bl_gem_latest_version(){
12
+ bl_jq_available
13
+ bl_curl_available
14
+
15
+ gem="${1:-}"
16
+
17
+ if [[ -z "${gem}" ]]; then
18
+ bl_fail "usage: bl_gem_version <gem name>"
19
+ fi
20
+
21
+ curl https://rubygems.org/api/v1/gems/${gem}.json \
22
+ |jq -r '.version'
23
+ }
Original file line number Diff line number Diff line change 5
5
# shellcheck disable=SC2086
6
6
. " $( dirname ${BASH_SOURCE[0]} ) /init"
7
7
8
- # Run BATS Tests
8
+ bl_info " Checking the changelog complies with keepachangelog.com format"
9
+ docker run \
10
+ --rm \
11
+ -v " ${PWD} /CHANGELOG.md:/CHANGELOG.md" \
12
+ cyberark/parse-a-changelog
13
+
14
+ bl_info " Running BATS Tests"
9
15
" ${BASH_LIB_DIR} /tests-for-this-repo/run-bats-tests"
10
16
11
- # Run Python Lint
17
+ bl_info " Running Python Lint"
12
18
" ${BASH_LIB_DIR} /tests-for-this-repo/run-python-lint"
13
19
14
- # Run gitleaks
20
+ bl_info " Running gitleaks"
15
21
" ${BASH_LIB_DIR} /tests-for-this-repo/run-gitleaks"
22
+
23
+ bl_info " Sucess! All tests passed."
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " parse_a_changelog" ,
3
+ "downloads" : 6660 ,
4
+ "version" : " 1.0.1" ,
5
+ "version_downloads" : 168 ,
6
+ "platform" : " ruby" ,
7
+ "authors" : " John Tuttle" ,
8
+ "info" : " Uses a grammar describing the keep-a-changelog format to attempt to parse a given file." ,
9
+ "licenses" : [
10
+ " Apache-2.0"
11
+ ],
12
+ "metadata" : {},
13
+ "yanked" : false ,
14
+ "sha" : " c081ae854570083ba56097d84a1fc66d47dd31f1a015edcb1ba2cbf9e2a4fe4a" ,
15
+ "project_uri" : " https://rubygems.org/gems/parse_a_changelog" ,
16
+ "gem_uri" : " https://rubygems.org/gems/parse_a_changelog-1.0.1.gem" ,
17
+ "homepage_uri" : " http://github.com/cyberark/parse-a-changelog" ,
18
+ "wiki_uri" : null ,
19
+ "documentation_uri" : " http://www.rubydoc.info/gems/parse_a_changelog/1.0.1" ,
20
+ "mailing_list_uri" : null ,
21
+ "source_code_uri" : null ,
22
+ "bug_tracker_uri" : null ,
23
+ "changelog_uri" : null ,
24
+ "dependencies" : {
25
+ "development" : [
26
+ {
27
+ "name" : " rspec" ,
28
+ "requirements" : " ~> 3.8"
29
+ },
30
+ {
31
+ "name" : " rspec_junit_formatter" ,
32
+ "requirements" : " ~> 0.4.1"
33
+ }
34
+ ],
35
+ "runtime" : [
36
+ {
37
+ "name" : " treetop" ,
38
+ "requirements" : " ~> 1.6"
39
+ }
40
+ ]
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ . " ${BASH_LIB_DIR} /test-utils/bats-support/load.bash"
2
+ . " ${BASH_LIB_DIR} /test-utils/bats-assert-1/load.bash"
3
+
4
+ . " ${BASH_LIB_DIR} /init"
5
+
6
+ teardown (){
7
+ unset curl
8
+ }
9
+
10
+
11
+ @test " bl_jq_available succeeds when jq is available" {
12
+ jq (){ : ; }
13
+ run bl_jq_available
14
+ assert_success
15
+ }
16
+
17
+ @test " bl_jq_available fails when jq is not available" {
18
+ real_path=" ${PATH} "
19
+ PATH=" "
20
+ run bl_jq_available
21
+ PATH=" ${real_path} "
22
+ assert_failure
23
+ assert_output --partial " jq not found"
24
+ }
25
+
26
+ @test " bl_curl_available succeeds when jq is available" {
27
+ jq (){ : ; }
28
+ run bl_curl_available
29
+ assert_success
30
+ }
31
+
32
+ @test " bl_curl_available fails when jq is not available" {
33
+ real_path=" ${PATH} "
34
+ PATH=" "
35
+ run bl_curl_available
36
+ PATH=" ${real_path} "
37
+ assert_failure
38
+ assert_output --partial " curl not found"
39
+ }
40
+
41
+ @test " bl_gem_latest_version fails when no gem name is supplied" {
42
+ run bl_gem_latest_version
43
+ assert_failure
44
+ assert_output --partial " usage"
45
+ }
46
+
47
+ @test " bl_gem_latest_version returns only the version number" {
48
+ curl (){
49
+ fixtures_dir=" ${BASH_LIB_DIR} /tests-for-this-repo/fixtures/ruby"
50
+ cat ${fixtures_dir} /ruby_gems_api_response.json
51
+ }
52
+
53
+ run bl_gem_latest_version parse_a_changelog
54
+ assert_success
55
+ assert_output " 1.0.1"
56
+ }
You can’t perform that action at this time.
0 commit comments