Class: Huck::Generators::FileGenerator

Inherits:
Huck::Generator show all
Defined in:
lib/huck/generators/file.rb

Overview

File generator reads any file and submits the raw content

Instance Attribute Summary

Attributes inherited from Huck::Generator

#config

Instance Method Summary collapse

Methods inherited from Huck::Generator

factory

Instance Method Details

#generateObject

Reads in a configured file and returns the data

Returns:

The text contained within the specified file



20
21
22
23
# File 'lib/huck/generators/file.rb', line 20

def generate
  verify_config
  IO.read(@config['path'])
end

#verify_configObject

Ensure that all JSON config items are properly set



9
10
11
12
13
# File 'lib/huck/generators/file.rb', line 9

def verify_config
  if !@config.has_key? 'path'
    raise Huck::Error, 'missing "file" generator config: "path"'
  end
end