Split_Lines 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+
6
+ coverage
7
+ rdoc
8
+ .yardoc
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ source "http://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in Bob.gemspec
6
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require "Split_Lines/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "Split_Lines"
8
+ s.version = Split_Lines::VERSION
9
+ s.authors = ["da99"]
10
+ s.email = ["i-hate-spam-45671204@mailinator.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Take a string and turn it to an array of lines.}
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 ")
16
+ }
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency "bacon"
24
+ s.add_development_dependency "rake"
25
+ s.add_development_dependency 'Bacon_Colored'
26
+ s.add_development_dependency 'pry'
27
+
28
+ # s.rubyforge_project = "Split_Lines"
29
+ # specify any dependencies here; for example:
30
+ # s.add_runtime_dependency "rest-client"
31
+ end
@@ -0,0 +1,11 @@
1
+ require 'Split_Lines/version'
2
+
3
+ class Split_Lines
4
+ Separator = %r![\r\n]+!
5
+ end # === class Split_Lines
6
+
7
+ def Split_Lines str
8
+ str.strip.split( Split_Lines::Separator ).reject { |str|
9
+ str.strip.empty?
10
+ }
11
+ end
@@ -0,0 +1,3 @@
1
+ class Split_Lines
2
+ VERSION = "0.1.0"
3
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.print e.message, "\n"
7
+ $stderr.print "Run `bundle install` to install missing gems\n"
8
+ exit e.status_code
9
+ end
10
+ require 'bacon'
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+
15
+ Bacon.summary_on_exit
data/spec/main.rb ADDED
@@ -0,0 +1,15 @@
1
+
2
+ require File.expand_path('spec/helper')
3
+ require 'Split_Lines'
4
+ require 'Bacon_Colored'
5
+ require 'pry'
6
+
7
+
8
+ # ======== Include the tests.
9
+ if ARGV.size > 1 && ARGV[1, ARGV.size - 1].detect { |a| File.exists?(a) }
10
+ # Do nothing. Bacon grabs the file.
11
+ else
12
+ Dir.glob('spec/tests/*.rb').each { |file|
13
+ require File.expand_path(file.sub('.rb', '')) if File.file?(file)
14
+ }
15
+ end
@@ -0,0 +1,37 @@
1
+
2
+ describe "Split_Lines(str)" do
3
+
4
+ it "splits lines on \\n" do
5
+ Split_Lines("test\ntest").should == %w{ test test }
6
+ end
7
+
8
+ it "splits lines on \\r\\n" do
9
+ Split_Lines("test\r\ntest").should == %w{ test test }
10
+ end
11
+
12
+ it "strips the string before splitting" do
13
+ Split_Lines( %! test \n test \n test ! ).should == [ 'test ', ' test ', ' test']
14
+ end
15
+
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' ]
18
+ end
19
+
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']
22
+ end
23
+
24
+ it "splits lies on \\r" do
25
+ Split_Lines(%! test\rtest !).should == %w{ test test }
26
+ end
27
+
28
+ it "does not split on \\t" do
29
+ Split_Lines(%! test \t test !).should == ["test \t test"]
30
+ end
31
+
32
+ it "splits on \\r\\t " do
33
+ Split_Lines(%! test \r\t test !).should == ['test ', "\t test"]
34
+ end
35
+
36
+ end # === Split_Lines(str)
37
+
data/spec/tests/bin.rb ADDED
@@ -0,0 +1,10 @@
1
+
2
+ describe "permissions of bin/" do
3
+
4
+ it "should be 750" do
5
+ `stat -c %a bin`.strip
6
+ .should.be == "750"
7
+ end
8
+
9
+ end # === permissions of bin/
10
+
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Split_Lines
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - da99
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bacon
16
+ requirement: &21228340 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *21228340
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &21227780 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *21227780
36
+ - !ruby/object:Gem::Dependency
37
+ name: Bacon_Colored
38
+ requirement: &21227320 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *21227320
47
+ - !ruby/object:Gem::Dependency
48
+ name: pry
49
+ requirement: &21226820 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ 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 "
60
+ email:
61
+ - i-hate-spam-45671204@mailinator.com
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - Gemfile
68
+ - Rakefile
69
+ - Split_Lines.gemspec
70
+ - lib/Split_Lines.rb
71
+ - lib/Split_Lines/version.rb
72
+ - spec/helper.rb
73
+ - spec/main.rb
74
+ - spec/tests/Split_Lines.rb
75
+ - spec/tests/bin.rb
76
+ homepage: ''
77
+ licenses: []
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.17
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Take a string and turn it to an array of lines.
100
+ test_files: []