lib/ronin/generators/generator.rb in ronin-gen-0.1.0 vs lib/ronin/generators/generator.rb in ronin-gen-0.1.1
- old
+ new
@@ -19,19 +19,20 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#++
#
require 'ronin/static/finders'
+require 'ronin/templates/erb'
require 'fileutils'
-require 'erb'
module Ronin
module Generators
class Generator
include Static::Finders
+ include Templates::Erb
#
# Runs the generator with the specified _path_.
#
def run(path)
@@ -72,10 +73,22 @@
puts " #{sub_path}"
end
#
+ # Touches the file at the specified _sub_path_.
+ #
+ # touch 'init.rb'
+ #
+ def touch(sub_path)
+ FileUtils.touch(expand_path(sub_path))
+
+ print_path(sub_path)
+ return sub_path
+ end
+
+ #
# Opens the file at the specified _sub_path_. If a _block_ is given,
# it will be passed a newly created File object.
#
# file('metadata.xml') do |file|
# ...
@@ -124,13 +137,10 @@
#
# render_template 'ronin/platform/generators/Rakefile.erb'
# # => "..."
#
def render_template(static_file)
- static_file = find_static_file(static_file)
- erb = ERB.new(File.read(static_file))
-
- return erb.result(binding)
+ erb_file(find_static_file(static_file))
end
#
# Renders the ERB template using the specified _static_file_,
# saving the result to the specified _sub_path_.