# Development tasks. Everything runs through the Ruby that is on PATH — the # library and its test suite have no dependencies beyond the standard library, # so there is nothing to install first. # # make list the targets # make test run the suite with minitest # make lint syntax and warning checks, no files touched # make build build the gem into pkg/ RUBY ?= ruby GEM ?= gem SOURCES = $(shell find lib test -name '*.rb') cepis.gemspec TESTS = $(shell find test -name '*_test.rb') VERSION = $(shell $(RUBY) -Ilib -e 'require "cepis/version"; print Cepis::VERSION') .DEFAULT_GOAL := help .PHONY: help test lint format build check clean help: @echo 'Targets:' @echo ' test run the test suite' @echo ' lint ruby -w -c over the tree, plus rubocop when installed' @echo ' format apply rubocop -A, when installed (writes)' @echo ' build build the gem into pkg/' @echo ' check lint + test + build, in that order' @echo ' clean remove build artefacts' test: @set -e; for f in $(TESTS); do $(RUBY) -Ilib -Itest $$f; done # Read-only by design, so it is safe in CI and in a pre-commit hook. Ruby has # no formatter or linter in the standard library; rubocop is not a dependency # of this gem, so it is used only when it happens to be installed. lint: @set -e; for f in $(SOURCES); do $(RUBY) -w -c $$f >/dev/null; done @echo 'syntax OK: $(words $(SOURCES)) files' $(RUBY) -w -Ilib -e 'require "cepis"' @if command -v rubocop >/dev/null 2>&1; then rubocop; else \ echo 'rubocop not installed: syntax and warning checks only'; fi format: @if command -v rubocop >/dev/null 2>&1; then rubocop -A; else \ echo 'rubocop not installed: nothing to format with'; fi build: @mkdir -p pkg $(GEM) build cepis.gemspec --output pkg/cepis-$(VERSION).gem # The order matters: lint is the fastest to fail, build the slowest, so a # broken run reports the cheapest problem first. check: lint test build clean: rm -rf pkg doc .yardoc