File tree Expand file tree Collapse file tree 8 files changed +100
-5
lines changed Expand file tree Collapse file tree 8 files changed +100
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
66
77## [ Unreleased]
8+ ### Added
9+ - Retrieve latest version for gem from rubygems.org
810
911## [ 2.0.1] - 2020-02-19
1012### Added
Original file line number Diff line number Diff line change @@ -194,6 +194,15 @@ 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+ </ol>
204+ </td>
205+ </tr>
197206 <tr>
198207 <td><a href="test-utils/lib">test-utils</a></td>
199208 <td>Helpers for executing tests</td>
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_gem_latest_version(){
4+ gem="${1:-}"
5+ if [[ -z "${gem}" ]]; then
6+ bl_fail "usage: bl_gem_version <gem name>"
7+ fi
8+ curl https://rubygems.org/api/v1/gems/${gem}.json \
9+ |jq -r '.version'
10+ }
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+ @test " bl_gem_latest_version fails when no gem name is supplied" {
11+ run bl_gem_latest_version
12+ assert_failure
13+ assert_output --partial " usage"
14+ }
15+
16+ @test " bl_gem_latest_version returns only the version number" {
17+ curl (){
18+ fixtures_dir=" ${BASH_LIB_DIR} /tests-for-this-repo/fixtures/ruby"
19+ cat ${fixtures_dir} /ruby_gems_api_response.json
20+ }
21+
22+ run bl_gem_latest_version parse_a_changelog
23+ assert_success
24+ assert_output " 1.0.1"
25+ }
You can’t perform that action at this time.
0 commit comments