From 44d4c7d308f7bf10d430f4b8ddff2fef4b70a8ae Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sun, 26 May 2013 19:38:50 +0400 Subject: [PATCH] #37 Pick config from .spin file --- README.md | 13 +++++++++++++ lib/spin/cli.rb | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 373afba..ce0cf37 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,19 @@ spin serve -Itest Send a SIGQUIT to spin serve (`Ctrl+\`) if you want to re-run the last files that were ran via `spin push [files]`. +### With config file + +Like in RSpec, Spin automaticly fetches `.spin` file from home and current directories (current dir is prioritized). + +For example, if you create `~/.spin` with this content: + +``` +--push-results +--time +``` + +These options will be automaticly applied when you start the spin. + ### With Kicker As mentioned, this tool works best with an autotest(ish) workflow. I haven't actually used with with `autotest` itself, but it works great with [kicker](http://github.com/alloy/kicker). Here's the suggested workflow for a Rails app: diff --git a/lib/spin/cli.rb b/lib/spin/cli.rb index 0822655..529079f 100644 --- a/lib/spin/cli.rb +++ b/lib/spin/cli.rb @@ -3,6 +3,8 @@ module Spin module CLI + SPIN_CONFIG_FILE = ".spin" + class << self def run(argv) options = { @@ -35,7 +37,9 @@ def run(argv) options[:trailing_pushed_args] = trailing_pushed_args end end - parser.parse! + + argvs = (parser.default_argv + global_argvs).uniq + parser.parse!(argvs) subcommand = argv.shift case subcommand @@ -58,6 +62,17 @@ def usage Spin preloads your Rails environment to speed up your autotest(ish) workflow. USAGE end + + def global_argvs + [Dir.pwd, Dir.home].each do |path| + config_path = File.join(path, SPIN_CONFIG_FILE) + if File.exists?(config_path) + return File.read(config_path).split("\n").compact.reject(&:empty?) + end + end + + [] + end end end end