Class: Foobara::RemoteGenerator::GenerateTypescript
- Inherits:
-
Generators::Generate
- Object
- Command
- Generators::Generate
- Foobara::RemoteGenerator::GenerateTypescript
- Defined in:
- foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb
Defined Under Namespace
Classes: MissingManifestError
Constant Summary
Constants included from TruncatedInspect
Instance Attribute Summary collapse
-
#command_manifest ⇒ Object
Returns the value of attribute command_manifest.
-
#manifest_data ⇒ Object
Returns the value of attribute manifest_data.
Attributes inherited from Generators::Generate
Attributes included from CommandPatternImplementation::Concerns::Subcommands
Attributes included from CommandPatternImplementation::Concerns::Runtime
Attributes included from CommandPatternImplementation::Concerns::Errors
Attributes included from CommandPatternImplementation::Concerns::Inputs
Instance Method Summary collapse
- #add_all_commands_to_set_of_elements_to_generate ⇒ Object
- #add_root_manifest_to_set_of_elements_to_generate ⇒ Object
- #base_generator ⇒ Object
- #execute ⇒ Object
- #load_manifest_if_needed ⇒ Object
- #manifest ⇒ Object
- #templates_dir ⇒ Object
- #validate ⇒ Object
Methods inherited from Generators::Generate
#each_element_to_generate, #elements_to_generate, #generate_element, #generated, #generated_elements, #include_non_templated_files, #paths_to_source_code
Methods inherited from Command
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Methods included from CommandPatternImplementation::Concerns::Reflection
Methods included from CommandPatternImplementation::Concerns::DomainMappers
#domain_map, #domain_map!, #run_mapped_subcommand!
Methods included from CommandPatternImplementation::Concerns::Subcommands
#run_subcommand!, #subcommand?
Methods included from CommandPatternImplementation::Concerns::Entities
Methods included from CommandPatternImplementation::Concerns::Transactions
#auto_detect_current_transactions, #commit_transaction, #open_transaction, #opened_transactions, #relevant_entity_classes, #rollback_transaction, #transactions
Methods included from CommandPatternImplementation::Concerns::StateMachine
Methods included from CommandPatternImplementation::Concerns::Runtime
#halt!, #run, #run!, #run_execute, #succeed, #success?, #validate_records
Methods included from CommandPatternImplementation::Concerns::Errors
Methods included from CommandPatternImplementation::Concerns::Inputs
#cast_and_validate_inputs, #initialize, #method_missing, #respond_to_missing?, #respond_to_missing_for_inputs?
Methods included from TruncatedInspect
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Foobara::CommandPatternImplementation::Concerns::Inputs
Instance Attribute Details
#command_manifest ⇒ Object
Returns the value of attribute command_manifest.
38 39 40 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 38 def command_manifest @command_manifest end |
#manifest_data ⇒ Object
Returns the value of attribute manifest_data.
38 39 40 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 38 def manifest_data @manifest_data end |
Instance Method Details
#add_all_commands_to_set_of_elements_to_generate ⇒ Object
69 70 71 72 73 74 75 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 69 def add_all_commands_to_set_of_elements_to_generate manifest.commands.each do |command| elements_to_generate << command elements_to_generate << command.domain elements_to_generate << command.organization end end |
#add_root_manifest_to_set_of_elements_to_generate ⇒ Object
77 78 79 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 77 def add_root_manifest_to_set_of_elements_to_generate elements_to_generate << manifest end |
#base_generator ⇒ Object
40 41 42 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 40 def base_generator Services::TypescriptFromManifestBaseGenerator end |
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 14 def execute load_manifest_if_needed include_non_templated_files add_root_manifest_to_set_of_elements_to_generate # TODO: allow specifying subset of commands add_all_commands_to_set_of_elements_to_generate each_element_to_generate do generate_element end paths_to_source_code end |
#load_manifest_if_needed ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 48 def load_manifest_if_needed self.manifest_data = if raw_manifest raw_manifest # TODO: introduce VCR to test the following elsif block # :nocov: elsif manifest_url url = URI.parse(manifest_url) response = Net::HTTP.get_response(url) manifest_json = if response.is_a?(Net::HTTPSuccess) response.body else raise "Could not get manifest from #{url}: " \ "#{response.code} #{response.}" end JSON.parse(manifest_json) # :nocov: end end |
#manifest ⇒ Object
81 82 83 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 81 def manifest @manifest ||= Manifest::RootManifest.new(manifest_data) end |
#templates_dir ⇒ Object
44 45 46 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 44 def templates_dir "#{__dir__}/../../templates" end |
#validate ⇒ Object
30 31 32 33 34 35 36 |
# File 'foobara-typescript-remote-command-generator-0.0.18/src/remote_generator/generate_typescript.rb', line 30 def validate if raw_manifest.nil? && manifest_url.nil? # :nocov: add_runtime_error(MissingManifestError.new(message: "Either raw_manifest or manifest_url must be given")) # :nocov: end end |