Split_Lines 0.1.0 → 1.0.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.md +37 -0
- data/Split_Lines.gemspec +4 -3
- data/lib/Split_Lines.rb +5 -3
- data/lib/Split_Lines/version.rb +1 -1
- data/spec/tests/Split_Lines.rb +9 -5
- metadata +35 -14
data/README.md
ADDED
@@ -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
|
+
|
data/Split_Lines.gemspec
CHANGED
@@ -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
|
-
|
15
|
-
|
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")
|
data/lib/Split_Lines.rb
CHANGED
@@ -5,7 +5,9 @@ class Split_Lines
|
|
5
5
|
end # === class Split_Lines
|
6
6
|
|
7
7
|
def Split_Lines str
|
8
|
-
str.
|
9
|
-
str.strip
|
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
|
data/lib/Split_Lines/version.rb
CHANGED
data/spec/tests/Split_Lines.rb
CHANGED
@@ -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
|
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
|
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
|
21
|
+
Split_Lines(%! test \n\n \t \r test \r\n test !).should == ['test', 'test', 'test']
|
22
22
|
end
|
23
23
|
|
24
|
-
it "splits
|
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
|
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:
|
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-
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
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:
|
58
|
-
|
59
|
-
|
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.
|
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.
|