muck-engine 3.3.10 → 3.3.11

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.10
1
+ 3.3.11
@@ -230,7 +230,9 @@ module MuckEngineHelper
230
230
  def truncate_on_word(text, length = 270, end_string = ' ...')
231
231
  return '' if text.blank?
232
232
  if text.length > length + end_string.length
233
- stop_index = text.rindex(' ', length - end_string.length)
233
+ no_html_end_string = strip_tags(end_string)
234
+ stop_index = text.rindex(' ', length - no_html_end_string.length)
235
+ raise "End string (omission text) was longer than the allowed length for the entire string. Please use a shorter omission string - ie '...'" if stop_index.blank?
234
236
  text[0,stop_index] + end_string
235
237
  else
236
238
  text + end_string
data/muck-engine.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-engine}
8
- s.version = "3.3.10"
8
+ s.version = "3.3.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball", "Joel Duffin"]
@@ -60,11 +60,16 @@ describe MuckEngineHelper do
60
60
  end
61
61
 
62
62
  describe "html_summarize_by_chars" do
63
+ before do
64
+ @html = "<div>This <span>text</span> will need to be reduced down to characters without any html.</div>"
65
+ end
63
66
  it "should remove html and summarize to 270 chars" do
64
- html = "<div>This <span>text</span> will need to be reduced down to characters without any html.</div>"
65
- result = helper.html_summarize_by_chars(html, 30)
67
+ result = helper.html_summarize_by_chars(@html, 30)
66
68
  result.should == "This text will need to be..."
67
69
  end
70
+ it "should raise an error if omission text is too long" do
71
+ helper.html_summarize_by_chars(@html, 30, 'a really long omission text that will be longer than the allowed number of strings').should raise_error
72
+ end
68
73
  end
69
74
 
70
75
  describe "truncate_words" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-engine
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 3
9
- - 10
10
- version: 3.3.10
9
+ - 11
10
+ version: 3.3.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Ball