gmailish 0.0.1
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 +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +20 -0
- data/.simplecov +19 -0
- data/.travis.yml +8 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +89 -0
- data/Rakefile +1 -0
- data/gmailish.gemspec +29 -0
- data/lib/gmailish.rb +7 -0
- data/lib/gmailish/account.rb +41 -0
- data/lib/gmailish/actions.rb +53 -0
- data/lib/gmailish/all.rb +7 -0
- data/lib/gmailish/error.rb +6 -0
- data/lib/gmailish/flagger.rb +27 -0
- data/lib/gmailish/labeler.rb +29 -0
- data/lib/gmailish/message.rb +42 -0
- data/lib/gmailish/mover.rb +25 -0
- data/lib/gmailish/version.rb +3 -0
- data/spec/gmailish_spec.rb +135 -0
- data/spec/lib/gmailish/account_spec.rb +89 -0
- data/spec/lib/gmailish/actions_spec.rb +116 -0
- data/spec/lib/gmailish/error_spec.rb +19 -0
- data/spec/lib/gmailish/flagger_spec.rb +45 -0
- data/spec/lib/gmailish/labeler_spec.rb +75 -0
- data/spec/lib/gmailish/message_spec.rb +146 -0
- data/spec/lib/gmailish/mover_spec.rb +49 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/data.rb +7 -0
- metadata +183 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gmailish
|
4
|
+
describe Message do
|
5
|
+
let(:instance) { Gmailish::Message.new(account, uid) }
|
6
|
+
let(:uid) { 37 }
|
7
|
+
let(:account) {
|
8
|
+
fire_double(
|
9
|
+
'Net::IMAP'
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it 'takes arguments' do
|
15
|
+
instance
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.process' do
|
20
|
+
subject { described_class.process(account, uid) }
|
21
|
+
|
22
|
+
it 'calls off to process' do
|
23
|
+
described_class.any_instance.should_receive(:message).twice
|
24
|
+
described_class.any_instance.should_receive(:actions)
|
25
|
+
|
26
|
+
subject
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#process' do
|
31
|
+
subject { instance.process }
|
32
|
+
|
33
|
+
let(:rfc) { 'RFC822' }
|
34
|
+
|
35
|
+
let(:labeler) {
|
36
|
+
fire_double(
|
37
|
+
'Gmailish::Labeler',
|
38
|
+
:transfered => true
|
39
|
+
)
|
40
|
+
}
|
41
|
+
|
42
|
+
let(:flagger) {
|
43
|
+
fire_double(
|
44
|
+
'Gmailish::Flagger',
|
45
|
+
:unread => true
|
46
|
+
)
|
47
|
+
}
|
48
|
+
|
49
|
+
let(:mover) {
|
50
|
+
fire_double(
|
51
|
+
'Gmailish::Mover',
|
52
|
+
:archive => true
|
53
|
+
)
|
54
|
+
}
|
55
|
+
|
56
|
+
context 'actions' do
|
57
|
+
before { instance.stub(:message) }
|
58
|
+
|
59
|
+
it 'runs' do
|
60
|
+
Labeler.should_receive(:new).
|
61
|
+
with(account, uid).
|
62
|
+
and_return(labeler)
|
63
|
+
|
64
|
+
Flagger.should_receive(:new).
|
65
|
+
with(account, uid).
|
66
|
+
and_return(flagger)
|
67
|
+
|
68
|
+
Mover.should_receive(:new).
|
69
|
+
with(account, uid).
|
70
|
+
and_return(mover)
|
71
|
+
|
72
|
+
subject
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'message' do
|
77
|
+
before { instance.stub(:actions) }
|
78
|
+
|
79
|
+
let(:messages) { [ message ] }
|
80
|
+
let(:message) {
|
81
|
+
fire_double(
|
82
|
+
'Net::IMAP::FetchData',
|
83
|
+
:attr => attr
|
84
|
+
)
|
85
|
+
}
|
86
|
+
|
87
|
+
let(:mail) {
|
88
|
+
fire_double(
|
89
|
+
'Mail'
|
90
|
+
)
|
91
|
+
}
|
92
|
+
|
93
|
+
let(:attr) {
|
94
|
+
{
|
95
|
+
"UID" => 105,
|
96
|
+
"RFC822" => body
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
let(:body) {
|
101
|
+
"Delivered-To: venkmanapp+9eac16a@gmail.com"
|
102
|
+
}
|
103
|
+
|
104
|
+
context 'none' do
|
105
|
+
it 'return Mail object' do
|
106
|
+
account.should_receive(:uid_fetch).
|
107
|
+
with(uid, rfc).
|
108
|
+
and_return(nil)
|
109
|
+
|
110
|
+
message.should_not_receive(:attr)
|
111
|
+
|
112
|
+
subject
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'single' do
|
117
|
+
it 'return Mail object' do
|
118
|
+
account.should_receive(:uid_fetch).
|
119
|
+
with(uid, rfc).
|
120
|
+
and_return(message)
|
121
|
+
|
122
|
+
Mail.should_receive(:new).
|
123
|
+
with(body).
|
124
|
+
and_return(mail)
|
125
|
+
|
126
|
+
expect(subject).to_not be_nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'multiple' do
|
131
|
+
it 'return Mail object' do
|
132
|
+
account.should_receive(:uid_fetch).
|
133
|
+
with(uid, rfc).
|
134
|
+
and_return(messages)
|
135
|
+
|
136
|
+
Mail.should_receive(:new).
|
137
|
+
with(body).
|
138
|
+
and_return(mail)
|
139
|
+
|
140
|
+
expect(subject).to_not be_nil
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gmailish
|
4
|
+
describe Mover do
|
5
|
+
let(:instance) { Mover.new(account, uid) }
|
6
|
+
let(:uid) { 37 }
|
7
|
+
let(:account) {
|
8
|
+
fire_double(
|
9
|
+
'Net::IMAP'
|
10
|
+
)
|
11
|
+
}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it 'takes arguments' do
|
15
|
+
instance
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#archive' do
|
20
|
+
subject { instance.archive }
|
21
|
+
|
22
|
+
let(:labeler) {
|
23
|
+
fire_double(
|
24
|
+
'Gmailish::Labeler',
|
25
|
+
:all_mail => true
|
26
|
+
)
|
27
|
+
}
|
28
|
+
|
29
|
+
let(:flagger) {
|
30
|
+
fire_double(
|
31
|
+
'Gmailish::Flagger',
|
32
|
+
:delete => true
|
33
|
+
)
|
34
|
+
}
|
35
|
+
|
36
|
+
it 'calls off to Labeler and Flagger' do
|
37
|
+
Labeler.should_receive(:new).
|
38
|
+
with(account, uid).
|
39
|
+
and_return(labeler)
|
40
|
+
|
41
|
+
Flagger.should_receive(:new).
|
42
|
+
with(account, uid).
|
43
|
+
and_return(flagger)
|
44
|
+
|
45
|
+
subject
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
ENV["RAILS_ENV"] ||= 'test'
|
7
|
+
|
8
|
+
require 'rspec/fire'
|
9
|
+
require 'rspec/autorun'
|
10
|
+
require 'gmailish'
|
11
|
+
|
12
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.order = "random"
|
16
|
+
config.filter_run :focus => true
|
17
|
+
config.color_enabled = true
|
18
|
+
config.run_all_when_everything_filtered = true
|
19
|
+
|
20
|
+
config.include RSpec::Fire
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec::Fire.configure do |config|
|
24
|
+
config.verify_constant_names = true
|
25
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module Gmailish
|
2
|
+
class SupportData
|
3
|
+
def self.fake_fetch_data_response
|
4
|
+
{"UID"=>111, "RFC822"=>"Delivered-To: venkmanapp+40f7f061c2f7254b1b50f699d9eac16a@gmail.com\r\nReceived: by 10.67.2.8 with SMTP id bk8csp76264pad;\r\n Wed, 27 Mar 2013 07:37:43 -0700 (PDT)\r\nReturn-Path: <chuckjhardy@gmail.com>\r\nReceived-SPF: pass (google.com: domain of chuckjhardy@gmail.com designates 10.50.77.113 as permitted sender) client-ip=10.50.77.113\r\nAuthentication-Results: mr.google.com;\r\n spf=pass (google.com: domain of chuckjhardy@gmail.com designates 10.50.77.113 as permitted sender) smtp.mail=chuckjhardy@gmail.com;\r\n dkim=pass header.i=@gmail.com\r\nX-Received: from mr.google.com ([10.50.77.113])\r\n by 10.50.77.113 with SMTP id r17mr2239264igw.89.1364395063322 (num_hops = 1);\r\n Wed, 27 Mar 2013 07:37:43 -0700 (PDT)\r\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n d=gmail.com; s=20120113;\r\n h=x-received:mime-version:in-reply-to:references:from:date:message-id\r\n :subject:to:content-type;\r\n bh=4VQaatCoScZcHWE3RJ0x5oxemkkqJcA8KSuLWATUz2A=;\r\n b=eLqylx/txCVXYGKxv2XmyKUoA7WYcftCrFUuZlVadUShO/t+hCugIY/StTVJMwtwcH\r\n i+b0pyWKWR6xe1F2Fsg/iTNf7zsBCAkMfRHWszp3iMOQ7X7L4dmZd9sSQ3FlYLHxbSgK\r\n Qad+dCI8IzK6jwiRjz5wvR6zxa/IqvwkFHw4eNceIN4VUyqLSNS2xcB6QwOYVI0bLWXE\r\n 434beOnAd4jd+nQfz2yhm1ztoYFUT3HpUW2lq9WNtOVi8VDxcjS/hvw5+HG+EkviOu9J\r\n S54pLriacYQhmi+Rlgl3YXVewaaEISxkgAG2X5c+tnFU5PL/F60B3QSRduMdAvqPXv4e\r\n wo4A==\r\nX-Received: by 10.50.77.113 with SMTP id r17mr2239264igw.89.1364395063317;\r\n Wed, 27 Mar 2013 07:37:43 -0700 (PDT)\r\nMIME-Version: 1.0\r\nReceived: by 10.64.68.101 with HTTP; Wed, 27 Mar 2013 07:37:03 -0700 (PDT)\r\nIn-Reply-To: <-3268989094069137341@unknownmsgid>\r\nReferences: <-3268989094069137341@unknownmsgid>\r\nFrom: Chuck Hardy <chuckjhardy@gmail.com>\r\nDate: Wed, 27 Mar 2013 14:37:03 +0000\r\nMessage-ID: <CAL2fzerGytNXJ0k+HwEfHq_sZxnRU5i0shSmXUrUKVr9EJd9Sw@mail.gmail.com>\r\nSubject: Fwd: Raising and Rescuing Custom Errors in Rails | We Are Stac\r\nTo: venkmanapp+40f7f061c2f7254b1b50f699d9eac16a@gmail.com\r\nContent-Type: multipart/alternative; boundary=047d7bd76900151d2e04d8e8fb12\r\n\r\n--047d7bd76900151d2e04d8e8fb12\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\n---------- Forwarded message ----------\r\nFrom: Chuck Hardy <chuckjhardy@gmail.com>\r\nDate: 27 March 2013 09:29\r\nSubject: Raising and Rescuing Custom Errors in Rails | We Are Stac\r\nTo: ChuckJHardy <chuckjhardy@gmail.com>\r\n\r\n\r\nhttp://wearestac.com/blog/raising-and-rescuing-custom-errors-in-rails\r\n\r\n\r\nSent from my iPhone\r\n\r\n\r\n\r\n-- \r\nChuck J Hardy\r\n\r\n--047d7bd76900151d2e04d8e8fb12\r\nContent-Type: text/html; charset=ISO-8859-1\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n<div dir=3D\"ltr\"><br><br><div class=3D\"gmail_quote\">---------- Forwarded me=\r\nssage ----------<br>From: <b class=3D\"gmail_sendername\">Chuck Hardy</b> <sp=\r\nan dir=3D\"ltr\"><<a href=3D\"mailto:chuckjhardy@gmail.com\">chuckjhardy@gma=\r\nil.com</a>></span><br>\r\n\r\nDate: 27 March 2013 09:29<br>Subject: Raising and Rescuing Custom Errors in=\r\n Rails | We Are Stac<br>To: ChuckJHardy <<a href=3D\"mailto:chuckjhardy@g=\r\nmail.com\">chuckjhardy@gmail.com</a>><br><br><br><a href=3D\"http://weares=\r\ntac.com/blog/raising-and-rescuing-custom-errors-in-rails\" target=3D\"_blank\"=\r\n>http://wearestac.com/blog/raising-and-rescuing-custom-errors-in-rails</a><=\r\nbr>\r\n\r\n\r\n<br>\r\n<br>\r\nSent from my iPhone<br>\r\n</div><br><br clear=3D\"all\"><div><br></div>-- <br>Chuck J Hardy\r\n</div>\r\n\r\n--047d7bd76900151d2e04d8e8fb12--\r\n", "FLAGS"=>[:Seen]}
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gmailish
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Charles J Hardy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mail
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.5.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.5.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.13.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.13.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-fire
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.1.3
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.1.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.7.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.7.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov-vim
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.0.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.0.1
|
111
|
+
description: Grabs unread emails for Gmail, marks them as read, applies a given label
|
112
|
+
and archives them.
|
113
|
+
email:
|
114
|
+
- chuckjhardy@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .coveralls.yml
|
120
|
+
- .gitignore
|
121
|
+
- .simplecov
|
122
|
+
- .travis.yml
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- gmailish.gemspec
|
128
|
+
- lib/gmailish.rb
|
129
|
+
- lib/gmailish/account.rb
|
130
|
+
- lib/gmailish/actions.rb
|
131
|
+
- lib/gmailish/all.rb
|
132
|
+
- lib/gmailish/error.rb
|
133
|
+
- lib/gmailish/flagger.rb
|
134
|
+
- lib/gmailish/labeler.rb
|
135
|
+
- lib/gmailish/message.rb
|
136
|
+
- lib/gmailish/mover.rb
|
137
|
+
- lib/gmailish/version.rb
|
138
|
+
- spec/gmailish_spec.rb
|
139
|
+
- spec/lib/gmailish/account_spec.rb
|
140
|
+
- spec/lib/gmailish/actions_spec.rb
|
141
|
+
- spec/lib/gmailish/error_spec.rb
|
142
|
+
- spec/lib/gmailish/flagger_spec.rb
|
143
|
+
- spec/lib/gmailish/labeler_spec.rb
|
144
|
+
- spec/lib/gmailish/message_spec.rb
|
145
|
+
- spec/lib/gmailish/mover_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
- spec/support/data.rb
|
148
|
+
homepage: https://github.com/ChuckJHardy/Gmailish
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.0.3
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Grabs unread emails for Gmail, marks them as read, applies a given label
|
172
|
+
and archives them.
|
173
|
+
test_files:
|
174
|
+
- spec/gmailish_spec.rb
|
175
|
+
- spec/lib/gmailish/account_spec.rb
|
176
|
+
- spec/lib/gmailish/actions_spec.rb
|
177
|
+
- spec/lib/gmailish/error_spec.rb
|
178
|
+
- spec/lib/gmailish/flagger_spec.rb
|
179
|
+
- spec/lib/gmailish/labeler_spec.rb
|
180
|
+
- spec/lib/gmailish/message_spec.rb
|
181
|
+
- spec/lib/gmailish/mover_spec.rb
|
182
|
+
- spec/spec_helper.rb
|
183
|
+
- spec/support/data.rb
|