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
66
77## [ Unreleased]
88
9+ ## [ 2.0.2] - 2020-03-10
10+ ### Added
11+ - Retrieve latest version for gem from rubygems.org
12+
913## [ 2.0.1] - 2020-02-19
1014### Added
1115- 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.
194194 </ol>
195195 </td>
196196 </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>
197208 <tr>
198209 <td><a href="test-utils/lib">test-utils</a></td>
199210 <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(){
2828 local download_url
2929 local bin_path
3030
31+ bl_curl_available
32+
3133 if [[ -z " ${os_arch} " ]]; then
3234 if [[ " ${OSTYPE} " =~ " darwin" ]]; then
3335 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}"
2626
2727# Load the filehandling module for the abspath
2828# 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
3030 . " ${BASH_LIB_DIR_RELATIVE} /${lib} /lib"
3131done
3232
Original file line number Diff line number Diff line change @@ -68,4 +68,3 @@ function bl_error(){
6868function bl_fatal(){
6969 bl_log fatal " ${* } "
7070}
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 55# shellcheck disable=SC2086
66. " $( dirname ${BASH_SOURCE[0]} ) /init"
77
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"
915" ${BASH_LIB_DIR} /tests-for-this-repo/run-bats-tests"
1016
11- # Run Python Lint
17+ bl_info " Running Python Lint"
1218" ${BASH_LIB_DIR} /tests-for-this-repo/run-python-lint"
1319
14- # Run gitleaks
20+ bl_info " Running gitleaks"
1521" ${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