Class: EasyType::Generators::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers, PathHelpers
Defined in:
lib/easy_type/generators/base.rb

Direct Known Subclasses

EasyGenerator, RegularTypeGenerator

Constant Summary

Constants included from Helpers

Helpers::HEADER_LINE_REGEX

Class Method Summary collapse

Instance Method Summary collapse

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) ⇒ Base

Returns a new instance of Base.



18
19
20
21
22
23
24
25
26
# File 'lib/easy_type/generators/base.rb', line 18

def initialize(type_name, options)
  @name         = type_name
  @force        = options.fetch(:force) {false}
  #
  # use not because the parser automaticlay create a false when no-comments is specified
  #
  @no_comments  = !options.fetch(:no_comments) {true} 
  check_context
end

Class Method Details

.load(generator) ⇒ Object



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

def self.load(generator)
  require "easy_type/generators/#{generator}_generator"
  generator_name = camelize(generator)
  eval("EasyType::Generators::#{generator_name}Generator")
  rescue LoadError
    fail "Generator easy_type/generators/#{generator} not found."
end

Instance Method Details

#create_provider_directoryObject

Create the directory where all providers for the specified type reside.



46
47
48
# File 'lib/easy_type/generators/base.rb', line 46

def create_provider_directory
  create_directory provider_directory
end

#create_type_directoryObject

Create the directory where all the type code resides



39
40
41
# File 'lib/easy_type/generators/base.rb', line 39

def create_type_directory
  create_directory type_directory
end

#runObject

Run the scaffolder It created the directories and the nescessary files



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

def run
  create_type_directory
  create_provider_directory
end