ruby-gmail 0.3.0 → 0.3.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.
- data/README.markdown +9 -14
- data/Rakefile +4 -0
- data/VERSION +1 -1
- data/lib/gmail.rb +27 -8
- data/lib/gmail/message.rb +9 -4
- data/ruby-gmail.gemspec +1 -1
- data/test/test_helper.rb +1 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# Notice
|
2
2
|
|
3
|
-
|
3
|
+
I have pushed verion 0.3.1 to rubygems.org (Yay, thanks Nick Quaranto for the help) which is a build straight from master.
|
4
4
|
|
5
|
-
Second, this gem
|
5
|
+
Second, this gem is getting back on track. See [this issue here](https://github.com/dcparker/ruby-gmail/issues/58) for more information.
|
6
6
|
|
7
7
|
# ruby-gmail
|
8
8
|
|
9
|
-
* Homepage: [http://dcparker.github.com/ruby-gmail/](http://dcparker.github.com/ruby-gmail/)
|
10
9
|
* Code: [http://github.com/dcparker/ruby-gmail](http://github.com/dcparker/ruby-gmail)
|
11
|
-
* Gem: [http://gemcutter.org/gems/ruby-gmail](http://
|
10
|
+
* Gem: [http://gemcutter.org/gems/ruby-gmail](http://rubygems.org/gems/ruby-gmail)
|
12
11
|
|
13
12
|
## Author(s)
|
14
13
|
|
15
14
|
* Daniel Parker of BehindLogic.com
|
15
|
+
* Nathan Herald
|
16
16
|
|
17
17
|
Extra thanks for specific feature contributions from:
|
18
18
|
|
@@ -100,19 +100,13 @@ A Rubyesque interface to Gmail, with all the tools you'll need. Search, read and
|
|
100
100
|
# Save all attachments in the "Faxes" label to a folder
|
101
101
|
folder = "/where/ever"
|
102
102
|
gmail.mailbox("Faxes").emails.each do |email|
|
103
|
-
|
104
|
-
|
103
|
+
email.attachments.each do |attachment|
|
104
|
+
file = File.new(folder + attachment.filename, "w+")
|
105
|
+
file << attachment.decoded
|
106
|
+
file.close
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
108
|
-
# Save just the first attachment from the newest unread email (assuming pdf)
|
109
|
-
# For #save_to_file:
|
110
|
-
# + provide a path - save to attachment filename in path
|
111
|
-
# + provide a filename - save to file specified
|
112
|
-
# + provide no arguments - save to attachment filename in current directory
|
113
|
-
email = gmail.inbox.emails(:unread).first
|
114
|
-
email.attachments[0].save_to_file("/path/to/location")
|
115
|
-
|
116
110
|
# Add a label to a message
|
117
111
|
email.label("Faxes")
|
118
112
|
|
@@ -130,6 +124,7 @@ Creating emails now uses the amazing [Mail](http://rubygems.org/gems/mail) rubyg
|
|
130
124
|
body "Text of plaintext message."
|
131
125
|
end
|
132
126
|
html_part do
|
127
|
+
content_type 'text/html; charset=UTF-8'
|
133
128
|
body "<p>Text of <em>html</em> message.</p>"
|
134
129
|
end
|
135
130
|
add_file "/path/to/some_image.jpg"
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/gmail.rb
CHANGED
@@ -38,14 +38,29 @@ class Gmail
|
|
38
38
|
in_label('inbox')
|
39
39
|
end
|
40
40
|
|
41
|
+
def destroy_label(name)
|
42
|
+
imap.delete(name)
|
43
|
+
end
|
44
|
+
|
45
|
+
def rename_label(oldname, newname)
|
46
|
+
imap.rename(oldname, newname)
|
47
|
+
end
|
48
|
+
|
41
49
|
def create_label(name)
|
42
50
|
imap.create(name)
|
43
51
|
end
|
44
52
|
|
53
|
+
def mailbox_list
|
54
|
+
imap.list("","*")
|
55
|
+
end
|
56
|
+
|
45
57
|
# List the available labels
|
46
58
|
def labels
|
47
|
-
|
48
|
-
label[:name]
|
59
|
+
mailbox_list.inject([]) do |labels,label|
|
60
|
+
labels << label[:name] unless label.attr.include?(:Noselect)
|
61
|
+
|
62
|
+
labels
|
63
|
+
end
|
49
64
|
end
|
50
65
|
|
51
66
|
# gmail.label(name)
|
@@ -54,18 +69,22 @@ class Gmail
|
|
54
69
|
end
|
55
70
|
alias :mailbox :label
|
56
71
|
|
72
|
+
def find_label_by_attribute(attribute)
|
73
|
+
mailbox_list.find{ |label| label.attr.include?(attribute.to_sym.capitalize) }
|
74
|
+
end
|
75
|
+
|
57
76
|
# don't mark emails as read on the server when downloading them
|
58
77
|
attr_accessor :peek
|
59
78
|
|
60
79
|
###########################
|
61
80
|
# MAKING EMAILS
|
62
|
-
#
|
81
|
+
#
|
63
82
|
# gmail.generate_message do
|
64
83
|
# ...inside Mail context...
|
65
84
|
# end
|
66
|
-
#
|
85
|
+
#
|
67
86
|
# gmail.deliver do ... end
|
68
|
-
#
|
87
|
+
#
|
69
88
|
# mail = Mail.new...
|
70
89
|
# gmail.deliver!(mail)
|
71
90
|
###########################
|
@@ -105,12 +124,12 @@ class Gmail
|
|
105
124
|
@logged_in = false if res && res.name == 'OK'
|
106
125
|
end
|
107
126
|
end
|
108
|
-
|
127
|
+
|
109
128
|
# Shutdown socket and disconnect
|
110
129
|
def disconnect
|
111
130
|
logout if logged_in?
|
112
131
|
@imap.disconnect unless @imap.disconnected?
|
113
|
-
end
|
132
|
+
end
|
114
133
|
|
115
134
|
def in_mailbox(mailbox, &block)
|
116
135
|
if block_given?
|
@@ -139,7 +158,7 @@ class Gmail
|
|
139
158
|
def inspect
|
140
159
|
"#<Gmail:#{'0x%x' % (object_id << 1)} (#{meta.username}) #{'dis' if !logged_in?}connected>"
|
141
160
|
end
|
142
|
-
|
161
|
+
|
143
162
|
# Accessor for @imap, but ensures that it's logged in first.
|
144
163
|
def imap
|
145
164
|
unless logged_in?
|
data/lib/gmail/message.rb
CHANGED
@@ -38,7 +38,7 @@ class Gmail
|
|
38
38
|
when :deleted
|
39
39
|
flag(:Deleted)
|
40
40
|
when :spam
|
41
|
-
|
41
|
+
move_to_special_folder(:Junk)
|
42
42
|
end ? true : false
|
43
43
|
end
|
44
44
|
|
@@ -78,11 +78,14 @@ class Gmail
|
|
78
78
|
label(name) && delete!
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
82
|
-
|
81
|
+
def move_to_special_folder(attribute)
|
82
|
+
name = @gmail.find_label_by_attribute(attribute).name
|
83
|
+
move_to(name)
|
83
84
|
end
|
84
85
|
|
85
|
-
|
86
|
+
def archive!
|
87
|
+
move_to_special_folder(:All)
|
88
|
+
end
|
86
89
|
|
87
90
|
# Parsed MIME message object
|
88
91
|
def message
|
@@ -93,6 +96,8 @@ class Gmail
|
|
93
96
|
@message ||= Mail.new(_body)
|
94
97
|
end
|
95
98
|
|
99
|
+
private
|
100
|
+
|
96
101
|
# Delegate all other methods to the Mail message
|
97
102
|
def method_missing(*args, &block)
|
98
103
|
if block_given?
|
data/ruby-gmail.gemspec
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-gmail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shared-mime-info
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 1.8.23
|
106
|
+
rubygems_version: 1.8.23.2
|
107
107
|
signing_key:
|
108
108
|
specification_version: 3
|
109
109
|
summary: A Rubyesque interface to Gmail, with all the tools you'll need.
|