sep 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,28 +1,32 @@
1
1
  module Sep
2
2
  class Separator
3
- attr_reader :original_text, :words_data
3
+ attr_reader :text, :words_data
4
4
 
5
5
  ANALYSIS = /([[:punct:]\s]*)(\w+)([[:punct:]]*)(\s*)/
6
6
 
7
7
  # text - String text to separate
8
8
  def initialize(text)
9
- @original_text = text
9
+ @text = text
10
10
 
11
11
  analyze
12
12
  end
13
13
 
14
14
  def leading_space
15
- original_text.match(/(\s*)/).captures[0]
15
+ text.match(/(\s*)/).captures[0]
16
16
  end
17
17
 
18
- def whitespace
18
+ def space
19
19
  [leading_space] + words_data.map {|wd| wd[:space_post] }
20
20
  end
21
21
 
22
+ def words
23
+ words_data.map {|wd| wd[:word] }
24
+ end
25
+
22
26
  private
23
27
 
24
28
  def scanned_text
25
- original_text.scan(ANALYSIS)
29
+ text.scan(ANALYSIS)
26
30
  end
27
31
 
28
32
  def analyze
@@ -1,3 +1,3 @@
1
1
  module Sep
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -5,10 +5,11 @@ describe Sep::Separator do
5
5
 
6
6
  let(:sep) { described_class.new(text) }
7
7
 
8
- describe "#original_text" do
9
- subject { sep.original_text }
8
+ describe "#text" do
9
+ subject { sep.text }
10
10
 
11
11
  it { should be_a(String) }
12
+ it { should == text }
12
13
  end
13
14
 
14
15
  describe "#words_data" do
@@ -37,6 +38,11 @@ describe Sep::Separator do
37
38
  end
38
39
 
39
40
  describe "#words" do
41
+ let(:words) { described_class.new(text).words }
42
+
43
+ subject { words.slice(0..4) }
44
+
45
+ it { should == %w{THE MEANING OF ALCHEMY The} }
40
46
  end
41
47
 
42
48
  describe "#leading_space" do
@@ -45,11 +51,11 @@ describe Sep::Separator do
45
51
  it { should == "\n\n" }
46
52
  end
47
53
 
48
- describe "#whitespace" do
49
- let(:whitespace) { described_class.new(text).whitespace }
54
+ describe "#space" do
55
+ let(:space) { described_class.new(text).space }
50
56
 
51
57
  describe "0..4" do
52
- subject { whitespace.slice(0..4) }
58
+ subject { space.slice(0..4) }
53
59
 
54
60
  it { should match_array(["\n\n", " ", " ", " ", "\n\n\n"]) }
55
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: