luggage 1.1.1 → 1.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05ff8f011e4e73d7be9c891dac56c206f28d9fc4
4
- data.tar.gz: 92a3d1845a0de22df435c7f3e78eec6150a69f24
3
+ metadata.gz: 4dcaf5c5940857410afb20c4e5bca8e13dcd7104
4
+ data.tar.gz: 019ce4b62e899a33b2119bb24b1d0f327ea3c634
5
5
  SHA512:
6
- metadata.gz: 00a3930bf00f7376a0b43f8f25b857b7f44b1c3b68d5fe80e9bcde1127914eb546cb80b2692d6580d270c15966246a01157948621914725d63107ec0f395f6cd
7
- data.tar.gz: 2c8fed78b22756f2a80d26f1bbd558c75faba9161a3b3b624688c4cdb2dcf91fbd1d9401987fabebb28a1b8d9b3396ff771f9d31cd0b41099442885fb9912f0f
6
+ metadata.gz: 99b5fea709397491179ab1f6c19c6e2b04ea6b933f2eae238f39e2d670120c02520618e01763315d31a2a1aa44a40f3ec55901af07a0635c441d1c7ddeb01408
7
+ data.tar.gz: da1204cc9373fa4703403ace74d4058b8458011fce034df33baa80903091ec22e069d8282f0dee25de7aedebbdbe52eb547e04102d7bf553cbb43b9da9bbcbb3
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  #Changes
2
2
 
3
+ ## 1.1.2
4
+
5
+ * Remove hidden reliance on ActiveRecord's `#present?` helper. - Ben Hamill
6
+
3
7
  ## 1.1.1
4
8
 
5
9
  * Fix bug when trying to use XOAUTH to authenticate. - Ben Hamill
@@ -28,7 +28,9 @@ module Luggage
28
28
  # Returns true if this mailbox exists on the remote server, false otherwise
29
29
  #
30
30
  def exists?
31
- @exists ||= connection.list("", name).present?
31
+ return @exists if instance_variable_defined?(:@exists)
32
+
33
+ @exists = !connection.list("", name).empty?
32
34
  end
33
35
 
34
36
  # Deletes this mailbox on the remote server
@@ -36,7 +36,7 @@ module Luggage
36
36
  # `connection` should be an authenticated Imap connection
37
37
  # `mailbox` should be either a Mailbox or a string describing a remote mailbox
38
38
  # `args[:date]` when this message is appended to the remote server, this is the date which will be used
39
- # `args[:template]` use this file as the initial raw email content.
39
+ # `args[:template]` use this file as the initial raw email content.
40
40
  # `args[:message_id]` use this as for the Message-ID header. This header is used to identify messages across requests
41
41
  #
42
42
  def initialize(connection, mailbox, args = {}, &block)
@@ -87,10 +87,10 @@ module Luggage
87
87
  #
88
88
  def exists?
89
89
  mailbox.select!
90
- connection.uid_search("HEADER Message-ID #{message_id}").present?
90
+ connection.uid_search("HEADER Message-ID #{message_id}")
91
91
  end
92
92
 
93
- # Proxy all other methods to this instance's Mail::Message
93
+ # Proxy all other methods to this instance's Mail::Message
94
94
  #
95
95
  def method_missing(meth, *args, &block)
96
96
  if mail.respond_to?(meth)
@@ -117,16 +117,15 @@ module Luggage
117
117
  end
118
118
 
119
119
  def mail
120
- reload unless @mail.present?
120
+ reload if @mail.nil?
121
121
  @mail
122
122
  end
123
123
 
124
124
  def uid
125
- unless @uid.present?
126
- mailbox.select!
127
- @uid = fetch_uid
128
- end
129
- @uid
125
+ return @uid if instance_variable_defined?(:@uid)
126
+
127
+ mailbox.select!
128
+ @uid = fetch_uid
130
129
  end
131
130
 
132
131
  def fetch_uid
@@ -1,3 +1,3 @@
1
1
  module Luggage
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -42,9 +42,9 @@ describe Luggage::Factory do
42
42
  describe "#mailboxes" do
43
43
  before(:each) do
44
44
  connection.stub(:list).
45
- and_return([
46
- OpenStruct.new(:name => "Mailbox_1"),
47
- OpenStruct.new(:name => "Mailbox_2"),
45
+ and_return([
46
+ OpenStruct.new(:name => "Mailbox_1"),
47
+ OpenStruct.new(:name => "Mailbox_2"),
48
48
  OpenStruct.new(:name => "Mailbox_3"),
49
49
  OpenStruct.new(:name => "Mailbox_4") ])
50
50
  end
@@ -62,7 +62,7 @@ describe Luggage::Message do
62
62
  end
63
63
 
64
64
  it "sets date if passed" do
65
- date = 2.days.ago
65
+ date = Date.today - 2
66
66
  expect(Luggage::Message.new(connection, :mailbox, :date => date).date).to eq(date)
67
67
  end
68
68
 
@@ -90,7 +90,7 @@ describe Luggage::Message do
90
90
  it "fetches raw email" do
91
91
  connection.should_receive(:uid_fetch).
92
92
  with([1], ["FLAGS", "INTERNALDATE", "BODY.PEEK[]"]).
93
- and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" => 1.day.ago.to_s}}] )
93
+ and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" => (Time.now - 60 * 60 * 24).to_s}}] )
94
94
 
95
95
  message.reload
96
96
  end
@@ -98,7 +98,7 @@ describe Luggage::Message do
98
98
  it "fetches flags" do
99
99
  connection.should_receive(:uid_fetch).
100
100
  with([1], ["FLAGS", "INTERNALDATE", "BODY.PEEK[]"]).
101
- and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" => 1.day.ago.to_s}}] )
101
+ and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" => (Time.now - 60 * 60 * 24).to_s}}] )
102
102
 
103
103
  message.reload
104
104
  end
@@ -120,7 +120,7 @@ describe Luggage::Message do
120
120
  end
121
121
 
122
122
  it "appends message to mailbox" do
123
- message_date = 2.days.ago
123
+ message_date = Date.today - 2
124
124
  message.stub(:raw_message).and_return("Random Content")
125
125
  message.stub(:flags).and_return([:Seen])
126
126
  message.stub(:date).and_return(message_date)
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rspec'
2
2
  require 'rspec/mocks'
3
3
  require 'rspec/expectations'
4
- require 'active_support/time'
5
4
  require 'pry'
6
5
 
7
6
  require 'luggage'
@@ -24,7 +23,13 @@ shared_context "factories" do
24
23
  c.stub(:select)
25
24
  c.stub(:send_command)
26
25
  c.stub(:uid_store)
27
- c.stub(:uid_fetch).and_return( [{:attr => {"BODY[]" => "raw_body", "FLAGS" => [], "INTERNALDATE" => 1.day.ago.to_s}}] )
26
+ c.stub(:uid_fetch).and_return([{
27
+ :attr => {
28
+ "BODY[]" => "raw_body",
29
+ "FLAGS" => [],
30
+ "INTERNALDATE" => (Time.now - 60 * 60 * 24).to_s
31
+ }
32
+ }])
28
33
  c.stub(:uid_search).and_return([1])
29
34
  c.stub(:list).and_return([])
30
35
  c
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.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Michael