Class: PostageappGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/postageapp/postageapp_generator.rb

Overview

Rails 3 Generator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



10
11
12
13
14
15
# File 'lib/generators/postageapp/postageapp_generator.rb', line 10

def self.source_root
  @__source_root ||= File.expand_path(
    '../../../generators/postageapp/templates',
    File.dirname(__FILE__)
  )
end

Instance Method Details

#api_keyObject



30
31
32
# File 'lib/generators/postageapp/postageapp_generator.rb', line 30

def api_key
  options[:api_key]
end

#installObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/postageapp/postageapp_generator.rb', line 17

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