ruby-gmail 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/README.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ # This fork
2
+
3
+ contains a fix to a bug in the initializer, which was discussed [here](http://github.com/dcparker/ruby-gmail/issues#issue/7/comment/141607)
4
+
5
+ * * * *
6
+
1
7
  # ruby-gmail
2
8
 
3
9
  * Homepage: [http://dcparker.github.com/ruby-gmail/](http://dcparker.github.com/ruby-gmail/)
data/Rakefile CHANGED
@@ -1,15 +1,6 @@
1
1
  # -*- ruby -*-
2
2
 
3
3
  require 'rubygems'
4
- require 'hoe'
5
-
6
- Hoe.spec 'ruby-gmail' do
7
- developer 'Daniel Parker', 'gems@behindlogic.com'
8
- extra_deps << ['shared-mime-info', '>= 0']
9
- self.readme_file = 'README.markdown'
10
- self.url = "http://dcparker.github.com/ruby-gmail"
11
- self.post_install_message = "\n\033[34mIf ruby-gmail saves you TWO hours of work, want to compensate me for, like, a half-hour?\nSupport me in making new and better gems:\033[0m \033[31;4mhttp://pledgie.com/campaigns/7087\033[0m\n\n"
12
- end
13
4
 
14
5
  begin
15
6
  require 'jeweler'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.1.0
data/lib/gmail.rb CHANGED
@@ -19,8 +19,8 @@ class Gmail
19
19
  meta.username = username =~ /@/ ? username : username + '@gmail.com'
20
20
  meta.password = password
21
21
  @imap = Net::IMAP.new('imap.gmail.com',993,true,nil,false)
22
+ @imap.login(username, password)
22
23
  if block_given?
23
- @imap.login(username, password)
24
24
  yield self
25
25
  logout
26
26
  end
@@ -55,10 +55,8 @@ class Gmail
55
55
 
56
56
  # List the available labels
57
57
  def labels
58
- (@imap.list("", "%") + @imap.list("[Gmail]/", "%")).inject([]) do |lables,label|
59
- label[:name].each_line { |l| labels << l }
60
- labels
61
- end
58
+ (@imap.list("", "%") + @imap.list("[Gmail]/", "%")).inject([]) { |labels,label|
59
+ label[:name].each_line { |l| labels << l }; labels }
62
60
  end
63
61
 
64
62
  def in_mailbox(mailbox, &block)
data/lib/mime/entity.rb CHANGED
@@ -150,11 +150,16 @@ module MIME
150
150
  # Renders this data structure into a string, encoded
151
151
  def to_s
152
152
  multipart_boundary # initialize the boundary if necessary
153
- {'charset' => 'utf-8', 'content-transfer-encoding' => @encoding}.merge(headers).inject('') {|a,(k,v)| a << "#{MIME.capitalize_header(k)}: #{v}\r\n"} + "\r\n" + if content.is_a?(Array)
154
- "\r\n--#{multipart_boundary}\r\n" + content.collect {|part| part.to_s }.join("\r\n--#{multipart_boundary}\r\n") + "\r\n--#{multipart_boundary}--\r\n"
155
- else
156
- content.to_s
157
- end
153
+
154
+ headers_string = {'charset' => 'utf-8', 'content-transfer-encoding' => @encoding} \
155
+ .merge(headers) \
156
+ .inject('') {|a,(k,v)| a << "#{MIME.capitalize_header(k)}: #{v}\r\n" }
157
+
158
+ content_string = content.is_a?(Array) ?
159
+ content.to_s :
160
+ content.collect {|part| "--#{multipart_boundary}\r\n#{part.to_s}\r\n" }.join + "--#{multipart_boundary}--\r\n"
161
+
162
+ [headers_string, content_string].join("\r\n")
158
163
  end
159
164
 
160
165
  # Converts this data structure into a string, but decoded if necessary
@@ -58,16 +58,18 @@ module MIME
58
58
  end
59
59
  raise ArgumentError, "Must pass in either: [an array with two elements: headers(hash) and content(string or array)] OR [a hash containing :type, :boundary, and :content(being the former or a string)]"
60
60
  end
61
+
62
+ # Parse a tmail object into our Entity object
61
63
  def from_tmail(tmail)
62
64
  raise ArgumentError, "Expecting a TMail::Mail object." unless tmail.is_a?(TMail::Mail)
63
- @headers ||= Hash.new {|h,k| @tmail.header[k].to_s }
65
+ @headers ||= Hash.new {|h,k| tmail.header[k].to_s }
64
66
  if multipart?
65
- @content = @tmail.parts.collect { |tpart| Entity.new.from_tmail(tpart) }
67
+ @content = tmail.parts.collect { |tpart| Entity.new.from_tmail(tpart) }
66
68
  else
67
- set_content @tmail.body # TMail has already decoded it, but we need it still encoded
69
+ set_content tmail.body # TMail has already decoded it, but we need it still encoded
68
70
  end
69
71
  end
70
-
72
+
71
73
  ##############
72
74
  # ATTRIBUTES #
73
75
 
@@ -0,0 +1,67 @@
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{ruby-gmail}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["BehindLogic"]
12
+ s.date = %q{2010-05-05}
13
+ s.description = %q{A Rubyesque interface to Gmail, with all the tools you'll need. Search, read and send multipart emails; archive, mark as read/unread, delete emails; and manage labels.}
14
+ s.email = %q{gems@behindlogic.com}
15
+ s.extra_rdoc_files = [
16
+ "README.markdown"
17
+ ]
18
+ s.files = [
19
+ ".autotest",
20
+ ".gitignore",
21
+ "History.txt",
22
+ "Manifest.txt",
23
+ "README.markdown",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/gmail.rb",
27
+ "lib/gmail/mailbox.rb",
28
+ "lib/gmail/message.rb",
29
+ "lib/ietf/rfc2045.rb",
30
+ "lib/ietf/rfc822.rb",
31
+ "lib/mime/entity.rb",
32
+ "lib/mime/entity_tmail.rb",
33
+ "lib/mime/message.rb",
34
+ "lib/smtp_tls.rb",
35
+ "ruby-gmail.gemspec",
36
+ "test/test_gmail.rb",
37
+ "test/test_helper.rb"
38
+ ]
39
+ s.homepage = %q{http://dcparker.github.com/ruby-gmail}
40
+ s.post_install_message = %q{
41
+ If ruby-gmail saves you TWO hours of work, want to compensate me for, like, a half-hour?
42
+ Support me in making new and better gems: http://pledgie.com/campaigns/7087
43
+
44
+ }
45
+ s.rdoc_options = ["--charset=UTF-8"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = %q{1.3.6}
48
+ s.summary = %q{A Rubyesque interface to Gmail, with all the tools you'll need.}
49
+ s.test_files = [
50
+ "test/test_gmail.rb",
51
+ "test/test_helper.rb"
52
+ ]
53
+
54
+ if s.respond_to? :specification_version then
55
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
56
+ s.specification_version = 3
57
+
58
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
59
+ s.add_runtime_dependency(%q<shared-mime-info>, [">= 0"])
60
+ else
61
+ s.add_dependency(%q<shared-mime-info>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<shared-mime-info>, [">= 0"])
65
+ end
66
+ end
67
+
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 9
9
- version: 0.0.9
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - BehindLogic
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-18 00:00:00 -04:00
17
+ date: 2010-05-05 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -39,6 +39,7 @@ extra_rdoc_files:
39
39
  - README.markdown
40
40
  files:
41
41
  - .autotest
42
+ - .gitignore
42
43
  - History.txt
43
44
  - Manifest.txt
44
45
  - README.markdown
@@ -53,6 +54,7 @@ files:
53
54
  - lib/mime/entity_tmail.rb
54
55
  - lib/mime/message.rb
55
56
  - lib/smtp_tls.rb
57
+ - ruby-gmail.gemspec
56
58
  - test/test_gmail.rb
57
59
  - test/test_helper.rb
58
60
  has_rdoc: true