decoration_mail 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/decoration_mail.gemspec +1 -2
- data/lib/decoration_mail/base.rb +1 -1
- data/lib/decoration_mail/html.rb +9 -3
- data/lib/decoration_mail/version.rb +1 -1
- data/spec/decoration_mail/base_spec.rb +7 -0
- data/spec/decoration_mail/html_spec.rb +24 -0
- metadata +18 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7556c609c70c2e9d612827105bbe8a43314391
|
4
|
+
data.tar.gz: fc75966a7363b32e78ab925377ec1fb6ee769dad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b3b99dd20fd9020f034ccd3075ba7befa43f002f2a44298c5461b9f42ccc38faa796f36a686d1c00a67a571b4c9d7b25272ccbef156eb96217c856aee3b3fe
|
7
|
+
data.tar.gz: d1a1d911d951077d8135e63b6ddc069a732819c1c25fd89b14e5a73f9726f6cf6068ed19913279ffca75dabe452ab25642dc6c5cef354c87e3dc1d2e381edc3b
|
data/decoration_mail.gemspec
CHANGED
@@ -22,6 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "nokogiri"
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
24
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "debugger"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
27
26
|
end
|
data/lib/decoration_mail/base.rb
CHANGED
@@ -17,7 +17,7 @@ module DecorationMail
|
|
17
17
|
image.instance_eval(&block)
|
18
18
|
|
19
19
|
if @html_body.match /#{image.content_id}/
|
20
|
-
@html_body.update_img_src(image.content_id, image.
|
20
|
+
@html_body.update_img_src(image.content_id, image.path)
|
21
21
|
else
|
22
22
|
case options[:other_images]
|
23
23
|
when :top
|
data/lib/decoration_mail/html.rb
CHANGED
@@ -18,15 +18,21 @@ module DecorationMail
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def append_img(src)
|
21
|
-
@tree.css('body').children.after(%(<br /><div style="text-align:center;"><img src="#{src}" /></div>))
|
21
|
+
@tree.css('body').children.after(%(<br /><div style="text-align:center;"><img src="#{src}" /></div>)) if src
|
22
22
|
end
|
23
23
|
|
24
24
|
def prepend_img(src)
|
25
|
-
@tree.css('body').children.before(%(<div style="text-align:center;"><img src="#{src}" /></div><br />))
|
25
|
+
@tree.css('body').children.before(%(<div style="text-align:center;"><img src="#{src}" /></div><br />)) if src
|
26
26
|
end
|
27
27
|
|
28
28
|
def update_img_src(from, to)
|
29
|
-
@tree.css("img[src=\"#{from}\"]").each
|
29
|
+
@tree.css("img[src=\"#{from}\"]").each do |e|
|
30
|
+
if to
|
31
|
+
e['src'] = to
|
32
|
+
else
|
33
|
+
e.remove
|
34
|
+
end
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
def to_s
|
@@ -66,6 +66,13 @@ describe DecorationMail::Base do
|
|
66
66
|
html.should match /http:\/\/exmaple\.com/
|
67
67
|
end
|
68
68
|
|
69
|
+
it "imageのpathがnilだと、imgタグ自体が削除されること" do
|
70
|
+
html = subject.save do |image|
|
71
|
+
image.path = nil
|
72
|
+
end
|
73
|
+
html.should_not match /<img/
|
74
|
+
end
|
75
|
+
|
69
76
|
it "other_imagesオプションで:topを指定すると添付画像をデコメ上部に貼り付ける" do
|
70
77
|
html = subject.save(:other_images => :top) {}
|
71
78
|
html.should match /20110205153513\.jpg/
|
@@ -27,6 +27,14 @@ describe DecorationMail::HTML do
|
|
27
27
|
subject.append_img('http://example.com/img.gif')
|
28
28
|
subject.to_s.should == %(<div>ほげほげ<br><div style="text-align:center;"><img src="http://example.com/img.gif"></div>\n</div>)
|
29
29
|
end
|
30
|
+
|
31
|
+
context "when src is nil" do
|
32
|
+
before{ subject.append_img(nil) }
|
33
|
+
|
34
|
+
it "ignores the img" do
|
35
|
+
subject.to_s.should == %(<div>ほげほげ</div>)
|
36
|
+
end
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
describe "#prepend_img" do
|
@@ -36,6 +44,14 @@ describe DecorationMail::HTML do
|
|
36
44
|
subject.prepend_img('http://example.com/img.gif')
|
37
45
|
subject.to_s.should == %(<div>\n<div style="text-align:center;"><img src="http://example.com/img.gif"></div>\n<br>ほげほげ</div>)
|
38
46
|
end
|
47
|
+
|
48
|
+
context "when src is nil" do
|
49
|
+
before{ subject.prepend_img(nil) }
|
50
|
+
|
51
|
+
it "ignores the img" do
|
52
|
+
subject.to_s.should == %(<div>ほげほげ</div>)
|
53
|
+
end
|
54
|
+
end
|
39
55
|
end
|
40
56
|
|
41
57
|
describe "#update_img_src" do
|
@@ -45,6 +61,14 @@ describe DecorationMail::HTML do
|
|
45
61
|
subject.update_img_src('cid:hoge', 'http://example.com/img.gif')
|
46
62
|
subject.to_s.should == %(<div>ほげほげ<img src="http://example.com/img.gif"><img src="fuga.gif">\n</div>)
|
47
63
|
end
|
64
|
+
|
65
|
+
context "when src is nil" do
|
66
|
+
before{ subject.update_img_src('cid:hoge', nil) }
|
67
|
+
|
68
|
+
it "deletes the img tag" do
|
69
|
+
subject.to_s.should == %(<div>ほげほげ<img src="fuga.gif">\n</div>)
|
70
|
+
end
|
71
|
+
end
|
48
72
|
end
|
49
73
|
|
50
74
|
describe "#to_s" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decoration_mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dai Akatsuka
|
@@ -9,92 +9,78 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '2.2'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '2.2'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: nokogiri
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - ~>
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.3'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - ~>
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.3'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '2.14'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: debugger
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - '>='
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - '>='
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '0'
|
83
|
+
version: '2.14'
|
98
84
|
description: Decoration Mail Parser
|
99
85
|
email:
|
100
86
|
- d.akatsuka@gmail.com
|
@@ -103,7 +89,7 @@ executables: []
|
|
103
89
|
extensions: []
|
104
90
|
extra_rdoc_files: []
|
105
91
|
files:
|
106
|
-
- .gitignore
|
92
|
+
- ".gitignore"
|
107
93
|
- Gemfile
|
108
94
|
- LICENSE.txt
|
109
95
|
- README.rdoc
|
@@ -136,17 +122,17 @@ require_paths:
|
|
136
122
|
- lib
|
137
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
124
|
requirements:
|
139
|
-
- -
|
125
|
+
- - ">="
|
140
126
|
- !ruby/object:Gem::Version
|
141
127
|
version: '0'
|
142
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
129
|
requirements:
|
144
|
-
- -
|
130
|
+
- - ">="
|
145
131
|
- !ruby/object:Gem::Version
|
146
132
|
version: '0'
|
147
133
|
requirements: []
|
148
134
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.4.4
|
150
136
|
signing_key:
|
151
137
|
specification_version: 4
|
152
138
|
summary: Decoration Mail Parser
|