rubysl-net-pop 1.0.0 → 2.0.1

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: 5c2c96967c03048355f1f17b405229c6553fec35
4
- data.tar.gz: b85de853dc60e4e85b4ea79c9f49eb5d0f1a539f
3
+ metadata.gz: 896f3788387dfaf00e15b08b5a9bacd2a709fc12
4
+ data.tar.gz: 9fe03654a751342fa0a14f47e500523e024bffb5
5
5
  SHA512:
6
- metadata.gz: aecb1ca7aeb605c9b9cb1a692655819e02aa79e38bd4b91a6a03019db4e6eeb5f11c238dc9090dc07d7e4e19325c6fe38b68b5841bb892f65ade155292112e8c
7
- data.tar.gz: 2f2df75754e68638ad4d75efc3357f67d4504d6af415ff9d138d9cbe5d38a75c73db877ac40c2b86fd3f3a4c0eb206bc86e7b0f1efd0f5ce6af69a8b5a67ccec
6
+ metadata.gz: f3d385e0f120752506b2d929a86d90fbbe54feac1be6a95598c5ebbdd67a1f214b8921237b79949c9d44525aac8b7f94ba3c09e00e39f9ca6cbb7c179345d48b
7
+ data.tar.gz: 348c6c9c2cbc2875fa56627afb2f685f02f8be26a4da2aa8d98c0cacaccf63cedf93a2d011bba8163e3cc68678b1f14a32977f390a332714f74bfc40ea4f25a4
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  before_install:
3
+ - rvm use $RVM --install --binary --fuzzy
3
4
  - gem update --system
4
5
  - gem --version
5
6
  - gem install rubysl-bundler
7
+ env:
8
+ - RVM=rbx-nightly-d21 RUBYLIB=lib
6
9
  script: bundle exec mspec spec
7
- rvm:
8
- - rbx-nightly-18mode
@@ -3,20 +3,20 @@
3
3
  # Copyright (c) 1999-2007 Yukihiro Matsumoto.
4
4
  #
5
5
  # Copyright (c) 1999-2007 Minero Aoki.
6
- #
6
+ #
7
7
  # Written & maintained by Minero Aoki <aamine@loveruby.net>.
8
8
  #
9
9
  # Documented by William Webber and Minero Aoki.
10
- #
10
+ #
11
11
  # This program is free software. You can re-distribute and/or
12
12
  # modify this program under the same terms as Ruby itself,
13
13
  # Ruby Distribute License.
14
- #
14
+ #
15
15
  # NOTE: You can find Japanese version of this document at:
16
16
  # http://www.ruby-lang.org/ja/man/html/net_pop.html
17
- #
18
- # $Id$
19
- #
17
+ #
18
+ # $Id: pop.rb 40829 2013-05-19 14:50:47Z kazu $
19
+ #
20
20
  # See Net::POP3 for documentation.
21
21
  #
22
22
 
@@ -25,7 +25,7 @@ require 'digest/md5'
25
25
  require 'timeout'
26
26
 
27
27
  begin
28
- require "openssl/ssl"
28
+ require "openssl"
29
29
  rescue LoadError
30
30
  end
31
31
 
@@ -41,29 +41,27 @@ module Net
41
41
  # Unexpected response from the server.
42
42
  class POPBadResponse < POPError; end
43
43
 
44
- #
45
- # = Net::POP3
46
44
  #
47
45
  # == What is This Library?
48
- #
49
- # This library provides functionality for retrieving
46
+ #
47
+ # This library provides functionality for retrieving
50
48
  # email via POP3, the Post Office Protocol version 3. For details
51
49
  # of POP3, see [RFC1939] (http://www.ietf.org/rfc/rfc1939.txt).
52
- #
50
+ #
53
51
  # == Examples
54
- #
55
- # === Retrieving Messages
56
- #
57
- # This example retrieves messages from the server and deletes them
52
+ #
53
+ # === Retrieving Messages
54
+ #
55
+ # This example retrieves messages from the server and deletes them
58
56
  # on the server.
59
57
  #
60
58
  # Messages are written to files named 'inbox/1', 'inbox/2', ....
61
59
  # Replace 'pop.example.com' with your POP3 server address, and
62
60
  # 'YourAccount' and 'YourPassword' with the appropriate account
63
61
  # details.
64
- #
62
+ #
65
63
  # require 'net/pop'
66
- #
64
+ #
67
65
  # pop = Net::POP3.new('pop.example.com')
68
66
  # pop.start('YourAccount', 'YourPassword') # (1)
69
67
  # if pop.mails.empty?
@@ -80,19 +78,19 @@ module Net
80
78
  # puts "#{pop.mails.size} mails popped."
81
79
  # end
82
80
  # pop.finish # (3)
83
- #
81
+ #
84
82
  # 1. Call Net::POP3#start and start POP session.
85
83
  # 2. Access messages by using POP3#each_mail and/or POP3#mails.
86
84
  # 3. Close POP session by calling POP3#finish or use the block form of #start.
87
- #
85
+ #
88
86
  # === Shortened Code
89
- #
87
+ #
90
88
  # The example above is very verbose. You can shorten the code by using
91
89
  # some utility methods. First, the block form of Net::POP3.start can
92
90
  # be used instead of POP3.new, POP3#start and POP3#finish.
93
- #
91
+ #
94
92
  # require 'net/pop'
95
- #
93
+ #
96
94
  # Net::POP3.start('pop.example.com', 110,
97
95
  # 'YourAccount', 'YourPassword') do |pop|
98
96
  # if pop.mails.empty?
@@ -109,11 +107,11 @@ module Net
109
107
  # puts "#{pop.mails.size} mails popped."
110
108
  # end
111
109
  # end
112
- #
110
+ #
113
111
  # POP3#delete_all is an alternative for #each_mail and #delete.
114
- #
112
+ #
115
113
  # require 'net/pop'
116
- #
114
+ #
117
115
  # Net::POP3.start('pop.example.com', 110,
118
116
  # 'YourAccount', 'YourPassword') do |pop|
119
117
  # if pop.mails.empty?
@@ -128,11 +126,11 @@ module Net
128
126
  # end
129
127
  # end
130
128
  # end
131
- #
129
+ #
132
130
  # And here is an even shorter example.
133
- #
131
+ #
134
132
  # require 'net/pop'
135
- #
133
+ #
136
134
  # i = 0
137
135
  # Net::POP3.delete_all('pop.example.com', 110,
138
136
  # 'YourAccount', 'YourPassword') do |m|
@@ -141,14 +139,14 @@ module Net
141
139
  # end
142
140
  # i += 1
143
141
  # end
144
- #
142
+ #
145
143
  # === Memory Space Issues
146
- #
144
+ #
147
145
  # All the examples above get each message as one big string.
148
146
  # This example avoids this.
149
- #
147
+ #
150
148
  # require 'net/pop'
151
- #
149
+ #
152
150
  # i = 1
153
151
  # Net::POP3.delete_all('pop.example.com', 110,
154
152
  # 'YourAccount', 'YourPassword') do |m|
@@ -159,49 +157,51 @@ module Net
159
157
  # i += 1
160
158
  # end
161
159
  # end
162
- #
160
+ #
163
161
  # === Using APOP
164
- #
162
+ #
165
163
  # The net/pop library supports APOP authentication.
166
164
  # To use APOP, use the Net::APOP class instead of the Net::POP3 class.
167
165
  # You can use the utility method, Net::POP3.APOP(). For example:
168
- #
166
+ #
169
167
  # require 'net/pop'
170
- #
168
+ #
171
169
  # # Use APOP authentication if $isapop == true
172
170
  # pop = Net::POP3.APOP($is_apop).new('apop.example.com', 110)
173
171
  # pop.start(YourAccount', 'YourPassword') do |pop|
174
172
  # # Rest of the code is the same.
175
173
  # end
176
- #
174
+ #
177
175
  # === Fetch Only Selected Mail Using 'UIDL' POP Command
178
- #
176
+ #
179
177
  # If your POP server provides UIDL functionality,
180
178
  # you can grab only selected mails from the POP server.
181
179
  # e.g.
182
- #
180
+ #
183
181
  # def need_pop?( id )
184
182
  # # determine if we need pop this mail...
185
183
  # end
186
- #
184
+ #
187
185
  # Net::POP3.start('pop.example.com', 110,
188
186
  # 'Your account', 'Your password') do |pop|
189
187
  # pop.mails.select { |m| need_pop?(m.unique_id) }.each do |m|
190
188
  # do_something(m.pop)
191
189
  # end
192
190
  # end
193
- #
191
+ #
194
192
  # The POPMail#unique_id() method returns the unique-id of the message as a
195
193
  # String. Normally the unique-id is a hash of the message.
196
- #
194
+ #
197
195
  class POP3 < Protocol
198
196
 
199
- Revision = %q$Revision$.split[1]
197
+ # svn revision of this library
198
+ Revision = %q$Revision: 40829 $.split[1]
200
199
 
201
200
  #
202
201
  # Class Parameters
203
202
  #
204
203
 
204
+ # returns the port for POP3
205
205
  def POP3.default_port
206
206
  default_pop3_port()
207
207
  end
@@ -210,7 +210,7 @@ module Net
210
210
  def POP3.default_pop3_port
211
211
  110
212
212
  end
213
-
213
+
214
214
  # The default port for POP3S connections, port 995
215
215
  def POP3.default_pop3s_port
216
216
  995
@@ -324,7 +324,7 @@ module Net
324
324
 
325
325
  @ssl_params = nil
326
326
 
327
- # call-seq:
327
+ # :call-seq:
328
328
  # Net::POP.enable_ssl(params = {})
329
329
  #
330
330
  # Enable SSL for all new instances.
@@ -333,6 +333,7 @@ module Net
333
333
  @ssl_params = create_ssl_params(*args)
334
334
  end
335
335
 
336
+ # Constructs proper parameters from arguments
336
337
  def POP3.create_ssl_params(verify_or_params = {}, certs = nil)
337
338
  begin
338
339
  params = verify_or_params.to_hash
@@ -355,18 +356,24 @@ module Net
355
356
  @ssl_params = nil
356
357
  end
357
358
 
359
+ # returns the SSL Parameters
360
+ #
361
+ # see also POP3.enable_ssl
358
362
  def POP3.ssl_params
359
363
  return @ssl_params
360
364
  end
361
365
 
366
+ # returns +true+ if POP3.ssl_params is set
362
367
  def POP3.use_ssl?
363
368
  return !@ssl_params.nil?
364
369
  end
365
370
 
371
+ # returns whether verify_mode is enable from POP3.ssl_params
366
372
  def POP3.verify
367
373
  return @ssl_params[:verify_mode]
368
374
  end
369
375
 
376
+ # returns the :ca_file or :ca_path from POP3.ssl_params
370
377
  def POP3.certs
371
378
  return @ssl_params[:ca_file] || @ssl_params[:ca_path]
372
379
  end
@@ -375,7 +382,7 @@ module Net
375
382
  # Session management
376
383
  #
377
384
 
378
- # Creates a new POP3 object and open the connection. Equivalent to
385
+ # Creates a new POP3 object and open the connection. Equivalent to
379
386
  #
380
387
  # Net::POP3.new(address, port, isapop).start(account, password)
381
388
  #
@@ -396,7 +403,7 @@ module Net
396
403
  isapop = false, &block) # :yield: pop
397
404
  new(address, port, isapop).start(account, password, &block)
398
405
  end
399
-
406
+
400
407
  # Creates a new POP3 object.
401
408
  #
402
409
  # +address+ is the hostname or ip address of your POP3 server.
@@ -412,7 +419,7 @@ module Net
412
419
  @ssl_params = POP3.ssl_params
413
420
  @port = port
414
421
  @apop = isapop
415
-
422
+
416
423
  @command = nil
417
424
  @socket = nil
418
425
  @started = false
@@ -434,8 +441,8 @@ module Net
434
441
  def use_ssl?
435
442
  return !@ssl_params.nil?
436
443
  end
437
-
438
- # call-seq:
444
+
445
+ # :call-seq:
439
446
  # Net::POP#enable_ssl(params = {})
440
447
  #
441
448
  # Enables SSL for this instance. Must be called before the connection is
@@ -451,7 +458,8 @@ module Net
451
458
  @port = port || @port
452
459
  end
453
460
  end
454
-
461
+
462
+ # Disable SSL for all new instances.
455
463
  def disable_ssl
456
464
  @ssl_params = nil
457
465
  end
@@ -488,12 +496,12 @@ module Net
488
496
 
489
497
  # Seconds to wait until a connection is opened.
490
498
  # If the POP3 object cannot open a connection within this time,
491
- # it raises a TimeoutError exception.
499
+ # it raises a Net::OpenTimeout exception. The default value is 30 seconds.
492
500
  attr_accessor :open_timeout
493
501
 
494
502
  # Seconds to wait until reading one block (by one read(1) call).
495
503
  # If the POP3 object cannot complete a read() within this time,
496
- # it raises a TimeoutError exception.
504
+ # it raises a Net::ReadTimeout exception. The default value is 60 seconds.
497
505
  attr_reader :read_timeout
498
506
 
499
507
  # Set the read timeout.
@@ -530,8 +538,11 @@ module Net
530
538
  end
531
539
  end
532
540
 
533
- def do_start(account, password)
534
- s = timeout(@open_timeout) { TCPSocket.open(@address, port) }
541
+ # internal method for Net::POP3.start
542
+ def do_start(account, password) # :nodoc:
543
+ s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
544
+ TCPSocket.open(@address, port)
545
+ end
535
546
  if use_ssl?
536
547
  raise 'openssl library not installed' unless defined?(OpenSSL)
537
548
  context = OpenSSL::SSL::SSLContext.new
@@ -565,7 +576,8 @@ module Net
565
576
  end
566
577
  private :do_start
567
578
 
568
- def on_connect
579
+ # Does nothing
580
+ def on_connect # :nodoc:
569
581
  end
570
582
  private :on_connect
571
583
 
@@ -575,7 +587,12 @@ module Net
575
587
  do_finish
576
588
  end
577
589
 
578
- def do_finish
590
+ # nil's out the:
591
+ # - mails
592
+ # - number counter for mails
593
+ # - number counter for bytes
594
+ # - quits the current command, if any
595
+ def do_finish # :nodoc:
579
596
  @mails = nil
580
597
  @n_mails = nil
581
598
  @n_bytes = nil
@@ -588,7 +605,10 @@ module Net
588
605
  end
589
606
  private :do_finish
590
607
 
591
- def command
608
+ # Returns the current command.
609
+ #
610
+ # Raises IOError if there is no active socket
611
+ def command # :nodoc:
592
612
  raise IOError, 'POP session not opened yet' \
593
613
  if not @socket or @socket.closed?
594
614
  @command
@@ -635,7 +655,7 @@ module Net
635
655
 
636
656
  # Yields each message to the passed-in block in turn.
637
657
  # Equivalent to:
638
- #
658
+ #
639
659
  # pop3.mails.each do |popmail|
640
660
  # ....
641
661
  # end
@@ -687,6 +707,7 @@ module Net
687
707
  @mails.each {|m| m.uid = uidl[m.number] }
688
708
  end
689
709
 
710
+ # deguging output for +msg+
690
711
  def logging(msg)
691
712
  @debug_output << msg + "\n" if @debug_output
692
713
  end
@@ -694,9 +715,9 @@ module Net
694
715
  end # class POP3
695
716
 
696
717
  # class aliases
697
- POP = POP3
698
- POPSession = POP3
699
- POP3Session = POP3
718
+ POP = POP3 # :nodoc:
719
+ POPSession = POP3 # :nodoc:
720
+ POP3Session = POP3 # :nodoc:
700
721
 
701
722
  #
702
723
  # This class is equivalent to POP3, except that it uses APOP authentication.
@@ -742,7 +763,7 @@ module Net
742
763
  #
743
764
  # This method fetches the message. If called with a block, the
744
765
  # message is yielded to the block one chunk at a time. If called
745
- # without a block, the message is returned as a String. The optional
766
+ # without a block, the message is returned as a String. The optional
746
767
  # +dest+ argument will be prepended to the returned String; this
747
768
  # argument is essentially obsolete.
748
769
  #
@@ -753,7 +774,7 @@ module Net
753
774
  # n = 1
754
775
  # pop.mails.each do |popmail|
755
776
  # File.open("inbox/#{n}", 'w') do |f|
756
- # f.write popmail.pop
777
+ # f.write popmail.pop
757
778
  # end
758
779
  # popmail.delete
759
780
  # n += 1
@@ -792,7 +813,7 @@ module Net
792
813
  alias all pop #:nodoc: obsolete
793
814
  alias mail pop #:nodoc: obsolete
794
815
 
795
- # Fetches the message header and +lines+ lines of body.
816
+ # Fetches the message header and +lines+ lines of body.
796
817
  #
797
818
  # The optional +dest+ argument is obsolete.
798
819
  #
@@ -804,7 +825,7 @@ module Net
804
825
  dest
805
826
  end
806
827
 
807
- # Fetches the message header.
828
+ # Fetches the message header.
808
829
  #
809
830
  # The optional +dest+ argument is obsolete.
810
831
  #
@@ -868,11 +889,13 @@ module Net
868
889
 
869
890
  def initialize(sock)
870
891
  @socket = sock
871
- @error_occured = false
892
+ @error_occurred = false
872
893
  res = check_response(critical { recv_response() })
873
894
  @apop_stamp = res.slice(/<[!-~]+@[!-~]+>/)
874
895
  end
875
896
 
897
+ attr_reader :socket
898
+
876
899
  def inspect
877
900
  "#<#{self.class} socket=#{@socket}>"
878
901
  end
@@ -931,7 +954,7 @@ module Net
931
954
  @socket.each_message_chunk(&block)
932
955
  }
933
956
  end
934
-
957
+
935
958
  def dele(num)
936
959
  check_response(critical { get_response('DELE %d', num) })
937
960
  end
@@ -984,11 +1007,11 @@ module Net
984
1007
  end
985
1008
 
986
1009
  def critical
987
- return '+OK dummy ok response' if @error_occured
1010
+ return '+OK dummy ok response' if @error_occurred
988
1011
  begin
989
1012
  return yield()
990
1013
  rescue Exception
991
- @error_occured = true
1014
+ @error_occurred = true
992
1015
  raise
993
1016
  end
994
1017
  end
@@ -1,7 +1,7 @@
1
1
  module RubySL
2
2
  module Net
3
3
  module POP
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
6
6
  end
7
7
  end
@@ -16,8 +16,10 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.required_ruby_version = "~> 2.0"
20
+
19
21
  spec.add_development_dependency "bundler", "~> 1.3"
20
22
  spec.add_development_dependency "rake", "~> 10.0"
21
23
  spec.add_development_dependency "mspec", "~> 1.5"
22
- spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
24
+ spec.add_development_dependency "rubysl-prettyprint", "~> 2.0"
23
25
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysl-net-pop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-26 00:00:00.000000000 Z
11
+ date: 2013-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubysl-prettyprint
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '2.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: '2.0'
69
69
  description: Ruby standard library pop.
70
70
  email:
71
71
  - brixen@gmail.com
@@ -73,8 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
78
  - Gemfile
79
79
  - LICENSE
80
80
  - README.md
@@ -94,12 +94,12 @@ require_paths:
94
94
  - lib
95
95
  required_ruby_version: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - '>='
97
+ - - "~>"
98
98
  - !ruby/object:Gem::Version
99
- version: '0'
99
+ version: '2.0'
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
@@ -109,3 +109,4 @@ signing_key:
109
109
  specification_version: 4
110
110
  summary: Ruby standard library pop.
111
111
  test_files: []
112
+ has_rdoc: