Permalink
Browse files

Minor whitespace / formatting / documentation / dead code tidy-ups.

  • Loading branch information...
1 parent 03d8d13 commit 68f459beed247a9fbb4c40ce850d09edb50e3446 @MrJoy MrJoy committed Aug 22, 2012
View
@@ -1,5 +1,12 @@
== 2.5.0
+* Added support for new FactoryGirl naming convention.
+* Fixed that schema kept prepending additional newlines
+* Updates to make annotate smarter about when to touch a model
+* Recognize column+type, and don't change a file unless the column+type
+ combination of the new schema are different than that of the old (i.e., don't
+ regenerate if columns happen to be in a different order. That's just how life
+ is sometimes)
* Works better with Rails 3
* Bugfix: schema kept prepending additional newlines
* Updates to make annotate smarter about when to touch a model
@@ -22,6 +29,7 @@
* Leave magic encoding comment intact
* Fix issue #14 - RuntimeError: Already memoized
* Count a model as 'annotated' if any of its tests/fixtures are annotated
+* Support FactoryGirl
* Support :change migrations (Rails 3.1)
* Allow models with non-standard capitalization
* Widen type column so we can handle longtexts with chopping things off.
View
@@ -49,7 +49,7 @@ Into Gemfile from Github:
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
-Into environment gems From rubygems.org:
+Into environment gems from rubygems.org:
gem install annotate
View
@@ -22,7 +22,7 @@ OptionParser.new do |opts|
ENV['position'] = 'before' # hack: make sure default position is "before"
opts.on('-p', '--position [before|after]', ['before', 'after'],
- "Place the annotations at the top (before) or the bottom (after) of the model file") do |p|
+ "Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory file(s)") do |p|
ENV['position'] = p
end
@@ -67,15 +67,15 @@ OptionParser.new do |opts|
end
opts.on('-R', '--require path',
- "Additional files to require before loading models") do |path|
- if ENV['require']
+ "Additional file to require before loading models, may be used multiple times") do |path|
+ if !ENV['require'].blank?
ENV['require'] = ENV['require'] + ",#{path}"
else
ENV['require'] = path
end
- end\
+ end
- opts.on('-e', '--exclude [tests,fixtures]', Array, "Do not annotate fixtures, test files, or both") do |exclusions|
+ opts.on('-e', '--exclude [tests,fixtures,factories]', ['tests','fixtures','factories'], "Do not annotate fixtures, test files, and/or factories") do |exclusions|
exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
end
@@ -90,8 +90,6 @@ OptionParser.new do |opts|
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
-
-
end.parse!
ENV['is_cli'] = '1'
View
@@ -6,8 +6,7 @@ def self.load_tasks
if File.exists?('Rakefile')
require 'rake'
load 'Rakefile'
- # Rails 3 wants to load our .rake files for us.
- # TODO: selectively do this require on Rails 2.x?
+
Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
return true
else
@@ -6,4 +6,4 @@ def self.method_missing(name, *args)
# ignore this, so unknown/unloaded macros won't cause parsing to fail
end
end
-end
+end
@@ -9,11 +9,10 @@ module AnnotateModels
# File.join for windows reverse bar compat?
# I dont use windows, can`t test
- UNIT_TEST_DIR = File.join("test", "unit" )
+ UNIT_TEST_DIR = File.join("test", "unit")
SPEC_MODEL_DIR = File.join("spec", "models")
FIXTURE_TEST_DIR = File.join("test", "fixtures")
FIXTURE_SPEC_DIR = File.join("spec", "fixtures")
- FIXTURE_DIRS = ["test/fixtures","spec/fixtures"]
# Object Daddy http://github.com/flogic/object_daddy/tree/master
EXEMPLARS_TEST_DIR = File.join("test", "exemplars")
@@ -153,12 +152,9 @@ def get_index_info(klass)
# Returns true or false depending on whether the file was modified.
#
# === Options (opts)
- # :position<Symbol>:: where to place the annotated section in fixture or model file,
- # :before or :after. Default is :before.
- # :position_in_class<Symbol>:: where to place the annotated section in model file
- # :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
- # :position_in_others<Symbol>:: where to place the annotated section in the rest of
- # supported files
+ # :force<Symbol>:: whether to update the file even if it doesn't seem to need it.
+ # :position_in_*<Symbol>:: where to place the annotated section in fixture or model file,
+ # :before or :after. Default is :before.
#
def annotate_one_file(file_name, info_block, options={})
if File.exist?(file_name)
@@ -211,7 +207,9 @@ def annotate_one_file(file_name, info_block, options={})
def remove_annotation_of_file(file_name)
if File.exist?(file_name)
content = File.read(file_name)
+
content.sub!(PATTERN, '')
+
File.open(file_name, "wb") { |f| f.puts content }
end
end
@@ -412,7 +410,7 @@ def remove_annotations(options={})
puts "\t" + e.backtrace.join("\n\t") if options[:trace]
end
end
- puts "Removed annotation from: #{deannotated.join(', ')}"
+ puts "Removed annotations from: #{deannotated.join(', ')}"
end
def find_test_file(dir, file_name)
@@ -5,16 +5,17 @@
#
#
# Prepends the output of "rake routes" to the top of your routes.rb file.
-# Yes, it's simple but I'm thick and often need a reminder of what my routes mean.
+# Yes, it's simple but I'm thick and often need a reminder of what my routes
+# mean.
#
-# Running this task will replace any exising route comment generated by the task.
-# Best to back up your routes file before running:
+# Running this task will replace any exising route comment generated by the
+# task. Best to back up your routes file before running:
#
# Author:
# Gavin Montague
# gavin@leftbrained.co.uk
#
-# Released under the same license as Ruby. No Support. No Warranty.module AnnotateRoutes
+# Released under the same license as Ruby. No Support. No Warranty.
#
module AnnotateRoutes
PREFIX = "#== Route Map"
@@ -11,4 +11,4 @@ def copy_tasks
end
end
-end
+end
@@ -327,7 +327,7 @@ def annotate_one_file options = {}
File.read(@model_file_name).should == "#{@schema_info}#{@file_content}"
end
- it "should annotate before if given :position => :after" do
+ it "should annotate after if given :position => :after" do
annotate_one_file :position => :after
File.read(@model_file_name).should == "#{@file_content}\n#{@schema_info}"
end
@@ -373,7 +373,7 @@ class User < ActiveRecord::Base
}.should_not include("/spec/annotate/annotate_models_spec.rb:")
end
end
-
+
describe "if a file can't be deannotated" do
before do
write_model('user.rb', <<-EOS)
@@ -9,10 +9,6 @@ def mock_file(stubs={})
describe "Annotate Job" do
- before(:each) do
- File.should_receive(:join).with("config", "routes.rb").and_return("config/routes.rb")
- end
-
it "should check if routes.rb exists" do
File.should_receive(:exists?).with("config/routes.rb").and_return(false)
AnnotateRoutes.should_receive(:puts).with("Can`t find routes.rb")

0 comments on commit 68f459b

Please sign in to comment.