bergamasco 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e64dfebc3ce451322fa2cd72fcdaf931d92815e9
4
- data.tar.gz: ef49e69c7121b2b8f5a11fc976d29c70c9c9da9e
3
+ metadata.gz: 2408331adbbd94d3263b46bc845e4ee28b9d25e7
4
+ data.tar.gz: 31ef99f8504917494f39e7855cba98789bede309
5
5
  SHA512:
6
- metadata.gz: 3854c81a72b9d2b47794016d0308ebf5e6f28dd30e6daebe69d254cafa3c4ac5751ebbca4b9caa50c28a7e774a21861ab244e74755b66ad33ea0ca60389dd132
7
- data.tar.gz: 42a74df8e63e1da2e61ee872f1a32a13e448636263f4a39a4ec58c856e076dca74390295e15fc8943f42cded57d148310a3d23a1ab1a1f607c0e2459febb0e2c
6
+ metadata.gz: 07ed905d2d57fb0d3c5fb86f832346e4ceb9c594b77ca86c0522b6320643babc0a00352bb3c2d54da3fdc108300976626614836f3f074c9de3366ba570d37c42
7
+ data.tar.gz: 2bdfda5983ab9ab33f365d9fe1c1fb8dd2b503aaa5a22a7a210b88df4e9290f75cf125d3be67210f0dd8b5f99e464b8a514bc8d895fe99001d324a6123a0cbab
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bergamasco (0.2.7)
4
+ bergamasco (0.2.8)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  addressable (~> 2.3.8)
7
7
  builder (~> 3.2, >= 3.2.2)
@@ -79,4 +79,4 @@ DEPENDENCIES
79
79
  simplecov
80
80
 
81
81
  BUNDLED WITH
82
- 1.12.5
82
+ 1.13.6
@@ -2,8 +2,10 @@ module Bergamasco
2
2
  module Summarize
3
3
  # based on from https://github.com/middleman/middleman-blog/blob/master/lib/middleman-blog/blog_article.rb
4
4
  def self.summary(text, options={})
5
- if options[:separator]
6
- truncate_at_separator(text, options[:separator])
5
+ separator = options[:separator] || "READMORE"
6
+
7
+ if !options[:length] && text.include?(separator)
8
+ truncate_at_separator(text, separator)
7
9
  else
8
10
  max_length = options[:length] || 250
9
11
  ellipsis = options[:ellipsis] || "..."
@@ -1,3 +1,3 @@
1
1
  module Bergamasco
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -6,7 +6,7 @@ describe Bergamasco::Summarize do
6
6
  it 'should truncate after 250 characters' do
7
7
  filepath = fixture_path + 'cool-dois-without-yml.md'
8
8
  file = IO.read(filepath)
9
- content = subject.summary(file)
9
+ content = subject.summary(file, length: 250)
10
10
  expect(content.length).to eq(250)
11
11
  expect(content).to start_with("In 1998 Tim Berners-Lee coined")
12
12
  end
@@ -22,8 +22,7 @@ describe Bergamasco::Summarize do
22
22
  it 'should truncate at separator' do
23
23
  filepath = fixture_path + 'cool-dois-without-yml.md'
24
24
  file = IO.read(filepath)
25
- separator = "READMORE"
26
- content = subject.summary(file, separator: separator)
25
+ content = subject.summary(file)
27
26
  expect(content).to start_with("In 1998 Tim Berners-Lee coined")
28
27
  expect(content).to end_with("the referenced resource.")
29
28
  end
@@ -31,9 +30,8 @@ describe Bergamasco::Summarize do
31
30
  it 'should truncate at separator and convert to html' do
32
31
  filepath = fixture_path + 'cool-dois-without-yml.md'
33
32
  file = IO.read(filepath)
34
- separator = "READMORE"
35
33
  html = Bergamasco::Markdown.render_html(file, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.bib')
36
- content = subject.summary_from_html(html, separator: separator, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.bib')
34
+ content = subject.summary_from_html(html, skip_yaml_header: true, csl: 'spec/fixtures/apa.csl', bibliography: 'spec/fixtures/references.bib')
37
35
  expect(content).to start_with("In 1998 Tim Berners-Lee coined the term cool URIs (1998), that is URIs that don’t change.")
38
36
  expect(content).to end_with("the referenced resource.")
39
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bergamasco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner