-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a9bb08
commit b47ce21
Showing
220 changed files
with
7,191 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
/shellcheck* | ||
/out.txt | ||
/.clojure/ | ||
/.local/ | ||
/.problem/ | ||
/*.ys | ||
/*.clj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
YS_VERSION := 0.1.74 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
SHELL := bash | ||
|
||
BASE := $(shell pwd) | ||
|
||
include .yamlscript/exercise.mk | ||
|
||
YS_LOCAL_PREFIX := ../../../../.local/ys-$(YS_VERSION) | ||
|
||
YS_LOCAL_BIN := $(YS_LOCAL_PREFIX)/bin | ||
|
||
YS_BIN := $(YS_LOCAL_BIN)/ys-$(YS_VERSION) | ||
|
||
TEST_FILE ?= $(wildcard *-test.ys) | ||
|
||
|
||
export PATH := $(YS_LOCAL_BIN):$(PATH) | ||
|
||
export YSPATH := $(BASE) | ||
|
||
|
||
default: | ||
|
||
test: $(YS_BIN) | ||
prove -v $(TEST_FILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,55 @@ | ||
SHELL := bash | ||
|
||
test ?= $(wildcard *-test.ys) | ||
BASE := $(shell pwd) | ||
|
||
export YSPATH=$(shell pwd -P) | ||
include .yamlscript/exercise.mk | ||
|
||
YS_LOCAL_PREFIX := ../../../.local/ys-$(YS_VERSION) | ||
|
||
ifeq (,$(shell [[ "$(YS_LOCAL_PREFIX)" ]] && echo ok)) | ||
YS_LOCAL_PREFIX := ../.yamlscript/ys-$(YS_VERSION) | ||
endif | ||
|
||
YS_LOCAL_BIN := $(YS_LOCAL_PREFIX)/bin | ||
|
||
YS_BIN := $(YS_LOCAL_BIN)/ys-$(YS_VERSION) | ||
|
||
TEST_FILE ?= $(wildcard *-test.ys) | ||
|
||
export PATH := $(YS_LOCAL_BIN):$(PATH) | ||
|
||
export YSPATH := $(BASE) | ||
|
||
|
||
default: | ||
@echo " No default make rule. Try 'make test'." | ||
|
||
test: $(YS_BIN) | ||
prove -v $(TEST_FILE) | ||
|
||
$(YS_BIN): | ||
@echo "$$install_msg" | ||
|
||
install-ys: | ||
bash .yamlscript/exercism-ys-installer $(YS_VERSION) $(MAKE) | ||
|
||
|
||
define install_msg | ||
|
||
This YAMLScript Exercism exercise requires the YAMLScript interpreter file: | ||
|
||
$(YS_BIN) | ||
|
||
to be installed. | ||
|
||
You can install it with: | ||
|
||
$(MAKE) install-ys | ||
|
||
This should only take a few seconds and you only need to do this once. | ||
|
||
Other exercises will use the same file. | ||
|
||
endef | ||
|
||
test: | ||
prove -v $(test) | ||
export install_msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/env/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
main() { | ||
setup "$@" | ||
|
||
installed || install-from-local | ||
installed || install-from-release | ||
installed || install-from-build | ||
installed || | ||
die "Installing '$installed' failed. Giving up." \ | ||
"Consider filing an issue at: $gh_issue_url" | ||
|
||
echo | ||
echo 'Success!' | ||
echo | ||
echo "$installed is now installed." | ||
} | ||
|
||
installed() { [[ $(readlink "$bin/ys-0") == ys-$version ]]; } | ||
|
||
install-from-local() ( | ||
path=$(command -v "$ysfq") | ||
if [[ -f $path ]]; then | ||
cp "$path" "$bin"/ | ||
ln -fs "$ysfq" "$bin/ys-0" | ||
ln -fs "$ysfq" "$bin/ys" | ||
fi | ||
) | ||
|
||
install-from-release() ( | ||
echo "Installing '$installed' for this exercise." | ||
|
||
curl -s https://yamlscript.org/install | | ||
BIN=1 VERSION="$(YS_VERSION)" PREFIX="$prefix" bash | ||
) | ||
|
||
install-from-build() ( | ||
echo "The binary release install failed." | ||
echo "We can attempt to build and install $ysfq now." | ||
echo "This can take from 1 to 5 minutes to complete." | ||
echo | ||
printf "Enter 'y' to continue: " | ||
|
||
read -r answer | ||
|
||
[[ $answer == y ]] || | ||
die 'Giving up.' | ||
|
||
[[ -d /tmp && -w /tmp ]] || | ||
die "Can't write to /tmp" \ | ||
'Giving up.' | ||
|
||
set -x | ||
|
||
rm -fr "$yamlscript_clone" | ||
|
||
git clone --branch="$version" "$yamlscript_repo" "$yamlscript_clone" | ||
|
||
"$make" -C "$yamlscript_clone/ys" install PREFIX="$prefix" | ||
) | ||
|
||
setup() { | ||
version=$1 | ||
make=${2:-make} | ||
|
||
[[ $version =~ ^0\.1\.[0-9]+$ ]] || | ||
die "Invalid YS_VERSION '$version'" | ||
|
||
prefix=../.yamlscript/v$version | ||
bin=$prefix/bin | ||
ysfq=ys-$version | ||
installed=$bin/$ysfq | ||
yamlscript_repo=https://github.com/yamlscript | ||
yamlscript_clone=/tmp/yamlscript-exercism | ||
gh_issue_url=https://github.com/exercism/yamlscript/issues | ||
} | ||
|
||
die() { | ||
printf '%s\n' "$@" >&2 | ||
exit 1 | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# This Makefile is a decoy to attempt to detect when a non-GNU make is being | ||
# used and alert the user. | ||
|
||
test: | ||
@echo "You appear to be using a non-GNU version of the 'make' program." | ||
@echo "The YAMLScript Exercism track requires you to use GNU make." | ||
@echo "Please try 'make $@' again using GNU make." | ||
@exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
YS_VERSION := 0.1.74 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
SHELL := bash | ||
|
||
BASE := $(shell pwd) | ||
|
||
include .yamlscript/exercise.mk | ||
|
||
YS_LOCAL_PREFIX := ../../../../.local/ys-$(YS_VERSION) | ||
|
||
YS_LOCAL_BIN := $(YS_LOCAL_PREFIX)/bin | ||
|
||
YS_BIN := $(YS_LOCAL_BIN)/ys-$(YS_VERSION) | ||
|
||
TEST_FILE ?= $(wildcard *-test.ys) | ||
|
||
|
||
export PATH := $(YS_LOCAL_BIN):$(PATH) | ||
|
||
export YSPATH := $(BASE) | ||
|
||
|
||
default: | ||
|
||
test: $(YS_BIN) | ||
prove -v $(TEST_FILE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
YS_VERSION := 0.1.74 |
Oops, something went wrong.