gmail_omah 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data/lib/gmail_omah.rb +77 -0
- data.tar.gz.sig +2 -0
- metadata +127 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b3d137a0ba115d3aa8b2841ae80617101d6a620
|
4
|
+
data.tar.gz: fe998b964619967541401b13519d14b3f121256f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2222f785166ad7fcd7cab236936edebab8a45ec55df6c6b6f41c50c07fca75d8265756ebfae5f680b5f7231e79e89366f056382ec58ccfa0d6a9b6ee765b9ddc
|
7
|
+
data.tar.gz: d02bdc75f132243fff4bbf16c22c87e5a4e346c12cf656c28c8dc9ce525b47a67f3860fec4647dac36cf7d9de5e050dfcdbe8a7d036c953d5dbaf9f3a2ea7e74
|
checksums.yaml.gz.sig
ADDED
data/lib/gmail_omah.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: gmail_omah.rb
|
4
|
+
|
5
|
+
require 'gmail'
|
6
|
+
require 'omah'
|
7
|
+
require 'sps-pub'
|
8
|
+
|
9
|
+
class GmailOmah
|
10
|
+
|
11
|
+
def initialize(user: 'user', filepath: '.', mail: {}, sps: {}, email_address: nil)
|
12
|
+
|
13
|
+
@user = user
|
14
|
+
@mail = {user_name: '', password: '' }.merge mail
|
15
|
+
|
16
|
+
field = %i(user_name password).detect {|x| @mail[x].empty?}
|
17
|
+
return "GmailOmah: missing %s" % field if field
|
18
|
+
|
19
|
+
@sps = SPSPub.new(address: sps[:address], port: sps[:port]) if sps
|
20
|
+
@email_address = @mail[:user_name]
|
21
|
+
|
22
|
+
Dir.chdir filepath
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_email()
|
27
|
+
|
28
|
+
gmail = Gmail.new(@mail[:user_name], @mail[:password])
|
29
|
+
a = gmail.inbox.emails
|
30
|
+
|
31
|
+
return 'no new messages' unless a.any?
|
32
|
+
|
33
|
+
# fields we are interested in:
|
34
|
+
#
|
35
|
+
# :from, :message_id, :to, :subject, :date, :body.decoded,
|
36
|
+
# :text_part.to_s, html_part.to_s
|
37
|
+
|
38
|
+
messages = a.map.with_index.inject([]) do |r, x|
|
39
|
+
|
40
|
+
gmail_msg, i = x
|
41
|
+
msg = gmail_msg.message
|
42
|
+
|
43
|
+
begin
|
44
|
+
r << {
|
45
|
+
id: msg.message_id,
|
46
|
+
from: msg.from.is_a?(Array) ? msg.from.join(', ') : msg.from,
|
47
|
+
to: msg.to.is_a?(Array) ? msg.to.join(', ') : msg.to,
|
48
|
+
subject: msg.subject,
|
49
|
+
date: msg.date.to_s,
|
50
|
+
body_text: (msg.text_part ? msg.text_part.body.decoded : msg.body.decoded),
|
51
|
+
body_html: (msg.html_part ? msg.html_part.body.decoded : msg.body.decoded),
|
52
|
+
attachments: msg.attachments.map {|x| [x.filename, x.body.decoded] }
|
53
|
+
}
|
54
|
+
rescue
|
55
|
+
puts 'warning: ' + ($!).inspect
|
56
|
+
end
|
57
|
+
|
58
|
+
r
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
o = Omah.new user: @user
|
63
|
+
|
64
|
+
# messages are stored to the file dynarexdaily.xml
|
65
|
+
o.store messages
|
66
|
+
|
67
|
+
m = 'message'
|
68
|
+
m += 's' if messages.length > 1
|
69
|
+
fqm = "email/new: %s received %s new %s" \
|
70
|
+
% [@email_address, messages.length, m]
|
71
|
+
|
72
|
+
@sps.notice fqm if @sps
|
73
|
+
|
74
|
+
a.each {|email| email.delete! }
|
75
|
+
fqm
|
76
|
+
end
|
77
|
+
end
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gmail_omah
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTE1MDUyMzE2MDk1M1oXDTE2MDUyMjE2MDk1M1owSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
+
ggEBAMMPlcSK2Pm+nHG0n+DQTl8HARpdOixVPbki2myh6E5EZJLBn5rhAugwx0bs
|
19
|
+
mTgnMsyM2gZ494WgsmbuZzXBvKA7GQfA2LeYkV/sAd9ki1syHGDyK6PLtaU0SHvT
|
20
|
+
7wnyLCbWjUgdBJKbl+nXSwU/z7xCYUvc30UaCY1NaoeKlTGSm8eXGeHtM0c6eZD0
|
21
|
+
Vi/BTohy1c6QyV5t7VaN5LB8+/ubwvxXjVpKFlULdi7Q+3XYHUP4CuoVegsz3DD9
|
22
|
+
CcKcCWWAbrZ94zli13zz0e4yQQaxINQUFVhl9N/SsPafUAQII5w3wGjNJr6poq78
|
23
|
+
aBuquw9xIXM+QzxWqhMiDX8+9qsCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUi/JZthkPwtL7sWIsEhtZSDfin0EwJgYDVR0RBB8w
|
25
|
+
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEABBJu5Dw7
|
27
|
+
htsJzB6kUwFgV948Wt//0Bjha9gup+mIt7VNe6aaeilyCf9rfvTI0+Emf6WC1pUS
|
28
|
+
x11LNga0YrGaDTbt6030S//t/YluCNPUeHKd0vZmT256Xk/tfHtxYr69+96uIT0U
|
29
|
+
cucZerFoxm0jn8Yce0ygQ+bAQ3IRFxnGT2buRIzngyqUuuGGlKQ3mPVNwy1FAOB9
|
30
|
+
aET+ytxDyk1AxmL1pLbyQZn0jh19QXkjb+b7CJhmaDneGzeZhdaNF16kctADEAey
|
31
|
+
ndSRFD0AP3Aqx2T6Vl7mAQAlA2HfWcoImcyhITujG4RG/ucFJuXOE7REl/3kX9Z/
|
32
|
+
jVQ/sDgShsz7Ig==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2015-05-23 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: omah
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.4'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.0
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.4'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: gmail
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.5'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.5.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.5'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.5.0
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: sps-pub
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.4'
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.4.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0.4'
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.4.0
|
96
|
+
description:
|
97
|
+
email: james@r0bertson.co.uk
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- lib/gmail_omah.rb
|
103
|
+
homepage: https://github.com/jrobertson/gmail_omah
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.4.6
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Gmail gem + Omah (Offline Mail Helper) gem
|
127
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|