Class: Restapi::Client::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Restapi::Client::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/restapi/client/generator.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Class Method Summary collapse
Instance Method Summary collapse
- #generate_cli ⇒ Object
-
#initialize(*args) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
18 19 20 |
# File 'lib/restapi/client/generator.rb', line 18 def doc @doc end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
18 19 20 |
# File 'lib/restapi/client/generator.rb', line 18 def resource @resource end |
Class Method Details
.destination_root ⇒ Object
29 30 31 |
# File 'lib/restapi/client/generator.rb', line 29 def self.destination_root File.join(FileUtils.pwd, "client") end |
.source_root ⇒ Object
25 26 27 |
# File 'lib/restapi/client/generator.rb', line 25 def self.source_root File.("../template", __FILE__) end |
.start(client_name) ⇒ Object
33 34 35 |
# File 'lib/restapi/client/generator.rb', line 33 def self.start(client_name) super([client_name.parameterize.underscore], :destination_root => destination_root) end |
Instance Method Details
#generate_cli ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/restapi/client/generator.rb', line 37 def generate_cli template("README.tt", "README") template("Gemfile.tt", "Gemfile") template("bin.rb.tt", "bin/#{name}-client") chmod("bin/#{name}-client", 0755) template("client.rb.tt", "lib/#{name}_client.rb") template("base.rb.tt", "lib/#{name}_client/base.rb") template("cli_command.rb.tt", "lib/#{name}_client/cli_command.rb") doc[:resources].each do |key, resource| @resource = resource template("cli.rb.tt", "lib/#{name}_client/commands/#{resource_name}.thor") template("resource.rb.tt", "lib/#{name}_client/resources/#{resource_name}.rb") end end |