Class: OrigenAppGenerators::New
- Includes:
- Origen::Utility::InputCapture
- Defined in:
- lib/origen_app_generators/new.rb
Instance Method Summary collapse
-
#conclude ⇒ Object
Can’t compile this as contains some final ERB, so substitute instead def customize_doc_page file = filelist[:dest] gsub_file file, ‘TITLE_GOES_HERE’, @title if @type == :plugin gsub_file file, ‘INTRO_GOES_HERE’, “This generates a customized version of the [Generic Plugin](<%= path ‘origen_app_generators/plugin’ %>).” else gsub_file file, ‘INTRO_GOES_HERE’, “This generates a customized version of the [Generic Application](<%= path ‘origen_app_generators/application’ %>).” end end.
- #enable ⇒ Object
- #generate_files ⇒ Object
-
#get_common_user_input ⇒ Object
Naming of this method is important here to override the default user input which does not apply to this generator.
- #set_type ⇒ Object
Methods inherited from Base
#get_lastest_origen_version, #set_source_paths
Instance Method Details
#conclude ⇒ Object
Can’t compile this as contains some final ERB, so substitute instead def customize_doc_page
file = filelist[:doc_info][:dest]
gsub_file file, 'TITLE_GOES_HERE', @title
if @type == :plugin
gsub_file file, 'INTRO_GOES_HERE', "This generates a customized version of the [Generic Plugin](<%= path 'origen_app_generators/plugin' %>)."
else
gsub_file file, 'INTRO_GOES_HERE', "This generates a customized version of the [Generic Application](<%= path 'origen_app_generators/application' %>)."
end
end
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/origen_app_generators/new.rb', line 80 def conclude system "origen lint #{Origen.root}/lib/#{Origen.app.name}.rb" puts puts "New generator created at: #{filelist[:generator][:dest]}" puts puts "Create any template files you need for this generator in: #{filelist[:templates_dir][:dest]}" puts # puts "Before you go add some documentation about what this generates to: templates/web/origen_app_generators/origen_app_generators/#{@domain_namespace.underscore}/#{@classname.underscore}.md.erb" # puts end |
#enable ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/origen_app_generators/new.rb', line 25 def enable available = Origen.app.namespace.constantize::AVAILABLE test_inputs = Origen.app.namespace.constantize::TEST_INPUTS # **** Add require line **** module_declaration = /\nmodule #{Origen.app.namespace}/ inject_into_file "lib/#{Origen.app.name}.rb", "require '#{Origen.app.name}/#{@domain_namespace.underscore}/#{@classname.underscore}'\n", before: module_declaration # **** Add to the AVAILABLE hash **** if available[@domain_summary] existing_domain = /\s*('|")#{@domain_summary}('|") => \[\s*\n/ inject_into_file "lib/#{Origen.app.name}.rb", " #{Origen.app.namespace}::#{@domain_namespace}::#{@classname},\n", after: existing_domain else new_domain = "'\#{@domain_summary}' => [\n \#{Origen.app.namespace}::\#{@domain_namespace}::\#{@classname},\n],\n END\n available_hash = /AVAILABLE = {\\s*\\n/\n inject_into_file \"lib/\#{Origen.app.name}.rb\", new_domain, after: available_hash\n end\n\n # **** Add a starter set of test inputs ****\n # First work out what the selection numbers will be for the new generator\n if available[@domain_summary]\n first = available.size - available.find_index { |k, _| k == @domain_summary }\n second = available[@domain_summary].size\n else\n first = available.size + 1\n second = 0\n end\n inputs = \"\\n # \#{test_inputs.size} - \#{@domain_namespace}::\#{@classname}\\n\"\n if @parentclass == 'Plugin'\n inputs += \" ['\#{first}', '\#{second}', :default, :default, 'A cool plugin', 'yes', :default]\"\n else\n inputs += \" ['\#{first}', '\#{second}', :default, :default, :default]\"\n end\n inputs = \",\#{inputs}\" unless test_inputs.empty?\n end_of_test_inputs = /\\n\\s*]\\s*#\\s*END_OF_TEST_INPUTS/\n inject_into_file \"lib/\#{Origen.app.name}.rb\", inputs, before: end_of_test_inputs\nend\n" |
#generate_files ⇒ Object
21 22 23 |
# File 'lib/origen_app_generators/new.rb', line 21 def generate_files build_filelist end |
#get_common_user_input ⇒ Object
Naming of this method is important here to override the default user input which does not apply to this generator
9 10 11 12 13 14 15 |
# File 'lib/origen_app_generators/new.rb', line 9 def get_common_user_input get_domain get_name get_type get_summary @namespace = Origen.app.namespace end |
#set_type ⇒ Object
17 18 19 |
# File 'lib/origen_app_generators/new.rb', line 17 def set_type # Type not applicable in for this generator end |