Skip to content

Updates to make annotate smarter about when to touch a model #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion annotate.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Cuong Tran", "Alex Chaffee", "Marcos Piccinini"]
s.date = %q{2009-10-23}
s.default_executable = %q{annotate}
#s.default_executable = %q{annotate}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary for this patch? If not, could you resubmit the patch without this change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_executable is deprecated so the sooner the better

Sent from my iPhone

On Jun 21, 2011, at 2:18 PM, [email protected] wrote:

@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Cuong Tran", "Alex Chaffee", "Marcos Piccinini"]
s.date = %q{2009-10-23}

  • s.default_executable = %q{annotate}
  • #s.default_executable = %q{annotate}

Is this necessary for this patch?

Reply to this email directly or view it on GitHub:
https://github.com/ctran/annotate_models/pull/31/files#r49415

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm so out of date :-)
Will merge the patch.

s.description = %q{Annotates Rails Models, routes, fixtures, and others based on the database schema.}
s.email = ["[email protected]", "[email protected]", "[email protected]"]
s.executables = ["annotate"]
Expand Down
7 changes: 5 additions & 2 deletions lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ def annotate_one_file(file_name, info_block, options={})
old_content = File.read(file_name)

# Ignore the Schema version line because it changes with each migration
header = Regexp.new(/(^# Table name:.*?\n(#.*\n)*\n)/)
header = Regexp.new(/(^# Table name:.*?\n(#.*[\r]?\n)*[\r]?\n)/)
old_header = old_content.match(header).to_s
new_header = info_block.match(header).to_s

if old_header == new_header
old_columns = old_header && old_header.scan(/#[\t\s]+([\w\d]+)[\t\s]+\:([\d\w]+)/).sort
new_columns = new_header && new_header.scan(/#[\t\s]+([\w\d]+)[\t\s]+\:([\d\w]+)/).sort

if old_columns == new_columns
false
else
# Replace the old schema info with the new schema info
Expand Down