Class: Flak::Generate
- Inherits:
-
Thor
- Object
- Thor
- Flak::Generate
- Includes:
- Thor::Actions
- Defined in:
- lib/flak/thor/generate.rb
Overview
Thor tasks that generate files
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#project_options ⇒ Object
Returns the value of attribute project_options.
-
#tool_options ⇒ Object
Returns the value of attribute tool_options.
Class Method Summary collapse
-
.banner(task, namespace = false, subcommand = true) ⇒ Object
Format the help line so it reads flak generate something name, as opposed to flak generate:something name.
-
.source_root ⇒ Object
Provide source_root so that templates can be found.
Instance Method Summary collapse
-
#config(name) ⇒ Object
The config subcommand.
-
#plugin(name) ⇒ Object
The plugin subcommand.
-
#project(name) ⇒ Object
The project subcommand.
- #raia ⇒ Object
- #templates ⇒ Object
-
#tool(name) ⇒ Object
The tool subcommand.
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/flak/thor/generate.rb', line 10 def name @name end |
#project_options ⇒ Object
Returns the value of attribute project_options.
10 11 12 |
# File 'lib/flak/thor/generate.rb', line 10 def @project_options end |
#tool_options ⇒ Object
Returns the value of attribute tool_options.
10 11 12 |
# File 'lib/flak/thor/generate.rb', line 10 def @tool_options end |
Class Method Details
.banner(task, namespace = false, subcommand = true) ⇒ Object
Format the help line so it reads flak generate something name, as opposed to flak generate:something name.
207 208 209 |
# File 'lib/flak/thor/generate.rb', line 207 def self.(task, namespace = false, subcommand = true) task.formatted_usage(self, true, subcommand).split(':').join(' ') end |
.source_root ⇒ Object
Provide source_root so that templates can be found
13 14 15 |
# File 'lib/flak/thor/generate.rb', line 13 def self.source_root File.join(File.dirname(__FILE__), "templates") end |
Instance Method Details
#config(name) ⇒ Object
The config subcommand. Called with: flak generate config <name>. This is the same as the project subcommand, except it works from inside an existing project.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/flak/thor/generate.rb', line 48 def config(name) opts = self. self.name = name empty_directory("build") empty_directory("plugins") directory("config") directory("doc") template( "LICENSE.tt", "LICENSE.txt") template( "README.tt", "README.txt") template( "product.mel.tt" , "script/maya/erb/#{name}.mel.erb" ) if opts[:maya_module] copy_file("module.tt" , "resource/maya/module.erb" ) if opts[:maya_module] copy_file( "INSTALL.sh.tt", "resource/config/INSTALL.sh") template( "INSTALL.BAT.tt", "resource/config/INSTALL.BAT") template( "env.sh.tt" , "resource/config/env.sh" ) create_file "resource/raia/package.yml" do Flak::TargetFile.raia_package(name,opts) end create_file "project.yml" do Flak::TargetFile.project(name,opts) end # rakefile copy_file "Rakefile.tt", "Rakefile.rb" copy_file "gitignore.tt", ".gitignore" end |
#plugin(name) ⇒ Object
The plugin subcommand. Called with: flak generate plugin <name>. Creates an example plugin with the given name inside a flak project.
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/flak/thor/generate.rb', line 168 def plugin(name) self.name= name template("plugin.yml.tt", "config/#{name}.yml") template("plugin.rb.tt", "plugins/#{name}.rb") say("The plugin was created in plugins/#{name}.rb and a config file was made in config/#{name}.yml") say("To use this plugin, edit tool.yml") say("Add '#{name}' to the templates section, and add files needed by this plugin to a file list") say("See comments in plugins/#{name}.rb for more details") end |
#project(name) ⇒ Object
The project subcommand. Called with: flak generate project <name>. Creates a flak project and populates it with files as specified by the users answers to the project wizard.
36 37 38 39 40 41 |
# File 'lib/flak/thor/generate.rb', line 36 def project(name) empty_directory(name) inside name do invoke :config end end |
#raia ⇒ Object
182 183 184 185 186 187 188 189 |
# File 'lib/flak/thor/generate.rb', line 182 def raia name= File.basename(destination_root) opts = {} opts[:maya_module] = true create_file 'resource/raia/package.yml' do Flak::TargetFile.raia_package(name,opts) end end |
#templates ⇒ Object
195 196 197 198 |
# File 'lib/flak/thor/generate.rb', line 195 def templates self.name= File.basename(destination_root) directory("config") end |
#tool(name) ⇒ Object
The tool subcommand. Called with: flak generate tool <name>. Creates a tool inside a flak project and populates it with files as specified by the users answers to the tool wizard.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/flak/thor/generate.rb', line 84 def tool(name) opts = self. self.name= name create_file "#{name}/tool.yml" do Flak::TargetFile.tool(name,opts) end create_common_files create_maya_script_tree if opts[:maya_scripts] create_nuke_script_tree if opts[:nuke_scripts] create_shell_script_tree if opts[:shell_scripts] create_maya_plugin_files if opts[:maya_plugin_target] create_app_files if opts[:maya_app_target] || opts[:standalone_target] create_delight_tools_tree if opts[:delight_target] end |