Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
annotate
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
annotate
Commits
4bc53974
Commit
4bc53974
authored
Jun 08, 2012
by
Alex Chaffee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs against Rails 2.3.14
parent
637499db
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
9 deletions
+21
-9
annotate_models.rb
lib/annotate/annotate_models.rb
+6
-1
rails-2.3.gems
spec/integration/rails-2.3.gems
+1
-1
rails-2.3.gems.lock
spec/integration/rails-2.3.gems.lock
+1
-1
rails-3.2.gems
spec/integration/rails-3.2.gems
+1
-1
rails-3.2.gems.lock
spec/integration/rails-3.2.gems.lock
+1
-1
rails_integration_spec.rb
spec/integration/rails_integration_spec.rb
+11
-4
No files found.
lib/annotate/annotate_models.rb
View file @
4bc53974
...
@@ -317,7 +317,10 @@ module AnnotateModels
...
@@ -317,7 +317,10 @@ module AnnotateModels
# Retrieve loaded model class by path to the file where it's supposed to be defined.
# Retrieve loaded model class by path to the file where it's supposed to be defined.
def
get_loaded_model
(
model_path
)
def
get_loaded_model
(
model_path
)
ObjectSpace
.
each_object
.
ObjectSpace
.
each_object
.
select
{
|
c
|
c
.
is_a?
(
Class
)
&&
c
.
ancestors
.
include?
(
ActiveRecord
::
Base
)
}.
select
{
|
c
|
Class
===
c
and
# note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
c
.
ancestors
.
include?
(
ActiveRecord
::
Base
)
}.
detect
{
|
c
|
ActiveSupport
::
Inflector
.
underscore
(
c
)
==
model_path
}
detect
{
|
c
|
ActiveSupport
::
Inflector
.
underscore
(
c
)
==
model_path
}
end
end
...
@@ -357,6 +360,8 @@ module AnnotateModels
...
@@ -357,6 +360,8 @@ module AnnotateModels
rescue
Exception
=>
e
rescue
Exception
=>
e
# todo: check if all backtrace lines are in "gems" -- if so, it's an annotate bug, so print the whole stack trace.
# todo: check if all backtrace lines are in "gems" -- if so, it's an annotate bug, so print the whole stack trace.
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
(
#{
e
.
backtrace
.
first
}
)"
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
(
#{
e
.
backtrace
.
first
}
)"
# todo: save this backtrace somewhere nice
# puts "\t" + e.backtrace.join("\n\t")
end
end
end
end
if
annotated
.
empty?
if
annotated
.
empty?
...
...
spec/integration/rails-2.3.gems
View file @
4bc53974
source :rubygems
source :rubygems
gem "rails", "~>2.3
.14
"
gem "rails", "~>2.3"
gem "sqlite3"
gem "sqlite3"
spec/integration/rails-2.3.gems.lock
View file @
4bc53974
...
@@ -26,5 +26,5 @@ PLATFORMS
...
@@ -26,5 +26,5 @@ PLATFORMS
ruby
ruby
DEPENDENCIES
DEPENDENCIES
rails (~> 2.3
.14
)
rails (~> 2.3)
sqlite3
sqlite3
spec/integration/rails-3.2.gems
View file @
4bc53974
source :rubygems
source :rubygems
gem 'rails', "~>3.2
.2
"
gem 'rails', "~>3.2"
gem "sqlite3"
gem "sqlite3"
spec/integration/rails-3.2.gems.lock
View file @
4bc53974
...
@@ -83,5 +83,5 @@ PLATFORMS
...
@@ -83,5 +83,5 @@ PLATFORMS
ruby
ruby
DEPENDENCIES
DEPENDENCIES
rails (~> 3.2
.2
)
rails (~> 3.2)
sqlite3
sqlite3
spec/integration/rails_integration_spec.rb
View file @
4bc53974
...
@@ -35,6 +35,7 @@ describe "annotate inside Rails" do
...
@@ -35,6 +35,7 @@ describe "annotate inside Rails" do
rails_version
=
rails_version
.
split
(
" "
).
last
rails_version
=
rails_version
.
split
(
" "
).
last
rails_version
.
should
=~
/(\d+)(\.\d+)*/
rails_version
.
should
=~
/(\d+)(\.\d+)*/
rails_version
.
should
=~
/^
#{
base_version
}
/
rails_version
.
should
=~
/^
#{
base_version
}
/
puts
"
\n
Using Rails
#{
rails_version
}
"
`
#{
new_cmd
}
todo`
`
#{
new_cmd
}
todo`
Dir
.
chdir
(
"
#{
temp_dir
}
/todo"
)
do
Dir
.
chdir
(
"
#{
temp_dir
}
/todo"
)
do
...
@@ -42,23 +43,30 @@ describe "annotate inside Rails" do
...
@@ -42,23 +43,30 @@ describe "annotate inside Rails" do
`../rake db:migrate`
.
should
=~
/CreateTasks: migrated/
`../rake db:migrate`
.
should
=~
/CreateTasks: migrated/
File
.
read
(
"app/models/task.rb"
).
should
==
"class Task < ActiveRecord::Base
\n
end
\n
"
File
.
read
(
"app/models/task.rb"
).
should
==
"class Task < ActiveRecord::Base
\n
end
\n
"
`
#{
annotate_bin
}
`
.
chomp
.
should
==
"Annotated (1): Task"
`
#{
annotate_bin
}
`
.
chomp
.
should
==
"Annotated (1): Task"
File
.
read
(
"app/models/task.rb"
).
should
=
=
<<-
RUBY
expected_model
=
<<-
RUBY
# == Schema Information
# == Schema Information
#
#
# Table name: tasks
# Table name: tasks
#
#
# id :integer not null, primary key
# content :string(255)
# content :string(255)
# created_at :datetime not null
# created_at :datetime not null
# id :integer not null, primary key
# updated_at :datetime not null
# updated_at :datetime not null
#
#
class Task < ActiveRecord::Base
class Task < ActiveRecord::Base
end
end
RUBY
RUBY
if
base_version
==
"2.3"
# for some reason timestamps are not required in Rails 2.3.14
expected_model
.
gsub!
(
"datetime not null"
,
"datetime"
)
end
File
.
read
(
"app/models/task.rb"
).
should
==
expected_model
end
end
end
end
end
end
end
end
end
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment