Class: Sprout::GeneratorGenerator

Inherits:
Sprout::Generator::Base show all
Defined in:
sprout/lib/sprout/generators/generator/generator_generator.rb

Constant Summary

Constants included from Executable

DEFAULT_FILE_EXPRESSION, DEFAULT_PREFIX, DEFAULT_SHORT_PREFIX

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Sprout::Generator::Base

#create_template_paths, #default_search_paths, #directory, #do_show_template_paths, #execute, #file, #generator, inherited, #prepare_command, #resolve_template, #say, #template, #template_paths, #unexecute, #validate

Methods inherited from Executable::Base

add_param, add_param_alias, #binary_path, #binary_path=, #create_outer_task, #default_file_expression, #execute, #execute_delegate, #from_hash, #initialize, #library_added, #parse!, #parse_extra_options!, #parse_rake_task_arg, #prepare, set, static_default_value_collection, static_parameter_collection, #stderr, #stderr=, #stdout, #stdout=, #system_execute, #to_hash, #to_help, #to_rake, #to_shell, #update_rake_task_name_from_args

Methods included from Concern

#append_features, extended, #included

Constructor Details

This class inherits a constructor from Sprout::Executable::Base

Instance Attribute Details

- (String) bin

The name of the folder where binary or executable artifacts should be created by compiler tasks.

Returns:

  • (String)

    An instance of String



# File ''

add_param :bin, String, { :default => 'bin' }

- (String) extension

The default (primary) file extension for generated source files. This should hint at the project type.

Returns:

  • (String)

    An instance of String



# File ''

add_param :extension, String, { :default => '.as' }

- (String) fixtures

The name of the child folder of the test folder where fixtures should be generated.

Returns:

  • (String)

    An instance of String



# File ''

add_param :fixtures, String, { :default => 'fixtures' }

- (String) generators

The name of the folder where custom generators and templates will be found.

Returns:

  • (String)

    An instance of String



# File ''

add_param :generators, String, { :default => 'generators' }

- (String) lib

The name of the folder where external libraries will be installed.

Returns:

  • (String)

    An instance of String



# File ''

add_param :lib, String, { :default => 'lib' }

- (String) namespace

The default module that classes will be added to.

Returns:

  • (String)

    An instance of String



# File ''

add_param :namespace, String, { :default  => ''}

- (String) test

The name of the folder where tests should be generated.

Returns:

  • (String)

    An instance of String



# File ''

add_param :test, String, { :default => 'test' }

- (String) unit

The name of the child folder of the test folder where unit tests should be generated.

Returns:

  • (String)

    An instance of String



# File ''

add_param :unit, String, { :default => 'unit' }

- (String) vendor

The name of the folder where external source code should be placed.

Returns:

  • (String)

    An instance of String



# File ''

add_param :vendor, String, { :default => 'vendor' }

Instance Method Details

- (Object) manifest



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'sprout/lib/sprout/generators/generator/generator_generator.rb', line 49

def manifest  
  massage_input

  directory bin do
    template "#{input.dash_case}", "generator_executable"
  end

  directory lib do
    #We need to add a folder with the same name as the module to be used in order to faux namespace our generators to avoid collisions from super classes
    directory namespace do
      directory generators do
        template "#{input.snake_case}_generator.rb", "generator_class.rb"
        directory "templates" do
          template "#{input.camel_case}#{extension}", "generator_template"
        end
      end
    end
  end

  directory test do
    directory unit do
      template "#{input.snake_case}_generator_test.rb", "generator_test.rb"
      template "test_helper.rb", "generator_test_helper.rb"
    end
    directory fixtures do
      directory "generators"
    end
  end

  if !File.exists? 'Gemfile'
    template 'Gemfile', 'generator_gemfile'
  else
    say "[INFO] It seems you already have a Gemfile in this project, please be sure it has the following content:"
    say ''
    say '  gem "sprout", ">= #{Sprout::VERSION::STRING}"'
    say ''
    say '  group :development do'
    say '    gem "shoulda"'
    say '    gem "mocha"'
    say '  end'
    say ''
  end
end

- (Object) massage_input (protected)



95
96
97
98
# File 'sprout/lib/sprout/generators/generator/generator_generator.rb', line 95

def massage_input
  self.input = input.gsub(/_generator$/, '')
  self.input = input.gsub(/Generator$/, '')
end