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
ace6cdd7
Commit
ace6cdd7
authored
Jun 29, 2011
by
Robert Wahler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove trailing whitespace
Because my editor is set to do whitespace cleanup on write
parent
7c5965a5
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
40 deletions
+40
-40
History.txt
History.txt
+1
-1
README.rdoc
README.rdoc
+2
-2
Rakefile
Rakefile
+3
-3
annotate
bin/annotate
+10
-10
annotate.rb
lib/annotate.rb
+1
-1
annotate_models.rb
lib/annotate/annotate_models.rb
+11
-11
annotate_routes.rb
lib/annotate/annotate_routes.rb
+11
-11
migrate.rake
tasks/migrate.rake
+1
-1
No files found.
History.txt
View file @
ace6cdd7
...
...
@@ -14,7 +14,7 @@
* -i to show database indexes in annotations
* -e to exclude annotating tests or fixtures
* -m to include the migration version number in the annotation
* --model-dir to annotate model files stored a different place than app/models
* --model-dir to annotate model files stored a different place than app/models
* Ignore unknown macros ('acts_as_whatever')
== 2.0 2009-02-03
...
...
README.rdoc
View file @
ace6cdd7
...
...
@@ -70,7 +70,7 @@ To annotate routes.rb:
annotate -r
To automatically annotate after running 'rake db:migrate':
[needs more clarity] unpack the gem into vendor/plugins, or maybe vendor/gems, or maybe just require tasks/migrate.rake.
If you install annotate_models as a plugin, it will automatically
...
...
@@ -137,5 +137,5 @@ Modifications by:
- Gavin Montague - http://github.com/govan/
- Alexander Semyonov - http://github.com/rotuka/
- Nathan Brazil - http://github.com/bitaxis/
and many others that I may have missed to add.
Rakefile
View file @
ace6cdd7
...
...
@@ -17,15 +17,15 @@ begin
gem
.
authors
=
[
'Cuong Tran'
,
"Alex Chaffee"
,
"Marcos Piccinini"
]
gem
.
files
=
FileList
[
"[A-Z]*.*"
,
"{bin,lib,tasks,spec}/**/*"
]
gem
.
rubyforge_project
=
"annotate"
# note that Jeweler automatically reads the version from VERSION.yml
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler
::
RubyforgeTasks
.
new
do
|
rubyforge
|
rubyforge
.
doc_task
=
"rdoc"
end
rescue
LoadError
puts
"Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end
...
...
bin/annotate
View file @
ace6cdd7
...
...
@@ -8,33 +8,33 @@ task = :annotate_models
OptionParser
.
new
do
|
opts
|
opts
.
banner
=
"Usage: annotate [options] [model_file]*"
opts
.
on
(
'-d'
,
'--delete'
,
opts
.
on
(
'-d'
,
'--delete'
,
"Remove annotations from all model files"
)
do
task
=
:remove_annotation
end
opts
.
on
(
'-p'
,
'--position [before|after]'
,
[
'before'
,
'after'
],
"Place the annotations at the top (before) or the bottom (after) of the model file"
)
do
|
p
|
opts
.
on
(
'-p'
,
'--position [before|after]'
,
[
'before'
,
'after'
],
"Place the annotations at the top (before) or the bottom (after) of the model file"
)
do
|
p
|
ENV
[
'position'
]
=
p
end
opts
.
on
(
'-r'
,
'--routes'
,
opts
.
on
(
'-r'
,
'--routes'
,
"Annotate routes.rb with the output of 'rake routes'"
)
do
task
=
:annotate_routes
end
opts
.
on
(
'-v'
,
'--version'
,
"Show the current version of this gem"
)
do
opts
.
on
(
'-v'
,
'--version'
,
"Show the current version of this gem"
)
do
puts
"annotate v
#{
Annotate
.
version
}
"
;
exit
end
opts
.
on
(
'-m'
,
'--show-migration'
,
opts
.
on
(
'-m'
,
'--show-migration'
,
"Include the migration version number in the annotation"
)
do
ENV
[
'include_version'
]
=
"yes"
end
opts
.
on
(
'-i'
,
'--show-indexes'
,
"List the table's database indexes in the annotation"
)
do
opts
.
on
(
'-i'
,
'--show-indexes'
,
"List the table's database indexes in the annotation"
)
do
ENV
[
'show_indexes'
]
=
"yes"
end
...
...
@@ -43,7 +43,7 @@ OptionParser.new do |opts|
ENV
[
'simple_indexes'
]
=
"yes"
end
opts
.
on
(
'--model-dir dir'
,
opts
.
on
(
'--model-dir dir'
,
"Annotate model files stored in dir rather than app/models"
)
do
|
dir
|
ENV
[
'model_dir'
]
=
dir
end
...
...
lib/annotate.rb
View file @
ace6cdd7
...
...
@@ -13,7 +13,7 @@ module Annotate
version
=
"0.0.0"
end
end
def
self
.
load_tasks
if
File
.
exists?
(
'Rakefile'
)
require
'rake'
...
...
lib/annotate/annotate_models.rb
View file @
ace6cdd7
...
...
@@ -178,12 +178,12 @@ module AnnotateModels
if
annotate_one_file
(
model_file_name
,
info
,
options_with_position
(
options
,
:position_in_class
))
annotated
=
true
end
unless
ENV
[
'exclude_tests'
]
[
File
.
join
(
UNIT_TEST_DIR
,
"
#{
model_name
}
_test.rb"
),
# test
File
.
join
(
SPEC_MODEL_DIR
,
"
#{
model_name
}
_spec.rb"
),
# spec
].
each
do
|
file
|
].
each
do
|
file
|
# todo: add an option "position_in_test" -- or maybe just ask if anyone ever wants different positions for model vs. test vs. fixture
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_fixture
))
end
...
...
@@ -194,14 +194,14 @@ module AnnotateModels
File
.
join
(
EXEMPLARS_TEST_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
File
.
join
(
EXEMPLARS_SPEC_DIR
,
"
#{
model_name
}
_exemplar.rb"
),
# Object Daddy
File
.
join
(
BLUEPRINTS_DIR
,
"
#{
model_name
}
_blueprint.rb"
),
# Machinist Blueprints
].
each
do
|
file
|
].
each
do
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_fixture
))
end
FIXTURE_DIRS
.
each
do
|
dir
|
fixture_file_name
=
File
.
join
(
dir
,
klass
.
table_name
+
".yml"
)
if
File
.
exist?
(
fixture_file_name
)
annotate_one_file
(
fixture_file_name
,
info
,
options_with_position
(
options
,
:position_in_fixture
))
annotate_one_file
(
fixture_file_name
,
info
,
options_with_position
(
options
,
:position_in_fixture
))
end
end
end
...
...
@@ -210,14 +210,14 @@ module AnnotateModels
[
File
.
join
(
SPEC_FACTORIES_DIR
,
"
#{
model_name
}
_factory.rb"
),
# spec/factories
File
.
join
(
TEST_FACTORIES_DIR
,
"
#{
model_name
}
_factory.rb"
),
# test/factories
].
each
do
|
file
|
].
each
do
|
file
|
annotate_one_file
(
file
,
info
,
options_with_position
(
options
,
:position_in_factory
))
end
end
annotated
end
# position = :position_in_fixture or :position_in_class
def
options_with_position
(
options
,
position_in
)
options
.
merge
(
:position
=>
(
options
[
position_in
]
||
options
[
:position
]))
...
...
@@ -298,7 +298,7 @@ module AnnotateModels
puts
"Unable to annotate
#{
file
}
:
#{
e
.
inspect
}
"
puts
""
# todo: check if all backtrace lines are in "gems" -- if so, it's an annotate bug, so print the whole stack trace.
# puts e.backtrace.join("\n\t")
# puts e.backtrace.join("\n\t")
end
end
if
annotated
.
empty?
...
...
@@ -327,17 +327,17 @@ module AnnotateModels
fixture_file_name
=
File
.
join
(
dir
,
klass
.
table_name
+
".yml"
)
remove_annotation_of_file
(
fixture_file_name
)
if
File
.
exist?
(
fixture_file_name
)
end
[
File
.
join
(
UNIT_TEST_DIR
,
"
#{
klass
.
name
.
underscore
}
_test.rb"
),
File
.
join
(
SPEC_MODEL_DIR
,
"
#{
klass
.
name
.
underscore
}
_spec.rb"
)].
each
do
|
file
|
remove_annotation_of_file
(
file
)
if
File
.
exist?
(
file
)
end
[
File
.
join
(
SPEC_FACTORIES_DIR
,
"
#{
klass
.
name
.
underscore
}
_factory.rb"
),
File
.
join
(
TEST_FACTORIES_DIR
,
"
#{
klass
.
name
.
underscore
}
_factory.rb"
)].
each
do
|
file
|
remove_annotation_of_file
(
file
)
if
File
.
exist?
(
file
)
end
end
rescue
Exception
=>
e
puts
"Unable to annotate
#{
file
}
:
#{
e
.
message
}
"
...
...
lib/annotate/annotate_routes.rb
View file @
ace6cdd7
# == Annotate Routes
#
#
# Based on:
#
#
#
#
#
# Prepends the output of "rake routes" to the top of your routes.rb file.
# Yes, it's simple but I'm thick and often need a reminder of what my routes mean.
#
#
# Running this task will replace any exising route comment generated by the task.
# Best to back up your routes file before running:
#
#
# Author:
# Gavin Montague
# gavin@leftbrained.co.uk
#
#
# Released under the same license as Ruby. No Support. No Warranty.module AnnotateRoutes
#
module
AnnotateRoutes
module
AnnotateRoutes
PREFIX
=
"#== Route Map"
def
self
.
do_annotate
def
self
.
do_annotate
routes_rb
=
File
.
join
(
"config"
,
"routes.rb"
)
header
=
PREFIX
+
"
\n
# Generated on
#{
Time
.
now
.
strftime
(
"%d %b %Y %H:%M"
)
}
\n
#"
if
File
.
exists?
routes_rb
...
...
@@ -29,8 +29,8 @@ module AnnotateRoutes
routes_map
=
routes_map
.
inject
(
header
){
|
sum
,
line
|
sum
<<
"
\n
# "
<<
line
}
content = File.read(routes_rb)
content, old = content.split(/^#== Route .*?
\n
/)
File.open(routes_rb, "wb") do |f|
f.puts content.sub!(/
\n
?
\z
/, "
\n
") + routes_map
File.open(routes_rb, "wb") do |f|
f.puts content.sub!(/
\n
?
\z
/, "
\n
") + routes_map
end
puts "Route file annotated."
else
...
...
tasks/migrate.rake
View file @
ace6cdd7
...
...
@@ -2,7 +2,7 @@
# (They are not used to build annotate itself.)
# Append annotations to Rake tasks for ActiveRecord, so annotate automatically gets
# run after doing db:migrate.
# run after doing db:migrate.
# Unfortunately it relies on ENV for options; it'd be nice to be able to set options
# in a per-project config file so this task can read them.
namespace
:db
do
...
...
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