Skip to content

Commit

Permalink
Enable --show-indexes option for models
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Gunderloy authored and Mike Gunderloy committed Mar 18, 2012
1 parent dc19187 commit 286b566
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.rdoc
Expand Up @@ -67,6 +67,12 @@ You can disable run at start with (default is true):
...
end

You can annotate indexes on your models with (default is false):

guard 'annotate', :show_indexes => true
...
end

== Development

- Source hosed at {GitHub}[https://github.com/cpjolicoeur/guard-annotate]
Expand Down
9 changes: 8 additions & 1 deletion lib/guard/annotate.rb
Expand Up @@ -15,6 +15,7 @@ def initialize( watchers=[], options={} )
options[:tests] = false if options[:tests].nil?
options[:routes] = false if options[:routes].nil?
options[:run_at_start] = true if options[:run_at_start].nil?
options[:show_indexes] = false if options[:show_indexes].nil?
end

def start
Expand Down Expand Up @@ -55,10 +56,16 @@ def annotate_tests_flags
options[:tests] ? "" : "--exclude tests,fixtures"
end

def show_indexes?
options[:show_indexes]
end

def run_annotate
UI.info 'Running annotate', :reset => true
started_at = Time.now
@result = system("bundle exec annotate #{annotate_tests_flags} -p #{annotation_position}")
annotate_models_command = "bundle exec annotate #{annotate_tests_flags} -p #{annotation_position}"
annotate_models_command += " --show-indexes" if show_indexes?
@result = system(annotate_models_command)
Notifier::notify( @result, Time.now - started_at ) if notify?

if annotate_routes?
Expand Down
12 changes: 12 additions & 0 deletions spec/guard/annotate_spec.rb
Expand Up @@ -70,6 +70,18 @@
subject.start
end
end

describe "indexes" do
it "should not add indexes to annotations by default" do
subject.options[:show_indexes].should be_false
end

it "should allow user to add indexes to annotations if desired" do
subject = Guard::Annotate.new( [], :show_indexes => true )
subject.should_receive(:system).with("bundle exec annotate --exclude tests,fixtures -p before --show-indexes")
subject.start
end
end
end
end

Expand Down

0 comments on commit 286b566

Please sign in to comment.