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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: df402fc74963c48ba73d231cf7f287e4aa3e4a20
4
- data.tar.gz: '0758f84597240f89b6e0b7ff2335716d534a18dd'
2
+ SHA256:
3
+ metadata.gz: 3c00283980915bb989645a55819a4c10205ea9587864a32281a6ab488a02e4a1
4
+ data.tar.gz: 362a10ba357168758ffd3223c0820ee51d339e048ba05495de5126f2827de2b1
5
5
  SHA512:
6
- metadata.gz: 4085bb795b9a96f165b8b5f5b8167031c985f6b363733d40f609b62957bb1804d1ad0e32763f9df51684120b29c0f40f5b701fced189d806c8c0ed7a5c77bfae
7
- data.tar.gz: 8d25a764db7c3031a816d9f678460e491d7888f4930104fb9e0eda3286103ca3a597a14f866b19129322f651f98d5658ef7da9947eb04df1d885fa1d482ccae4
6
+ metadata.gz: cd5a3f10a775fad607530a95eec7bda87bf3b76b44a2dd903717e3a7863cc7eae58522777b60f70e1a137f0ee0a1f0354cf1078f970947eaf4343d5d61d5cfc8
7
+ data.tar.gz: 6e19ac031a7f8db4552590f20d3273ac8fe777f5e006cf5397e06078dc309085294a34285b6360c32bb50c1c66519e92a746d8545b31eb5443cda49aaa88929d
data/.standard.yml ADDED
@@ -0,0 +1,4 @@
1
+ ruby_version: 2.3.0
2
+ ignore:
3
+ - '**/*':
4
+ - Style/SpecialGlobalVars
data/.travis.yml CHANGED
@@ -1,19 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.10
5
- - 2.2.5
6
- - 2.3.1
3
+ - 2.6.0
4
+ - 2.5.3
5
+ - 2.4.5
6
+ - 2.3.8
7
7
  - ruby-head
8
- - jruby-1.7.25
9
- - jruby-9.1.0.0
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-1.7.25
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
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in rsplit.gemspec
4
4
  gemspec
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The zlib license (Zlib)
2
2
 
3
- Copyright (c) 2015 Tatsuya Otsuka
3
+ Copyright (c) 2019 Tatsuya Otsuka
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
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/Tatzyr/rsplit.svg?branch=master)](https://travis-ci.org/Tatzyr/rsplit)
5
- [![Code Climate](https://codeclimate.com/github/Tatzyr/rsplit/badges/gpa.svg)](https://codeclimate.com/github/Tatzyr/rsplit)
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
- "1.2.3".split(".", 2) #=> ["1", "2.3"]
14
- "1.2.3".rsplit(".", 2) #=> ["1.2", "3"]
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/Tatzyr/rsplit.
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/Tatzyr)
49
+ [Tatsuya Otsuka](https://github.com/tatzyr)
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "standard/rake"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task :default => :spec
7
+ task default: [:standard, :spec]
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
- str.reverse.split(sep, limit).map(&:reverse).reverse
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
@@ -1,5 +1,5 @@
1
1
  # -*- frozen_string_literal: true -*-
2
2
 
3
3
  module RSplit
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/rsplit.gemspec CHANGED
@@ -1,27 +1,25 @@
1
- # coding: utf-8
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 'rsplit/version'
3
+ require "rsplit/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "rsplit"
8
- spec.version = RSplit::VERSION
9
- spec.authors = ["Tatsuya Otsuka"]
10
- spec.email = ["tatzyr@gmail.com"]
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 = %q{Divides string into substrings based on a delimiter (starting from right), returning an array of these substrings.}
13
- spec.homepage = "https://github.com/Tatzyr/rsplit"
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 = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
- spec.bindir = "exe"
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.required_ruby_version = ">= 2.0.0"
21
- spec.license = "Zlib"
19
+ spec.license = "Zlib"
22
20
 
23
- spec.add_development_dependency "bundler", "~> 1.10"
24
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "rake"
25
23
  spec.add_development_dependency "rspec"
26
- spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
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.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: 2016-07-03 00:00:00.000000000 Z
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: '1.10'
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: '1.10'
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: '10.0'
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: '10.0'
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: codeclimate-test-reporter
56
+ name: standard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.4'
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.4'
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/Tatzyr/rsplit
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: 2.0.0
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
- rubyforge_project:
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: