Skip to content
Browse files

Enable --show-indexes option for models

  • Loading branch information...
1 parent dc19187 commit 286b5662dc9cb9d6c9a2113171f13770fe35a52d @ffmike ffmike committed Mar 18, 2012
Showing with 26 additions and 1 deletion.
  1. +6 −0 README.rdoc
  2. +8 −1 lib/guard/annotate.rb
  3. +12 −0 spec/guard/annotate_spec.rb
View
6 README.rdoc
@@ -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]
View
9 lib/guard/annotate.rb
@@ -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
@@ -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?
View
12 spec/guard/annotate_spec.rb
@@ -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

0 comments on commit 286b566

Please sign in to comment.
Something went wrong with that request. Please try again.