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



8
9
10
# File 'lib/generators/postageapp/postageapp_generator.rb', line 8

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

Instance Method Details

#api_keyObject



23
24
25
# File 'lib/generators/postageapp/postageapp_generator.rb', line 23

def api_key
  options[:api_key]
end

#installObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/postageapp/postageapp_generator.rb', line 12

def install
  if !options[:api_key]
    puts 'Must pass --api-key with API key of your PostageApp.com project'
    exit
  end
  
  template 'initializer.rb', 'config/initializers/postageapp.rb'
  copy_file 'postageapp_tasks.rake', 'lib/tasks/postageapp_tasks.rake'
  puts run('rake postageapp:test')
end