Class: MaileeRails::Setup
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MaileeRails::Setup
- Includes:
- Rails::Generators::Actions
- Defined in:
- lib/mailee/railties.rb
Overview
Creates the mailee:rails:setup generator. This generator creates an initializer called “mailee.rb” by asking the user his api URL, and defining it to Mailee::Config.site attribute wich makes all that ActiveResource stuff works.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mailee/railties.rb', line 14 def create puts "Please enter your api URL:" attempts = 0 url = readline.gsub(/\n/,'').gsub(/\s+/, '') while url !~ /^https?:\/\/api\.[a-f0-9]{13}\.[a-z\-]+?\.mailee\.me\/?$/ attempts += 1 if attempts < 3 puts "Invalid URL. Please try again:" url = readline.gsub(/\n/,'').gsub(/\s+/, '') else puts "I think you need support. Please talk to us on IRC (#maileeme) or send an email to [email protected]" exit end end url.gsub!('http://','https://') initializer("mailee.rb") do "Mailee::Config.site = '#{url}'" end puts "*** Keep your key top secret, ok?" puts "*** If anything goes wrong, reach us on IRC (#mailee) or by email on [email protected]" puts "*** Thanks for using Mailee.me" end |