Skip to content

Commit 918bc42

Browse files
committed
Resolve conflict between generated rakefile and CLI tool.
1 parent 9d52904 commit 918bc42

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

bin/annotate_models

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ OptionParser.new do |opts|
8383

8484
end.parse!
8585

86+
ENV['is_cli'] = '1'
8687
if Annotate.load_tasks
8788
Rake::Task[task].invoke
8889
else

lib/annotate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def self.load_tasks
1818
load 'Rakefile'
1919
# Rails 3 wants to load our .rake files for us.
2020
# TODO: selectively do this require on Rails 2.x?
21-
#Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
21+
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
2222
return true
2323
else
2424
return false

lib/generators/annotate_models/templates/auto_annotate_models.rake

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
33
# NOTE: to have a dev-mode tool do its thing in production.
44
if(Rails.env.development?)
5-
require 'annotate/tasks'
6-
7-
ENV['position_in_class'] = "before"
8-
ENV['position_in_fixture'] = "before"
9-
ENV['position_in_factory'] = "before"
10-
ENV['show_indexes'] = "true"
11-
ENV['include_version'] = "false"
12-
ENV['exclude_tests'] = "false"
13-
ENV['exclude_fixtures'] = "false"
14-
ENV['ignore_model_sub_dir'] = "false"
15-
ENV['skip_on_db_migrate'] = "false"
16-
ENV['format_rdoc'] = "false"
17-
ENV['format_markdown'] = "false"
18-
ENV['no_sort'] = "false"
19-
ENV['force'] = "false"
5+
task :set_annotation_options do
6+
ENV['position_in_class'] = "before"
7+
ENV['position_in_fixture'] = "before"
8+
ENV['position_in_factory'] = "before"
9+
ENV['show_indexes'] = "true"
10+
ENV['include_version'] = "false"
11+
ENV['exclude_tests'] = "false"
12+
ENV['exclude_fixtures'] = "false"
13+
ENV['ignore_model_sub_dir'] = "false"
14+
ENV['skip_on_db_migrate'] = "false"
15+
ENV['format_rdoc'] = "false"
16+
ENV['format_markdown'] = "false"
17+
ENV['no_sort'] = "false"
18+
ENV['force'] = "false"
19+
end
2020
end

lib/tasks/annotate_models.rake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
if(!ENV['is_cli'])
2+
task :set_annotation_options
3+
task :annotate_models => :set_annotation_options
4+
end
5+
16
desc "Add schema information (as comments) to model and fixture files"
27
task :annotate_models => :environment do
38
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'annotate', 'annotate_models'))

0 commit comments

Comments
 (0)