Skip to content

Commit 22cad04

Browse files
committed
#116 Option clear_description enabled
1 parent 2b817bc commit 22cad04

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

plugins/filter/description_link.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def run
3434
def rewrite_link(feed)
3535
new_link = URI.extract(feed.description, %w{http https}).uniq.last
3636
feed.link = new_link unless new_link.nil?
37+
38+
if @config['clear_description'] == 1
39+
feed.description = ""
40+
end
41+
3742
feed
3843
end
3944
end

spec/plugins/filter/description_link_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,38 @@
3535
subject.run
3636
subject.instance_variable_get(:@pipeline)[0].items[0].link.
3737
should == "http://test2.id774.net"
38+
subject.instance_variable_get(:@pipeline)[0].items[0].description.
39+
should == "aaa bbb ccc http://test2.id774.net"
40+
}
41+
end
42+
end
43+
44+
context "It should be empty description if clear_description specified" do
45+
46+
subject {
47+
Automatic::Plugin::FilterDescriptionLink.new({
48+
'clear_description' => 1,
49+
},
50+
AutomaticSpec.generate_pipeline {
51+
feed {
52+
item "http://test1.id774.net",
53+
"dummy title",
54+
"aaa bbb ccc http://test2.id774.net",
55+
"Mon, 07 Mar 2011 15:54:11 +0900"
56+
}
57+
}
58+
)
59+
}
60+
61+
describe "#run" do
62+
its(:run) { should have(1).feeds }
63+
64+
specify {
65+
subject.run
66+
subject.instance_variable_get(:@pipeline)[0].items[0].link.
67+
should == "http://test2.id774.net"
68+
subject.instance_variable_get(:@pipeline)[0].items[0].description.
69+
should == ""
3870
}
3971
end
4072
end

0 commit comments

Comments
 (0)