Commit 67fd10c2 by Cuong Tran

Add an option to exclude timestamp in routes, #136

parent ecbd5fa6
......@@ -179,6 +179,7 @@ you can do so with a simple environment variable, instead of editing the
--format
--force Force new annotations even if there are no changes.
--trace If unable to annotate a file, print the full stack trace, not just the exception message.
--no-timestamp Do not include an updated time in routes
== Sorting
......
......@@ -132,6 +132,10 @@ OptionParser.new do |opts|
ENV['force'] = 'yes'
end
opts.on('--no-timestamp', 'Exclude timestamp in (routes) annotation') do
ENV['no_timestamp'] = 'true'
end
opts.on('--trace', 'If unable to annotate a file, print the full stack trace, not just the exception message.') do |value|
ENV['trace'] = 'yes'
end
......
......@@ -22,7 +22,7 @@ module Annotate
FLAG_OPTIONS=[
:show_indexes, :simple_indexes, :include_version, :exclude_tests,
:exclude_fixtures, :exclude_factories, :ignore_model_sub_dir,
:format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
:format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace, :no_timestamp
]
OTHER_OPTIONS=[
:model_dir, :ignore_columns
......
......@@ -33,7 +33,7 @@ module AnnotateRoutes
routes_map.shift if(routes_map.first =~ /^\(in \//)
header = [
"#{PREFIX} (Updated #{Time.now.strftime("%Y-%m-%d %H:%M")})",
"#{PREFIX}" + (options[:no_timestamp] ? "" : " (Updated #{Time.now.strftime("%Y-%m-%d %H:%M")})"),
"#"
] + routes_map.map { |line| "# #{line}".rstrip }
......
......@@ -57,6 +57,12 @@ describe AnnotateRoutes do
AnnotateRoutes.do_annotations
end
it "should not add a timestamp when :no-timestamp is passed" do
File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo\n")
@mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map\n#\n# another good line\n# good line\n/)
AnnotateRoutes.do_annotations :no_timestamp => true
end
end
describe "When Removing Annotation" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment