gmail 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGELOG.md +6 -1
- data/README.md +2 -2
- data/VERSION +1 -1
- data/gmail.gemspec +79 -0
- data/lib/gmail/mailbox.rb +2 -2
- data/lib/gmail/message.rb +15 -3
- data/spec/account.yml.example +2 -0
- data/spec/mailbox_spec.rb +9 -19
- data/spec/spec_helper.rb +17 -1
- metadata +6 -4
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -240,8 +240,8 @@ Or, generate the message first and send it later
|
|
240
240
|
|
241
241
|
## Copyright
|
242
242
|
|
243
|
-
Copyrignt (c) 2010 Kriss 'nu7hatch' Kowalik
|
244
|
-
Copyright (c) 2009-2010 BehindLogic
|
243
|
+
* Copyrignt (c) 2010 Kriss 'nu7hatch' Kowalik
|
244
|
+
* Copyright (c) 2009-2010 BehindLogic
|
245
245
|
|
246
246
|
See LICENSE for details.
|
247
247
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/gmail.gemspec
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gmail}
|
8
|
+
s.version = "0.3.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["BehindLogic", "Kriss 'nu7hatch' Kowalik"]
|
12
|
+
s.date = %q{2010-10-28}
|
13
|
+
s.description = %q{ A Rubyesque interface to Gmail, with all the tools you'll need. Search,
|
14
|
+
read and send multipart emails; archive, mark as read/unread, delete emails;
|
15
|
+
and manage labels.
|
16
|
+
}
|
17
|
+
s.email = %q{kriss.kowalik@gmail.com}
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.md"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".gitignore",
|
24
|
+
"CHANGELOG.md",
|
25
|
+
"LICENSE",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"TODO.md",
|
29
|
+
"VERSION",
|
30
|
+
"gmail.gemspec",
|
31
|
+
"lib/gmail.rb",
|
32
|
+
"lib/gmail/client.rb",
|
33
|
+
"lib/gmail/labels.rb",
|
34
|
+
"lib/gmail/mailbox.rb",
|
35
|
+
"lib/gmail/message.rb",
|
36
|
+
"lib/gmail/version.rb",
|
37
|
+
"spec/account.yml.example",
|
38
|
+
"spec/client_spec.rb",
|
39
|
+
"spec/gmail_spec.rb",
|
40
|
+
"spec/mailbox_spec.rb",
|
41
|
+
"spec/message_spec.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
s.homepage = %q{http://github.com/nu7hatch/gmail}
|
45
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = %q{1.3.7}
|
48
|
+
s.summary = %q{A Rubyesque interface to Gmail, with all the tools you'll need.}
|
49
|
+
s.test_files = [
|
50
|
+
"spec/message_spec.rb",
|
51
|
+
"spec/mailbox_spec.rb",
|
52
|
+
"spec/spec_helper.rb",
|
53
|
+
"spec/client_spec.rb",
|
54
|
+
"spec/gmail_spec.rb"
|
55
|
+
]
|
56
|
+
|
57
|
+
if s.respond_to? :specification_version then
|
58
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
+
s.specification_version = 3
|
60
|
+
|
61
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
62
|
+
s.add_runtime_dependency(%q<mime>, [">= 0.1"])
|
63
|
+
s.add_runtime_dependency(%q<mail>, [">= 2.2.1"])
|
64
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.0"])
|
65
|
+
s.add_development_dependency(%q<mocha>, [">= 0.9"])
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<mime>, [">= 0.1"])
|
68
|
+
s.add_dependency(%q<mail>, [">= 2.2.1"])
|
69
|
+
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
70
|
+
s.add_dependency(%q<mocha>, [">= 0.9"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<mime>, [">= 0.1"])
|
74
|
+
s.add_dependency(%q<mail>, [">= 2.2.1"])
|
75
|
+
s.add_dependency(%q<rspec>, ["~> 2.0"])
|
76
|
+
s.add_dependency(%q<mocha>, [">= 0.9"])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
data/lib/gmail/mailbox.rb
CHANGED
data/lib/gmail/message.rb
CHANGED
@@ -122,15 +122,27 @@ module Gmail
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def method_missing(meth, *args, &block)
|
125
|
-
# Delegate rest directly to the message.
|
126
|
-
|
125
|
+
# Delegate rest directly to the message.
|
126
|
+
if envelope.respond_to?(meth)
|
127
|
+
envelope.send(meth, *args, &block)
|
128
|
+
elsif message.respond_to?(meth)
|
129
|
+
message.send(meth, *args, &block)
|
130
|
+
else
|
131
|
+
super(meth, *args, &block)
|
132
|
+
end
|
127
133
|
end
|
128
134
|
|
135
|
+
def envelope
|
136
|
+
@envelope ||= @gmail.mailbox(@mailbox.name) {
|
137
|
+
@gmail.conn.uid_fetch(uid, "ENVELOPE")[0].attr["ENVELOPE"]
|
138
|
+
}
|
139
|
+
end
|
140
|
+
|
129
141
|
private
|
130
142
|
|
131
143
|
def message
|
132
144
|
@message ||= Mail.new(@gmail.mailbox(@mailbox.name) {
|
133
|
-
@gmail.conn.uid_fetch(uid, "RFC822")[0].attr["RFC822"]
|
145
|
+
@gmail.conn.uid_fetch(uid, "RFC822")[0].attr["RFC822"] # RFC822
|
134
146
|
})
|
135
147
|
end
|
136
148
|
end # Message
|
data/spec/mailbox_spec.rb
CHANGED
@@ -2,13 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "A Gmail mailbox" do
|
4
4
|
subject { Gmail::Mailbox }
|
5
|
-
|
6
|
-
def within_gmail(&block)
|
7
|
-
gmail = Gmail.connect!(*TEST_ACCOUNT)
|
8
|
-
yield(gmail)
|
9
|
-
gmail.logout if gmail
|
10
|
-
end
|
11
|
-
|
5
|
+
|
12
6
|
context "on initialize" do
|
13
7
|
it "should set client and name" do
|
14
8
|
within_gmail do |gmail|
|
@@ -17,7 +11,7 @@ describe "A Gmail mailbox" do
|
|
17
11
|
mailbox.name.should == "TEST"
|
18
12
|
end
|
19
13
|
end
|
20
|
-
|
14
|
+
|
21
15
|
it "should work in INBOX by default" do
|
22
16
|
within_gmail do |gmail|
|
23
17
|
mailbox = subject.new(@gmail)
|
@@ -25,24 +19,20 @@ describe "A Gmail mailbox" do
|
|
25
19
|
end
|
26
20
|
end
|
27
21
|
end
|
28
|
-
|
22
|
+
|
29
23
|
context "instance" do
|
30
|
-
|
31
|
-
within_gmail do |gmail|
|
32
|
-
mailbox = subject.new(gmail, box)
|
33
|
-
yield(mailbox) if block_given?
|
34
|
-
mailbox
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
24
|
+
|
38
25
|
it "should be able to count all emails" do
|
39
26
|
mock_mailbox do |mailbox|
|
40
27
|
mailbox.count.should > 0
|
41
28
|
end
|
42
29
|
end
|
43
|
-
|
30
|
+
|
44
31
|
it "should be able to find messages" do
|
45
|
-
|
32
|
+
mock_mailbox do |mailbox|
|
33
|
+
message = mailbox.emails.first
|
34
|
+
mailbox.emails(:all, :from => message.from.first.name) == message.from.first.name
|
35
|
+
end
|
46
36
|
end
|
47
37
|
end
|
48
38
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,10 +4,26 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'rspec'
|
6
6
|
require 'mocha'
|
7
|
+
require 'yaml'
|
7
8
|
require 'gmail'
|
8
9
|
|
9
10
|
RSpec.configure do |config|
|
10
11
|
config.mock_with :mocha
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
def within_gmail(&block)
|
15
|
+
gmail = Gmail.connect!(*TEST_ACCOUNT)
|
16
|
+
yield(gmail)
|
17
|
+
gmail.logout if gmail
|
18
|
+
end
|
19
|
+
|
20
|
+
def mock_mailbox(box="INBOX", &block)
|
21
|
+
within_gmail do |gmail|
|
22
|
+
mailbox = subject.new(gmail, box)
|
23
|
+
yield(mailbox) if block_given?
|
24
|
+
mailbox
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Run test by creating your own test account with credentials in account.yml
|
29
|
+
TEST_ACCOUNT = YAML.load_file(File.join(File.dirname(__FILE__), 'account.yml'))
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- BehindLogic
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-28 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -97,12 +97,14 @@ files:
|
|
97
97
|
- Rakefile
|
98
98
|
- TODO.md
|
99
99
|
- VERSION
|
100
|
+
- gmail.gemspec
|
100
101
|
- lib/gmail.rb
|
101
102
|
- lib/gmail/client.rb
|
102
103
|
- lib/gmail/labels.rb
|
103
104
|
- lib/gmail/mailbox.rb
|
104
105
|
- lib/gmail/message.rb
|
105
106
|
- lib/gmail/version.rb
|
107
|
+
- spec/account.yml.example
|
106
108
|
- spec/client_spec.rb
|
107
109
|
- spec/gmail_spec.rb
|
108
110
|
- spec/mailbox_spec.rb
|