<?xml version="1.0" encoding="UTF-8"?>
<article>
  <body>&lt;html&gt;&lt;small&gt;
&#35352;&#20107;&#12398;&#24341;&#36234;&#12375;&#12363;&#12425;&#28431;&#12428;&#12390;&#12356;&#12383;&#12398;&#12391;&#12469;&#12523;&#12505;&#12540;&#12472;&#12290;
&lt;/small&gt;&lt;/html&gt;

Generator&#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20316;&#12426;&#26041;&#12434;&#12513;&#12514;&#12375;&#12390;&#12362;&#12365;&#12414;&#12377;&#12290;

&#12414;&#12378;&#12399;&#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#38619;&#24418;&#12434;&#20316;&#12426;&#12414;&#12377;&#12290;

shell-unix-generic&gt;&gt;
$ ./script/generate plugin foo
&lt;&lt;--

&#27425;&#12395;Generator&#12503;&#12521;&#12464;&#12452;&#12531;&#12395;&#24517;&#35201;&#12394;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12434;&#29992;&#24847;&#12290;

shell-unix-generic&gt;&gt;
$ mkdir -p vendor/plugins/foo/generators/foo/templates
&lt;&lt;--

FooGenerator&#12463;&#12521;&#12473;&#12398;&#23450;&#32681;&#12501;&#12449;&#12452;&#12523;&#12434;&#20316;&#25104;

**vendor/plugins/foo/generators/foo/foo_generator.rb**

ruby_on_rails&gt;&gt;
class FooGenerator &lt; Rails::Generator::NamedBase
  def initialize(runtime_args, runtime_options = {})
    super
    &#65374; &#24341;&#25968;&#12539;&#12458;&#12503;&#12471;&#12519;&#12531;&#12398;&#35299;&#37320;&#12392;&#21021;&#26399;&#21270; &#65374;
  end

  def manifest
    record do |m|
      &#65374; &#12510;&#12491;&#12501;&#12455;&#12473;&#12488; &#65374;
    end
  end
end
&lt;&lt;--

&#12510;&#12491;&#12501;&#12455;&#12473;&#12488;&#12398;&#26360;&#12365;&#26041;&#12399;
[&#12371;&#12398;&#36794;](http://dev.rubyonrails.org/browser/trunk/railties/lib/rails_generator/generators/components/controller/controller_generator.rb)
&#12364;&#21442;&#32771;&#12395;&#12394;&#12426;&#12414;&#12377;&#12290;&#22522;&#24213;&#12463;&#12521;&#12473;&#12399;&#12289;Rails::Generator::Base&#12398;&#27966;&#29983;&#12463;&#12521;&#12473;&#12394;&#12425;&#20309;&#12391;&#12418;OK&#12391;&#12377;&#12290;

&#32154;&#12356;&#12390;&#12289;&#12510;&#12491;&#12501;&#12455;&#12473;&#12488;&#12363;&#12425;&#21442;&#29031;&#12377;&#12427;&#12486;&#12531;&#12503;&#12524;&#12540;&#12488;&#12501;&#12449;&#12452;&#12523;&#12434;templates&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12398;&#20013;&#12395;&#20316;&#12426;&#12414;&#12377;&#12290;&#12486;&#12531;&#12503;&#12524;&#12540;&#12488;&#12501;&#12449;&#12452;&#12523;&#12399;ERb&#12486;&#12531;&#12503;&#12524;&#12540;&#12488;&#12394;&#12398;&#12391;&#12289;Generator&#12463;&#12521;&#12473;&#12398;&#12467;&#12531;&#12486;&#12463;&#12473;&#12488;&#12391;rhtml&#12434;&#26360;&#12367;&#12424;&#12358;&#12394;&#24863;&#12376;&#12391;&#35352;&#36848;&#12391;&#12365;&#12414;&#12377;&#12290;

&#20197;&#19978;&#12391;&#23436;&#20102;&#12290;Generator&#12434;&#20351;&#12358;&#12392;&#12365;&#12399;&#20197;&#19979;&#12398;&#36890;&#12426;&#12290;

shell-unix-generic&gt;&gt;
$ ./script/generate foo 
&lt;&lt;--

&#12510;&#12491;&#12501;&#12455;&#12473;&#12488;&#12398;&#26360;&#24335;&#12434;&#20197;&#19979;&#12395;&#12414;&#12392;&#12417;&#12390;&#12362;&#12365;&#12414;&#12377;&#12290;

&lt;html&gt;
&lt;div style=&quot;margin: 0px 30px 0px 30px&quot;&gt;
&lt;/html&gt;

**`m.class_collisions( *class_names)`**

&#29983;&#25104;&#12377;&#12427;&#12463;&#12521;&#12473;&#21517;&#12398;&#34909;&#31361;&#12434;&#26908;&#20986;&#12375;&#12414;&#12377;&#12290;
Generator&#12391;&#29983;&#25104;&#12377;&#12427;&#20104;&#23450;&#12398;&#12463;&#12521;&#12473;&#21517;&#12434;&#12377;&#12409;&#12390;&#21015;&#35352;&#12375;&#12390;&#12362;&#12365;&#12414;&#12375;&#12423;&#12358;&#12290;

**`m.directory(relative_path)`**

RAILS_ROOT&#12363;&#12425;&#12398;&#30456;&#23550;&#12497;&#12473;&#12391;&#12289;&#25351;&#23450;&#12375;&#12383;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12434;&#21033;&#29992;&#12377;&#12427;&#20107;&#12434;
&#23459;&#35328;&#12375;&#12414;&#12377;&#12290;

**`m.template(relative_source, relative_destination, template_options = {})`**

Generator&#12364;&#29983;&#25104;&#12377;&#12427;&#12501;&#12449;&#12452;&#12523;&#12434;&#23459;&#35328;&#12375;&#12414;&#12377;&#12290;`relative_source`&#12399;&#12289;templates&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12363;&#12425;&#12398;&#30456;&#23550;&#12497;&#12473;&#12391;ERb&#12486;&#12531;&#12503;&#12524;&#12540;&#12488;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;`relative_destination`&#12395;&#12399;&#29983;&#25104;&#12373;&#12428;&#12427;&#12501;&#12449;&#12452;&#12523;&#12398;&#22580;&#25152;&#12434;`RAILS_ROOT`&#12363;&#12425;&#12398;&#30456;&#23550;&#12497;&#12473;&#12391;&#35352;&#36848;&#12375;&#12414;&#12377;&#12290;

`template_options`&#12395;&#12399;&#12289;`:assigns =&gt; {:foo =&gt; some_thing}`
&#12398;&#12424;&#12358;&#12394;&#24863;&#12376;&#12391;&#12289;ERb&#12486;&#12531;&#12503;&#12524;&#12540;&#12488;&#12363;&#12425;&#21442;&#29031;&#21487;&#33021;&#12394;&#20516;&#12434;&#35373;&#23450;&#12377;&#12427;&#20107;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;

**`m.readme( *relative_sources)`**

help&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#25351;&#23450;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#32676;&#12399;&#21336;&#32020;&#12395;&#36899;&#32154;&#20986;&#21147;&#12373;&#12428;&#12414;&#12377;&#12290;

**`m.migration_template(relative_source, relative_destination, template_options = {})`**

migration&#12501;&#12449;&#12452;&#12523;&#12398;&#29983;&#25104;&#12434;&#23459;&#35328;&#12375;&#12414;&#12377;&#12290;migration&#12501;&#12449;&#12452;&#12523;&#12399;&#12289;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#20808;&#38957;&#12395;005_&#12398;&#12424;&#12358;&#12394;&#12503;&#12524;&#12501;&#12451;&#12483;&#12463;&#12473;&#12364;&#20184;&#12367;&#12398;&#12391;&#12289;&#23554;&#29992;&#12398;&#12513;&#12477;&#12483;&#12489;&#12364;&#29992;&#24847;&#12373;&#12428;&#12390;&#12356;&#12414;&#12377;&#12290;

`relative_destination`&#12399;&#12289;migration&#12501;&#12449;&#12452;&#12523;&#12434;&#37197;&#32622;&#12377;&#12427;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12434;&#12289;`RAILS_ROOT`&#12363;&#12425;&#12398;&#30456;&#23550;&#12497;&#12473;&#12391;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&#29983;&#25104;&#12377;&#12427;&#12501;&#12449;&#12452;&#12523;&#21517;&#12399;&#12289;`template_options[:migration_file_name]`
&#12391;&#26126;&#31034;&#30340;&#12395;&#25351;&#23450;&#12377;&#12427;&#12363;&#12289;&#12373;&#12418;&#12394;&#12367;&#12400;Generator&#12398;&#24341;&#25968;&#12363;&#12425;&#33258;&#21205;&#30340;&#12395;&#27770;&#23450;&#12373;&#12428;&#12414;&#12377;&#12290;

&#12381;&#12398;&#12411;&#12363;&#12398;&#25369;&#21205;&#12399;m.template&#12392;&#21516;&#12376;&#12391;&#12377;&#12290;&#12288;

**`m.dependency(generator_name, args, runtime_options = {})`**

Generator&#12398;&#20381;&#23384;&#38306;&#20418;&#12434;&#23459;&#35328;&#12375;&#12414;&#12377;&#12290;&#12371;&#12428;&#12395;&#12424;&#12387;&#12390;&#12513;&#12479;&#12472;&#12455;&#12493;&#12524;&#12540;&#12479;&#12434;&#35352;&#36848;&#12377;&#12427;&#20107;&#12418;&#21487;&#33021;&#12391;&#12377;&#12290;&#32032;&#26228;&#12425;&#12375;&#12356;&#12391;&#12377;&#12397;&#12290;

**`m.file(relative_source, relative_destination, file_options = {}) {|sf| ...}`**

&#12501;&#12449;&#12452;&#12523;&#12398;&#12467;&#12500;&#12540;&#12434;&#23459;&#35328;&#12375;&#12414;&#12377;&#12290;`relative_source`&#12289;`relative_destination`
&#12399;&#12381;&#12428;&#12382;&#12428;`RAILS_ROOT`&#12363;&#12425;&#12398;&#30456;&#23550;&#12497;&#12473;&#12391;&#12377;&#12290;
`file_options`&#12395;&#12399;&#12289;`:chmod`, `:shebang`, `:collision`&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;
&#35443;&#32048;&#12394;&#25369;&#21205;&#12395;&#12388;&#12356;&#12390;&#12399;
[&#12371;&#12385;&#12425;](http://edgedocs.planetargon.org/classes/Rails/Generator/Commands/Create.html#M004122)
&#12434;&#21442;&#29031;&#12398;&#12371;&#12392;&#12290;

&#12502;&#12525;&#12483;&#12463;&#24341;&#25968;&#12399;&#12289;`relative_source`&#12391;&#25351;&#23450;&#12375;&#12383;&#12501;&#12449;&#12452;&#12523;&#12364;&#20309;&#12425;&#12363;&#12398;&#12486;&#12531;&#12503;&#12524;&#12540;&#12488;&#12501;&#12449;&#12452;&#12523;&#12391;&#12354;&#12427;&#12392;&#12365;&#12395;&#12289;&#12486;&#12531;&#12503;&#12524;&#12540;&#12488;&#12434;&#23637;&#38283;&#12377;&#12427;&#20966;&#29702;&#12434;&#35352;&#36848;&#12375;&#12414;&#12377;&#12290;&#12381;&#12358;&#12391;&#12394;&#12356;&#22580;&#21512;&#12399;&#30465;&#30053;&#21487;&#33021;&#12391;&#12377;&#12290;

&lt;html&gt;&lt;/div&gt;&lt;/html&gt;

&#12424;&#12426;&#35443;&#32048;&#12394;&#24773;&#22577;&#12364;&#24517;&#35201;&#12394;&#22580;&#21512;&#12399;&#12289;
[Rails::Generator::Commands::Create&#12463;&#12521;&#12473;&#12398;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;](http://edgedocs.planetargon.org/classes/Rails/Generator/Commands/Create.html)
&#21450;&#12403;
[Create&#12463;&#12521;&#12473;&#12398;&#22522;&#24213;&#12463;&#12521;&#12473;&#12391;&#12354;&#12427;Rails::Generator::Commands::Base&#12398;&#12489;&#12461;&#12517;&#12513;&#12531;&#12488;](http://edgedocs.planetargon.org/classes/Rails/Generator/Commands/Base.html)
&#12434;&#12372;&#35239;&#12367;&#12384;&#12373;&#12356;&#12290;

**&#26356;&#26032;&#23653;&#27508;**

 * 2006/08/10 &#12510;&#12491;&#12501;&#12455;&#12473;&#12488;&#12398;&#26360;&#12365;&#26041;&#12434;&#26368;&#24460;&#12398;&#26041;&#12395;&#12414;&#12392;&#12417;&#12390;&#12362;&#12365;&#12414;&#12375;&#12383;&#12290;
 * 2007/11/22 &#35352;&#20107;&#12398;&#31227;&#34892;&#12363;&#12425;&#12418;&#12428;&#12390;&#12356;&#12383;&#12398;&#12391;&#12469;&#12523;&#12505;&#12540;&#12472;</body>
  <cached-tag-list>rails plugin generator</cached-tag-list>
  <comments-count type="integer">0</comments-count>
  <created-at type="datetime">2007-11-22T05:10:56+00:00</created-at>
  <daily-archive-id type="integer">232</daily-archive-id>
  <filter-type>blue_stole</filter-type>
  <id type="integer">215</id>
  <monthly-archive-id type="integer">6</monthly-archive-id>
  <pdf-digest nil="true"></pdf-digest>
  <permalink>/takiuchi/archive/76</permalink>
  <published-at type="datetime">2007-11-22T05:43:00+00:00</published-at>
  <secret>918455db-d98d-472d-9d97-0dd48e1596e5</secret>
  <title>Generator&#12503;&#12521;&#12464;&#12452;&#12531;&#12398;&#20316;&#12426;&#26041;</title>
  <updated-at type="datetime">2008-10-22T18:47:08+00:00</updated-at>
  <user-id type="integer">1</user-id>
</article>
