Skip to content

#37 Pick config from .spin file #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 16 additions & 1 deletion lib/spin/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

module Spin
module CLI
SPIN_CONFIG_FILE = ".spin"

class << self
def run(argv)
options = {
Expand Down Expand Up @@ -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
Expand All @@ -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