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
8f1fe151
Commit
8f1fe151
authored
Jul 20, 2011
by
Mal McKay
Committed by
Mel Riffe
Jul 28, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow models with non standard capitalization
parent
ddfba1f7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
annotate_models.rb
lib/annotate/annotate_models.rb
+4
-0
annotate_models_spec.rb
spec/annotate/annotate_models_spec.rb
+9
-0
No files found.
lib/annotate/annotate_models.rb
View file @
8f1fe151
...
@@ -239,7 +239,11 @@ module AnnotateModels
...
@@ -239,7 +239,11 @@ module AnnotateModels
begin
begin
parts
.
inject
(
Object
)
{
|
klass
,
part
|
klass
.
const_get
(
part
)
}
parts
.
inject
(
Object
)
{
|
klass
,
part
|
klass
.
const_get
(
part
)
}
rescue
LoadError
,
NameError
rescue
LoadError
,
NameError
begin
Object
.
const_get
(
parts
.
last
)
Object
.
const_get
(
parts
.
last
)
rescue
LoadError
,
NameError
Object
.
const_get
(
Module
.
constants
.
detect
{
|
c
|
parts
.
last
.
downcase
==
c
.
downcase
})
end
end
end
end
end
...
...
spec/annotate/annotate_models_spec.rb
View file @
8f1fe151
...
@@ -69,6 +69,11 @@ EOS
...
@@ -69,6 +69,11 @@ EOS
acts_as_awesome :yah
acts_as_awesome :yah
end
end
EOS
EOS
create
(
'foo_with_capitals.rb'
,
<<-
EOS
)
class FooWithCAPITALS < ActiveRecord::Base
acts_as_awesome :yah
end
EOS
end
end
it
"should work"
do
it
"should work"
do
klass
=
AnnotateModels
.
get_model_class
(
"foo.rb"
)
klass
=
AnnotateModels
.
get_model_class
(
"foo.rb"
)
...
@@ -78,6 +83,10 @@ EOS
...
@@ -78,6 +83,10 @@ EOS
klass
=
AnnotateModels
.
get_model_class
(
"foo_with_macro.rb"
)
klass
=
AnnotateModels
.
get_model_class
(
"foo_with_macro.rb"
)
klass
.
name
.
should
==
"FooWithMacro"
klass
.
name
.
should
==
"FooWithMacro"
end
end
it
"should find models with non standard capitalization"
do
klass
=
AnnotateModels
.
get_model_class
(
"foo_with_capitals.rb"
)
klass
.
name
.
should
==
"FooWithCAPITALS"
end
end
end
end
end
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