mail-iso-2022-jp 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.
- data/Gemfile +2 -2
- data/Rakefile +2 -2
- data/lib/mail-iso-2022-jp/patches.rb +15 -4
- metadata +50 -26
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -14,10 +14,10 @@ Rake::TestTask.new(:test) do |t|
|
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'Generate documentation for the mail-iso-2022-jp library.'
|
17
|
-
RDoc::Task.new
|
17
|
+
RDoc::Task.new do |rdoc|
|
18
18
|
rdoc.rdoc_dir = 'rdoc'
|
19
19
|
rdoc.title = 'MailIso2022Jp'
|
20
20
|
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
-
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('README.md')
|
22
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
23
|
end
|
@@ -7,12 +7,22 @@ module Mail
|
|
7
7
|
WAVE_DASH = "〜" # U+301C
|
8
8
|
FULLWIDTH_TILDE = "~" # U+FF5E
|
9
9
|
NKF_OPTIONS = "--oc=CP50220 -xj"
|
10
|
+
if RUBY_VERSION >= '1.9'
|
11
|
+
ENCODE = {'iso-2022-jp' => Encoding::CP50221}
|
12
|
+
def self.encoding_to_charset(str, charset)
|
13
|
+
str.encode(ENCODE[charset.to_s.downcase] || charset).force_encoding(charset)
|
14
|
+
end
|
15
|
+
end
|
10
16
|
|
11
17
|
class Message
|
12
18
|
def process_body_raw_with_iso_2022_jp_encoding
|
13
19
|
if @charset.to_s.downcase == 'iso-2022-jp'
|
14
|
-
@body_raw.gsub
|
15
|
-
|
20
|
+
@body_raw = @body_raw.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
|
21
|
+
if RUBY_VERSION >= '1.9'
|
22
|
+
@body_raw = Mail.encoding_to_charset(@body_raw, @charset)
|
23
|
+
else
|
24
|
+
@body_raw = NKF.nkf(NKF_OPTIONS, @body_raw)
|
25
|
+
end
|
16
26
|
end
|
17
27
|
process_body_raw_without_iso_2022_jp_encoding
|
18
28
|
end
|
@@ -41,13 +51,14 @@ module Mail
|
|
41
51
|
|
42
52
|
def initialize_with_iso_2022_jp_encoding(value = nil, charset = 'utf-8')
|
43
53
|
if charset.to_s.downcase == 'iso-2022-jp'
|
44
|
-
value.gsub
|
45
|
-
value = NKF.nkf(NKF_OPTIONS, value)
|
54
|
+
value = value.to_s.gsub(/#{WAVE_DASH}/, FULLWIDTH_TILDE)
|
46
55
|
if RUBY_VERSION >= '1.9'
|
56
|
+
value = Mail.encoding_to_charset(value, charset)
|
47
57
|
value.force_encoding('ascii-8bit')
|
48
58
|
value = b_value_encode(value)
|
49
59
|
value.force_encoding('ascii-8bit')
|
50
60
|
else
|
61
|
+
value = NKF.nkf(NKF_OPTIONS, value)
|
51
62
|
value = b_value_encode(value)
|
52
63
|
end
|
53
64
|
end
|
metadata
CHANGED
@@ -1,61 +1,85 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-iso-2022-jp
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Kohei MATSUSHITA
|
9
14
|
- Tsutomu KURODA
|
10
15
|
autorequire:
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
|
19
|
+
date: 2011-12-04 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
16
22
|
name: mail
|
17
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
25
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 2
|
33
|
+
- 5
|
22
34
|
version: 2.2.5
|
23
35
|
type: :runtime
|
24
|
-
|
25
|
-
version_requirements: *19552660
|
36
|
+
version_requirements: *id001
|
26
37
|
description: A patch that provides 'mail' gem with iso-2022-jp conversion capability.
|
27
38
|
email: hermes@oiax.jp
|
28
39
|
executables: []
|
40
|
+
|
29
41
|
extensions: []
|
42
|
+
|
30
43
|
extra_rdoc_files: []
|
31
|
-
|
44
|
+
|
45
|
+
files:
|
32
46
|
- README.md
|
33
47
|
- Gemfile
|
34
48
|
- Rakefile
|
35
|
-
- lib/mail-iso-2022-jp/patches.rb
|
36
49
|
- lib/mail-iso-2022-jp.rb
|
50
|
+
- lib/mail-iso-2022-jp/patches.rb
|
37
51
|
homepage: http://github.com/kuroda/mail-iso-2022-jp
|
38
52
|
licenses: []
|
53
|
+
|
39
54
|
post_install_message:
|
40
55
|
rdoc_options: []
|
41
|
-
|
56
|
+
|
57
|
+
require_paths:
|
42
58
|
- lib
|
43
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
60
|
none: false
|
45
|
-
requirements:
|
46
|
-
- -
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
|
49
|
-
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
69
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
55
77
|
requirements: []
|
78
|
+
|
56
79
|
rubyforge_project:
|
57
80
|
rubygems_version: 1.8.10
|
58
81
|
signing_key:
|
59
82
|
specification_version: 3
|
60
83
|
summary: A patch that provides 'mail' gem with iso-2022-jp conversion capability.
|
61
84
|
test_files: []
|
85
|
+
|