character_set 1.4.0-java → 1.4.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +29 -0
- data/.github/workflows/tests.yml +22 -0
- data/.rubocop.yml +11 -0
- data/BENCHMARK.md +29 -29
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/benchmarks/shared.rb +5 -1
- data/character_set.gemspec +15 -5
- data/ext/character_set/character_set.c +3 -4
- data/lib/character_set/core_ext/regexp_ext.rb +1 -1
- data/lib/character_set/core_ext/string_ext.rb +1 -1
- data/lib/character_set/expression_converter.rb +4 -3
- data/lib/character_set/parser.rb +1 -1
- data/lib/character_set/ruby_fallback.rb +5 -1
- data/lib/character_set/ruby_fallback/character_set_methods.rb +2 -3
- data/lib/character_set/ruby_fallback/set_methods.rb +23 -15
- data/lib/character_set/shared_methods.rb +5 -9
- data/lib/character_set/version.rb +1 -1
- metadata +53 -23
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea526d8837bf86cb0f983b04c116dd2e1d54e43efc92cc922515d3621c1031c8
|
4
|
+
data.tar.gz: 83ab9e34f04f3008440dc124e30a0dd87a6671967c081e68929ca83acfd9e3a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e6ac6cfdb82133126209f383cbce459d93ee5183c49cb9b3fa8e9c8e3a3c97dbbe42d0b11136602a5b3e32654a925f6a138a1666b50ca18244103f74c4f8d07
|
7
|
+
data.tar.gz: ed0515b677589cdef16e2b1d20f3acdcb53b8f01349fcb09f640f6f63fae31eeab295763a3b5d3505f2530e95b7a6642ba35224f8b1452c5a12e17a1ff3ac07c
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# based on https://github.com/rails/rails/blob/4a78dcb/.github/workflows/rubocop.yml
|
2
|
+
|
3
|
+
name: rubocop linting
|
4
|
+
|
5
|
+
on: [push, pull_request]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- name: Set up Ruby
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7
|
17
|
+
- name: Cache gems
|
18
|
+
uses: actions/cache@v1
|
19
|
+
with:
|
20
|
+
path: vendor/bundle
|
21
|
+
key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
|
22
|
+
restore-keys: |
|
23
|
+
${{ runner.os }}-rubocop-
|
24
|
+
- name: Install gems
|
25
|
+
run: |
|
26
|
+
bundle config path vendor/bundle
|
27
|
+
bundle install --jobs 4 --retry 3
|
28
|
+
- name: Run rubocop
|
29
|
+
run: bundle exec rubocop --lint
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
matrix:
|
11
|
+
ruby: [ '2.2', '2.7', '3.0', 'ruby-head', 'jruby-head' ]
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
- name: Install dependencies
|
20
|
+
run: bundle install --jobs 4
|
21
|
+
- name: Test with Rake
|
22
|
+
run: bundle exec rake
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- '**/doc/*'
|
4
|
+
- '**/pkg/*'
|
5
|
+
- '**/spec/ruby-spec/**/*'
|
6
|
+
- '**/vendor/**/*' # vendored dependencies
|
7
|
+
NewCops: enable
|
8
|
+
RubyInterpreters:
|
9
|
+
- ruby
|
10
|
+
- rake
|
11
|
+
TargetRubyVersion: 2.4 # really 2.1, but 2.4 is lowest supported by rubocop
|
data/BENCHMARK.md
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
Results of `rake:benchmark` on ruby
|
1
|
+
Results of `rake:benchmark` on ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
|
2
2
|
|
3
3
|
```
|
4
4
|
Counting non-letters
|
5
5
|
|
6
|
-
CharacterSet#count_in:
|
7
|
-
String#count:
|
6
|
+
CharacterSet#count_in: 9472902.2 i/s
|
7
|
+
String#count: 2221799.9 i/s - 4.26x slower
|
8
8
|
```
|
9
9
|
```
|
10
10
|
Detecting non-whitespace
|
11
11
|
|
12
|
-
CharacterSet#cover?:
|
13
|
-
Regexp#match?:
|
12
|
+
CharacterSet#cover?: 12388427.2 i/s
|
13
|
+
Regexp#match?: 7901676.8 i/s - 1.57x slower
|
14
14
|
```
|
15
15
|
```
|
16
16
|
Detecting non-letters
|
17
17
|
|
18
|
-
CharacterSet#cover?:
|
19
|
-
Regexp#match?:
|
18
|
+
CharacterSet#cover?: 12263689.1 i/s
|
19
|
+
Regexp#match?: 4940889.9 i/s - 2.48x slower
|
20
20
|
```
|
21
21
|
```
|
22
22
|
Removing whitespace
|
23
23
|
|
24
|
-
CharacterSet#delete_in:
|
25
|
-
String#gsub:
|
24
|
+
CharacterSet#delete_in: 2406722.6 i/s
|
25
|
+
String#gsub: 235760.3 i/s - 10.21x slower
|
26
26
|
```
|
27
27
|
```
|
28
28
|
Removing whitespace, emoji and umlauts
|
29
29
|
|
30
|
-
CharacterSet#delete_in:
|
31
|
-
String#gsub:
|
30
|
+
CharacterSet#delete_in: 1653607.6 i/s
|
31
|
+
String#gsub: 272782.9 i/s - 6.06x slower
|
32
32
|
```
|
33
33
|
```
|
34
34
|
Removing non-whitespace
|
35
35
|
|
36
|
-
CharacterSet#keep_in:
|
37
|
-
String#gsub:
|
36
|
+
CharacterSet#keep_in: 2671038.2 i/s
|
37
|
+
String#gsub: 242551.0 i/s - 11.01x slower
|
38
38
|
```
|
39
39
|
```
|
40
40
|
Extracting emoji
|
41
41
|
|
42
|
-
CharacterSet#keep_in:
|
43
|
-
String#gsub:
|
42
|
+
CharacterSet#keep_in: 1726496.5 i/s
|
43
|
+
String#gsub: 215609.2 i/s - 8.01x slower
|
44
44
|
```
|
45
45
|
```
|
46
46
|
Extracting emoji to an Array
|
47
47
|
|
48
|
-
CharacterSet#scan:
|
49
|
-
String#scan:
|
48
|
+
CharacterSet#scan: 2373856.1 i/s
|
49
|
+
String#scan: 480000.5 i/s - 4.95x slower
|
50
50
|
```
|
51
51
|
```
|
52
52
|
Detecting whitespace
|
53
53
|
|
54
|
-
CharacterSet#used_by?:
|
55
|
-
Regexp#match?:
|
54
|
+
CharacterSet#used_by?: 11988328.7 i/s
|
55
|
+
Regexp#match?: 6758146.8 i/s - 1.77x slower
|
56
56
|
```
|
57
57
|
```
|
58
58
|
Detecting emoji in a large string
|
59
59
|
|
60
|
-
CharacterSet#used_by?:
|
61
|
-
Regexp#match?:
|
60
|
+
CharacterSet#used_by?: 288223.3 i/s
|
61
|
+
Regexp#match?: 102384.2 i/s - 2.82x slower
|
62
62
|
```
|
63
63
|
```
|
64
64
|
Adding entries
|
65
65
|
|
66
|
-
CharacterSet#add:
|
67
|
-
SortedSet#add:
|
66
|
+
CharacterSet#add: 2538251.2 i/s
|
67
|
+
SortedSet#add: 443925.9 i/s - 5.72x slower
|
68
68
|
```
|
69
69
|
```
|
70
70
|
Removing entries
|
71
71
|
|
72
|
-
CharacterSet#delete:
|
73
|
-
SortedSet#delete:
|
72
|
+
CharacterSet#delete: 2487620.8 i/s
|
73
|
+
SortedSet#delete: 628816.1 i/s - 3.96x slower
|
74
74
|
```
|
75
75
|
```
|
76
76
|
Merging entries
|
77
77
|
|
78
|
-
CharacterSet#merge:
|
79
|
-
SortedSet#merge:
|
78
|
+
CharacterSet#merge: 551.6 i/s
|
79
|
+
SortedSet#merge: 1.4 i/s - 393.59x slower
|
80
80
|
```
|
81
81
|
```
|
82
82
|
Getting the min and max
|
83
83
|
|
84
|
-
CharacterSet#minmax:
|
85
|
-
SortedSet#minmax:
|
84
|
+
CharacterSet#minmax: 636890.7 i/s
|
85
|
+
SortedSet#minmax: 254.1 i/s - 2506.20x slower
|
86
86
|
```
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.4.1] - 2020-01-10
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
- multiple fixes for Ruby 3
|
11
|
+
- fixed segfault for some `String` manipulation cases
|
12
|
+
- added `sorted_set` as dependency, so `CharacterSet::Pure` (non-C fallback) works
|
13
|
+
- fixed error when parsing a `Regexp` with an empty intersection (e.g. `/[a&&]/`)
|
14
|
+
|
7
15
|
## [1.4.0] - 2019-06-07
|
8
16
|
|
9
17
|
### Added
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# CharacterSet
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/character_set.svg)](http://badge.fury.io/rb/character_set)
|
4
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/jaynetics/character_set/workflows/tests/badge.svg)](https://github.com/jaynetics/character_set/actions)
|
5
5
|
[![codecov](https://codecov.io/gh/jaynetics/character_set/branch/master/graph/badge.svg)](https://codecov.io/gh/jaynetics/character_set)
|
6
6
|
|
7
7
|
This is a C-extended Ruby gem to work with sets of Unicode codepoints. It can read and write these sets in various formats and implements the stdlib `Set` interface for them.
|
data/benchmarks/shared.rb
CHANGED
@@ -3,7 +3,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
require 'benchmark/ips'
|
5
5
|
require 'character_set'
|
6
|
-
|
6
|
+
if RUBY_VERSION.to_f >= 3.0 && !RUBY_PLATFORM[/java/i]
|
7
|
+
require 'sorted_set'
|
8
|
+
else
|
9
|
+
require 'set'
|
10
|
+
end
|
7
11
|
|
8
12
|
def benchmark(caption: nil, cases: {})
|
9
13
|
puts caption
|
data/character_set.gemspec
CHANGED
@@ -22,13 +22,23 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.required_ruby_version = '>= 2.1.0'
|
24
24
|
|
25
|
+
# SortedSet, needed for RubyFallback, was moved to a gem in Ruby 3.
|
26
|
+
# This dependency is only used if the C extension is unavailable.
|
27
|
+
# JRuby has it in the stdlib.
|
28
|
+
if RUBY_VERSION.to_f >= 3.0 && !RUBY_PLATFORM[/java/i]
|
29
|
+
s.add_dependency 'sorted_set', '~> 1.0'
|
30
|
+
end
|
31
|
+
|
25
32
|
s.add_development_dependency 'benchmark-ips', '~> 2.7'
|
26
|
-
s.add_development_dependency 'codecov', '~> 0.1'
|
27
33
|
s.add_development_dependency 'get_process_mem', '~> 0.2.3'
|
28
|
-
s.add_development_dependency 'rake', '~>
|
29
|
-
s.add_development_dependency 'rake-compiler', '~> 1.
|
34
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
35
|
+
s.add_development_dependency 'rake-compiler', '~> 1.1'
|
30
36
|
s.add_development_dependency 'range_compressor', '~> 1.0'
|
31
|
-
s.add_development_dependency 'regexp_parser', '~> 1.
|
32
|
-
s.add_development_dependency 'regexp_property_values', '~> 0
|
37
|
+
s.add_development_dependency 'regexp_parser', '~> 1.6'
|
38
|
+
s.add_development_dependency 'regexp_property_values', '~> 1.0'
|
33
39
|
s.add_development_dependency 'rspec', '~> 3.8'
|
40
|
+
if RUBY_VERSION.to_f >= 2.7
|
41
|
+
s.add_development_dependency 'codecov', '~> 0.2.12'
|
42
|
+
s.add_development_dependency 'rubocop', '~> 1.8'
|
43
|
+
end
|
34
44
|
end
|
@@ -216,6 +216,7 @@ cs_method_hash(VALUE self)
|
|
216
216
|
cs_cp cp, len, hash, four_byte_value;
|
217
217
|
cs_ar *cps;
|
218
218
|
cps = cs_fetch_cps(self, &len);
|
219
|
+
four_byte_value = 0;
|
219
220
|
|
220
221
|
hash = 17;
|
221
222
|
for (cp = 0; cp < len; cp++)
|
@@ -1074,7 +1075,7 @@ cs_method_count_in(VALUE self, VALUE str)
|
|
1074
1075
|
data = cs_fetch_data(self);
|
1075
1076
|
count = 0;
|
1076
1077
|
each_cp(str, count_str_cp, data->cps, data->len, data, &count);
|
1077
|
-
return INT2NUM(count);
|
1078
|
+
return INT2NUM((int)count);
|
1078
1079
|
}
|
1079
1080
|
|
1080
1081
|
static inline int
|
@@ -1194,7 +1195,7 @@ cs_apply_to_str(VALUE set, VALUE str, int delete, int bang)
|
|
1194
1195
|
return rb_str_dup(str);
|
1195
1196
|
}
|
1196
1197
|
|
1197
|
-
new_str_buf = rb_str_buf_new(orig_len);
|
1198
|
+
new_str_buf = rb_str_buf_new(orig_len + 30); // len + margin
|
1198
1199
|
str_enc = rb_enc_get(str);
|
1199
1200
|
rb_enc_associate(new_str_buf, str_enc);
|
1200
1201
|
rb_str_modify(new_str_buf);
|
@@ -1241,8 +1242,6 @@ cs_apply_to_str(VALUE set, VALUE str, int delete, int bang)
|
|
1241
1242
|
else
|
1242
1243
|
{
|
1243
1244
|
RB_OBJ_WRITE(new_str_buf, &(RBASIC(new_str_buf))->klass, rb_obj_class(str));
|
1244
|
-
// slightly cumbersome approach needed for compatibility with Ruby < 2.3:
|
1245
|
-
RBASIC(new_str_buf)->flags |= (RBASIC(str)->flags & (FL_TAINT));
|
1246
1245
|
str = new_str_buf;
|
1247
1246
|
}
|
1248
1247
|
|
@@ -5,7 +5,7 @@ class CharacterSet
|
|
5
5
|
Error = Class.new(ArgumentError)
|
6
6
|
|
7
7
|
def convert(expression)
|
8
|
-
CharacterSet.require_optional_dependency('regexp_parser')
|
8
|
+
CharacterSet.require_optional_dependency('regexp_parser', __method__)
|
9
9
|
|
10
10
|
case expression
|
11
11
|
when Regexp::Expression::Root
|
@@ -16,13 +16,14 @@ class CharacterSet
|
|
16
16
|
|
17
17
|
when Regexp::Expression::CharacterSet
|
18
18
|
content = expression.map { |subexp| convert(subexp) }.reduce(:+)
|
19
|
+
content ||= CharacterSet[]
|
19
20
|
expression.negative? ? content.inversion : content
|
20
21
|
|
21
22
|
when Regexp::Expression::CharacterSet::Intersection
|
22
23
|
expression.map { |subexp| convert(subexp) }.reduce(:&)
|
23
24
|
|
24
25
|
when Regexp::Expression::CharacterSet::IntersectedSequence
|
25
|
-
expression.map { |subexp| convert(subexp) }.reduce(:+)
|
26
|
+
expression.map { |subexp| convert(subexp) }.reduce(:+) || CharacterSet[]
|
26
27
|
|
27
28
|
when Regexp::Expression::CharacterSet::Range
|
28
29
|
start, finish = expression.map { |subexp| convert(subexp) }
|
@@ -67,7 +68,7 @@ class CharacterSet
|
|
67
68
|
raise Error, 'Groups must contain exactly one expression, e.g. ([a-z])'
|
68
69
|
end
|
69
70
|
|
70
|
-
when Regexp::Expression::Alternation
|
71
|
+
when Regexp::Expression::Alternation # rubocop:disable Lint/DuplicateBranch
|
71
72
|
expression.map { |subexp| convert(subexp) }.reduce(:+)
|
72
73
|
|
73
74
|
when Regexp::Expression::Alternative
|
data/lib/character_set/parser.rb
CHANGED
@@ -5,7 +5,7 @@ class CharacterSet
|
|
5
5
|
def codepoints_from_enumerable(object)
|
6
6
|
raise ArgumentError, 'pass an Enumerable' unless object.respond_to?(:each)
|
7
7
|
# Use #each to check first element (only this works for all Enumerables)
|
8
|
-
object.each do |e|
|
8
|
+
object.each do |e| # rubocop:disable Lint/UnreachableLoop
|
9
9
|
return object if e.is_a?(Integer) && e >= 0 && e < 0x110000
|
10
10
|
return object.map(&:ord) if e.is_a?(String) && e.length == 1
|
11
11
|
raise ArgumentError, "#{e.inspect} is not valid as a codepoint"
|
@@ -31,7 +31,7 @@ class CharacterSet
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def ranges
|
34
|
-
CharacterSet.require_optional_dependency('range_compressor')
|
34
|
+
CharacterSet.require_optional_dependency('range_compressor', __method__)
|
35
35
|
RangeCompressor.compress(self)
|
36
36
|
end
|
37
37
|
|
@@ -121,10 +121,9 @@ class CharacterSet
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def make_new_str(original, &block)
|
124
|
-
|
124
|
+
str!(original)
|
125
125
|
.each_codepoint
|
126
126
|
.each_with_object(''.encode(original.encoding), &block)
|
127
|
-
original.tainted? ? new_string.taint : new_string
|
128
127
|
end
|
129
128
|
end
|
130
129
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class CharacterSet
|
2
2
|
module RubyFallback
|
3
3
|
module SetMethods
|
4
|
-
Enumerable.instance_methods
|
4
|
+
(Enumerable.instance_methods -
|
5
|
+
%i[include? member? to_a] +
|
6
|
+
%i[empty? length size]).each do |mthd|
|
5
7
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
6
8
|
def #{mthd}(*args, &block)
|
7
9
|
@__set.#{mthd}(*args, &block)
|
@@ -9,7 +11,7 @@ class CharacterSet
|
|
9
11
|
RUBY
|
10
12
|
end
|
11
13
|
|
12
|
-
%
|
14
|
+
%i[< <= > >= disjoint? intersect? proper_subset? proper_superset?
|
13
15
|
subset? superset?].each do |mthd|
|
14
16
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
15
17
|
def #{mthd}(enum, &block)
|
@@ -21,8 +23,8 @@ class CharacterSet
|
|
21
23
|
RUBY
|
22
24
|
end
|
23
25
|
|
24
|
-
%
|
25
|
-
each filter!
|
26
|
+
%i[<< add add? clear collect! delete delete? delete_if
|
27
|
+
each filter! map! keep_if reject!
|
26
28
|
select! subtract].each do |mthd|
|
27
29
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
28
30
|
def #{mthd}(*args, &block)
|
@@ -32,22 +34,22 @@ class CharacterSet
|
|
32
34
|
RUBY
|
33
35
|
end
|
34
36
|
|
35
|
-
|
37
|
+
# revert if https://github.com/knu/sorted_set/issues/2 is resolved
|
38
|
+
%i[=== include? member?].each do |mthd|
|
36
39
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
37
|
-
def #{mthd}(
|
38
|
-
|
39
|
-
enum = enum.map { |el| el.is_a?(String) ? el.ord : el }
|
40
|
-
end
|
41
|
-
self.class.new(@__set.#{mthd}(enum, &block).to_a)
|
40
|
+
def #{mthd}(*args, &block)
|
41
|
+
!!@__set.#{mthd}(*args, &block)
|
42
42
|
end
|
43
43
|
RUBY
|
44
44
|
end
|
45
45
|
|
46
|
-
%
|
46
|
+
%i[& + - ^ | difference intersection union].each do |mthd|
|
47
47
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
48
|
-
def #{mthd}
|
49
|
-
|
50
|
-
|
48
|
+
def #{mthd}(enum, &block)
|
49
|
+
if enum.respond_to?(:map)
|
50
|
+
enum = enum.map { |el| el.is_a?(String) ? el.ord : el }
|
51
|
+
end
|
52
|
+
self.class.new(@__set.#{mthd}(enum, &block).to_a)
|
51
53
|
end
|
52
54
|
RUBY
|
53
55
|
end
|
@@ -81,7 +83,13 @@ class CharacterSet
|
|
81
83
|
|
82
84
|
def eql?(other)
|
83
85
|
return false unless other.is_a?(self.class)
|
84
|
-
|
86
|
+
# revert if https://github.com/knu/sorted_set/issues/3 is resolved
|
87
|
+
hash == other.hash
|
88
|
+
end
|
89
|
+
|
90
|
+
# revert if https://github.com/knu/sorted_set/issues/3 is resolved
|
91
|
+
def hash
|
92
|
+
@__set.to_a.hash
|
85
93
|
end
|
86
94
|
|
87
95
|
def initialize_dup(orig)
|
@@ -22,14 +22,14 @@ class CharacterSet
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def of_property(property_name)
|
25
|
-
require_optional_dependency('regexp_property_values')
|
25
|
+
require_optional_dependency('regexp_property_values', __method__)
|
26
26
|
|
27
27
|
property = RegexpPropertyValues[property_name.to_s]
|
28
28
|
from_ranges(*property.matched_ranges)
|
29
29
|
end
|
30
30
|
|
31
31
|
def of_regexp(regexp)
|
32
|
-
require_optional_dependency('regexp_parser')
|
32
|
+
require_optional_dependency('regexp_parser', __method__)
|
33
33
|
|
34
34
|
root = ::Regexp::Parser.parse(regexp)
|
35
35
|
of_expression(root)
|
@@ -39,16 +39,12 @@ class CharacterSet
|
|
39
39
|
ExpressionConverter.convert(expression)
|
40
40
|
end
|
41
41
|
|
42
|
-
def require_optional_dependency(name)
|
42
|
+
def require_optional_dependency(name, method)
|
43
43
|
required_optional_dependencies[name] ||= begin
|
44
44
|
require name
|
45
45
|
true
|
46
46
|
rescue ::LoadError
|
47
|
-
|
48
|
-
loc.absolute_path.to_s.include?('/lib/character_set')
|
49
|
-
end
|
50
|
-
method = entry_point && entry_point.label
|
51
|
-
raise LoadError, 'You must the install the optional dependency '\
|
47
|
+
raise LoadError, 'You must install the optional dependency '\
|
52
48
|
"'\#{name}' to use the method `\#{method}'."
|
53
49
|
end
|
54
50
|
end
|
@@ -155,7 +151,7 @@ class CharacterSet
|
|
155
151
|
end
|
156
152
|
|
157
153
|
def divide(&func)
|
158
|
-
|
154
|
+
CharacterSet.require_optional_dependency('set', __method__)
|
159
155
|
Set.new(to_a).divide(&func)
|
160
156
|
end
|
161
157
|
RUBY
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: character_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Janosch Müller
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: sorted_set
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
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: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: benchmark-ips
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.7'
|
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: '2.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: get_process_mem
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.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: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake-compiler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: range_compressor
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,28 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.6'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
110
|
+
version: '1.6'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: regexp_property_values
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
117
|
+
version: '1.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0
|
124
|
+
version: '1.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,34 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '3.8'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: codecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.2.12
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.2.12
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.8'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.8'
|
139
167
|
- !ruby/object:Gem::Dependency
|
140
168
|
name: range_compressor
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,7 +178,7 @@ dependencies:
|
|
150
178
|
- - "~>"
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '1.0'
|
153
|
-
description:
|
181
|
+
description:
|
154
182
|
email:
|
155
183
|
- janosch84@gmail.com
|
156
184
|
executables: []
|
@@ -158,9 +186,11 @@ extensions: []
|
|
158
186
|
extra_rdoc_files: []
|
159
187
|
files:
|
160
188
|
- ".gitattributes"
|
189
|
+
- ".github/workflows/lint.yml"
|
190
|
+
- ".github/workflows/tests.yml"
|
161
191
|
- ".gitignore"
|
162
192
|
- ".rspec"
|
163
|
-
- ".
|
193
|
+
- ".rubocop.yml"
|
164
194
|
- BENCHMARK.md
|
165
195
|
- CHANGELOG.md
|
166
196
|
- Gemfile
|
@@ -221,7 +251,7 @@ homepage: https://github.com/jaynetics/character_set
|
|
221
251
|
licenses:
|
222
252
|
- MIT
|
223
253
|
metadata: {}
|
224
|
-
post_install_message:
|
254
|
+
post_install_message:
|
225
255
|
rdoc_options: []
|
226
256
|
require_paths:
|
227
257
|
- lib
|
@@ -236,8 +266,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
266
|
- !ruby/object:Gem::Version
|
237
267
|
version: '0'
|
238
268
|
requirements: []
|
239
|
-
rubygems_version: 3.
|
240
|
-
signing_key:
|
269
|
+
rubygems_version: 3.2.3
|
270
|
+
signing_key:
|
241
271
|
specification_version: 4
|
242
272
|
summary: Build, read, write and compare sets of Unicode codepoints.
|
243
273
|
test_files: []
|