rsplit 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.standard.yml +4 -0
- data/.travis.yml +7 -13
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +8 -20
- data/Rakefile +2 -1
- data/lib/rsplit.rb +14 -6
- data/lib/rsplit/version.rb +1 -1
- data/rsplit.gemspec +15 -17
- metadata +19 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3c00283980915bb989645a55819a4c10205ea9587864a32281a6ab488a02e4a1
|
4
|
+
data.tar.gz: 362a10ba357168758ffd3223c0820ee51d339e048ba05495de5126f2827de2b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd5a3f10a775fad607530a95eec7bda87bf3b76b44a2dd903717e3a7863cc7eae58522777b60f70e1a137f0ee0a1f0354cf1078f970947eaf4343d5d61d5cfc8
|
7
|
+
data.tar.gz: 6e19ac031a7f8db4552590f20d3273ac8fe777f5e006cf5397e06078dc309085294a34285b6360c32bb50c1c66519e92a746d8545b31eb5443cda49aaa88929d
|
data/.standard.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,19 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.3.
|
3
|
+
- 2.6.0
|
4
|
+
- 2.5.3
|
5
|
+
- 2.4.5
|
6
|
+
- 2.3.8
|
7
7
|
- ruby-head
|
8
|
-
- jruby-
|
9
|
-
|
10
|
-
- jruby-head
|
11
|
-
- rbx-2
|
12
|
-
before_install: gem install bundler -v 1.10.6
|
8
|
+
- jruby-9.2.0.0
|
9
|
+
before_install: gem install bundler
|
13
10
|
matrix:
|
14
11
|
allow_failures:
|
15
12
|
- rvm: ruby-head
|
16
|
-
- rvm: jruby-
|
17
|
-
- rvm: jruby-9.1.0.0
|
18
|
-
- rvm: jruby-head
|
19
|
-
- rvm: rbx-2
|
13
|
+
- rvm: jruby-9.2.0.0
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# String#rsplit
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/rsplit.svg)](http://badge.fury.io/rb/rsplit)
|
4
|
-
[![Build Status](https://travis-ci.org/
|
5
|
-
[![
|
6
|
-
[![Test Coverage](https://codeclimate.com/github/Tatzyr/rsplit/badges/coverage.svg)](https://codeclimate.com/github/Tatzyr/rsplit/coverage)
|
7
|
-
[![Dependency Status](https://gemnasium.com/Tatzyr/rsplit.svg)](https://gemnasium.com/Tatzyr/rsplit)
|
4
|
+
[![Build Status](https://travis-ci.org/tatzyr/rsplit.svg?branch=master)](https://travis-ci.org/tatzyr/rsplit)
|
5
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
8
6
|
|
9
7
|
Divides string into substrings based on a delimiter (starting from right),
|
10
8
|
returning an array of these substrings.
|
11
9
|
|
12
10
|
```ruby
|
13
|
-
|
14
|
-
|
11
|
+
require "rsplit"
|
12
|
+
|
13
|
+
"1.2.3".split(".", 2) #=> ["1", "2.3"]
|
14
|
+
"1.2.3".rsplit(".", 2) #=> ["1.2", "3"]
|
15
15
|
```
|
16
16
|
|
17
17
|
## Installation
|
@@ -30,18 +30,6 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
$ gem install rsplit
|
32
32
|
|
33
|
-
## Usage
|
34
|
-
|
35
|
-
```ruby
|
36
|
-
require "rsplit"
|
37
|
-
|
38
|
-
"Dalton Kuhic dalton.kuhic@example.com".rsplit(" ", 2)
|
39
|
-
# => ["Dalton Kuhic", "dalton.kuhic@example.com"]
|
40
|
-
|
41
|
-
"Sallie Hickle Jr. sallie@example.org".rsplit(" ", 2)
|
42
|
-
# => ["Sallie Hickle Jr.", "sallie@example.org"]
|
43
|
-
```
|
44
|
-
|
45
33
|
## Development
|
46
34
|
|
47
35
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -50,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
50
38
|
|
51
39
|
## Contributing
|
52
40
|
|
53
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tatzyr/rsplit.
|
54
42
|
|
55
43
|
## Licence
|
56
44
|
|
@@ -58,4 +46,4 @@ See [LICENSE](LICENSE).
|
|
58
46
|
|
59
47
|
## Author
|
60
48
|
|
61
|
-
[Tatsuya Otsuka](https://github.com/
|
49
|
+
[Tatsuya Otsuka](https://github.com/tatzyr)
|
data/Rakefile
CHANGED
data/lib/rsplit.rb
CHANGED
@@ -8,7 +8,7 @@ module RSplit
|
|
8
8
|
sep = $; if sep.nil?
|
9
9
|
case sep
|
10
10
|
when NilClass
|
11
|
-
# do nothing
|
11
|
+
nil # do nothing
|
12
12
|
when String
|
13
13
|
valid_encoding?(sep)
|
14
14
|
sep = sep.reverse
|
@@ -16,7 +16,14 @@ module RSplit
|
|
16
16
|
raise TypeError, "wrong argument type #{sep.class} (expected String)"
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
if block_given?
|
20
|
+
str.reverse.split(sep, limit).reverse_each do |elem|
|
21
|
+
yield elem.reverse
|
22
|
+
end
|
23
|
+
str
|
24
|
+
else
|
25
|
+
str.reverse.split(sep, limit).map(&:reverse).reverse
|
26
|
+
end
|
20
27
|
end
|
21
28
|
|
22
29
|
module_function :rsplit
|
@@ -28,14 +35,15 @@ module RSplit
|
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
31
|
-
|
32
38
|
class String
|
33
39
|
# :call-seq:
|
34
|
-
# rsplit(sep = $;, limit = 0)
|
40
|
+
# rsplit(sep = $;, limit = 0) -> array
|
41
|
+
# rsplit(sep = $;, limit = 0) {|elem| block } -> str
|
42
|
+
|
35
43
|
#
|
36
44
|
# Divides string into substrings based on a delimiter (starting from right), returning an array of these substrings.
|
37
45
|
#
|
38
|
-
def rsplit(*args)
|
39
|
-
RSplit.rsplit(self, *args)
|
46
|
+
def rsplit(*args, &proc)
|
47
|
+
RSplit.rsplit(self, *args, &proc)
|
40
48
|
end
|
41
49
|
end
|
data/lib/rsplit/version.rb
CHANGED
data/rsplit.gemspec
CHANGED
@@ -1,27 +1,25 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require "rsplit/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
6
|
+
spec.name = "rsplit"
|
7
|
+
spec.version = RSplit::VERSION
|
8
|
+
spec.authors = ["Tatsuya Otsuka"]
|
9
|
+
spec.email = ["tatzyr@gmail.com"]
|
11
10
|
|
12
|
-
spec.summary
|
13
|
-
spec.homepage
|
11
|
+
spec.summary = "Divides string into substrings based on a delimiter (starting from right), returning an array of these substrings."
|
12
|
+
spec.homepage = "https://github.com/tatzyr/rsplit"
|
14
13
|
|
15
|
-
spec.files
|
16
|
-
spec.bindir
|
17
|
-
spec.executables
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.bindir = "exe"
|
16
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
17
|
spec.require_paths = ["lib"]
|
19
18
|
|
20
|
-
spec.
|
21
|
-
spec.license = "Zlib"
|
19
|
+
spec.license = "Zlib"
|
22
20
|
|
23
|
-
spec.add_development_dependency "bundler"
|
24
|
-
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
25
23
|
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency "standard"
|
27
25
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsplit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuya Otsuka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: standard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '0'
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- tatzyr@gmail.com
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".rspec"
|
78
|
+
- ".standard.yml"
|
78
79
|
- ".travis.yml"
|
79
80
|
- Gemfile
|
80
81
|
- LICENSE
|
@@ -85,7 +86,7 @@ files:
|
|
85
86
|
- lib/rsplit.rb
|
86
87
|
- lib/rsplit/version.rb
|
87
88
|
- rsplit.gemspec
|
88
|
-
homepage: https://github.com/
|
89
|
+
homepage: https://github.com/tatzyr/rsplit
|
89
90
|
licenses:
|
90
91
|
- Zlib
|
91
92
|
metadata: {}
|
@@ -97,18 +98,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
98
|
requirements:
|
98
99
|
- - ">="
|
99
100
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
101
|
+
version: '0'
|
101
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
103
|
requirements:
|
103
104
|
- - ">="
|
104
105
|
- !ruby/object:Gem::Version
|
105
106
|
version: '0'
|
106
107
|
requirements: []
|
107
|
-
|
108
|
-
rubygems_version: 2.6.6
|
108
|
+
rubygems_version: 3.0.2
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Divides string into substrings based on a delimiter (starting from right),
|
112
112
|
returning an array of these substrings.
|
113
113
|
test_files: []
|
114
|
-
has_rdoc:
|