Class: Smartgen::Resource
- Inherits:
-
Object
- Object
- Smartgen::Resource
- 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
-
#config ⇒ Object
Returns the Configuration for this resource.
-
#configure {|config| ... } ⇒ Object
Yields a Configuration, so that you can configure the generation of files.
-
#generate! ⇒ Object
Generate files, based on the current Configuration.
Instance Method Details
#config ⇒ Object
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.
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 |