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