gmail 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,13 @@
1
1
  # Gmail gem changelog
2
2
 
3
- ## 0.3.1
3
+ ## 0.3.3
4
+
5
+ * Added #expunge to Mailbox (Thanks bb)
6
+ * Added more mailbox filters (Thanks bb)
7
+ * Added shortcuts for mailbox filters
8
+ * Minor bugfixes
9
+
10
+ ## 0.3.2
4
11
 
5
12
  * Added envelope fetching
6
13
  * Minor bugfixes
data/README.md CHANGED
@@ -14,6 +14,7 @@ API, is well tested, better documented and have many other improvements.
14
14
 
15
15
  Extra thanks for specific feature contributions from:
16
16
 
17
+ * [Arthur Chiu](http://github.com/achiu)
17
18
  * [Justin Perkins](http://github.com/justinperkins)
18
19
  * [Mikkel Malmberg](http://github.com/mikker)
19
20
  * [Julien Blanchard](http://github.com/julienXX)
data/Rakefile CHANGED
@@ -1,52 +1,45 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
-
5
- begin
6
- require 'jeweler'
7
-
8
- Jeweler::Tasks.new do |gem|
9
- gem.name = "gmail"
10
- gem.summary = %Q{A Rubyesque interface to Gmail, with all the tools you'll need.}
11
- gem.description = <<-DESCR
12
- A Rubyesque interface to Gmail, with all the tools you'll need. Search,
13
- read and send multipart emails; archive, mark as read/unread, delete emails;
14
- and manage labels.
15
- DESCR
16
- gem.email = "kriss.kowalik@gmail.com"
17
- gem.homepage = "http://github.com/nu7hatch/gmail"
18
- gem.authors = ["BehindLogic", "Kriss 'nu7hatch' Kowalik"]
19
- gem.add_dependency 'mime', '>= 0.1'
20
- gem.add_dependency 'mail', '>= 2.2.1'
21
- gem.add_development_dependency 'rspec', '~> 2.0'
22
- gem.add_development_dependency 'mocha', '>= 0.9'
23
- end
24
- Jeweler::GemcutterTasks.new
25
- rescue LoadError
26
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
27
- end
28
-
1
+ # -*- ruby -*-
2
+ $:.unshift(File.expand_path('../lib', __FILE__))
3
+ require 'gmail/version'
29
4
  require 'rspec/core/rake_task'
5
+ require 'rake/rdoctask'
6
+
30
7
  RSpec::Core::RakeTask.new(:spec) do |t|
31
8
  t.pattern = 'spec/**/*_spec.rb'
32
- t.rspec_opts = %q[--colour --backtrace]
9
+ t.rspec_opts = %q[-c -b]
33
10
  end
34
11
 
35
12
  RSpec::Core::RakeTask.new(:rcov) do |t|
36
13
  t.rcov = true
37
- t.rspec_opts = %q[--colour --backtrace]
38
- t.rcov_opts = %q[--exclude "spec" --text-report]
14
+ t.rspec_opts = %q[-c -b]
15
+ t.rcov_opts = %q[-T -x "spec"]
39
16
  end
40
17
 
41
- task :spec => :check_dependencies
42
- task :rcov => :check_dependencies
43
- task :default => :spec
44
-
45
- require 'rake/rdoctask'
46
18
  Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
19
  rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "Ruby GMail #{version}"
20
+ rdoc.title = "Gmail #{Gmail.version}"
50
21
  rdoc.rdoc_files.include('README*')
51
22
  rdoc.rdoc_files.include('lib/**/*.rb')
52
23
  end
24
+
25
+ task :default => :spec
26
+
27
+ desc "Build current version as a rubygem"
28
+ task :build do
29
+ `gem build gmail.gemspec`
30
+ `mkdir -p pkg`
31
+ `mv gmail-*.gem pkg/`
32
+ end
33
+
34
+ desc "Relase current version to rubygems.org"
35
+ task :release => :build do
36
+ `git tag -am "Version bump to #{Gmail.version}" v#{Gmail.version}`
37
+ `git push origin master`
38
+ `git push origin master --tags`
39
+ `gem push pkg/gmail-#{Gmail.version}.gem`
40
+ end
41
+
42
+ desc "Perform installation via rubygems"
43
+ task :install => :build do
44
+ `gem install pkg/gmail-#{Gmail.version}.gem`
45
+ end
@@ -1,79 +1,22 @@
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 -*-
1
+ # -*- ruby -*-
2
+ $:.unshift(File.expand_path('../lib', __FILE__))
3
+ require 'gmail/version'
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{gmail}
8
- s.version = "0.3.2"
6
+ s.name = 'gmail'
7
+ s.version = Gmail.version
8
+ s.homepage = 'http://github.com/nu7hatch/gmail'
9
+ s.email = ['chris@nu7hat.ch']
10
+ s.authors = ['BehindLogic', 'Chris Kowalik']
11
+ s.summary = %q{A Rubyesque interface to Gmail, with all the tools you will need.}
12
+ s.description = %q{A Rubyesque interface to Gmail, with all the tools you will need. Search, read and send multipart emails; archive, mark as read/unread, delete emails; and manage labels.}
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
15
+ s.require_paths = %w[lib]
16
+ s.extra_rdoc_files = %w[LICENSE README.md CHANGELOG.md TODO.md]
9
17
 
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
18
+ s.add_runtime_dependency 'mime', ['>= 0.1']
19
+ s.add_runtime_dependency 'mail', ['>= 2.2.1']
20
+ s.add_development_dependency 'rspec', ['~> 2.0']
21
+ s.add_development_dependency 'mocha', ['>= 0.9']
78
22
  end
79
-
@@ -1,5 +1,6 @@
1
1
  module Gmail
2
2
  class Labels
3
+ include Enumerable
3
4
  attr_reader :connection
4
5
  alias :conn :connection
5
6
 
@@ -15,6 +16,11 @@ module Gmail
15
16
  end
16
17
  end
17
18
  alias :list :all
19
+ alias :to_a :all
20
+
21
+ def each(*args, &block)
22
+ all.each(*args, &block)
23
+ end
18
24
 
19
25
  # Returns +true+ when given label defined.
20
26
  def exists?(label)
@@ -1,9 +1,19 @@
1
1
  module Gmail
2
2
  class Mailbox
3
3
  MAILBOX_ALIASES = {
4
- :all => ['ALL'],
5
- :unread => ['UNSEEN'], #'UNREAD'],
6
- :read => ['SEEN'], #'READ']
4
+ :all => ['ALL'],
5
+ :seen => ['SEEN'],
6
+ :unseen => ['UNSEEN'],
7
+ :read => ['SEEN'],
8
+ :unread => ['UNSEEN'],
9
+ :flagged => ['FLAGGED'],
10
+ :unflagged => ['UNFLAGGED'],
11
+ :starred => ['FLAGGED'],
12
+ :unstarred => ['UNFLAGGED'],
13
+ :deleted => ['DELETED'],
14
+ :undeleted => ['UNDELETED'],
15
+ :draft => ['DRAFT'],
16
+ :undrafted => ['UNDRAFT']
7
17
  }
8
18
 
9
19
  attr_reader :name
@@ -32,7 +42,7 @@ module Gmail
32
42
  args << :all if args.size == 0
33
43
 
34
44
  if args.first.is_a?(Symbol)
35
- search = MAILBOX_ALIASES[args.shift]
45
+ search = MAILBOX_ALIASES[args.shift].dup
36
46
  opts = args.first.is_a?(Hash) ? args.first : {}
37
47
 
38
48
  opts[:after] and search.concat ['SINCE', opts[:after].to_imap_date]
@@ -76,6 +86,11 @@ module Gmail
76
86
  emails(*args).size
77
87
  end
78
88
 
89
+ # This permanently removes messages which are marked as deleted
90
+ def expunge
91
+ @gmail.mailbox(name) { @gmail.conn.expunge }
92
+ end
93
+
79
94
  # Cached messages.
80
95
  def messages
81
96
  @messages ||= {}
@@ -88,5 +103,11 @@ module Gmail
88
103
  def to_s
89
104
  name
90
105
  end
106
+
107
+ MAILBOX_ALIASES.each { |mailbox|
108
+ define_method(mailbox) do |*args, &block|
109
+ emails(mailbox, *args, &block)
110
+ end
111
+ }
91
112
  end # Message
92
113
  end # Gmail
@@ -68,6 +68,7 @@ module Gmail
68
68
  def delete!
69
69
  @mailbox.messages.delete(uid)
70
70
  flag(:Deleted)
71
+ move_to('[Gmail]/Trash') unless %w[[Gmail]/Spam [Gmail]/Trash].include?(@mailbox.name)
71
72
  end
72
73
 
73
74
  # Archive this message.
@@ -1,9 +1,9 @@
1
1
  module Gmail
2
2
  class Version #:nodoc:
3
- STRING = File.open(File.join(File.dirname(__FILE__), "../../VERSION")).read.strip
4
- MAJOR = STRING.split(".")[0]
5
- MINOR = STRING.split(".")[1]
6
- TINY = STRING.split(".")[2]
3
+ MAJOR = 0
4
+ MINOR = 3
5
+ PATCH = 3
6
+ STRING = [MAJOR, MINOR, PATCH].join('.')
7
7
  end # Version
8
8
 
9
9
  def self.version # :nodoc:
metadata CHANGED
@@ -1,22 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmail
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - BehindLogic
14
- - Kriss 'nu7hatch' Kowalik
14
+ - Chris Kowalik
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-28 00:00:00 +02:00
19
+ date: 2010-11-21 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -80,8 +80,9 @@ dependencies:
80
80
  version: "0.9"
81
81
  type: :development
82
82
  version_requirements: *id004
83
- description: " A Rubyesque interface to Gmail, with all the tools you'll need. Search, \n read and send multipart emails; archive, mark as read/unread, delete emails; \n and manage labels.\n"
84
- email: kriss.kowalik@gmail.com
83
+ description: A Rubyesque interface to Gmail, with all the tools you will need. Search, read and send multipart emails; archive, mark as read/unread, delete emails; and manage labels.
84
+ email:
85
+ - chris@nu7hat.ch
85
86
  executables: []
86
87
 
87
88
  extensions: []
@@ -89,6 +90,8 @@ extensions: []
89
90
  extra_rdoc_files:
90
91
  - LICENSE
91
92
  - README.md
93
+ - CHANGELOG.md
94
+ - TODO.md
92
95
  files:
93
96
  - .gitignore
94
97
  - CHANGELOG.md
@@ -96,7 +99,6 @@ files:
96
99
  - README.md
97
100
  - Rakefile
98
101
  - TODO.md
99
- - VERSION
100
102
  - gmail.gemspec
101
103
  - lib/gmail.rb
102
104
  - lib/gmail/client.rb
@@ -115,8 +117,8 @@ homepage: http://github.com/nu7hatch/gmail
115
117
  licenses: []
116
118
 
117
119
  post_install_message:
118
- rdoc_options:
119
- - --charset=UTF-8
120
+ rdoc_options: []
121
+
120
122
  require_paths:
121
123
  - lib
122
124
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -143,10 +145,6 @@ rubyforge_project:
143
145
  rubygems_version: 1.3.7
144
146
  signing_key:
145
147
  specification_version: 3
146
- summary: A Rubyesque interface to Gmail, with all the tools you'll need.
147
- test_files:
148
- - spec/message_spec.rb
149
- - spec/mailbox_spec.rb
150
- - spec/spec_helper.rb
151
- - spec/client_spec.rb
152
- - spec/gmail_spec.rb
148
+ summary: A Rubyesque interface to Gmail, with all the tools you will need.
149
+ test_files: []
150
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.2