swdyh / cutagem forked from cho45/cutagem

Very customable gem skelton generator (Ruby)

This URL has Read+Write access

swdyh (author)
Fri Apr 03 20:38:37 -0700 2009
commit  a0bdfa10b8ff0dbaee7cb7dc9141e53c28d0dd4b
tree    6f5a909f8cc1028a4f7cdf16089f71bbb55e19fa
parent  535a5df4d452207b1546a302ad252cde0dd43ad0
name age message
file ChangeLog Loading commit data...
file README
file Rakefile
directory bin/
directory lib/
directory templates/
directory test/
README
= cutagem - Cut a Gem for creating new beautiful gem.

by cho45 <cho45@lowreal.net>

== Description

cutagem (Cut a Gem) is yet another executable for creating gem skelton.

This is similar in concept to newgem[http://newgem.rubyforge.org/] but
more customizable for each user.

cutagem (Cut a Gem: 宝石のカット) は新しい gem のスケルトンを作るコマンドです。

newgem[http://newgem.rubyforge.org/] とよく似たものですが、cutagem は
各ユーザがカスタマイズしやすいようになっています。

== Concept

* User customizable templates.
* Not use hoe, etc. Because it makes difficult to customize the created Rakefile.
  A time like this, copy and paste is better than DRY.
* Do not use more config file which is written what can be written in Rakefile
  in default template.

   

* ユーザ固有のテンプレート
* hoe とかを使いません。これは生成された Rakefile を更めてその gem 用に
  カスタマイズしたいときにめんどくさくないようにです。
* このパッケージのテンプレートは、
  Rakefile に書けば済むことを設定として分離したりしません。

== Installation

=== Gem Installation

  gem install cutagem

=== Subversion Repository

Hosted by CodeRepos[http://coderepos.org/share/browser/lang/ruby/cutagem]

  svn co http://svn.coderepos.org/share/lang/ruby/cutagem/

== Usage

Most simple sample:

  $ cutagem gemname
  Using Template: .cutagem/templates/default
  ~/.cutagem/config.yaml is not found. Use default.
  cp -r /pathto/templates/default /pathto/gemname
  Rename test/gemname_test.rb to test/gemname_test.rb
  Rename lib/gempath.rb to lib/gemname.rb
  Done.
  Type any key to edit Rakefile.
  

When +gemname+ includes hyphens, it's replaced with "/".

  $ cutagem module-test
  Using Template: .cutagem/templates/default
  ~/.cutagem/config.yaml is found. Use it.
  cp -r /pathto/templates/default /pathto/module-test
  Rename test/gemname_test.rb to test/module-test_test.rb
  Rename lib/gempath.rb to lib/module/test.rb
  Done.
  Type any key to edit Rakefile.


  $ ls module-test/lib/module/test.rb
  module-test/lib/module/test.rb


Select templates interactively. (<code>-s</code>, <code>--select</code> option)

  $ cutagem -s module-test
  Select template:
   1. .cutagem/templates/default
   2. default
   3. command
  1
  Using Template: .cutagem/templates/default
  ~/.cutagem/config.yaml is found. Use it.
  cp -r /pathto/templates/default /pathto/module-test
  Rename test/gemname_test.rb to test/module-test_test.rb
  Rename lib/gempath.rb to lib/module/test.rb
  Done.
  Type any key to edit Rakefile.


Edit user configuration.

  $ cutagem -c
  [Open ~/.cutagem/config.yaml with $EDITOR]

Other options:

  Usage: cutagem [options] gemname
  
  Options:
  -s, --select                     Select template interactively.
  -d, --desc                       Describe this gem.
  -c, --config                     Configure user values. Use $EDITOR
      --copy-template NAME         Copy template to user template dir naming NAME
      --version                    Show version string `0.0.2'


== Customization

+cutagem+ reads ~/.cutagem/templates/* for using it as custom template.
Especially "default" template is precedence.

You can make new template by coping the existing template using '--copy-template NAME' option.

=== Priority Example

Library installed templates:

* default
* command

User templates:

* ~/.cutagem/templates/default
* ~/.cutagem/templates/foobar

Priority order:

1. ~/.cutagem/templates/default
2. ~/.cutagem/templates/foobar
3. default (system)
4. command (system)

If you want to check this priority, add <code>-s</code>, <code>--select</code> option to +cutagem+.


=== Template Spec.

==== File Name Replacement

[gemname]
  The argument +gemname+.
[gempath]
  The string created by replacing "-" with "/" in +gemname+.
  (ex. gemname is <code>hoge-hoge</code> then, gempath is <code>hoge/hoge</code>)
  The path is automatically created.

==== ERB Replacement

All files process through ERB.

[<%=gemname%>]
  same as filename.
[<%=gempath%>]
  same as filename.
[<%=gemclass%>]
  classfied gemname.
  (ex. gemname is <code>hoge-hoge_fuga</code> then, gemclass is <code>Hoge::HogeFuga</code>)
[<%=author%>]
  ENV["USER"] or ~/.cutagem/config.yaml#author
[<%=email%>]
  <code>#{ENV["USER"]}@#{ENV["HOST"]}</code> or ~/.cutagem/config.yaml#email
[<%=description%>]
  <code>-d</code>, <code>--desc</code> option's value
[<%=config["user_config_value"]%>]
  Replace with ~/.cutagem/config.yaml entry.

Of course ERB is Ruby, you can write everything in the bracket.

== Copyright

Author::    cho45 <cho45@lowreal.net>
Copyright:: Copyright (c) 2007 cho45 www.lowreal.net
License::   Ruby's