Very customable gem skelton generator (Ruby)
Ruby
Pull request Compare This branch is 8 commits ahead of cho45:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
templates
test
.gitignore
ChangeLog
README
Rakefile
cutagem.gemspec

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