class GemspecGenerator
Generates the rakefile that will bring in the serverspec tasks
Public Class Methods
new(options = {})
click to toggle source
# File lib/serverspec_launcher/generators/gemspec_generator.rb, line 7 def initialize(options = {}) path = options[:root_path] ? "#{options[:root_path]}/" : '' @template_path = File.expand_path('../../../../templates', __FILE__) @project_name = Dir.pwd.split('/')[-1] @gemspec_file = "#{path}#{@project_name}.gemspec" @gem_file = "#{path}Gemfile" @name = options[:name] || '<Your Name>' @email = options[:email] || '<Your email>' end
Public Instance Methods
gemfile_template()
click to toggle source
# File lib/serverspec_launcher/generators/gemspec_generator.rb, line 21 def gemfile_template File.read "#{@template_path}/Gemfile.erb" end
gemspec_template()
click to toggle source
# File lib/serverspec_launcher/generators/gemspec_generator.rb, line 17 def gemspec_template File.read "#{@template_path}/gemspec.rb.erb" end
generate()
click to toggle source
# File lib/serverspec_launcher/generators/gemspec_generator.rb, line 26 def generate renderer = ERB.new gemspec_template File.open(@gemspec_file, 'w') { |file| file.write renderer.result(binding) } if Dir['*.gemspec'].empty? renderer = ERB.new gemfile_template File.open(@gem_file, 'w') { |file| file.write renderer.result(binding) } unless File.exists? @gem_file end