Class: TestUnit::CreateGenerator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- TestUnit::CreateGenerator
- Includes:
- Thor::Actions
- Defined in:
- lib/test_unit/create_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #copy_generator_files ⇒ Object
- #plural_name ⇒ Object
- #singular_name ⇒ Object
- #update_setup ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
20 21 22 |
# File 'lib/test_unit/create_generator.rb', line 20 def exit_on_failure? true end |
Instance Method Details
#class_name ⇒ Object
43 44 45 |
# File 'lib/test_unit/create_generator.rb', line 43 def class_name singular_name.capitalize end |
#copy_generator_files ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/test_unit/create_generator.rb', line 47 def copy_generator_files return if [:dry_run] say "Adding files...", :green template "templates/template_generator.rb.erb", "lib/test_unit/generators/operations/#{name}_generator.rb" template "templates/template_generator_spec.rb.erb", "spec/test_unit/generators/operations/#{name}_generator_spec.rb" create_file "lib/test_unit/generators/operations/#{name}/templates/#{name}_test.rb.erb" do "This is #{name}.rb.erb" end end |
#plural_name ⇒ Object
35 36 37 |
# File 'lib/test_unit/create_generator.rb', line 35 def plural_name name.pluralize end |
#singular_name ⇒ Object
39 40 41 |
# File 'lib/test_unit/create_generator.rb', line 39 def singular_name name.singularize end |
#update_setup ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/test_unit/create_generator.rb', line 61 def update_setup say "Updating setup...", :green setup_file = "lib/test_unit/generators/operations/setup/templates/generators.rb" include_text = " \"test_unit/generators/operations/#{name}_generator\" if defined?(#{library})\nrequire" insert_into_file setup_file, include_text.to_s, after: Regexp.new(Regexp.escape("require")) end |