split-where 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/split-where.rb +39 -0
  2. data/split-where.gemspec +28 -0
  3. metadata +49 -0
@@ -0,0 +1,39 @@
1
+ # -*- encoding : utf-8 -*-
2
+
3
+ module SplitWhere
4
+ module String
5
+ # The new split_where make split of strings using conditions to determine
6
+ # where he can cut or not the string
7
+ # @param [Hash{:value=>String, :outside=>String}] :value for split, :outside is a condition to split
8
+ #@note exemple: "'xx','yy,',l{},'dg,'g"
9
+ #@note exemple: "a,b,c"
10
+ # 0123456789012345678901234
11
+ def split_where(args)
12
+ list = []
13
+ enable = true
14
+ s = ""
15
+ count = 0
16
+ while(self[count])
17
+ c = self[count]
18
+ if args[:outside] == c
19
+ enable = enable ? false : true
20
+ end
21
+
22
+ if c == args[:value] && enable == true
23
+ list << s
24
+ s=""
25
+ else
26
+ s += c
27
+ end
28
+ count += 1
29
+ end
30
+ list << s if s
31
+ list
32
+ end
33
+ end
34
+ end
35
+
36
+ # Original class of String...
37
+ class String
38
+ include SplitWhere::String
39
+ end
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'split-where'
5
+ s.version = '0.0.3'
6
+ s.summary = 'The best split'
7
+ s.description = <<-EOF
8
+ split_where is the best split for specific situations, such as when a
9
+ character is within quotation marks or apostrophes, use your imagination.
10
+ EOF
11
+ s.requirements << 'One string to split xD'
12
+ s.files = [
13
+ 'lib/split-where.rb',
14
+ 'split-where.gemspec'
15
+ ]
16
+
17
+ s.has_rdoc = true
18
+ s.author = 'Thiago Coutinho'
19
+ s.email = 'thiago@osfeio.com'
20
+ s.rubyforge_project = 'split-where'
21
+ s.homepage = "http://github.com/selialkile/split-where"
22
+ end
23
+
24
+ if __FILE__ == $0
25
+ Gem::Builder.new(spec).build
26
+ else
27
+ spec
28
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: split-where
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thiago Coutinho
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-19 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ! " split_where is the best split for specific situations, such as
15
+ when a \n character is within quotation marks or apostrophes, use your imagination.\n"
16
+ email: thiago@osfeio.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/split-where.rb
22
+ - split-where.gemspec
23
+ homepage: http://github.com/selialkile/split-where
24
+ licenses: []
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements:
42
+ - One string to split xD
43
+ rubyforge_project: split-where
44
+ rubygems_version: 1.8.15
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: The best split
48
+ test_files: []
49
+ has_rdoc: true