Split_Lines 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,37 @@
1
+
2
+ Split\_Lines
3
+ ===========
4
+
5
+ A Ruby gem that extracts each line from text, strips,
6
+ rejects empty lines, and returns an Array.
7
+
8
+ Installation
9
+ ----
10
+
11
+ gem install Split_Lines
12
+
13
+ Usage
14
+ ----
15
+
16
+ require "Split_Lines"
17
+
18
+ Split_Lines %@
19
+ cd /my_apps
20
+
21
+ pwd
22
+ @
23
+ # --> [ 'cd /my_apps', 'pwd' ]
24
+
25
+ Run Tests
26
+ ---------
27
+
28
+ git clone git@github.com:da99/Split_Lines.git
29
+ cd Split_Lines
30
+ bundle update
31
+ bundle exec bacon spec/main.rb
32
+
33
+ ...
34
+ ---
35
+
36
+ The End.
37
+
@@ -8,11 +8,12 @@ Gem::Specification.new do |s|
8
8
  s.version = Split_Lines::VERSION
9
9
  s.authors = ["da99"]
10
10
  s.email = ["i-hate-spam-45671204@mailinator.com"]
11
- s.homepage = ""
11
+ s.homepage = "https://github.com/da99/Split_Lines"
12
12
  s.summary = %q{Take a string and turn it to an array of lines.}
13
13
  s.description = %q{
14
- Turns a string into an array of lines without an \\n\\r in
15
- each entry: Strip_Lines(" test \\n test ")
14
+ A function that splits a string into
15
+ an Array of stripped, non-empty lines:
16
+ Strip_Lines(" test \n \n test ")
16
17
  }
17
18
 
18
19
  s.files = `git ls-files`.split("\n")
@@ -5,7 +5,9 @@ class Split_Lines
5
5
  end # === class Split_Lines
6
6
 
7
7
  def Split_Lines str
8
- str.strip.split( Split_Lines::Separator ).reject { |str|
9
- str.strip.empty?
10
- }
8
+ str.split( Split_Lines::Separator ).map { |str|
9
+ s = str.strip
10
+ next if s.empty?
11
+ s
12
+ }.compact
11
13
  end
@@ -1,3 +1,3 @@
1
1
  class Split_Lines
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -10,18 +10,18 @@ describe "Split_Lines(str)" do
10
10
  end
11
11
 
12
12
  it "strips the string before splitting" do
13
- Split_Lines( %! test \n test \n test ! ).should == [ 'test ', ' test ', ' test']
13
+ Split_Lines( %! test \n test \n test ! ).should == [ 'test', 'test', 'test']
14
14
  end
15
15
 
16
16
  it "strips the string no matter how many new lines: \\n\\n\\n" do
17
- Split_Lines( %! test \n\n\n test ! ).should == [ 'test ', ' test' ]
17
+ Split_Lines( %! test \n\n\n test ! ).should == [ 'test', 'test' ]
18
18
  end
19
19
 
20
20
  it "ignores all whitespace inside new lines: \\n \\t \\n" do
21
- Split_Lines(%! test \n\n \t \r test \r\n test !).should == ['test ', ' test ', ' test']
21
+ Split_Lines(%! test \n\n \t \r test \r\n test !).should == ['test', 'test', 'test']
22
22
  end
23
23
 
24
- it "splits lies on \\r" do
24
+ it "splits lines on \\r" do
25
25
  Split_Lines(%! test\rtest !).should == %w{ test test }
26
26
  end
27
27
 
@@ -30,7 +30,11 @@ describe "Split_Lines(str)" do
30
30
  end
31
31
 
32
32
  it "splits on \\r\\t " do
33
- Split_Lines(%! test \r\t test !).should == ['test ', "\t test"]
33
+ Split_Lines(%! test \r\t test !).should == ['test', "test"]
34
+ end
35
+
36
+ it "strips each line after splitting" do
37
+ Split_Lines(%! test \r\t test !).should == ['test', "test"]
34
38
  end
35
39
 
36
40
  end # === Split_Lines(str)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Split_Lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-20 00:00:00.000000000 Z
12
+ date: 2012-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon
16
- requirement: &21228340 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *21228340
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &21227780 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *21227780
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: Bacon_Colored
38
- requirement: &21227320 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *21227320
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: pry
49
- requirement: &21226820 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,9 +69,14 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *21226820
58
- description: ! "\n Turns a string into an array of lines without an \\n\\r in \n
59
- \ each entry: Strip_Lines(\" test \\n test \")\n "
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: ! "\n A function that splits a string into \n an Array of stripped,
79
+ non-empty lines: \n Strip_Lines(\" test \\n \\n test \")\n "
60
80
  email:
61
81
  - i-hate-spam-45671204@mailinator.com
62
82
  executables: []
@@ -65,6 +85,7 @@ extra_rdoc_files: []
65
85
  files:
66
86
  - .gitignore
67
87
  - Gemfile
88
+ - README.md
68
89
  - Rakefile
69
90
  - Split_Lines.gemspec
70
91
  - lib/Split_Lines.rb
@@ -73,7 +94,7 @@ files:
73
94
  - spec/main.rb
74
95
  - spec/tests/Split_Lines.rb
75
96
  - spec/tests/bin.rb
76
- homepage: ''
97
+ homepage: https://github.com/da99/Split_Lines
77
98
  licenses: []
78
99
  post_install_message:
79
100
  rdoc_options: []
@@ -93,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
114
  version: '0'
94
115
  requirements: []
95
116
  rubyforge_project:
96
- rubygems_version: 1.8.17
117
+ rubygems_version: 1.8.19
97
118
  signing_key:
98
119
  specification_version: 3
99
120
  summary: Take a string and turn it to an array of lines.