Class: Gris::Generators::ApiGenerator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Gris::Generators::ApiGenerator
- Includes:
- Thor::Actions
- Defined in:
- lib/gris/generators/api_generator.rb
Instance Method Summary collapse
- #api ⇒ Object
- #append_endpoint_links_to_root_presenter ⇒ Object
- #append_endpoint_to_application_endpoint ⇒ Object
- #name_tableize ⇒ Object
- #name_underscore ⇒ Object
- #output_directory ⇒ Object
- #path_to_application_endpoint ⇒ Object
- #path_to_root_presenter ⇒ Object
Instance Method Details
#api ⇒ Object
48 49 50 51 52 53 |
# File 'lib/gris/generators/api_generator.rb', line 48 def api self.class.source_root "#{File.dirname(__FILE__)}/templates/api" say 'Generating api...' directory '.', output_directory say 'API files created!', :green end |
#append_endpoint_links_to_root_presenter ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/gris/generators/api_generator.rb', line 39 def append_endpoint_links_to_root_presenter say 'Appending links to RootPresenter.' insert_into_file path_to_root_presenter, after: "# Additional endpoint links\n" do text = "\n" text << " resource_links :#{name_underscore}\n" text end end |
#append_endpoint_to_application_endpoint ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/gris/generators/api_generator.rb', line 31 def append_endpoint_to_application_endpoint say 'Mounting new endpoint on ApplicationEndpoint.' insert_into_file path_to_application_endpoint, after: "# Additional mounted endpoints\n" do text = " mount #{name.classify.pluralize}Endpoint\n" text end end |
#name_tableize ⇒ Object
15 16 17 |
# File 'lib/gris/generators/api_generator.rb', line 15 def name_tableize name.tableize end |
#name_underscore ⇒ Object
11 12 13 |
# File 'lib/gris/generators/api_generator.rb', line 11 def name_underscore name.underscore end |
#output_directory ⇒ Object
19 20 21 |
# File 'lib/gris/generators/api_generator.rb', line 19 def output_directory '.' end |
#path_to_application_endpoint ⇒ Object
23 24 25 |
# File 'lib/gris/generators/api_generator.rb', line 23 def path_to_application_endpoint "#{output_directory}/app/endpoints/application_endpoint.rb" end |
#path_to_root_presenter ⇒ Object
27 28 29 |
# File 'lib/gris/generators/api_generator.rb', line 27 def path_to_root_presenter "#{output_directory}/app/presenters/root_presenter.rb" end |