Permalink
Browse files

- Added Rails 3 compatible generators.

  • Loading branch information...
1 parent 7ebbaa8 commit b880c737b640032dff2abde234467b9ceab0f2f9 Amol Hatwár committed May 23, 2010
View
@@ -13,6 +13,11 @@ Install using:
script/plugin install git://github.com/look/fetcher.git
+== Dependencies
+
+This plugin depends on the SystemTimer gem. Do not forget to add it to your Gemfile. After adding,
+remember to do a "bundle install"
+
== Usage
Create a new fetcher object like the following:
@@ -89,4 +94,6 @@ You can read more about how to use the Fetcher in the PeepCode book {Receiving E
Created by Dan Weinand and Luke Francl. Development supported by {Slantwise Design}[http://slantwisedesign.com].
+Generators for Rails 3 compatibility added by Amol Hatwár, Exceed Consulting.
+
Licensed under the terms of the MIT License. Be excellent to each other.
@@ -1,9 +1,10 @@
Description:
- Create a fetcher daemon
+ Create a fetcher daemon with a given name
Example:
- ./script/generate fetcher_daemon sms
+ ./script/generate fetcher_daemon MailReader
This will create:
- /config/sms_fetcher.yml
- /script/sms_fetcher
+ /config/mail_reader_fetcher.yml
+ /script/mail_reader_fetcher
+ /lib/daemon.rb
@@ -1,17 +1,23 @@
+defaults: &defaults
+ type: imap # pop OR imap
+ server: imap.example.com # server hostname
+ port: # 993 for IMAPs
+ ssl: true # Remove if not using SSL
+ username: # Username
+ password: # Password
+ receiver: # ActionMailer that will receive mail
+ use_login: true # Required for GMAIL
+ sleep_time: # Poll Frequency. 60 seconds by default
+ authentication: # LOGIN, CRAM-MD5, PASSWORD (IMAP Only)
+
development:
- type: pop
- server: localhost
- username: username
- password: password
+ <<: *defaults
+ # Override other values here
test:
- type: pop
- server: localhost
- username: username
- password: password
+ <<: *defaults
+ # Override other values here
production:
- type: pop
- server: localhost
- username: username
- password: password
+ <<: *defaults
+ # Override other values here
@@ -3,8 +3,8 @@ require File.dirname(__FILE__) + '/../config/environment.rb'
class <%=class_name%>FetcherDaemon < Daemon::Base
- @config = YAML.load_file("#{RAILS_ROOT}/config/<%=file_name%>.yml")
- @config = @config[RAILS_ENV].to_options
+ @config = YAML.load_file("#{Rails.root}/config/<%=file_name%>.yml")
+ @config = @config[Rails.env].to_options
@sleep_time = @config.delete(:sleep_time) || 60
def self.start
@@ -0,0 +1,12 @@
+require 'rails/generators'
+
+class FetcherDaemonGenerator < Rails::Generators::NamedBase
+ source_root File.join(File.dirname(__FILE__), '../../../generators/fetcher_daemon', 'templates')
+
+ def create_fetcher_daemon
+ copy_file('daemon.rb', "lib/daemon.rb")
+ template('config.yml', File.join('config', "#{file_name}.yml"))
+ template('daemon', File.join('script', "#{file_name}_fetcher"))
+ chmod(File.join("script", "#{file_name}_fetcher"), 0755)
+ end
+end

0 comments on commit b880c73

Please sign in to comment.