Skip to content

Commit c6aa2c0

Browse files
committed
Updating WORKSPACE example
1 parent 846c85b commit c6aa2c0

File tree

8 files changed

+135
-135
lines changed

8 files changed

+135
-135
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ Note: we have a short guide on [Building your first Ruby Project](https://github
6161
```python
6262
workspace(name = "my_ruby_project")
6363

64-
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
65-
bazel_skylib_workspace()
66-
6764
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
6865
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
6966

@@ -74,7 +71,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
7471
git_repository(
7572
name = "bazelruby_rules_ruby",
7673
remote = "https://github.com/bazelruby/rules_ruby.git",
77-
branch = "develop",
74+
branch = "develop"
7875
)
7976

8077
load(
@@ -90,14 +87,17 @@ rules_ruby_dependencies()
9087
# RBENV installation if the Ruby version matches.
9188
#———————————————————————————————————————————————————————————————————————
9289

90+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
91+
bazel_skylib_workspace()
92+
9393
rules_ruby_select_sdk(version = "2.7.0")
9494

9595
#———————————————————————————————————————————————————————————————————————
9696
# Now, load the ruby_bundle rule & install gems specified in the Gemfile
9797
#———————————————————————————————————————————————————————————————————————
9898

9999
load(
100-
"@bazelruby_rules_ruby//ruby:defs.bzl",
100+
"@bazelruby_rules_ruby//ruby:defs.bzl",
101101
"ruby_bundle",
102102
)
103103

bin/deps

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fi
1111
# shellcheck disable=SC1090
1212
source "${BashMatic}/init.sh" 1>/dev/null 2>&1
1313

14-
__version::detect() {
14+
__version.detect() {
1515
local file="$1"
1616
if [[ -f ${file} ]]; then
1717
/bin/cat "${file}" | head -1
@@ -26,9 +26,9 @@ __version::detect() {
2626
}
2727

2828
# Application Constants
29-
export RulesRuby__RulesVersion=$(__version::detect .rules_version)
29+
export RulesRuby__RulesVersion=$(__version.detect .rules_version)
3030
export RulesRuby__RubyVersion=2.7.0
31-
export RulesRuby__BazelVersion=$(__version::detect .bazelversion)
31+
export RulesRuby__BazelVersion=$(__version.detect .bazelversion)
3232

3333
bazel-sha() {
3434
bazel info | grep output_path | awk 'BEGIN{FS="/"}{ for(i = 1; i <= NF; i++) { if (length($i) == 32) print $i; } }'
@@ -46,18 +46,18 @@ help-example() {
4646
printf " ${bldpur}$*${clr}"
4747
}
4848

49-
deps::start-clock() {
49+
deps.start-clock() {
5050
export __start=$(millis)
5151
}
5252

53-
deps::print-duration() {
53+
deps.print-duration() {
5454
local finish=$(millis)
5555
local duration=$(( finish - __start ))
56-
info "Total running time for was ${bldylw}$(lib::time::duration::millis-to-secs ${duration}) seconds.\n\n"
56+
info "Total running time for was ${bldylw}$(lib.time.duration.millis-to-secs ${duration}) seconds.\n\n"
5757
}
5858

5959

60-
run::set-all abort-on-error
60+
run.set-all abort-on-error
6161

6262
# ensure we can exit with Ctrl-C
6363
trap exit 1 INT

bin/linter

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@ source "bin/deps"
1111
[[ -n $(command -v rubocop) ]] || {
1212
# shellcheck disable=SC1091
1313
source bin/setup
14-
setup::main gems
14+
setup.main gems
1515
}
1616

1717
export __git_pre="/tmp/rules-ruby-git-status-before-commit.$$"
1818
export __git_post="/tmp/rules-ruby-git-status-after-commit.$$"
1919

20-
__lint::cleanup() {
20+
__lint.cleanup() {
2121
for f in "${__git_pre}" "${__git_post}"; do
2222
[[ -f "${f}" ]] && rm -f "${f}"
2323
done
2424
}
2525

26-
deps::start-clock
27-
run::set-all abort-on-error
26+
deps.start-clock
27+
run.set-all abort-on-error
2828

29-
__lint::actions() {
29+
__lint.actions() {
3030
local sep="${1:-', '}"
31-
printf "${bldylw}$(lib::array::join "${sep}" $(lib::util::functions-matching "lint::" | sed 's/ main//g'))${clr}"
31+
printf "${bldylw}$(lib.array.join "${sep}" $(lib.util.functions-matching "lint." | sed 's/ main//g'))${clr}"
3232
}
3333

34-
lint::help() {
34+
lint.help() {
3535
printf "
3636
$(help-header USAGE)
3737
${bldblk}# without any arguments runs a complete setup.${clr}
3838
$(help-usage "bin/linter")
3939
4040
${bldblk}# alternatively, a partial linter name can be passed:${clr}
41-
$(help-usage "bin/linter [ $(__lint::actions " | ") ]")
41+
$(help-usage "bin/linter [ $(__lint.actions " | ") ]")
4242
4343
$(help-header DESCRIPTION:)
4444
Runs various linters either all serially, or by name based on
@@ -59,17 +59,17 @@ $(help-example bin/linter buildifier)
5959
exit 0
6060
}
6161

62-
lint::rubocop() {
63-
h2::green "Running Rubocop, please wait..."
62+
lint.rubocop() {
63+
h2.green "Running Rubocop, please wait..."
6464
run "rubocop || rubocop -a"
6565
inf "Rubocop completed."
6666
ok:
6767
}
6868

6969
# runs buildifer from the PATH if it exists, otherwise bazel target
7070
# we want before-commit to be as fast as possible.
71-
lint::buildifier() {
72-
h2::green "Buildifier"
71+
lint.buildifier() {
72+
h2.green "Buildifier"
7373
if [[ -n $(command -v buildifier) ]]; then
7474
info "Running $(command -v buildifier).."
7575
run "find . -name 'BUILD*' -o -name 'WORKSPACE' -o -name '*.bzl' | grep -v '.git' | xargs buildifier -v"
@@ -79,25 +79,25 @@ lint::buildifier() {
7979
fi
8080
}
8181

82-
lint::all() {
82+
lint.all() {
8383
# number of modified files
8484
local changes_before=$(git status -s | md5)
85-
trap __lint::cleanup EXIT
85+
trap __lint.cleanup EXIT
8686
git status -s >"${__git_pre}"
8787

8888
set -e
89-
run::set-all abort-on-error
90-
lint::rubocop
89+
run.set-all abort-on-error
90+
lint.rubocop
9191

9292
set -e
93-
run::set-all abort-on-error
94-
lint::buildifier
93+
run.set-all abort-on-error
94+
lint.buildifier
9595

9696
git status -s >"${__git_post}"
9797

9898
local changes_after=$(git status -s | md5)
9999
if [[ ${changes_before} != "${changes_after}" ]]; then
100-
hl::subtle "Git status -s output changed after before-commit hook."
100+
hl.subtle "Git status -s output changed after before-commit hook."
101101
info "Changes before before-commit hook:"
102102
hr
103103
diff "${pre}" "${post}"
@@ -113,32 +113,32 @@ lint::all() {
113113
}
114114

115115

116-
lint::main() {
116+
lint.main() {
117117
local action="$1"
118118
[[ "${action}" == "-h" || ${action} == "--help" ]] && action="help"
119-
local func="lint::${action}"
119+
local func="lint.${action}"
120120

121121
if [[ -n ${action} ]]; then
122-
if lib::util::is-a-function "${func}"; then
122+
if lib.util.is-a-function "${func}"; then
123123
[[ ${action} != "help" ]] && h2 "Executing partial linting for ${bldylw}${action}"
124124
shift
125125
${func} "$@"
126126
local code=$?
127127
[[ ${code} -eq 0 ]] && success "Linter ${action} was successful"
128128
[[ ${code} -ne 0 ]] && error "Linter failed for ${action}"
129-
deps::print-duration
129+
deps.print-duration
130130
exit ${code}
131131
else
132-
h1 "Invalid action provided." "Valid lint actions are: $(__lint::actions)"
132+
h1 "Invalid action provided." "Valid lint actions are: $(__lint.actions)"
133133
exit 1
134134
fi
135135
else
136136
set +e
137-
lint::all
138-
deps::print-duration
137+
lint.all
138+
deps.print-duration
139139
fi
140140
}
141141

142-
lint::main "$@"
142+
lint.main "$@"
143143

144144
exit 0

bin/setup

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ source "bin/deps"
1111
# Private Functions
1212
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————
1313

14-
__setup::actions() {
14+
__setup.actions() {
1515
local sep="${1}"
16-
printf "${bldylw}$(lib::array::join "${sep}" $(lib::util::functions-matching "setup::" | sed 's/ main//g'))${clr}"
16+
printf "${bldylw}$(lib.array.join "${sep}" $(lib.util.functions-matching "setup." | sed 's/ main//g'))${clr}"
1717
}
1818

1919
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————
2020
# Public Functions
2121
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————
2222

23-
setup::help() {
23+
setup.help() {
2424
printf "
2525
$(help-header USAGE)
2626
${bldblk}# without any arguments runs a complete setup.${clr}
2727
$(help-usage "bin/setup")
2828
2929
${bldblk}# alternatively, a sub-setup function name can be passed:${clr}
30-
$(help-usage "bin/setup [ $(__setup::actions " | ") ]")
30+
$(help-usage "bin/setup [ $(__setup.actions " | ") ]")
3131
3232
$(help-header DESCRIPTION:)
3333
Runs full setup without any arguments.
@@ -49,13 +49,13 @@ etc.
4949
"
5050
}
5151

52-
setup::gems() {
52+
setup.gems() {
5353
for gem in rubocop relaxed-rubocop rubocop-performance; do
54-
lib::gem::install ${gem}
54+
lib.gem.install ${gem}
5555
done
5656
}
5757

58-
setup::remove-git-hook() {
58+
setup.remove-git-hook() {
5959
set -e
6060
[[ -L .git/hooks/pre-commit ]] && {
6161
info 'Removing git commit hook...'
@@ -65,7 +65,7 @@ setup::remove-git-hook() {
6565
set +e
6666
}
6767

68-
setup::git-hook() {
68+
setup.git-hook() {
6969
set -e
7070
if [[ ! -L .git/hooks/pre-commit ]]; then
7171
info 'Installing git pre-commit hook'
@@ -76,7 +76,7 @@ setup::git-hook() {
7676
set +e
7777
}
7878

79-
setup::os-specific() {
79+
setup.os-specific() {
8080
local os=$(uname -s | tr '[:upper:]' '[:lower:]')
8181
local setup_script
8282
setup_script="./bin/setup-${os}"
@@ -86,7 +86,7 @@ setup::os-specific() {
8686
# shellcheck disable=SC1090
8787
source "${setup_script}"
8888
# run it's main function
89-
eval "setup::${os} \"$*\""
89+
eval "setup.${os} \"$*\""
9090
echo
9191
if [[ -z ${CI} ]]; then
9292
h2 "Please note — to print your Bazel environment run " "${bldylw}bin/show-env"
@@ -100,13 +100,13 @@ setup::os-specific() {
100100
return 0
101101
}
102102

103-
setup::main() {
103+
setup.main() {
104104
local action="$1"
105105
[[ "${action}" == "-h" || ${action} == "--help" ]] && action="help"
106-
local func="setup::${action}"
106+
local func="setup.${action}"
107107

108108
if [[ -n ${action} ]]; then
109-
if lib::util::is-a-function "${func}"; then
109+
if lib.util.is-a-function "${func}"; then
110110
[[ ${action} != "help" ]] && h2 "Executing partial setup for action ${bldylw}${action}"
111111
shift
112112
${func} "$@"
@@ -115,16 +115,16 @@ setup::main() {
115115
[[ ${code} -ne 0 ]] && error "Error setting up ${action}"
116116
exit ${code}
117117
else
118-
h1 "Invalid action provided." "Valid actions are: $(__setup::actions " | ")"
118+
h1 "Invalid action provided." "Valid actions are: $(__setup.actions " | ")"
119119
exit 1
120120
fi
121121
else
122122
set +e
123123
h2 "Installing required development dependencies for working with rules_ruby and Bazel."
124-
setup::gems
125-
[[ -z ${CI} ]] && setup::git-hook
126-
setup::os-specific "$@"
124+
setup.gems
125+
[[ -z ${CI} ]] && setup.git-hook
126+
setup.os-specific "$@"
127127
fi
128128
}
129129

130-
setup::main "$@"
130+
setup.main "$@"

0 commit comments

Comments
 (0)