Sha256: 24f0d882272dd3423bd060a6e96cd0064236701c9a8efabab5234171fae2ad10

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

require 'rails/generators'

# Rails 3 Generator
class PostageappGenerator < Rails::Generators::Base
  class_option :api_key,
    :aliases => [ '-k=value', '--api-key=value' ],
    :type => :string,
    :desc => 'Your PostageApp API key'
  
  def self.source_root
    @_hoptoad_source_root ||= File.expand_path(
      '../../../../generators/postageapp/templates',
      __FILE__
    )
  end
  
  def install
    unless (options[:api_key])
      puts 'Must pass --api-key with API key of your PostageApp.com project'

      exit(-1)
    end
    
    template('initializer.rb', 'config/initializers/postageapp.rb')
    copy_file('postageapp_tasks.rake', 'lib/tasks/postageapp_tasks.rake')

    puts run('rake postageapp:test')
  end
  
  def api_key
    options[:api_key]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
postageapp-1.2.0 lib/generators/postageapp/postageapp_generator.rb