net-imap 0.4.9.1 → 0.4.10

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.

Potentially problematic release.


This version of net-imap might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b975c88ca0ef753df9f90a9aa827f87a3d3d521c3b394d0c47963e9d29ac664a
4
- data.tar.gz: ef0fa4c471880ee3ba9fcec9091ae31b5ac48c5cc0fffbb33375d502f3f40b4d
3
+ metadata.gz: 40824569aad7172418bde7db999c302e9cf0243977526e8ec908083957dd6117
4
+ data.tar.gz: 89ce211e3be5c350bf890ecd1e161926824fd547f6225e5a16a0dbec7b62d77b
5
5
  SHA512:
6
- metadata.gz: f1b85f9559e7a65a82e3726ebd54dd948b4dd9b42028b22131f61a8f9ea0e7e699f3c8e5909bc8dc4c669144b10638817639107d6bb708fb4016fb117928a812
7
- data.tar.gz: c111b3c37dd177d686bc5e65b6608dbc66b060a87509092f594047d49ca67a901d8357373f10ab1e31aced4574a8ef70757a161e9f23892a8a01c59a9b1a9df4
6
+ metadata.gz: 1a2712176f738c38b2c81682f5d488c94ea0c2a5902c9e7aa5ef92c83ada7b0534458ff3850384534a06a12c1d44ef8710a36e3cbb926e5d844fe6a9d36c2b3f
7
+ data.tar.gz: 64aa5b6a2305d1a34055cdf79a3ce466131e3165c184583d03a21f1183f57a5f3745d926a4feacf93cd670a0454941b4000090a03d109643a412c6298e1b6827
@@ -31,7 +31,7 @@ jobs:
31
31
  - name: Build with RDoc
32
32
  run: bundle exec rake rdoc
33
33
  - name: Upload artifact
34
- uses: actions/upload-pages-artifact@v2
34
+ uses: actions/upload-pages-artifact@v3
35
35
  with: { path: 'doc' }
36
36
 
37
37
  deploy:
@@ -43,4 +43,4 @@ jobs:
43
43
  steps:
44
44
  - name: Deploy to GitHub Pages
45
45
  id: deployment
46
- uses: actions/deploy-pages@v3
46
+ uses: actions/deploy-pages@v4
data/Gemfile CHANGED
@@ -4,6 +4,10 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
+ gem "digest"
8
+ gem "strscan"
9
+ gem "base64"
10
+
7
11
  gem "rake"
8
12
  gem "rdoc"
9
13
  gem "test-unit"
@@ -9,7 +9,7 @@ module Net
9
9
  # For backward compatibility, SearchResult inherits from Array.
10
10
  class SearchResult < Array
11
11
 
12
- # Returns a frozen SearchResult populated with the given +seq_nums+.
12
+ # Returns a SearchResult populated with the given +seq_nums+.
13
13
  #
14
14
  # Net::IMAP::SearchResult[1, 3, 5, modseq: 9]
15
15
  # # => Net::IMAP::SearchResult[1, 3, 5, modseq: 9]
@@ -22,19 +22,15 @@ module Net
22
22
  # §3.1.6]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1.6].
23
23
  attr_reader :modseq
24
24
 
25
- # Returns a frozen SearchResult populated with the given +seq_nums+.
25
+ # Returns a SearchResult populated with the given +seq_nums+.
26
26
  #
27
27
  # Net::IMAP::SearchResult.new([1, 3, 5], modseq: 9)
28
28
  # # => Net::IMAP::SearchResult[1, 3, 5, modseq: 9]
29
29
  def initialize(seq_nums, modseq: nil)
30
30
  super(seq_nums.to_ary.map { Integer _1 })
31
31
  @modseq = Integer modseq if modseq
32
- freeze
33
32
  end
34
33
 
35
- # Returns a frozen copy of +other+.
36
- def initialize_copy(other); super; freeze end
37
-
38
34
  # Returns whether +other+ is a SearchResult with the same values and the
39
35
  # same #modseq. The order of numbers is irrelevant.
40
36
  #
@@ -907,7 +907,7 @@ module Net
907
907
  # normalized form, this will yield the same values as #each_element.
908
908
  #
909
909
  # Related: #entries, #each_element
910
- def each_entry(&block)
910
+ def each_entry(&block) # :yields: integer or range or :*
911
911
  return to_enum(__method__) unless block_given?
912
912
  return each_element(&block) unless @string
913
913
  @string.split(",").each do yield tuple_to_entry str_to_tuple _1 end
@@ -927,7 +927,9 @@ module Net
927
927
  self
928
928
  end
929
929
 
930
- private def tuple_to_entry((min, max))
930
+ private
931
+
932
+ def tuple_to_entry((min, max))
931
933
  if min == STAR_INT then :*
932
934
  elsif max == STAR_INT then min..
933
935
  elsif min == max then min
@@ -935,6 +937,8 @@ module Net
935
937
  end
936
938
  end
937
939
 
940
+ public
941
+
938
942
  # Yields each range in #ranges to the block and returns self.
939
943
  # Returns an enumerator when called without a block.
940
944
  #
@@ -1002,7 +1006,9 @@ module Net
1002
1006
  nil
1003
1007
  end
1004
1008
 
1005
- private def each_tuple_with_index
1009
+ private
1010
+
1011
+ def each_tuple_with_index
1006
1012
  idx_min = 0
1007
1013
  @tuples.each do |min, max|
1008
1014
  yield min, max, idx_min, (idx_max = idx_min + (max - min))
@@ -1011,7 +1017,7 @@ module Net
1011
1017
  idx_min
1012
1018
  end
1013
1019
 
1014
- private def reverse_each_tuple_with_index
1020
+ def reverse_each_tuple_with_index
1015
1021
  idx_max = -1
1016
1022
  @tuples.reverse_each do |min, max|
1017
1023
  yield min, max, (idx_min = idx_max - (max - min)), idx_max
@@ -1020,6 +1026,8 @@ module Net
1020
1026
  idx_max
1021
1027
  end
1022
1028
 
1029
+ public
1030
+
1023
1031
  # :call-seq: at(index) -> integer or nil
1024
1032
  #
1025
1033
  # Returns a number from +self+, without modifying the set. Behaves the
@@ -1086,7 +1094,9 @@ module Net
1086
1094
 
1087
1095
  alias slice :[]
1088
1096
 
1089
- private def slice_length(start, length)
1097
+ private
1098
+
1099
+ def slice_length(start, length)
1090
1100
  start = Integer(start.to_int)
1091
1101
  length = Integer(length.to_int)
1092
1102
  raise ArgumentError, "length must be positive" unless length.positive?
@@ -1094,7 +1104,7 @@ module Net
1094
1104
  slice_range(start..last)
1095
1105
  end
1096
1106
 
1097
- private def slice_range(range)
1107
+ def slice_range(range)
1098
1108
  first = range.begin || 0
1099
1109
  last = range.end || -1
1100
1110
  last -= 1 if range.exclude_end? && range.end && last != STAR_INT
@@ -1109,6 +1119,8 @@ module Net
1109
1119
  end
1110
1120
  end
1111
1121
 
1122
+ public
1123
+
1112
1124
  # Returns a frozen SequenceSet with <tt>*</tt> converted to +max+, numbers
1113
1125
  # and ranges over +max+ removed, and ranges containing +max+ converted to
1114
1126
  # end at +max+.
data/lib/net/imap.rb CHANGED
@@ -717,7 +717,7 @@ module Net
717
717
  # * {IMAP URLAUTH Authorization Mechanism Registry}[https://www.iana.org/assignments/urlauth-authorization-mechanism-registry/urlauth-authorization-mechanism-registry.xhtml]
718
718
  #
719
719
  class IMAP < Protocol
720
- VERSION = "0.4.9.1"
720
+ VERSION = "0.4.10"
721
721
 
722
722
  # Aliases for supported capabilities, to be used with the #enable command.
723
723
  ENABLE_ALIASES = {
data/net-imap.gemspec CHANGED
@@ -35,7 +35,4 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_dependency "net-protocol"
37
37
  spec.add_dependency "date"
38
-
39
- spec.add_development_dependency "digest"
40
- spec.add_development_dependency "strscan"
41
38
  end
@@ -0,0 +1,167 @@
1
+ require 'net/imap'
2
+ require "getoptlong"
3
+
4
+ $stdout.sync = true
5
+ $port = nil
6
+ $user = ENV["USER"] || ENV["LOGNAME"]
7
+ $auth = "login"
8
+ $ssl = false
9
+ $starttls = false
10
+
11
+ def usage
12
+ <<EOF
13
+ usage: #{$0} [options] <host>
14
+
15
+ --help print this message
16
+ --port=PORT specifies port
17
+ --user=USER specifies user
18
+ --auth=AUTH specifies auth type
19
+ --starttls use starttls
20
+ --ssl use ssl
21
+ EOF
22
+ end
23
+
24
+ begin
25
+ require 'io/console'
26
+ rescue LoadError
27
+ def _noecho(&block)
28
+ system("stty", "-echo")
29
+ begin
30
+ yield STDIN
31
+ ensure
32
+ system("stty", "echo")
33
+ end
34
+ end
35
+ else
36
+ def _noecho(&block)
37
+ STDIN.noecho(&block)
38
+ end
39
+ end
40
+
41
+ def get_password
42
+ print "password: "
43
+ begin
44
+ return _noecho(&:gets).chomp
45
+ ensure
46
+ puts
47
+ end
48
+ end
49
+
50
+ def get_command
51
+ printf("%s@%s> ", $user, $host)
52
+ if line = gets
53
+ return line.strip.split(/\s+/)
54
+ else
55
+ return nil
56
+ end
57
+ end
58
+
59
+ parser = GetoptLong.new
60
+ parser.set_options(['--debug', GetoptLong::NO_ARGUMENT],
61
+ ['--help', GetoptLong::NO_ARGUMENT],
62
+ ['--port', GetoptLong::REQUIRED_ARGUMENT],
63
+ ['--user', GetoptLong::REQUIRED_ARGUMENT],
64
+ ['--auth', GetoptLong::REQUIRED_ARGUMENT],
65
+ ['--starttls', GetoptLong::NO_ARGUMENT],
66
+ ['--ssl', GetoptLong::NO_ARGUMENT])
67
+ begin
68
+ parser.each_option do |name, arg|
69
+ case name
70
+ when "--port"
71
+ $port = arg
72
+ when "--user"
73
+ $user = arg
74
+ when "--auth"
75
+ $auth = arg
76
+ when "--ssl"
77
+ $ssl = true
78
+ when "--starttls"
79
+ $starttls = true
80
+ when "--debug"
81
+ Net::IMAP.debug = true
82
+ when "--help"
83
+ usage
84
+ exit
85
+ end
86
+ end
87
+ rescue
88
+ abort usage
89
+ end
90
+
91
+ $host = ARGV.shift
92
+ unless $host
93
+ abort usage
94
+ end
95
+
96
+ imap = Net::IMAP.new($host, :port => $port, :ssl => $ssl)
97
+ begin
98
+ imap.starttls if $starttls
99
+ class << password = method(:get_password)
100
+ alias to_str call
101
+ end
102
+ imap.authenticate($auth, $user, password)
103
+ while true
104
+ cmd, *args = get_command
105
+ break unless cmd
106
+ begin
107
+ case cmd
108
+ when "list"
109
+ for mbox in imap.list("", args[0] || "*")
110
+ if mbox.attr.include?(Net::IMAP::NOSELECT)
111
+ prefix = "!"
112
+ elsif mbox.attr.include?(Net::IMAP::MARKED)
113
+ prefix = "*"
114
+ else
115
+ prefix = " "
116
+ end
117
+ print prefix, mbox.name, "\n"
118
+ end
119
+ when "select"
120
+ imap.select(args[0] || "inbox")
121
+ print "ok\n"
122
+ when "close"
123
+ imap.close
124
+ print "ok\n"
125
+ when "summary"
126
+ unless messages = imap.responses["EXISTS"][-1]
127
+ puts "not selected"
128
+ next
129
+ end
130
+ if messages > 0
131
+ for data in imap.fetch(1..-1, ["ENVELOPE"])
132
+ print data.seqno, ": ", data.attr["ENVELOPE"].subject, "\n"
133
+ end
134
+ else
135
+ puts "no message"
136
+ end
137
+ when "fetch"
138
+ if args[0]
139
+ data = imap.fetch(args[0].to_i, ["RFC822.HEADER", "RFC822.TEXT"])[0]
140
+ puts data.attr["RFC822.HEADER"]
141
+ puts data.attr["RFC822.TEXT"]
142
+ else
143
+ puts "missing argument"
144
+ end
145
+ when "logout", "exit", "quit"
146
+ break
147
+ when "help", "?"
148
+ print <<EOF
149
+ list [pattern] list mailboxes
150
+ select [mailbox] select mailbox
151
+ close close mailbox
152
+ summary display summary
153
+ fetch [msgno] display message
154
+ logout logout
155
+ help, ? display help message
156
+ EOF
157
+ else
158
+ print "unknown command: ", cmd, "\n"
159
+ end
160
+ rescue Net::IMAP::Error
161
+ puts $!
162
+ end
163
+ end
164
+ ensure
165
+ imap.logout
166
+ imap.disconnect
167
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-imap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9.1
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-01-05 00:00:00.000000000 Z
12
+ date: 2024-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-protocol
@@ -39,34 +39,6 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: digest
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: strscan
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
42
  description: Ruby client api for Internet Message Access Protocol
71
43
  email:
72
44
  - shugo@ruby-lang.org
@@ -127,6 +99,7 @@ files:
127
99
  - rakelib/rfcs.rake
128
100
  - rakelib/saslprep.rake
129
101
  - rakelib/string_prep_tables_generator.rb
102
+ - sample/net-imap.rb
130
103
  homepage: https://github.com/ruby/net-imap
131
104
  licenses:
132
105
  - Ruby
@@ -150,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
123
  - !ruby/object:Gem::Version
151
124
  version: '0'
152
125
  requirements: []
153
- rubygems_version: 3.4.19
126
+ rubygems_version: 3.4.22
154
127
  signing_key:
155
128
  specification_version: 4
156
129
  summary: Ruby client api for Internet Message Access Protocol