luggage 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dcaf5c5940857410afb20c4e5bca8e13dcd7104
4
- data.tar.gz: 019ce4b62e899a33b2119bb24b1d0f327ea3c634
3
+ metadata.gz: d26e7a17d30fe62e65aebba3677c9947be2129f0
4
+ data.tar.gz: 02e19e80be8b1fceee116f1b6b683c9d98ff2ac7
5
5
  SHA512:
6
- metadata.gz: 99b5fea709397491179ab1f6c19c6e2b04ea6b933f2eae238f39e2d670120c02520618e01763315d31a2a1aa44a40f3ec55901af07a0635c441d1c7ddeb01408
7
- data.tar.gz: da1204cc9373fa4703403ace74d4058b8458011fce034df33baa80903091ec22e069d8282f0dee25de7aedebbdbe52eb547e04102d7bf553cbb43b9da9bbcbb3
6
+ metadata.gz: 41fd1f37fe4d66a1e206e9dca496fcdc6b64cac0676dd71ae1d54d27cfd76046584374fcfbc0013fa6fdcc1514094928a71e7adf05c4b6e0361634524d8ba7fb
7
+ data.tar.gz: 46ddd62da10c99c667c00d17e8040bc1a0fac974d6399cf9ab0dbe85050456962158c4ce30d358c615766d98a8f92fd8a57407f0d539c080d00efb3057b9cc27
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  #Changes
2
2
 
3
+ ## Unreleased
4
+
5
+ * Add `Message#copy_to!`. - Ben Hamill
6
+
3
7
  ## 1.1.2
4
8
 
5
9
  * Remove hidden reliance on ActiveRecord's `#present?` helper. - Ben Hamill
@@ -4,6 +4,25 @@ module Luggage
4
4
 
5
5
  attr_reader :connection, :name
6
6
 
7
+ def self.convert_mailbox_name(mailbox_name)
8
+ case mailbox_name
9
+ when :g_all
10
+ "[Gmail]/All Mail"
11
+ when :g_sent
12
+ "[Gmail]/Sent"
13
+ when :g_trash
14
+ "[Gmail]/Trash"
15
+ when :inbox, :spam, :sent, :trash
16
+ mailbox_name.to_s.upcase
17
+ when Symbol
18
+ mailbox_name.to_s
19
+ when String
20
+ mailbox_name
21
+ else
22
+ nil
23
+ end
24
+ end
25
+
7
26
  # This provides an interface to a remote Imap mailbox
8
27
  #
9
28
  # `connection` should be an authenticated Net::IMAP
@@ -7,21 +7,10 @@ module Luggage
7
7
  end
8
8
 
9
9
  def [](*args, &block)
10
- case args.first
11
- when String
12
- mailbox(args.first, &block)
13
- when :inbox, :spam, :sent, :trash
14
- mailbox(args.first.to_s.upcase, &block)
15
- when :g_all
16
- mailbox("[Gmail]/All Mail", &block)
17
- when :g_sent
18
- mailbox("[Gmail]/Sent", &block)
19
- when :g_trash
20
- mailbox("[Gmail]/Trash", &block)
21
- when Symbol
22
- mailbox(args.first, &block)
23
- when nil
24
- mailboxes
10
+ mailbox_name = Luggage::Mailbox.convert_mailbox_name(args.first)
11
+
12
+ if mailbox_name
13
+ mailbox(mailbox_name, &block)
25
14
  else
26
15
  super
27
16
  end
@@ -75,6 +75,13 @@ module Luggage
75
75
  connection.append(mailbox.name, raw_message, flags.map {|f| f.to_sym.upcase}, date)
76
76
  end
77
77
 
78
+ # Uses IMAP's COPY command to copy the message into the named mailbox
79
+ #
80
+ def copy_to!(mailbox_name)
81
+ mailbox.select!
82
+ connection.uid_copy([uid], Luggage::Mailbox.convert_mailbox_name(mailbox_name))
83
+ end
84
+
78
85
  # Add the 'Deleted' flag to this message on the remote server
79
86
  #
80
87
  def delete!
@@ -1,3 +1,3 @@
1
1
  module Luggage
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luggage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Michael