diff --git a/.gitignore b/.gitignore index e5fe43d..37ec740 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /shellcheck* /out.txt /.clojure/ +/.local/ /.problem/ /*.ys /*.clj diff --git a/Makefile b/Makefile index f5478b4..7c419c8 100644 --- a/Makefile +++ b/Makefile @@ -4,28 +4,38 @@ ROOT := $(shell pwd) BIN := bin -YS := $(BIN)/ys +YS_VERSION := 0.1.74 + +YS_LOCAL := .local +YS_LOCAL_PREFIX := $(YS_LOCAL)/ys-$(YS_VERSION) +YS_LOCAL_BIN := $(YS_LOCAL_PREFIX)/bin +YS := $(YS_LOCAL_PREFIX)/bin/ys-$(YS_VERSION) CFGLET := $(BIN)/configlet SHELLCHECK := $(BIN)/shellcheck VERIFY := $(BIN)/verify-exercises ifdef EXERCISM_YAMLSCRIPT_GHA -YS := ys +YS := ys-$(YS_VERSION) SHELLCHECK := shellcheck endif -export PATH := $(ROOT)/bin:$(PATH) +export PATH := $(ROOT)/bin:$(YS_LOCAL_BIN):$(PATH) -EXERCISE_DIRS := $(shell find exercises -name .meta) +EXERCISE_DIRS := $(shell find exercises -name .meta | sort) EXERCISE_DIRS := $(EXERCISE_DIRS:%/.meta=%) EXERCISES := $(EXERCISE_DIRS:exercises/practice/%=%) + EXERCISE_MAKEFILES := $(EXERCISE_DIRS:%=%/Makefile) +EXERCISE_GNU_MAKEFILES := $(EXERCISE_DIRS:%=%/GNUmakefile) +EXERCISE_YS_MAKEFILES := $(EXERCISE_DIRS:%=%/.yamlscript/exercise.mk) +EXERCISE_META_MAKEFILES := $(EXERCISE_DIRS:%=%/.meta/Makefile) +EXERCISE_YS_INSTALLERS := $(EXERCISE_DIRS:%=%/.yamlscript/exercism-ys-installer) + a := ( b := ) EXERCISE_META_LINKS := \ - $(shell ls -d exercises/practice/*/*-test.ys \ - exercises/practice/*/Makefile \ - | perl -pe 's{$a.*$b/$a.*$b}{$$1/.meta/$$2}') + $(shell ls exercises/practice/*/.yamlscript/exercise.mk \ + | perl -pe 's{$a.*$b/$a.*/.*$b}{$$1/.meta/$$2}') CHECKS := \ check-yaml \ @@ -35,7 +45,11 @@ CHECKS := \ GEN_FILES := \ $(EXERCISE_MAKEFILES) \ + $(EXERCISE_GNU_MAKEFILES) \ + $(EXERCISE_YS_MAKEFILES) \ + $(EXERCISE_META_MAKEFILES) \ $(EXERCISE_META_LINKS) \ + $(EXERCISE_YS_INSTALLERS) \ config.json \ SHELL_FILES := \ @@ -149,18 +163,31 @@ clean: realclean: clean $(RM) $(CFGLET) $(RM) $(SHELLCHECK) - $(RM) $(BIN)/ys* - $(RM) -r $(CLOJURE_REPO) $(PROBLEM_REPO) + $(RM) -r $(CLOJURE_REPO) $(PROBLEM_REPO) $(YS_LOCAL) reset: git checkout -- config.* git status -- exercises | grep exercises | xargs rm -fr -exercises/practice/%/Makefile: common/exercise.mk +exercises/practice/%/GNUmakefile: common/exercise.mk + cp -p $< $@ + +exercises/practice/%/GNUmakefile: common/makefile.mk + cp -p $< $@ + +exercises/practice/%/.yamlscript/exercise.mk: common/exercise-extra.mk + mkdir -p $$(dirname $@) cp -p $< $@ -$(EXERCISE_META_LINKS): - ( d=$$(dirname $@); f=$$(basename $@); cd $$d && ln -fs ../$$f ) +exercises/practice/%/.meta/Makefile: common/exercise-meta.mk + cp -p $< $@ + +exercises/practice/%/.meta/.yamlscript/exercise.mk: ../../.yamlscript/exercise.mk + ln -fs $@ $< + +exercises/practice/%/.yamlscript/exercism-ys-installer: common/exercism-ys-installer + mkdir -p $$(dirname $@) + cp -p $< $@ %.json: %.yaml $(YS) Makefile @@ -175,13 +202,15 @@ $(CLOJURE_REPO): $(CFGLET): $(BIN)/fetch-configlet + +ifdef EXERCISM_YAMLSCRIPT_GHA # Dummy rule for GHA -ys shellcheck: +$(YS) shellcheck: -ifndef EXERCISM_YAMLSCRIPT_GHA -bin/ys: +else +$(YS): curl -s https://yamlscript.org/install | \ - PREFIX=$(ROOT) BIN=1 bash + BIN=1 PREFIX=$(YS_LOCAL_PREFIX) VERSION=$(YS_VERSION) bash ifeq (,$(wildcard $(SHELLCHECK))) bin/shellcheck: $(SHELLCHECK_DIR) diff --git a/common/exercise-extra.mk b/common/exercise-extra.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/common/exercise-extra.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/common/exercise-meta.mk b/common/exercise-meta.mk new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/common/exercise-meta.mk @@ -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) diff --git a/common/exercise.mk b/common/exercise.mk index a12ebc6..ef378a9 100644 --- a/common/exercise.mk +++ b/common/exercise.mk @@ -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 diff --git a/common/exercism-ys-installer b/common/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/common/exercism-ys-installer @@ -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 "$@" diff --git a/common/makefile.mk b/common/makefile.mk new file mode 100644 index 0000000..06b6f00 --- /dev/null +++ b/common/makefile.mk @@ -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 diff --git a/config.json b/config.json index 169d76d..5969281 100644 --- a/config.json +++ b/config.json @@ -20,7 +20,10 @@ ], "test": [ "%{kebab_slug}-test.ys", - "Makefile" + "GNUmakefile", + "Makefile", + ".yamlscript/exercise.mk", + ".yamlscript/exercism-ys-installer" ], "example": [ ".meta/%{kebab_slug}.ys" diff --git a/config.yaml b/config.yaml index d8f3691..1fe9bfe 100644 --- a/config.yaml +++ b/config.yaml @@ -32,7 +32,10 @@ files: - '%{kebab_slug}.ys' test: - '%{kebab_slug}-test.ys' + - GNUmakefile - Makefile + - .yamlscript/exercise.mk + - .yamlscript/exercism-ys-installer example: - .meta/%{kebab_slug}.ys diff --git a/exercises/practice/acronym/.meta/.yamlscript/exercise.mk b/exercises/practice/acronym/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/acronym/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/acronym/.meta/Makefile b/exercises/practice/acronym/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/acronym/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/acronym/.meta/Makefile b/exercises/practice/acronym/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/acronym/.meta/Makefile @@ -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) diff --git a/exercises/practice/acronym/.yamlscript/exercise.mk b/exercises/practice/acronym/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/acronym/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/acronym/.yamlscript/exercism-ys-installer b/exercises/practice/acronym/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/acronym/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/acronym/GNUmakefile b/exercises/practice/acronym/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/acronym/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/all-your-base/.meta/.yamlscript/exercise.mk b/exercises/practice/all-your-base/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/all-your-base/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/all-your-base/.meta/Makefile b/exercises/practice/all-your-base/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/all-your-base/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/all-your-base/.meta/Makefile b/exercises/practice/all-your-base/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/all-your-base/.meta/Makefile @@ -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) diff --git a/exercises/practice/all-your-base/.yamlscript/exercise.mk b/exercises/practice/all-your-base/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/all-your-base/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/all-your-base/.yamlscript/exercism-ys-installer b/exercises/practice/all-your-base/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/all-your-base/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/all-your-base/GNUmakefile b/exercises/practice/all-your-base/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/all-your-base/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/allergies/.meta/.yamlscript/exercise.mk b/exercises/practice/allergies/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/allergies/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/allergies/.meta/Makefile b/exercises/practice/allergies/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/allergies/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/allergies/.meta/Makefile b/exercises/practice/allergies/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/allergies/.meta/Makefile @@ -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) diff --git a/exercises/practice/allergies/.yamlscript/exercise.mk b/exercises/practice/allergies/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/allergies/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/allergies/.yamlscript/exercism-ys-installer b/exercises/practice/allergies/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/allergies/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/allergies/GNUmakefile b/exercises/practice/allergies/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/allergies/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/anagram/.meta/.yamlscript/exercise.mk b/exercises/practice/anagram/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/anagram/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/anagram/.meta/Makefile b/exercises/practice/anagram/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/anagram/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/anagram/.meta/Makefile b/exercises/practice/anagram/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/anagram/.meta/Makefile @@ -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) diff --git a/exercises/practice/anagram/.yamlscript/exercise.mk b/exercises/practice/anagram/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/anagram/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/anagram/.yamlscript/exercism-ys-installer b/exercises/practice/anagram/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/anagram/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/anagram/GNUmakefile b/exercises/practice/anagram/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/anagram/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/atbash-cipher/.meta/.yamlscript/exercise.mk b/exercises/practice/atbash-cipher/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/atbash-cipher/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/atbash-cipher/.meta/Makefile b/exercises/practice/atbash-cipher/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/atbash-cipher/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/atbash-cipher/.meta/Makefile b/exercises/practice/atbash-cipher/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/atbash-cipher/.meta/Makefile @@ -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) diff --git a/exercises/practice/atbash-cipher/.yamlscript/exercise.mk b/exercises/practice/atbash-cipher/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/atbash-cipher/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/atbash-cipher/.yamlscript/exercism-ys-installer b/exercises/practice/atbash-cipher/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/atbash-cipher/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/atbash-cipher/GNUmakefile b/exercises/practice/atbash-cipher/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/atbash-cipher/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/bank-account/.meta/.yamlscript/exercise.mk b/exercises/practice/bank-account/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/bank-account/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/bank-account/.meta/Makefile b/exercises/practice/bank-account/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/bank-account/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/bank-account/.meta/Makefile b/exercises/practice/bank-account/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/bank-account/.meta/Makefile @@ -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) diff --git a/exercises/practice/bank-account/.yamlscript/exercise.mk b/exercises/practice/bank-account/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/bank-account/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/bank-account/.yamlscript/exercism-ys-installer b/exercises/practice/bank-account/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/bank-account/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/bank-account/GNUmakefile b/exercises/practice/bank-account/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/bank-account/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/binary-search/.meta/.yamlscript/exercise.mk b/exercises/practice/binary-search/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/binary-search/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/binary-search/.meta/Makefile b/exercises/practice/binary-search/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/binary-search/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/binary-search/.meta/Makefile b/exercises/practice/binary-search/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/binary-search/.meta/Makefile @@ -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) diff --git a/exercises/practice/binary-search/.yamlscript/exercise.mk b/exercises/practice/binary-search/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/binary-search/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/binary-search/.yamlscript/exercism-ys-installer b/exercises/practice/binary-search/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/binary-search/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/binary-search/GNUmakefile b/exercises/practice/binary-search/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/binary-search/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/bob/.meta/.yamlscript/exercise.mk b/exercises/practice/bob/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/bob/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/bob/.meta/Makefile b/exercises/practice/bob/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/bob/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/bob/.meta/Makefile b/exercises/practice/bob/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/bob/.meta/Makefile @@ -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) diff --git a/exercises/practice/bob/.yamlscript/exercise.mk b/exercises/practice/bob/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/bob/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/bob/.yamlscript/exercism-ys-installer b/exercises/practice/bob/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/bob/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/bob/GNUmakefile b/exercises/practice/bob/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/bob/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/bottle-song/.meta/.yamlscript/exercise.mk b/exercises/practice/bottle-song/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/bottle-song/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/bottle-song/.meta/Makefile b/exercises/practice/bottle-song/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/bottle-song/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/bottle-song/.meta/Makefile b/exercises/practice/bottle-song/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/bottle-song/.meta/Makefile @@ -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) diff --git a/exercises/practice/bottle-song/.yamlscript/exercise.mk b/exercises/practice/bottle-song/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/bottle-song/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/bottle-song/.yamlscript/exercism-ys-installer b/exercises/practice/bottle-song/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/bottle-song/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/bottle-song/GNUmakefile b/exercises/practice/bottle-song/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/bottle-song/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/darts/.meta/.yamlscript/exercise.mk b/exercises/practice/darts/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/darts/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/darts/.meta/Makefile b/exercises/practice/darts/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/darts/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/darts/.meta/Makefile b/exercises/practice/darts/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/darts/.meta/Makefile @@ -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) diff --git a/exercises/practice/darts/.yamlscript/exercise.mk b/exercises/practice/darts/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/darts/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/darts/.yamlscript/exercism-ys-installer b/exercises/practice/darts/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/darts/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/darts/GNUmakefile b/exercises/practice/darts/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/darts/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/difference-of-squares/.meta/.yamlscript/exercise.mk b/exercises/practice/difference-of-squares/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/difference-of-squares/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/difference-of-squares/.meta/Makefile b/exercises/practice/difference-of-squares/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/difference-of-squares/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/difference-of-squares/.meta/Makefile b/exercises/practice/difference-of-squares/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/difference-of-squares/.meta/Makefile @@ -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) diff --git a/exercises/practice/difference-of-squares/.yamlscript/exercise.mk b/exercises/practice/difference-of-squares/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/difference-of-squares/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/difference-of-squares/.yamlscript/exercism-ys-installer b/exercises/practice/difference-of-squares/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/difference-of-squares/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/difference-of-squares/GNUmakefile b/exercises/practice/difference-of-squares/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/difference-of-squares/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/etl/.meta/.yamlscript/exercise.mk b/exercises/practice/etl/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/etl/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/etl/.meta/Makefile b/exercises/practice/etl/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/etl/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/etl/.meta/Makefile b/exercises/practice/etl/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/etl/.meta/Makefile @@ -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) diff --git a/exercises/practice/etl/.yamlscript/exercise.mk b/exercises/practice/etl/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/etl/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/etl/.yamlscript/exercism-ys-installer b/exercises/practice/etl/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/etl/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/etl/GNUmakefile b/exercises/practice/etl/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/etl/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/hamming/.meta/.yamlscript/exercise.mk b/exercises/practice/hamming/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/hamming/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/hamming/.meta/Makefile b/exercises/practice/hamming/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/hamming/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/hamming/.meta/Makefile b/exercises/practice/hamming/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/hamming/.meta/Makefile @@ -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) diff --git a/exercises/practice/hamming/.yamlscript/exercise.mk b/exercises/practice/hamming/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/hamming/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/hamming/.yamlscript/exercism-ys-installer b/exercises/practice/hamming/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/hamming/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/hamming/GNUmakefile b/exercises/practice/hamming/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/hamming/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/hello-world/.meta/.yamlscript/exercise.mk b/exercises/practice/hello-world/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/hello-world/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/hello-world/.meta/Makefile b/exercises/practice/hello-world/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/hello-world/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/hello-world/.meta/Makefile b/exercises/practice/hello-world/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/hello-world/.meta/Makefile @@ -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) diff --git a/exercises/practice/hello-world/.yamlscript/exercise.mk b/exercises/practice/hello-world/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/hello-world/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/hello-world/.yamlscript/exercism-ys-installer b/exercises/practice/hello-world/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/hello-world/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/hello-world/GNUmakefile b/exercises/practice/hello-world/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/hello-world/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/isogram/.meta/.yamlscript/exercise.mk b/exercises/practice/isogram/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/isogram/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/isogram/.meta/Makefile b/exercises/practice/isogram/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/isogram/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/isogram/.meta/Makefile b/exercises/practice/isogram/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/isogram/.meta/Makefile @@ -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) diff --git a/exercises/practice/isogram/.yamlscript/exercise.mk b/exercises/practice/isogram/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/isogram/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/isogram/.yamlscript/exercism-ys-installer b/exercises/practice/isogram/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/isogram/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/isogram/GNUmakefile b/exercises/practice/isogram/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/isogram/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/largest-series-product/.meta/.yamlscript/exercise.mk b/exercises/practice/largest-series-product/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/largest-series-product/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/largest-series-product/.meta/Makefile b/exercises/practice/largest-series-product/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/largest-series-product/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/largest-series-product/.meta/Makefile b/exercises/practice/largest-series-product/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/largest-series-product/.meta/Makefile @@ -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) diff --git a/exercises/practice/largest-series-product/.yamlscript/exercise.mk b/exercises/practice/largest-series-product/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/largest-series-product/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/largest-series-product/.yamlscript/exercism-ys-installer b/exercises/practice/largest-series-product/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/largest-series-product/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/largest-series-product/GNUmakefile b/exercises/practice/largest-series-product/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/largest-series-product/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/leap/.meta/.yamlscript/exercise.mk b/exercises/practice/leap/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/leap/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/leap/.meta/Makefile b/exercises/practice/leap/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/leap/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/leap/.meta/Makefile b/exercises/practice/leap/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/leap/.meta/Makefile @@ -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) diff --git a/exercises/practice/leap/.yamlscript/exercise.mk b/exercises/practice/leap/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/leap/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/leap/.yamlscript/exercism-ys-installer b/exercises/practice/leap/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/leap/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/leap/GNUmakefile b/exercises/practice/leap/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/leap/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/luhn/.meta/.yamlscript/exercise.mk b/exercises/practice/luhn/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/luhn/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/luhn/.meta/Makefile b/exercises/practice/luhn/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/luhn/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/luhn/.meta/Makefile b/exercises/practice/luhn/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/luhn/.meta/Makefile @@ -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) diff --git a/exercises/practice/luhn/.yamlscript/exercise.mk b/exercises/practice/luhn/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/luhn/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/luhn/.yamlscript/exercism-ys-installer b/exercises/practice/luhn/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/luhn/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/luhn/GNUmakefile b/exercises/practice/luhn/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/luhn/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/matching-brackets/.meta/.yamlscript/exercise.mk b/exercises/practice/matching-brackets/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/matching-brackets/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/matching-brackets/.meta/Makefile b/exercises/practice/matching-brackets/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/matching-brackets/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/matching-brackets/.meta/Makefile b/exercises/practice/matching-brackets/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/matching-brackets/.meta/Makefile @@ -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) diff --git a/exercises/practice/matching-brackets/.yamlscript/exercise.mk b/exercises/practice/matching-brackets/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/matching-brackets/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/matching-brackets/.yamlscript/exercism-ys-installer b/exercises/practice/matching-brackets/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/matching-brackets/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/matching-brackets/GNUmakefile b/exercises/practice/matching-brackets/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/matching-brackets/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/minesweeper/.meta/.yamlscript/exercise.mk b/exercises/practice/minesweeper/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/minesweeper/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/minesweeper/.meta/Makefile b/exercises/practice/minesweeper/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/minesweeper/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/minesweeper/.meta/Makefile b/exercises/practice/minesweeper/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/minesweeper/.meta/Makefile @@ -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) diff --git a/exercises/practice/minesweeper/.yamlscript/exercise.mk b/exercises/practice/minesweeper/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/minesweeper/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/minesweeper/.yamlscript/exercism-ys-installer b/exercises/practice/minesweeper/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/minesweeper/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/minesweeper/GNUmakefile b/exercises/practice/minesweeper/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/minesweeper/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/nth-prime/.meta/.yamlscript/exercise.mk b/exercises/practice/nth-prime/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/nth-prime/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/nth-prime/.meta/Makefile b/exercises/practice/nth-prime/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/nth-prime/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/nth-prime/.meta/Makefile b/exercises/practice/nth-prime/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/nth-prime/.meta/Makefile @@ -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) diff --git a/exercises/practice/nth-prime/.yamlscript/exercise.mk b/exercises/practice/nth-prime/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/nth-prime/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/nth-prime/.yamlscript/exercism-ys-installer b/exercises/practice/nth-prime/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/nth-prime/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/nth-prime/GNUmakefile b/exercises/practice/nth-prime/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/nth-prime/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/nucleotide-count/.meta/.yamlscript/exercise.mk b/exercises/practice/nucleotide-count/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/nucleotide-count/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/nucleotide-count/.meta/Makefile b/exercises/practice/nucleotide-count/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/nucleotide-count/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/nucleotide-count/.meta/Makefile b/exercises/practice/nucleotide-count/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/nucleotide-count/.meta/Makefile @@ -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) diff --git a/exercises/practice/nucleotide-count/.yamlscript/exercise.mk b/exercises/practice/nucleotide-count/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/nucleotide-count/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/nucleotide-count/.yamlscript/exercism-ys-installer b/exercises/practice/nucleotide-count/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/nucleotide-count/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/nucleotide-count/GNUmakefile b/exercises/practice/nucleotide-count/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/nucleotide-count/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/pangram/.meta/.yamlscript/exercise.mk b/exercises/practice/pangram/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/pangram/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/pangram/.meta/Makefile b/exercises/practice/pangram/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/pangram/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/pangram/.meta/Makefile b/exercises/practice/pangram/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/pangram/.meta/Makefile @@ -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) diff --git a/exercises/practice/pangram/.yamlscript/exercise.mk b/exercises/practice/pangram/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/pangram/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/pangram/.yamlscript/exercism-ys-installer b/exercises/practice/pangram/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/pangram/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/pangram/GNUmakefile b/exercises/practice/pangram/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/pangram/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/perfect-numbers/.meta/.yamlscript/exercise.mk b/exercises/practice/perfect-numbers/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/perfect-numbers/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/perfect-numbers/.meta/Makefile b/exercises/practice/perfect-numbers/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/perfect-numbers/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/perfect-numbers/.meta/Makefile b/exercises/practice/perfect-numbers/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/perfect-numbers/.meta/Makefile @@ -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) diff --git a/exercises/practice/perfect-numbers/.yamlscript/exercise.mk b/exercises/practice/perfect-numbers/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/perfect-numbers/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/perfect-numbers/.yamlscript/exercism-ys-installer b/exercises/practice/perfect-numbers/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/perfect-numbers/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/perfect-numbers/GNUmakefile b/exercises/practice/perfect-numbers/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/perfect-numbers/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/phone-number/.meta/.yamlscript/exercise.mk b/exercises/practice/phone-number/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/phone-number/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/phone-number/.meta/Makefile b/exercises/practice/phone-number/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/phone-number/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/phone-number/.meta/Makefile b/exercises/practice/phone-number/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/phone-number/.meta/Makefile @@ -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) diff --git a/exercises/practice/phone-number/.yamlscript/exercise.mk b/exercises/practice/phone-number/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/phone-number/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/phone-number/.yamlscript/exercism-ys-installer b/exercises/practice/phone-number/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/phone-number/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/phone-number/GNUmakefile b/exercises/practice/phone-number/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/phone-number/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/protein-translation/.meta/.yamlscript/exercise.mk b/exercises/practice/protein-translation/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/protein-translation/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/protein-translation/.meta/Makefile b/exercises/practice/protein-translation/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/protein-translation/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/protein-translation/.meta/Makefile b/exercises/practice/protein-translation/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/protein-translation/.meta/Makefile @@ -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) diff --git a/exercises/practice/protein-translation/.yamlscript/exercise.mk b/exercises/practice/protein-translation/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/protein-translation/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/protein-translation/.yamlscript/exercism-ys-installer b/exercises/practice/protein-translation/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/protein-translation/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/protein-translation/GNUmakefile b/exercises/practice/protein-translation/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/protein-translation/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/queen-attack/.meta/.yamlscript/exercise.mk b/exercises/practice/queen-attack/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/queen-attack/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/queen-attack/.meta/Makefile b/exercises/practice/queen-attack/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/queen-attack/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/queen-attack/.meta/Makefile b/exercises/practice/queen-attack/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/queen-attack/.meta/Makefile @@ -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) diff --git a/exercises/practice/queen-attack/.yamlscript/exercise.mk b/exercises/practice/queen-attack/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/queen-attack/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/queen-attack/.yamlscript/exercism-ys-installer b/exercises/practice/queen-attack/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/queen-attack/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/queen-attack/GNUmakefile b/exercises/practice/queen-attack/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/queen-attack/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/raindrops/.meta/.yamlscript/exercise.mk b/exercises/practice/raindrops/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/raindrops/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/raindrops/.meta/Makefile b/exercises/practice/raindrops/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/raindrops/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/raindrops/.meta/Makefile b/exercises/practice/raindrops/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/raindrops/.meta/Makefile @@ -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) diff --git a/exercises/practice/raindrops/.yamlscript/exercise.mk b/exercises/practice/raindrops/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/raindrops/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/raindrops/.yamlscript/exercism-ys-installer b/exercises/practice/raindrops/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/raindrops/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/raindrops/GNUmakefile b/exercises/practice/raindrops/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/raindrops/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/reverse-string/.meta/.yamlscript/exercise.mk b/exercises/practice/reverse-string/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/reverse-string/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/reverse-string/.meta/Makefile b/exercises/practice/reverse-string/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/reverse-string/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/reverse-string/.meta/Makefile b/exercises/practice/reverse-string/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/reverse-string/.meta/Makefile @@ -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) diff --git a/exercises/practice/reverse-string/.yamlscript/exercise.mk b/exercises/practice/reverse-string/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/reverse-string/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/reverse-string/.yamlscript/exercism-ys-installer b/exercises/practice/reverse-string/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/reverse-string/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/reverse-string/GNUmakefile b/exercises/practice/reverse-string/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/reverse-string/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/rna-transcription/.meta/.yamlscript/exercise.mk b/exercises/practice/rna-transcription/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/rna-transcription/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/rna-transcription/.meta/Makefile b/exercises/practice/rna-transcription/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/rna-transcription/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/rna-transcription/.meta/Makefile b/exercises/practice/rna-transcription/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/rna-transcription/.meta/Makefile @@ -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) diff --git a/exercises/practice/rna-transcription/.yamlscript/exercise.mk b/exercises/practice/rna-transcription/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/rna-transcription/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/rna-transcription/.yamlscript/exercism-ys-installer b/exercises/practice/rna-transcription/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/rna-transcription/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/rna-transcription/GNUmakefile b/exercises/practice/rna-transcription/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/rna-transcription/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/robot-simulator/.meta/.yamlscript/exercise.mk b/exercises/practice/robot-simulator/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/robot-simulator/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/robot-simulator/.meta/Makefile b/exercises/practice/robot-simulator/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/robot-simulator/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/robot-simulator/.meta/Makefile b/exercises/practice/robot-simulator/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/robot-simulator/.meta/Makefile @@ -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) diff --git a/exercises/practice/robot-simulator/.yamlscript/exercise.mk b/exercises/practice/robot-simulator/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/robot-simulator/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/robot-simulator/.yamlscript/exercism-ys-installer b/exercises/practice/robot-simulator/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/robot-simulator/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/robot-simulator/GNUmakefile b/exercises/practice/robot-simulator/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/robot-simulator/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/roman-numerals/.meta/.yamlscript/exercise.mk b/exercises/practice/roman-numerals/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/roman-numerals/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/roman-numerals/.meta/Makefile b/exercises/practice/roman-numerals/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/roman-numerals/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/roman-numerals/.meta/Makefile b/exercises/practice/roman-numerals/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/roman-numerals/.meta/Makefile @@ -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) diff --git a/exercises/practice/roman-numerals/.yamlscript/exercise.mk b/exercises/practice/roman-numerals/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/roman-numerals/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/roman-numerals/.yamlscript/exercism-ys-installer b/exercises/practice/roman-numerals/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/roman-numerals/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/roman-numerals/GNUmakefile b/exercises/practice/roman-numerals/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/roman-numerals/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/rotational-cipher/.meta/.yamlscript/exercise.mk b/exercises/practice/rotational-cipher/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/rotational-cipher/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/rotational-cipher/.meta/Makefile b/exercises/practice/rotational-cipher/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/rotational-cipher/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/rotational-cipher/.meta/Makefile b/exercises/practice/rotational-cipher/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/rotational-cipher/.meta/Makefile @@ -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) diff --git a/exercises/practice/rotational-cipher/.yamlscript/exercise.mk b/exercises/practice/rotational-cipher/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/rotational-cipher/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/rotational-cipher/.yamlscript/exercism-ys-installer b/exercises/practice/rotational-cipher/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/rotational-cipher/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/rotational-cipher/GNUmakefile b/exercises/practice/rotational-cipher/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/rotational-cipher/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/run-length-encoding/.meta/.yamlscript/exercise.mk b/exercises/practice/run-length-encoding/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/run-length-encoding/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/run-length-encoding/.meta/Makefile b/exercises/practice/run-length-encoding/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/run-length-encoding/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/run-length-encoding/.meta/Makefile b/exercises/practice/run-length-encoding/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/run-length-encoding/.meta/Makefile @@ -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) diff --git a/exercises/practice/run-length-encoding/.yamlscript/exercise.mk b/exercises/practice/run-length-encoding/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/run-length-encoding/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/run-length-encoding/.yamlscript/exercism-ys-installer b/exercises/practice/run-length-encoding/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/run-length-encoding/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/run-length-encoding/GNUmakefile b/exercises/practice/run-length-encoding/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/run-length-encoding/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/scrabble-score/.meta/.yamlscript/exercise.mk b/exercises/practice/scrabble-score/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/scrabble-score/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/scrabble-score/.meta/Makefile b/exercises/practice/scrabble-score/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/scrabble-score/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/scrabble-score/.meta/Makefile b/exercises/practice/scrabble-score/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/scrabble-score/.meta/Makefile @@ -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) diff --git a/exercises/practice/scrabble-score/.yamlscript/exercise.mk b/exercises/practice/scrabble-score/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/scrabble-score/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/scrabble-score/.yamlscript/exercism-ys-installer b/exercises/practice/scrabble-score/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/scrabble-score/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/scrabble-score/GNUmakefile b/exercises/practice/scrabble-score/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/scrabble-score/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/secret-handshake/.meta/.yamlscript/exercise.mk b/exercises/practice/secret-handshake/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/secret-handshake/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/secret-handshake/.meta/Makefile b/exercises/practice/secret-handshake/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/secret-handshake/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/secret-handshake/.meta/Makefile b/exercises/practice/secret-handshake/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/secret-handshake/.meta/Makefile @@ -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) diff --git a/exercises/practice/secret-handshake/.yamlscript/exercise.mk b/exercises/practice/secret-handshake/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/secret-handshake/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/secret-handshake/.yamlscript/exercism-ys-installer b/exercises/practice/secret-handshake/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/secret-handshake/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/secret-handshake/GNUmakefile b/exercises/practice/secret-handshake/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/secret-handshake/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/space-age/.meta/.yamlscript/exercise.mk b/exercises/practice/space-age/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/space-age/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/space-age/.meta/Makefile b/exercises/practice/space-age/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/space-age/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/space-age/.meta/Makefile b/exercises/practice/space-age/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/space-age/.meta/Makefile @@ -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) diff --git a/exercises/practice/space-age/.yamlscript/exercise.mk b/exercises/practice/space-age/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/space-age/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/space-age/.yamlscript/exercism-ys-installer b/exercises/practice/space-age/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/space-age/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/space-age/GNUmakefile b/exercises/practice/space-age/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/space-age/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/sum-of-multiples/.meta/.yamlscript/exercise.mk b/exercises/practice/sum-of-multiples/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/sum-of-multiples/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/sum-of-multiples/.meta/Makefile b/exercises/practice/sum-of-multiples/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/sum-of-multiples/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/sum-of-multiples/.meta/Makefile b/exercises/practice/sum-of-multiples/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/sum-of-multiples/.meta/Makefile @@ -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) diff --git a/exercises/practice/sum-of-multiples/.yamlscript/exercise.mk b/exercises/practice/sum-of-multiples/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/sum-of-multiples/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/sum-of-multiples/.yamlscript/exercism-ys-installer b/exercises/practice/sum-of-multiples/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/sum-of-multiples/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/sum-of-multiples/GNUmakefile b/exercises/practice/sum-of-multiples/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/sum-of-multiples/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/triangle/.meta/.yamlscript/exercise.mk b/exercises/practice/triangle/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/triangle/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/triangle/.meta/Makefile b/exercises/practice/triangle/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/triangle/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/triangle/.meta/Makefile b/exercises/practice/triangle/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/triangle/.meta/Makefile @@ -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) diff --git a/exercises/practice/triangle/.yamlscript/exercise.mk b/exercises/practice/triangle/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/triangle/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/triangle/.yamlscript/exercism-ys-installer b/exercises/practice/triangle/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/triangle/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/triangle/GNUmakefile b/exercises/practice/triangle/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/triangle/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/two-fer/.meta/.yamlscript/exercise.mk b/exercises/practice/two-fer/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/two-fer/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/two-fer/.meta/Makefile b/exercises/practice/two-fer/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/two-fer/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/two-fer/.meta/Makefile b/exercises/practice/two-fer/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/two-fer/.meta/Makefile @@ -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) diff --git a/exercises/practice/two-fer/.yamlscript/exercise.mk b/exercises/practice/two-fer/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/two-fer/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/two-fer/.yamlscript/exercism-ys-installer b/exercises/practice/two-fer/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/two-fer/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/two-fer/GNUmakefile b/exercises/practice/two-fer/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/two-fer/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/word-count/.meta/.yamlscript/exercise.mk b/exercises/practice/word-count/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/word-count/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/word-count/.meta/Makefile b/exercises/practice/word-count/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/word-count/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/word-count/.meta/Makefile b/exercises/practice/word-count/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/word-count/.meta/Makefile @@ -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) diff --git a/exercises/practice/word-count/.yamlscript/exercise.mk b/exercises/practice/word-count/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/word-count/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/word-count/.yamlscript/exercism-ys-installer b/exercises/practice/word-count/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/word-count/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/word-count/GNUmakefile b/exercises/practice/word-count/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/word-count/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/exercises/practice/yacht/.meta/.yamlscript/exercise.mk b/exercises/practice/yacht/.meta/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/yacht/.meta/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/yacht/.meta/Makefile b/exercises/practice/yacht/.meta/Makefile deleted file mode 120000 index d0b0e8e..0000000 --- a/exercises/practice/yacht/.meta/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/exercises/practice/yacht/.meta/Makefile b/exercises/practice/yacht/.meta/Makefile new file mode 100644 index 0000000..1a2e50e --- /dev/null +++ b/exercises/practice/yacht/.meta/Makefile @@ -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) diff --git a/exercises/practice/yacht/.yamlscript/exercise.mk b/exercises/practice/yacht/.yamlscript/exercise.mk new file mode 100644 index 0000000..f2af7ab --- /dev/null +++ b/exercises/practice/yacht/.yamlscript/exercise.mk @@ -0,0 +1 @@ +YS_VERSION := 0.1.74 diff --git a/exercises/practice/yacht/.yamlscript/exercism-ys-installer b/exercises/practice/yacht/.yamlscript/exercism-ys-installer new file mode 100644 index 0000000..02081b9 --- /dev/null +++ b/exercises/practice/yacht/.yamlscript/exercism-ys-installer @@ -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 "$@" diff --git a/exercises/practice/yacht/GNUmakefile b/exercises/practice/yacht/GNUmakefile new file mode 100644 index 0000000..ef378a9 --- /dev/null +++ b/exercises/practice/yacht/GNUmakefile @@ -0,0 +1,55 @@ +SHELL := bash + +BASE := $(shell pwd) + +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 + +export install_msg diff --git a/src b/src deleted file mode 120000 index ea52621..0000000 --- a/src +++ /dev/null @@ -1 +0,0 @@ -exercises/practice \ No newline at end of file