From 60fc98a2525dbb00374776945e53af67f1c3ccf8 Mon Sep 17 00:00:00 2001 From: Cuong Tran Date: Sat, 22 Mar 2008 22:02:15 -0500 Subject: [PATCH] Merge changes from http://github.com/bumi/annotate_models/tree/master --- History.txt | 11 ++++++++--- README.txt | 8 ++++++-- bin/annotate | 11 ++++++++++- doc/created.rid | 2 +- doc/files/History_txt.html | 19 +++++++++++++++---- doc/files/License_txt.html | 2 +- doc/files/README_txt.html | 9 +++++++-- doc/files/bin/annotate.html | 3 ++- doc/files/lib/annotate_models/tasks_rb.html | 2 +- doc/files/lib/annotate_models/version_rb.html | 2 +- doc/files/lib/annotate_models_rb.html | 2 +- doc/files/website/index_txt.html | 12 +++++++++--- doc/index.html | 4 ++-- lib/annotate_models.rb | 13 +++++++++---- lib/annotate_models/version.rb | 2 +- website/index.html | 14 ++++++++++---- website/index.txt | 8 ++++++-- 17 files changed, 90 insertions(+), 34 deletions(-) diff --git a/History.txt b/History.txt index 829aaa051..884c0aae5 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,9 @@ -== 0.0.1 2008-02-27 +== 1.0.2 2008-03-22 + +* Add contributions from Michael Bumann (http://github.com/bumi) + * added an option "position" to choose to put the annotation, + * spec/fixtures now also get annotated + * added a task to remove the annotations + * these options can be specified from command line as -d and -p [before|after] + -* 1 major enhancement: - * Initial release diff --git a/README.txt b/README.txt index 5313b2773..5c7313da8 100644 --- a/README.txt +++ b/README.txt @@ -28,6 +28,9 @@ created comment block. cd [your project] annotate + annotate -d + annotate -p [before|after] + annotate -h == Source @@ -41,6 +44,7 @@ Released under the same license as Ruby. No Support. No Warranty. == Modifications - alex@pivotallabs.com - - ctran@pragmaquest.com - - Jack Danger at http://6brand.com/ + - Cuong Tran - http://github.com/ctran + - Jack Danger - http://github.com/JackDanger + - Michael Bumann - http://github.com/bumi diff --git a/bin/annotate b/bin/annotate index 6b0e39769..fa8a6fcca 100644 --- a/bin/annotate +++ b/bin/annotate @@ -1,5 +1,14 @@ #!/usr/bin/env ruby + +require 'optparse' require 'annotate_models/tasks' -Rake::Task['annotate_models'].invoke +task = "annotate_models" + +OptionParser.new do |opts| + opts.banner = "Usage: annotate [options]" + opts.on('-d', '--delete') { task = "remove_annotation" } + opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p } +end.parse! +Rake::Task[task].invoke diff --git a/doc/created.rid b/doc/created.rid index 09b1d0e77..93873e0a4 100644 --- a/doc/created.rid +++ b/doc/created.rid @@ -1 +1 @@ -Mon, 10 Mar 2008 02:26:29 -0500 +Sat, 22 Mar 2008 21:58:55 -0500 diff --git a/doc/files/History_txt.html b/doc/files/History_txt.html index 20438a5dc..bd7c830bf 100644 --- a/doc/files/History_txt.html +++ b/doc/files/History_txt.html @@ -56,7 +56,7 @@

History.txt

Last Update: - Mon Mar 10 01:50:15 -0500 2008 + Sat Mar 22 21:48:28 -0500 2008 @@ -69,12 +69,23 @@

History.txt

-

0.0.1 2008-02-27

+

1.0.2 2008-03-22

    -
  • 1 major enhancement: +
  • Add contributions from Michael Bumann (github.com/bumi)
      -
    • Initial release +
    • added an option "position" to choose to put the annotation, + +
    • +
    • spec/fixtures now also get annotated + +
    • +
    • added a task to remove the annotations + +
    • +
    • these options can be specified from command line as -d and -p +[before|after]
    diff --git a/doc/files/License_txt.html b/doc/files/License_txt.html index 14bfc73fe..089dcceb3 100644 --- a/doc/files/License_txt.html +++ b/doc/files/License_txt.html @@ -56,7 +56,7 @@

    License.txt

    Last Update: - Mon Mar 10 01:50:15 -0500 2008 + Sat Mar 22 20:47:25 -0500 2008
diff --git a/doc/files/README_txt.html b/doc/files/README_txt.html index c1f099922..93ecc3077 100644 --- a/doc/files/README_txt.html +++ b/doc/files/README_txt.html @@ -56,7 +56,7 @@

README.txt

Last Update: - Mon Mar 10 01:50:15 -0500 2008 + Sat Mar 22 21:53:08 -0500 2008
@@ -103,6 +103,9 @@

Usage

   cd [your project]
   annotate
+  annotate -d
+  annotate -p [before|after]
+  annotate -h
 

Source

@@ -119,7 +122,9 @@ 

Author

Modifications

  - alex@pivotallabs.com
- - ctran@pragmaquest.com
+ - Cuong Tran - http://github.com/ctran
+ - Jack Danger - http://github.com/JackDanger
+ - Michael Bumann - http://github.com/bumi
 
diff --git a/doc/files/bin/annotate.html b/doc/files/bin/annotate.html index 5554ad4c5..8b5b4cbcc 100644 --- a/doc/files/bin/annotate.html +++ b/doc/files/bin/annotate.html @@ -56,7 +56,7 @@

annotate

Last Update: - Mon Mar 10 02:16:17 -0500 2008 + Sat Mar 22 21:29:04 -0500 2008 @@ -73,6 +73,7 @@

annotate

Required files

+ optparse   annotate_models/tasks  
diff --git a/doc/files/lib/annotate_models/tasks_rb.html b/doc/files/lib/annotate_models/tasks_rb.html index 7fb8546f3..134e12ae6 100644 --- a/doc/files/lib/annotate_models/tasks_rb.html +++ b/doc/files/lib/annotate_models/tasks_rb.html @@ -56,7 +56,7 @@

tasks.rb

Last Update: - Mon Mar 10 02:16:17 -0500 2008 + Sat Mar 22 20:47:25 -0500 2008 diff --git a/doc/files/lib/annotate_models/version_rb.html b/doc/files/lib/annotate_models/version_rb.html index 9f2fcc22d..8b9822488 100644 --- a/doc/files/lib/annotate_models/version_rb.html +++ b/doc/files/lib/annotate_models/version_rb.html @@ -56,7 +56,7 @@

version.rb

Last Update: - Mon Mar 10 02:19:56 -0500 2008 + Sat Mar 22 21:42:43 -0500 2008 diff --git a/doc/files/lib/annotate_models_rb.html b/doc/files/lib/annotate_models_rb.html index 091e409f6..6078f7552 100644 --- a/doc/files/lib/annotate_models_rb.html +++ b/doc/files/lib/annotate_models_rb.html @@ -56,7 +56,7 @@

annotate_models.rb

Last Update: - Mon Mar 10 02:19:56 -0500 2008 + Sat Mar 22 21:39:51 -0500 2008 diff --git a/doc/files/website/index_txt.html b/doc/files/website/index_txt.html index d4fd205f0..f5b1e472f 100644 --- a/doc/files/website/index_txt.html +++ b/doc/files/website/index_txt.html @@ -56,7 +56,7 @@

index.txt

Last Update: - Mon Mar 10 01:50:15 -0500 2008 + Sat Mar 22 21:56:42 -0500 2008 @@ -105,7 +105,13 @@

index.txt

h2. Demonstration of usage

-Go to your RAILS_ROOT dir, then run annotate +Go to your project dir (RAILS_ROOT), then run: annotate +

+

+To remove annotations: annotate -d +

+

+To add annotations at the end of files: annotate -p after

h2. How to submit patches @@ -116,7 +122,7 @@

index.txt

The trunk repository is github.com/ctran/annotate_models. +href="http://github.com/ctran/annotate_models">github.com/ctran/annotate_models

A svn mirror is on rubyforge diff --git a/doc/index.html b/doc/index.html index 12f601f0b..6120c2146 100644 --- a/doc/index.html +++ b/doc/index.html @@ -5,12 +5,12 @@ - annotate-models's annotate-models-1.0.1 Documentation + annotate-models-1.0.2 Documentation diff --git a/lib/annotate_models.rb b/lib/annotate_models.rb index 25ac7afa9..770b8aef4 100644 --- a/lib/annotate_models.rb +++ b/lib/annotate_models.rb @@ -46,9 +46,14 @@ def get_schema_info(klass, header) end # Add a schema block to a file. If the file already contains - # a schema info block (a comment starting - # with "Schema as of ..."), remove it first. - + # a schema info block (a comment starting with "Schema as of ..."), remove it first. + # + # === Options (opts) + # :position:: where to place the annotated section in fixture or model file, + # "before" or "after". Default is "before". + # :position_in_class:: where to place the annotated section in model file + # :position_in_fixture:: where to place the annotated section in fixture file + # def annotate_one_file(file_name, info_block, options={}) if File.exist?(file_name) content = File.read(file_name) @@ -57,7 +62,7 @@ def annotate_one_file(file_name, info_block, options={}) content.sub!(/^# #{PREFIX}.*?\n(#.*\n)*\n/, '') # Write it back - new_content = options[:position] == "before" ? (info_block + content) : (content + info_block) + new_content = options[:position] == "after" ? (content + info_block) : (info_block + content) File.open(file_name, "w") { |f| f.puts new_content } end end diff --git a/lib/annotate_models/version.rb b/lib/annotate_models/version.rb index 16931ed51..cf5ac7045 100644 --- a/lib/annotate_models/version.rb +++ b/lib/annotate_models/version.rb @@ -2,7 +2,7 @@ module AnnotateModels #:nodoc: module VERSION #:nodoc: MAJOR = 1 MINOR = 0 - TINY = 1 + TINY = 2 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/website/index.html b/website/index.html index 53007d555..7b7117b34 100644 --- a/website/index.html +++ b/website/index.html @@ -33,7 +33,7 @@

annotate-models

Get Version

- 1.0.1 + 1.0.2

→ ‘annotate-models’

@@ -62,7 +62,13 @@

The basics

Demonstration of usage

-

Go to your RAILS_ROOT dir, then run annotate

+

Go to your project dir (RAILS_ROOT), then run: annotate

+ + +

To remove annotations: annotate -d

+ + +

To add annotations at the end of files: annotate -p after

How to submit patches

@@ -71,7 +77,7 @@

How to submit patches

See Using Git within a project

-

The trunk repository is http://github.com/ctran/annotate_models.

+

The trunk repository is http://github.com/ctran/annotate_models

A svn mirror is on rubyforge svn://rubyforge.org/var/svn/annotate-models/trunk

@@ -88,7 +94,7 @@

Contact

Comments are welcome. Send an email to Cuong Tran

- Cuong Tran, 10th March 2008
+ Cuong Tran, 22nd March 2008
Theme extended from Paul Battley

diff --git a/website/index.txt b/website/index.txt index 343eb10c5..96a5eabe1 100644 --- a/website/index.txt +++ b/website/index.txt @@ -21,13 +21,17 @@ This is now a gem that can run from command line h2. Demonstration of usage -Go to your RAILS_ROOT dir, then run annotate +Go to your project dir (RAILS_ROOT), then run: annotate + +To remove annotations: annotate -d + +To add annotations at the end of files: annotate -p after h2. How to submit patches See "Using Git within a project":http://drnicwilliams.com/2008/02/03/using-git-within-a-team/ -The trunk repository is http://github.com/ctran/annotate_models. +The trunk repository is http://github.com/ctran/annotate_models A svn mirror is on rubyforge svn://rubyforge.org/var/svn/annotate-models/trunk