From b3b061a480b2bb85189afd3271204fd13c1237b3 Mon Sep 17 00:00:00 2001 From: Aart van Halteren Date: Fri, 9 Aug 2013 15:19:57 +0200 Subject: [PATCH] mailing from crontab --- etc/daily_mailer | 2 +- report_mailer.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 report_mailer.rb diff --git a/etc/daily_mailer b/etc/daily_mailer index 6cfe946..0dc3e7c 100755 --- a/etc/daily_mailer +++ b/etc/daily_mailer @@ -4,5 +4,5 @@ source /usr/local/rvm/environments/ruby-1.9.3-p125@smartmeter cd /mnt/usb/ruby/smartmeter -ruby test-serial.rb +ruby report_mailer.rb diff --git a/report_mailer.rb b/report_mailer.rb new file mode 100644 index 0000000..7ca45f0 --- /dev/null +++ b/report_mailer.rb @@ -0,0 +1,16 @@ +require "rubygems" +require "bundler/setup" +require "active_record" +require "state_pattern" + +project_root = File.dirname(File.absolute_path(__FILE__)) +Dir.glob(project_root + "/app/models/*.rb").each{|f| require f} +Dir.glob(project_root + "/app/helpers/*.rb").each{|f| require f} + +connection_details = YAML::load(File.open('config/database.yml')) +ActiveRecord::Base.establish_connection(connection_details) + +if __FILE__ == $0 + ReadingsMailer.deliver +end +#p sync