Class: EasyType::Generators::EasyTypeGenerator

Inherits:
EasyGenerator show all
Defined in:
lib/easy_type/generators/easy_type_generator.rb

Constant Summary collapse

PROVIDER_TEMPLATE =
"easy_type_provider.rb.erb"
TYPE_TEMPLATE =
"easy_type.rb.erb"
PARAMETER_TEMPLATE =
"easy_type_name_attribute.rb.erb"

Constants included from Helpers

Helpers::HEADER_LINE_REGEX

Instance Method Summary collapse

Methods inherited from Base

#create_provider_directory, #create_type_directory, load

Methods included from Helpers

#camelize, #convert_csv_data_to_hash, included

Methods included from PathHelpers

#attribute_path, #create_directory, #create_source, included, #modulepath, #name_attribute_path, #provider_directory, #provider_path, #puppet_lib, #puppet_lib?, #save_file, #shared_attribute_path, #template_path, #type_attribute_directory, #type_directory, #type_path, #type_shared_directory, #write_file

Constructor Details

#initialize(type_name, options) ⇒ EasyTypeGenerator

Returns a new instance of EasyTypeGenerator.



11
12
13
14
15
16
# File 'lib/easy_type/generators/easy_type_generator.rb', line 11

def initialize(type_name, options)
  super(type_name, options)
  @provider    = options.fetch(:provider) {'default_provider'}
  @description = options.fetch(:description) {'A custom type'}
  @namevar     = options.fetch(:namevar) {'name'}
end

Instance Method Details

#create_easy_type_sourceObject

Create the easy type source file. ./lib/puppet/type/type_name.rb



33
34
35
# File 'lib/easy_type/generators/easy_type_generator.rb', line 33

def create_easy_type_source
  create_source(TYPE_TEMPLATE, type_path)
end

#create_name_attribute_sourceObject

Create the easy type name attribute source file. ./lib/puppet/type/type_name/parameter_name.rb



49
50
51
# File 'lib/easy_type/generators/easy_type_generator.rb', line 49

def create_name_attribute_source
  create_source(PARAMETER_TEMPLATE, name_attribute_path)
end

#create_simple_provider_sourceObject

Create the easy_type provider source file. ./lib/puppet/provider/type_name/provider_name.rb



41
42
43
# File 'lib/easy_type/generators/easy_type_generator.rb', line 41

def create_simple_provider_source
  create_source(PROVIDER_TEMPLATE, provider_path)
end

#runObject

Run the scaffolder It created the directories and the nescessary files



22
23
24
25
26
27
# File 'lib/easy_type/generators/easy_type_generator.rb', line 22

def run
  super
  create_easy_type_source
  create_simple_provider_source
  create_name_attribute_source
end