Class: Smartgen::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/smartgen/resource.rb

Overview

A Resource holds a Configuration used when generating files.

You create a resource and configure it like this:

Smartgen[:my_resource].configure do |config|
  config.src_files = ['docs/**/*']
  config.output_folder = 'public/docs'
end

To generate files, just call Resource#generate! on it:

Smartgen[:my_resource].generate!

Instance Method Summary collapse

Instance Method Details

#configObject

Returns the Configuration for this resource.



23
24
25
# File 'lib/smartgen/resource.rb', line 23

def config
  @config ||= Smartgen::Configuration.new
end

#configure {|config| ... } ⇒ Object

Yields a Configuration, so that you can configure the generation of files.

Yields:



18
19
20
# File 'lib/smartgen/resource.rb', line 18

def configure
  yield config if block_given?
end

#generate!Object

Generate files, based on the current Configuration.



28
29
30
# File 'lib/smartgen/resource.rb', line 28

def generate!
  generator.invoke_all
end