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
1e9a75ee
Commit
1e9a75ee
authored
Jul 22, 2011
by
Cuong Tran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #38 from mcommons/master
Allow for non standard model capitalization (mcommons/master)
parents
ddfba1f7
248e6650
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 @
1e9a75ee
...
...
@@ -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 @
1e9a75ee
...
...
@@ -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