Class: EasyType::Generators::Base

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

Overview

docs

Direct Known Subclasses

EasyGenerator, RegularTypeGenerator

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#camelize, #convert_csv_data_to_hash, #get_puppet_file, 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.



26
27
28
29
30
31
32
33
34
# File 'lib/easy_type/generators/base.rb', line 26

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



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

def self.load(generator)
  # rubocop: disable Style/EvalWithLocation
  require "easy_type/generators/#{generator}_generator"
  generator_name = camelize(generator)
  eval("EasyType::Generators::#{generator_name}Generator")
  # rubocop: enable Style/EvalWithLocation
rescue LoadError
  raise "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.



55
56
57
# File 'lib/easy_type/generators/base.rb', line 55

def create_provider_directory
  create_directory provider_directory
end

#create_type_directoryObject

Create the directory where all the type code resides



48
49
50
# File 'lib/easy_type/generators/base.rb', line 48

def create_type_directory
  create_directory type_directory
end

#runObject

Run the scaffolder It created the directories and the nescessary files



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

def run
  create_type_directory
  create_provider_directory
end