Sha256: a5fd0d1dacdfa580961f237e1d5d95f150c23d840f2d26b9e380fee76bd9653c

Contents?: true

Size: 824 Bytes

Versions: 7

Compression:

Stored size: 824 Bytes

Contents

# Wrapper around rake manifest
Rails::Generator::Commands::Create.class_eval do
  def rake(command)
    system "rake #{command}"
  end
end

# Rails 2 Generator
class PostageappGenerator < Rails::Generator::Base
  def add_options!(opt)
    opt.on('-k=key', '--api-key=key') do |value|
      options[:api_key] = value
    end
  end
  
  def manifest
    unless (options[:api_key])
      puts 'Must pass --api-key with API key of your PostageApp.com project'
      exit
    end
    
    record do |m|
      m.template 'initializer.rb', 'config/initializers/postageapp.rb', 
        assigns: { api_key: options[:api_key] },
        collision: :force
      m.directory 'lib/tasks'
      m.file 'postageapp_tasks.rake', 'lib/tasks/postageapp_tasks.rake',
        collision: :force
      m.rake 'postageapp:test'
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
postageapp-1.4.2 generators/postageapp/postageapp_generator.rb
postageapp-1.4.1 generators/postageapp/postageapp_generator.rb
postageapp-1.4.0 generators/postageapp/postageapp_generator.rb
postageapp-1.3.1 generators/postageapp/postageapp_generator.rb
postageapp-1.3.0 generators/postageapp/postageapp_generator.rb
postageapp-1.2.6 generators/postageapp/postageapp_generator.rb
postageapp-1.2.5 generators/postageapp/postageapp_generator.rb