ruby-slippers 0.0.26 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.26
1
+ 0.1.1
@@ -43,7 +43,7 @@ module RubySlippers
43
43
  else
44
44
  self[:body].match(/(.{1,#{length || config[:length] || config[:max]}}.*?)(\n|\Z)/m).to_s
45
45
  end
46
- markdown(sum.length == self[:body].length ? sum : sum.strip.sub(/\.\Z/, '…'))
46
+ markdown(sum.length >= self[:body].length-1 ? sum : sum.strip.sub(/\.\Z/, '…'))
47
47
  end
48
48
 
49
49
  def url
@@ -76,7 +76,16 @@ module RubySlippers
76
76
  def full_image_path
77
77
  self[:date].strftime("/img/articles/%Y/%B/#{self[:image]}").downcase
78
78
  end
79
-
79
+
80
+ def has_more?
81
+ self[:body].length > self.summary.length
82
+ end
83
+
84
+ def read_more_link()
85
+ return "" unless has_more?
86
+ "<div class=\"more-link\"><a href=\"<%= article.path %>\">read on &raquo;</a></div>"
87
+ end
88
+
80
89
  def title() self[:title] || "an article" end
81
90
  def date() @config[:date].call(self[:date]) end
82
91
  def author() self[:author] || @config[:author] end
@@ -5,4 +5,6 @@ image: ozma.png
5
5
 
6
6
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
7
7
 
8
+ ~
9
+
8
10
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -8,6 +8,17 @@ context RubySlippers::Engine::Article do
8
8
  @config[:summary] = {:length => 50}
9
9
  @config[:tag_separator] = ", "
10
10
  end
11
+
12
+ context "when the article body and summary are the same" do
13
+ setup do
14
+ RubySlippers::Engine::Article.new({
15
+ :title => "Dorothy & The Wizard of Oz.",
16
+ :body => "#Chapter I\nhello, *stranger*. ~"
17
+ }, @config)
18
+ end
19
+ should("not have a read_more_link") { topic.read_more_link == "" }
20
+ should("not end in ...") { topic.summary !~ /&hellip;<\/p>/ }
21
+ end
11
22
 
12
23
  context "with the bare essentials" do
13
24
  setup do
@@ -58,6 +69,8 @@ context RubySlippers::Engine::Article do
58
69
  should("have tags") { topic.tags }.equals "wizards, oz"
59
70
  should("have tag links") { topic.tag_links }.equals "<a href=\"/tagged/wizards\">wizards</a>, <a href=\"/tagged/oz\">oz</a>"
60
71
  should("have an image") { topic.image_src }.equals "/img/articles/1976/october/ozma.png"
72
+ should("have a read_more_link") { topic.read_more_link =~ /more-link/ }
73
+ should("end in ...") { topic.summary =~ /&hellip;<\/p>/ }
61
74
 
62
75
  context "and long first paragraph" do
63
76
  should("create a valid summary") { topic.summary }.equals "<p>" + ("a little bit of text." * 5).chop + "&hellip;</p>\n"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ruby-slippers
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.26
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - dreamr