Sha256: d1a510a9b60a14c28b091e83d0a7c51e27799a494a68471dec14069308ff0865

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

class TweakGenerator < Rails::Generator::Base

	TWEAKS_CONFIG_FILENAME = 'config/initializers/tweaks_config.rb'

  def manifest
    record do |m|
      m.directory "tweaks"
      m.template "tweak.erb", File.join("tweaks", "#{m.target.args.first}_tweak.rb") #:assigns => { :args => @gen_args }
			
			tweaks_config_filepath = File.expand_path(TWEAKS_CONFIG_FILENAME,RAILS_ROOT)
			tweaks_config_s = ''
			File.open(tweaks_config_filepath, "r") { |f| tweaks_config_s = f.read } if File.exists?(tweaks_config_filepath)
			STDOUT.puts "\n  Creating/appending #{m.target.args.first} config to #{tweaks_config_filepath}\n\n"
			tweaks_config_s += <<CONFIG_TEMPLATE

Tweaks.configure(
  :#{m.target.args.first},
  {
    # config values here
  }
)

CONFIG_TEMPLATE

			File.open(tweaks_config_filepath,'w') {|file| file.write tweaks_config_s }
		end			
	end	
				
  protected
  def banner
    "Usage: #{$0} #{spec.name} tweak_name"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tweaks-0.2.0 rails_generators/tweak/tweak_generator.rb
tweaks-0.1.0 rails_generators/tweak/tweak_generator.rb