bio-polymarker_db_batch 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/bio-polymarker_db_batch/polymarker_db_batch.rb +18 -11
- data/test/test_email.rb +43 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da45b3e074939e929a4f033239ea1266513885e6
|
4
|
+
data.tar.gz: 4d5a1811ae63656af0180ca532b6618048c371e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a0df21c2eaf9d19fdcf5df49248415b88931f2197139f1a3cef62c776cda476008518f56b42f9e5b7ea1601a87d0fb67117ed7122ead257589dcf97457620cd
|
7
|
+
data.tar.gz: 379bc02e20d8599eb2a88deb2e037a51d8043a125217d8ff3fa07376bd11a42b034a65aff544771d4e143c0bd8b0f6acecb79b73c59e4cde3db3144ee46ecb77
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -4,7 +4,7 @@ class Bio::DB::Polymarker
|
|
4
4
|
|
5
5
|
def initialize( props)
|
6
6
|
@properties =Hash[*File.read(props).split(/[=\n]+/)]
|
7
|
-
puts @properties.inspect
|
7
|
+
#puts @properties.inspect
|
8
8
|
end
|
9
9
|
|
10
10
|
def mysql_version
|
@@ -69,24 +69,31 @@ class Bio::DB::Polymarker
|
|
69
69
|
pst = con.prepare "UPDATE snp_file SET status = ? WHERE snp_file_id = ?"
|
70
70
|
pst.execute new_status, snp_file_id
|
71
71
|
con.commit
|
72
|
+
begin
|
73
|
+
send_email(to,id, status)
|
74
|
+
rescue
|
75
|
+
puts "Error sending email."
|
76
|
+
end
|
72
77
|
end
|
73
78
|
|
74
|
-
def send_email(to,
|
75
|
-
|
76
|
-
opts[:from] ||= 'polymarker@tgac.ac.uk'
|
77
|
-
opts[:from_alias] ||= 'Example Emailer'
|
78
|
-
opts[:subject] ||= "You need to see this"
|
79
|
-
opts[:body] ||= "Important stuff!"
|
79
|
+
def send_email(to,id, status)
|
80
|
+
options = @properties
|
80
81
|
|
81
82
|
msg = <<END_OF_MESSAGE
|
82
|
-
From: #{
|
83
|
+
From: #{options['email_from_alias']} <#{options['email_from']}>
|
83
84
|
To: <#{to}>
|
84
|
-
Subject: #{
|
85
|
+
Subject: Polymarker #{id} #{status}
|
86
|
+
|
87
|
+
The current status of your request (#{id}) is #{status}
|
88
|
+
The latest status and results (when done) are available in: #{options['web_domain']}/status?id=#{id}
|
89
|
+
|
85
90
|
|
86
91
|
#{opts[:body]}
|
87
92
|
END_OF_MESSAGE
|
88
|
-
Net::SMTP.
|
89
|
-
|
93
|
+
smtp = Net::SMTP.new options["email_server"], 587
|
94
|
+
smtp.enable_starttls
|
95
|
+
smtp.start( options["email_domain"], options["email_user"], options["email_pwd"], :login) do
|
96
|
+
smtp.send_message(msg, options["email_from"], to)
|
90
97
|
end
|
91
98
|
end
|
92
99
|
|
data/test/test_email.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#require 'bioruby-polyploid-tools'
|
3
|
+
require 'optparse'
|
4
|
+
require 'mysql'
|
5
|
+
require 'net/smtp'
|
6
|
+
|
7
|
+
#$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
8
|
+
#$: << File.expand_path('.')
|
9
|
+
#path=File.expand_path(File.dirname(__FILE__) + '/../lib/bio-polymarker_db_batch.rb')
|
10
|
+
#$stderr.puts "Loading: #{path}"
|
11
|
+
#require path
|
12
|
+
|
13
|
+
#options = {}
|
14
|
+
props = ""
|
15
|
+
|
16
|
+
OptionParser.new do |opts|
|
17
|
+
opts.banner = "Usage: run_pending_polymarker.rb [options]"
|
18
|
+
|
19
|
+
opts.on("-p", "--preferences FILE" "File with the preferences") do |o|
|
20
|
+
props = o
|
21
|
+
end
|
22
|
+
|
23
|
+
end.parse!
|
24
|
+
options =Hash[*File.read(props).split(/[=\n]+/)]
|
25
|
+
to = "ricardo.ramirez-gonzalez@tgac.ac.uk"
|
26
|
+
msg = <<END_OF_MESSAGE
|
27
|
+
From: #{options['email_from_alias']} <#{options['email_from']}>
|
28
|
+
To: <#{to}>
|
29
|
+
Subject: Test from ruby
|
30
|
+
|
31
|
+
The text we are sending!
|
32
|
+
END_OF_MESSAGE
|
33
|
+
|
34
|
+
puts options.inspect
|
35
|
+
smtp = Net::SMTP.new options["email_server"], 587
|
36
|
+
smtp.enable_starttls
|
37
|
+
smtp.start( options["email_domain"], options["email_user"], options["email_pwd"], :login) do
|
38
|
+
smtp.send_message(msg, options["email_from"], to)
|
39
|
+
end
|
40
|
+
|
41
|
+
#Net::SMTP.start(options["email_server"], 25, options["email_domain"], options["email_user"], options["email_pwd"], :cram_md5) do |smtp|
|
42
|
+
# smtp.send_message msg, opts[:from], to
|
43
|
+
#end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bio-polymarker_db_batch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo H. Ramirez-Gonzalez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bio-polyploid-tools
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/bio-polymarker_db_batch/polymarker_db_batch.rb
|
148
148
|
- test/helper.rb
|
149
149
|
- test/test_bio-polymarker_db_batch.rb
|
150
|
+
- test/test_email.rb
|
150
151
|
homepage: http://github.com/homonecloco/bioruby-polymarker_db_batch
|
151
152
|
licenses:
|
152
153
|
- MIT
|