ultra7 0.4.0 → 0.5.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: f62703e25a0ab003dc3357a058cd477a2e06f641
4
- data.tar.gz: 3f23a8005cd49ed42b90e6332b6eaee95840b733
3
+ metadata.gz: c5a3e1cae83da627a5d3d9e1ad0147e6f7521ca1
4
+ data.tar.gz: fa0a08df7b4028b3835725858e131244f25aea28
5
5
  SHA512:
6
- metadata.gz: 4bb714b90e0515d702ff2323d4d7f36512fe8b31f85b5d52b61f569958476d41354909d5cb637f2481a2dbbf4ffd70432c2e760c63ceb2ed6eadfdd9ba035fd2
7
- data.tar.gz: 791973fca61789c8ad943c828e9174228a4c463fa2e6b4caee4d87e60808e8667fd595566017fe42c9530b40276601b76337e673be6a57fe3616b98511710f9b
6
+ metadata.gz: 132176393aa4a6a2bc42bd744e4fdf73205af9b99d200b48980c07619631b4cc69a4078e9c849a452e139882a6dd46d5387febafaab1d815dc7a1bfe70f76525
7
+ data.tar.gz: 761e5694be3f35cc2cb368a0b9bcddb44564bfc6843f6b3e43bbbed8e800b8d2bc192fe7f1118e01068dfb3cfb17b3ac3fbcd9823bde5e7d9b9e3504e6b69220
data/CHANGELOG CHANGED
@@ -1,5 +1,12 @@
1
1
  ## CHANGELOG
2
2
 
3
+ - __2014/12/17__: 0.5.0 release.
4
+ - Enhanced handling for multi-line string input.
5
+ - Minor documentation edits for clarity.
6
+
7
+ - __2014/12/14__: 0.4.0 release.
8
+ - Very minor documentation corrections.
9
+
3
10
  - __2014/12/14__: 0.3.0 release.
4
11
  - Slight enhancement to MIME encoded-word handling.
5
12
 
data/README.md CHANGED
@@ -3,8 +3,8 @@ A UTF-7 MIME header decoder, plain and simple.
3
3
 
4
4
  ## What is Ultra7?
5
5
 
6
- * Ultra7 is a UTF-7 decoder for MIME message header names and values, per the MIME [encoded word syntax of RFC-2047](http://tools.ietf.org/html/rfc2047),
7
- * It is almost unlike [`Net::IMAP.decode_utf7`](http://ruby-doc.org/stdlib-2.0.0/libdoc/net/imap/rdoc/Net/IMAP.html#method-c-decode_utf7), which is meant for decoding mailbox names.
6
+ * Ultra7 is a UTF-7 decoder for MIME message headers, per the [MIME encoded word syntax of RFC-2047](http://tools.ietf.org/html/rfc2047).
7
+ * It is almost, but not quite, *completely unlike [`Net::IMAP.decode_utf7`](http://ruby-doc.org/stdlib-2.0.0/libdoc/net/imap/rdoc/Net/IMAP.html#method-c-decode_utf7)*, which is meant for decoding *mailbox names*. Ultra7 only does MIME message headers.
8
8
  * `Ultra7::MIME` is also a mixin, so you can conveniently combine it in another class by using
9
9
  `include`.
10
10
  * Read the [API documentation](http://www.rubydoc.info/gems/ultra7).
@@ -33,12 +33,12 @@ A UTF-7 MIME header decoder, plain and simple.
33
33
  puts Ultra7::MIME.decode_utf7('1 +- 1 = 2')
34
34
  => "1 + 1 = 2"
35
35
 
36
- # Decode a UTF-7 encoded string, returning string with default encoding
36
+ # Decodes UTF-7, returning string with default encoding
37
37
  puts Ultra7::MIME.decode_utf7('Hello, +ZeVnLIqe-')
38
38
  => "Hello, 日本語"
39
-
40
- # Decode a MIME encoded word, returning the decoded value
41
- # as a string with explicit UTF-8 encoding
39
+
40
+ # Decodes an actual Subject MIME header in UTF-7,
41
+ # returning string with explicit UTF-8 encoding
42
42
  subject = '=?unicode-1-1-utf-7?Q?+vDCy7A- +wMHQ3A- +xUy5vA-(+wuTTKA-)?='
43
43
  Ultra7::MIME.decode_utf7(subject, encoding: 'UTF-8')
44
44
  => "배달 상태 알림(실패)"
@@ -74,4 +74,4 @@ A UTF-7 MIME header decoder, plain and simple.
74
74
  Please see the {file:CHANGELOG} for this gem's release history.
75
75
 
76
76
  ## Copyright
77
- Copyright © 2014-2015, Brooke M. Fujita. All rights reserved. Please see the {file:LICENSE} file for further details.
77
+ Copyright © 2014-2015, Brooke M. Fujita. All rights reserved. Please see the {file:LICENSE} file for further details.
@@ -8,22 +8,21 @@ module Ultra7
8
8
  base.extend(ClassMethods)
9
9
  end
10
10
 
11
- # Returns the decoded value for the given
12
- # UTF-7 encoded `text`. If the optional
13
- # `encoding` value is not specified, in the `options`
11
+ # Parse the given UTF-7 encoded-word text
12
+ # and return the corresponding decoded value.
13
+ #
14
+ # If the `:encoding` name is not specified in the `options`
14
15
  # hash, then the resulting string will use the default
15
16
  # `Encoding.default_external` encoding.
16
17
  #
17
- # @param [String] text UTF-7 string or MIME encoded word
18
+ # @param [String] text UTF-7 encoded-word text
18
19
  # @param [Hash] options
19
- # @option options [String] :encoding the encoding for the decoded value
20
- # @return [String] decoded value, using either
21
- # `Encoding.default_external` or the given `:encoding`
22
- # @raise [ArgumentError] if the encoding passed in is not UTF-7,
23
- # or if the encoding for the decoded value is not valid
24
- def self.decode_utf7(text, options={encoding: nil})
20
+ # @return [String] UTF-7 decoded value
21
+ # @raise [ArgumentError] if text other than UTF-7 is passed in,
22
+ # or the named `:encoding` cannot be found
23
+ def self.decode_utf7(text, options={encoding: nil})
25
24
  # only deal with UTF-7 encoding
26
- text.scan(/=\?(.*)\?[q]\?/i).each {
25
+ text.scan(/=\?(.*)\?[q]\?/im).each {
27
26
  e = $1
28
27
  if e and !(e=~/utf\-7/i)
29
28
  raise ArgumentError.new("Cannot decode #{e} as UTF-7!")
@@ -32,13 +31,13 @@ module Ultra7
32
31
 
33
32
  # remove any opening charset and Q-encoding start/end markers
34
33
  # for MIME encoded words
35
- text = text.gsub(/\?=/, '').gsub(/=\?[^?]*utf\-7\?[q]\?/i, '')
34
+ text = text.gsub(/\?=/m, '').gsub(/=\?[^?]*utf\-7\?[q]\?/im, '')
36
35
 
37
36
  enc = options[:encoding].nil? \
38
37
  ? Encoding.default_external \
39
38
  : Encoding.find(options[:encoding])
40
39
 
41
- return text.gsub(/\+(.*?)-/n) {
40
+ return text.gsub(/\+(.*?)-/mn) {
42
41
  if $1.empty?
43
42
  "+"
44
43
  else
@@ -7,7 +7,7 @@
7
7
  # It may be used as a mixin.
8
8
  module Ultra7
9
9
  # Version string for this Rubygem.
10
- VERSION = "0.4.0"
10
+ VERSION = "0.5.0"
11
11
  end
12
12
 
13
13
  # Copyright (c) 2014-2015, Brooke M. Fujita.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultra7
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke M. Fujita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-14 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  ultra7 decodes UTF-7 in the context of MIME headers (c.f. https://tools.ietf.org/html/rfc2152).
@@ -17,7 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".yardopts"
20
+ - .yardopts
21
21
  - CHANGELOG
22
22
  - LICENSE
23
23
  - README.md
@@ -34,17 +34,17 @@ require_paths:
34
34
  - lib
35
35
  required_ruby_version: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - '>='
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.9'
40
40
  required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ">="
42
+ - - '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  requirements: []
46
46
  rubyforge_project:
47
- rubygems_version: 2.2.2
47
+ rubygems_version: 2.4.1
48
48
  signing_key:
49
49
  specification_version: 4
50
50
  summary: A UTF-7 MIME header decoder, plain and simple.