ohgiri 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -12,7 +12,7 @@ Simple library to shorten the text by the specified length.
12
12
  # => "Not that I ..."
13
13
 
14
14
  "All that glitters is not gold.".shorten(100)
15
- # => "All that glisters is not gold."
15
+ # => "All that glitters is not gold."
16
16
 
17
17
  "But break, my heart, for I must hold my tongue.".shorten
18
18
  # => "But bre..."
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.1.0
data/lib/ohgiri.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class String
2
- def shorten(length = 10)
3
- self.size > length ? "#{self[0, (length - 3)]}..." : self
2
+ def shorten(length = 10, ellipsis = '...')
3
+ self.size > length ? "#{self[0, (length - ellipsis.length)]}#{ellipsis}" : self
4
4
  end
5
5
  end
data/ohgiri.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ohgiri"
8
- s.version = "0.0.2"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jun Yokoyama"]
data/spec/ohgiri_spec.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe "Ohgiri" do
5
- let(:long_text) { String.new("There are more things in heaven and earth, Horatio.Than are dreamt of in your philosophy.") }
5
+ let(:long_text) { String.new("There are more things in heaven and earth, Horatio. Than are dreamt of in your philosophy.") }
6
6
  let(:ten_characters_text) { String.new("invitation") }
7
7
  let(:short_text) { String.new("Ophelia") }
8
8
  let(:japanese_text) { String.new("智に働けば角が立つ。 情に棹させば流される。 意地を通せば窮屈だ。 とかくに人の世は住みにくい。") }
@@ -30,11 +30,20 @@ describe "Ohgiri" do
30
30
  it "should returns shortened Japanese string in specified length" do
31
31
  japanese_text.shorten(20).should eq("智に働けば角が立つ。 情に棹させば...")
32
32
  end
33
- end
34
-
35
-
36
-
37
33
 
34
+ it "should returns shortened string with assigned ellipsis" do
35
+ long_text.shorten(20, '*').should eq("There are more thin*")
36
+ end
38
37
 
38
+ it "should returns shortened Japanese string with assigned ellipsis" do
39
+ japanese_text.shorten(20, '--').should eq("智に働けば角が立つ。 情に棹させば流--")
40
+ end
39
41
 
42
+ it "should returns shortened string with assigned ellipsis by Japanese characters" do
43
+ long_text.shorten(20, '以下略').should eq("There are more th以下略")
44
+ end
40
45
 
46
+ it "should returns ellipsis string if assigned ellipsis is longer than specified length" do
47
+ long_text.shorten(3, '以下省略').should eq("以下省略")
48
+ end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohgiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  segments:
111
111
  - 0
112
- hash: -1314608248367900049
112
+ hash: -1766940211948418941
113
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  none: false
115
115
  requirements: