chars 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +4 -3
- data/ChangeLog.md +4 -0
- data/Gemfile +11 -0
- data/Rakefile +6 -30
- data/gemspec.yml +1 -3
- data/lib/chars/char_set.rb +4 -4
- data/lib/chars/version.rb +1 -1
- data/spec/char_set_spec.rb +115 -95
- data/spec/chars_spec.rb +13 -13
- data/spec/extensions/integer_spec.rb +18 -18
- data/spec/extensions/string_spec.rb +20 -18
- data/spec/spec_helper.rb +0 -2
- metadata +19 -54
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a22fd4d88e24c4f378880de5e324ac4acc4ff197c541baa1b840a8852d420afa
|
4
|
+
data.tar.gz: ad9c7a38b080490366aaf4142eb642224d551da165ddeedfb4fc1fd0e6bf0728
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5886283079f3bfcf060facf0b0520a51f75066b0301a87750d262e1e4326fad164e541c9580aad1a3f86810430732b2e1933b2ccee26eda6667d0da2aaf2bf00
|
7
|
+
data.tar.gz: 0313dcedc0872cc15f84804bdea985bf726040b48d48018084800c8e07f4224267b5802df4da9d68c5ce79ff0239e4af7138db522fa8523647251524d51e6ba1
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [ push, pull_request ]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
tests:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby:
|
12
|
+
- 2.4
|
13
|
+
- 2.5
|
14
|
+
- 2.6
|
15
|
+
- 2.7
|
16
|
+
- 3.0
|
17
|
+
- jruby
|
18
|
+
name: Ruby ${{ matrix.ruby }}
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
- name: Install dependencies
|
26
|
+
run: bundle install --jobs 4 --retry 3
|
27
|
+
- name: Run tests
|
28
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/ChangeLog.md
CHANGED
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,36 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'rake'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
require 'rubygems/tasks'
|
3
|
+
require 'rubygems/tasks'
|
4
|
+
Gem::Tasks.new
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
warn e.message
|
11
|
-
warn "Run `gem install rubygems-tasks` to install 'rubygems/tasks'."
|
12
|
-
end
|
13
|
-
|
14
|
-
begin
|
15
|
-
gem 'rspec', '~> 2.4'
|
16
|
-
require 'rspec/core/rake_task'
|
17
|
-
|
18
|
-
RSpec::Core::RakeTask.new
|
19
|
-
rescue LoadError => e
|
20
|
-
task :spec do
|
21
|
-
abort "Please run `gem install rspec` to install RSpec."
|
22
|
-
end
|
23
|
-
end
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new
|
24
8
|
task :test => :spec
|
25
9
|
task :default => :spec
|
26
10
|
|
27
|
-
|
28
|
-
|
29
|
-
require 'yard'
|
30
|
-
|
31
|
-
YARD::Rake::YardocTask.new
|
32
|
-
rescue LoadError => e
|
33
|
-
task :yard do
|
34
|
-
abort "Please run `gem install yard` to install YARD."
|
35
|
-
end
|
36
|
-
end
|
11
|
+
require 'yard'
|
12
|
+
YARD::Rake::YardocTask.new
|
data/gemspec.yml
CHANGED
data/lib/chars/char_set.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'set'
|
2
2
|
|
3
3
|
module Chars
|
4
|
-
class CharSet <
|
4
|
+
class CharSet < Set
|
5
5
|
|
6
6
|
#
|
7
7
|
# Creates a new CharSet object.
|
@@ -120,7 +120,7 @@ module Chars
|
|
120
120
|
# If no block is given, an enumerator object will be returned.
|
121
121
|
#
|
122
122
|
def each_char
|
123
|
-
return enum_for(
|
123
|
+
return enum_for(__method__) unless block_given?
|
124
124
|
|
125
125
|
each { |byte| yield @chars[byte] }
|
126
126
|
end
|
@@ -191,7 +191,7 @@ module Chars
|
|
191
191
|
# If no block is given, an enumerator object will be returned.
|
192
192
|
#
|
193
193
|
def each_random_byte(n,&block)
|
194
|
-
return enum_for(
|
194
|
+
return enum_for(__method__,n) unless block_given?
|
195
195
|
|
196
196
|
n.times { yield random_byte }
|
197
197
|
return nil
|
@@ -213,7 +213,7 @@ module Chars
|
|
213
213
|
# If no block is given, an enumerator object will be returned.
|
214
214
|
#
|
215
215
|
def each_random_char(n,&block)
|
216
|
-
return enum_for(
|
216
|
+
return enum_for(__method__,n) unless block_given?
|
217
217
|
|
218
218
|
each_random_byte(n) { |byte| yield @chars[byte] }
|
219
219
|
end
|
data/lib/chars/version.rb
CHANGED
data/spec/char_set_spec.rb
CHANGED
@@ -2,193 +2,213 @@ require 'spec_helper'
|
|
2
2
|
require 'chars/chars'
|
3
3
|
|
4
4
|
describe Chars::CharSet do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@strings = @string_range.to_a
|
5
|
+
let(:integer_range) { (0x41..0x43) }
|
6
|
+
let(:string_range) { ('A'..'Z') }
|
7
|
+
let(:integers) { integer_range.to_a }
|
8
|
+
let(:strings) { string_range.to_a }
|
10
9
|
|
11
|
-
|
12
|
-
end
|
10
|
+
subject { described_class.new(*strings) }
|
13
11
|
|
14
12
|
describe "#initialize" do
|
15
13
|
it "may be created with String arguments" do
|
16
|
-
|
14
|
+
set = described_class.new(*strings)
|
17
15
|
|
18
|
-
|
16
|
+
expect(strings.all? { |s| set.include_char?(s) }).to be(true)
|
19
17
|
end
|
20
18
|
|
21
19
|
it "may be created with an Array of Strings" do
|
22
|
-
|
20
|
+
set = described_class.new(strings)
|
23
21
|
|
24
|
-
|
22
|
+
expect(strings.all? { |s| set.include_char?(s) }).to be(true)
|
25
23
|
end
|
26
24
|
|
27
25
|
it "may be created with a Range of Strings" do
|
28
|
-
|
26
|
+
set = described_class.new(string_range)
|
29
27
|
|
30
|
-
|
28
|
+
expect(strings.all? { |s| set.include_char?(s) }).to be(true)
|
31
29
|
end
|
32
30
|
|
33
31
|
it "may be created with Integer arguments" do
|
34
|
-
|
32
|
+
set = described_class.new(*integers)
|
35
33
|
|
36
|
-
|
34
|
+
expect(integers.all? { |i| set.include?(i) }).to be(true)
|
37
35
|
end
|
38
36
|
|
39
37
|
it "may be created with an Array of Integers" do
|
40
|
-
|
38
|
+
set = described_class.new(integers)
|
41
39
|
|
42
|
-
|
40
|
+
expect(integers.all? { |i| set.include?(i) }).to be(true)
|
43
41
|
end
|
44
42
|
|
45
43
|
it "may be created with a Range of Integers" do
|
46
|
-
|
44
|
+
set = described_class.new(integer_range)
|
47
45
|
|
48
|
-
|
46
|
+
expect(integers.all? { |i| set.include?(i) }).to be(true)
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
52
50
|
it "should include Strings" do
|
53
|
-
|
51
|
+
expect(subject.include_char?('A')).to be(true)
|
54
52
|
end
|
55
53
|
|
56
54
|
it "should include Integers" do
|
57
|
-
|
55
|
+
expect(subject).to include(0x41)
|
58
56
|
end
|
59
57
|
|
60
58
|
it "should be able to select bytes" do
|
61
|
-
|
59
|
+
sub_set = subject.select_bytes { |c| c <= 0x42 }
|
62
60
|
|
63
|
-
|
61
|
+
expect(sub_set).to be == [0x41, 0x42]
|
64
62
|
end
|
65
63
|
|
66
64
|
it "should be able to select chars" do
|
67
|
-
|
65
|
+
sub_set = subject.select_chars { |c| c <= 'B' }
|
68
66
|
|
69
|
-
|
67
|
+
expect(sub_set).to be == ['A', 'B']
|
70
68
|
end
|
71
69
|
|
72
70
|
it "should return a random byte" do
|
73
|
-
|
71
|
+
expect(subject).to include(subject.random_byte)
|
74
72
|
end
|
75
73
|
|
76
74
|
it "should return a random char" do
|
77
|
-
|
75
|
+
expect(subject.include_char?(subject.random_char)).to be(true)
|
78
76
|
end
|
79
77
|
|
80
78
|
it "should iterate over n random bytes" do
|
81
|
-
|
82
|
-
|
83
|
-
}.
|
79
|
+
expect(subject.each_random_byte(10).all? { |b|
|
80
|
+
subject.include?(b)
|
81
|
+
}).to be(true)
|
84
82
|
end
|
85
83
|
|
86
84
|
it "should iterate over n random chars" do
|
87
|
-
|
88
|
-
|
89
|
-
}.
|
85
|
+
expect(subject.each_random_char(10).all? { |c|
|
86
|
+
subject.include_char?(c)
|
87
|
+
}).to be(true)
|
90
88
|
end
|
91
89
|
|
92
|
-
|
93
|
-
bytes
|
90
|
+
describe "#random_bytes" do
|
91
|
+
it "should return a random Array of bytes" do
|
92
|
+
bytes = subject.random_bytes(10)
|
94
93
|
|
95
|
-
|
96
|
-
|
94
|
+
expect(bytes.all? { |b| subject.include?(b) }).to be(true)
|
95
|
+
end
|
97
96
|
|
98
|
-
|
99
|
-
|
97
|
+
context "with a range of lengths" do
|
98
|
+
it "should return a random Array of bytes with a varying length" do
|
99
|
+
bytes = subject.random_bytes(5..10)
|
100
100
|
|
101
|
-
|
101
|
+
expect(bytes.length).to be_between(5, 10)
|
102
|
+
expect(bytes.all? { |b| subject.include?(b) }).to be(true)
|
103
|
+
end
|
104
|
+
end
|
102
105
|
end
|
103
106
|
|
104
|
-
|
105
|
-
|
107
|
+
describe "#random_chars" do
|
108
|
+
it "should return a random Array of chars" do
|
109
|
+
chars = subject.random_chars(10)
|
106
110
|
|
107
|
-
|
108
|
-
|
109
|
-
end
|
111
|
+
expect(chars.all? { |c| subject.include_char?(c) }).to be(true)
|
112
|
+
end
|
110
113
|
|
111
|
-
|
112
|
-
|
114
|
+
context "with a range of lengths" do
|
115
|
+
it "should return a random Array of chars with a varying length" do
|
116
|
+
chars = subject.random_chars(5..10)
|
113
117
|
|
114
|
-
|
115
|
-
|
118
|
+
expect(chars.length).to be_between(5, 10)
|
119
|
+
expect(chars.all? { |c| subject.include_char?(c) }).to be(true)
|
120
|
+
end
|
121
|
+
end
|
116
122
|
end
|
117
123
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
124
|
+
describe "#random_string" do
|
125
|
+
it "should return a random String of chars" do
|
126
|
+
string = subject.random_string(10)
|
127
|
+
|
128
|
+
expect(string.chars.all? { |b| subject.include_char?(b) }).to be(true)
|
129
|
+
end
|
123
130
|
|
124
|
-
|
125
|
-
|
131
|
+
context "with a range of lengths" do
|
132
|
+
it "should return a random String of chars with a varying length" do
|
133
|
+
string = subject.random_string(5..10)
|
126
134
|
|
127
|
-
|
128
|
-
|
135
|
+
expect(string.length).to be_between(5, 10)
|
136
|
+
expect(string.chars.all? { |b| subject.include_char?(b) }).to be(true)
|
137
|
+
end
|
138
|
+
end
|
129
139
|
end
|
130
140
|
|
131
|
-
|
132
|
-
bytes
|
141
|
+
describe "#random_distinct_bytes" do
|
142
|
+
it "should return a random Array of unique bytes" do
|
143
|
+
bytes = subject.random_distinct_bytes(10)
|
133
144
|
|
134
|
-
|
135
|
-
|
136
|
-
|
145
|
+
expect(bytes.uniq).to be == bytes
|
146
|
+
expect(bytes.all? { |b| subject.include?(b) }).to be(true)
|
147
|
+
end
|
137
148
|
|
138
|
-
|
139
|
-
|
149
|
+
context "with a range of lengths" do
|
150
|
+
it "should return a random Array of unique bytes with a varying length" do
|
151
|
+
bytes = subject.random_distinct_bytes(5..10)
|
140
152
|
|
141
|
-
|
142
|
-
|
153
|
+
expect(bytes.uniq).to be == bytes
|
154
|
+
expect(bytes.length).to be_between(5, 10)
|
155
|
+
expect(bytes.all? { |b| subject.include?(b) }).to be(true)
|
156
|
+
end
|
157
|
+
end
|
143
158
|
end
|
144
159
|
|
145
|
-
|
146
|
-
|
160
|
+
describe "#random_distinct_chars" do
|
161
|
+
it "should return a random Array of unique chars" do
|
162
|
+
chars = subject.random_distinct_chars(10)
|
147
163
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
164
|
+
expect(chars.uniq).to be == chars
|
165
|
+
expect(chars.all? { |c| subject.include_char?(c) }).to be(true)
|
166
|
+
end
|
152
167
|
|
153
|
-
|
154
|
-
|
168
|
+
context "with a range of lengths" do
|
169
|
+
it "should return a random Array of unique chars with a varying length" do
|
170
|
+
chars = subject.random_distinct_chars(5..10)
|
155
171
|
|
156
|
-
|
157
|
-
|
158
|
-
|
172
|
+
expect(chars.uniq).to be == chars
|
173
|
+
expect(chars.length).to be_between(5, 10)
|
174
|
+
expect(chars.all? { |c| subject.include_char?(c) }).to be(true)
|
175
|
+
end
|
176
|
+
end
|
159
177
|
end
|
160
178
|
|
161
179
|
it "should be able to be compared with another set of chars" do
|
162
|
-
|
180
|
+
expect(subject).to be == described_class['A'..'Z']
|
163
181
|
end
|
164
182
|
|
165
183
|
it "should be able to be unioned with another set of chars" do
|
166
|
-
super_set = (
|
184
|
+
super_set = (subject | described_class['D'])
|
167
185
|
|
168
|
-
super_set.
|
169
|
-
super_set.
|
186
|
+
expect(super_set).to be_kind_of(described_class)
|
187
|
+
expect(super_set).to be == described_class['A'..'Z', 'D']
|
170
188
|
end
|
171
189
|
|
172
190
|
it "should be able to be removed from another set of chars" do
|
173
|
-
sub_set = (
|
191
|
+
sub_set = (subject - described_class['B'])
|
174
192
|
|
175
|
-
sub_set.
|
176
|
-
sub_set.
|
193
|
+
expect(sub_set).to be_kind_of(described_class)
|
194
|
+
expect(sub_set).to be_subset(subject)
|
177
195
|
end
|
178
196
|
|
179
|
-
|
180
|
-
|
181
|
-
|
197
|
+
describe "#strings_in" do
|
198
|
+
it "should find one sub-string from a String belonging to the char set" do
|
199
|
+
expect(subject.strings_in("AAAA")).to be == ["AAAA"]
|
200
|
+
end
|
182
201
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
202
|
+
it "should find sub-strings from a String belonging to the char set" do
|
203
|
+
expect(subject.strings_in("AAAA!B!CCCCCC")).to be == [
|
204
|
+
"AAAA",
|
205
|
+
"CCCCCC"
|
206
|
+
]
|
207
|
+
end
|
188
208
|
end
|
189
209
|
|
190
210
|
it "should determine if a String is made up of the characters from the char set" do
|
191
|
-
|
192
|
-
|
211
|
+
expect(subject).to be === "AABCBAA"
|
212
|
+
expect(subject).to_not be === "AA!!EE"
|
193
213
|
end
|
194
214
|
end
|
data/spec/chars_spec.rb
CHANGED
@@ -3,54 +3,54 @@ require 'chars/chars'
|
|
3
3
|
|
4
4
|
describe Chars do
|
5
5
|
it "should provide a numeric CharSet" do
|
6
|
-
|
6
|
+
expect(described_class::NUMERIC).to be =~ '0123456789'
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should provide an octal CharSet" do
|
10
|
-
|
10
|
+
expect(described_class::OCTAL).to be =~ "01234567"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should provide an upper-case hexadecimal CharSet" do
|
14
|
-
|
14
|
+
expect(described_class::UPPERCASE_HEXADECIMAL).to be =~ "0123456789ABCDEF"
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should provide a lower-case hexadecimal CharSet" do
|
18
|
-
|
18
|
+
expect(described_class::LOWERCASE_HEXADECIMAL).to be =~ "0123456789abcdef"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should provide a hexadecimal CharSet" do
|
22
|
-
|
22
|
+
expect(described_class::HEXADECIMAL).to be =~ "0123456789ABCDEFabcdef"
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should provide an upper-case alpha CharSet" do
|
26
|
-
|
26
|
+
expect(described_class::UPPERCASE_ALPHA).to be =~ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should provide a lower-case alpha CharSet" do
|
30
|
-
|
30
|
+
expect(described_class::LOWERCASE_ALPHA).to be =~ "abcdefghijklmnopqrstuvwxyz"
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should provide an alpha CharSet" do
|
34
|
-
|
34
|
+
expect(described_class::ALPHA).to be =~ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should provide an alpha-numeric CharSet" do
|
38
|
-
|
38
|
+
expect(described_class::ALPHA_NUMERIC).to be =~ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should provide a visible CharSet" do
|
42
|
-
|
42
|
+
expect(described_class::VISIBLE).to be =~ "!\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should provide a space CharSet" do
|
46
|
-
|
46
|
+
expect(described_class::SPACE).to be =~ "\t\n\v\f\r "
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should provide a punctuation CharSet" do
|
50
|
-
|
50
|
+
expect(described_class::PUNCTUATION).to be =~ " !\"'(),-.:;?[]`{}~"
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should provide a symbols CharSet" do
|
54
|
-
|
54
|
+
expect(described_class::SYMBOLS).to be =~ " !\"\#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
|
55
55
|
end
|
56
56
|
end
|
@@ -3,71 +3,71 @@ require 'chars/extensions/integer'
|
|
3
3
|
|
4
4
|
describe Integer do
|
5
5
|
it "should recognize numeric bytes" do
|
6
|
-
0x39.
|
6
|
+
expect(0x39).to be_numeric
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should recognize octal bytes" do
|
10
|
-
0x30.
|
10
|
+
expect(0x30).to be_octal
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should recognize upper-case hexadecimal bytes" do
|
14
|
-
0x44.
|
14
|
+
expect(0x44).to be_uppercase_hex
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should recognize lower-case hexadecimal bytes" do
|
18
|
-
0x61.
|
18
|
+
expect(0x61).to be_lowercase_hex
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should recognize hexadecimal bytes" do
|
22
|
-
0x63.
|
22
|
+
expect(0x63).to be_hex
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should recognize upper-case alpha bytes" do
|
26
|
-
0x4c.
|
26
|
+
expect(0x4c).to be_uppercase_alpha
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should recognize lower-case alpha bytes" do
|
30
|
-
0x71.
|
30
|
+
expect(0x71).to be_lowercase_alpha
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should recognize alpha bytes" do
|
34
|
-
0x7a.
|
34
|
+
expect(0x7a).to be_alpha
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should recognize alpha-numeric bytes" do
|
38
|
-
0x69.
|
38
|
+
expect(0x69).to be_alpha_numeric
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should recognize punctuation bytes" do
|
42
|
-
0x60.
|
42
|
+
expect(0x60).to be_punctuation
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should recognize symbolic bytes" do
|
46
|
-
0x26.
|
46
|
+
expect(0x26).to be_symbolic
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should recognize space bytes" do
|
50
|
-
0x20.
|
50
|
+
expect(0x20).to be_space
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should recognize visible bytes" do
|
54
|
-
0x41.
|
55
|
-
0x20.
|
54
|
+
expect(0x41).to be_visible
|
55
|
+
expect(0x20).to_not be_visible
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should recognize printable bytes" do
|
59
|
-
0x3f.
|
59
|
+
expect(0x3f).to be_printable
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should recognize control bytes" do
|
63
|
-
0x1b.
|
63
|
+
expect(0x1b).to be_control
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should recognize signed ASCII bytes" do
|
67
|
-
0x00.
|
67
|
+
expect(0x00).to be_signed_ascii
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should recognize ASCII bytes" do
|
71
|
-
0x80.
|
71
|
+
expect(0x80).to be_ascii
|
72
72
|
end
|
73
73
|
end
|
@@ -1,73 +1,75 @@
|
|
1
|
+
# encoding: US-ASCII
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'chars/extensions/string'
|
3
5
|
|
4
6
|
describe String do
|
5
7
|
it "should recognize numeric strings" do
|
6
|
-
"0987".
|
8
|
+
expect("0987").to be_numeric
|
7
9
|
end
|
8
10
|
|
9
11
|
it "should recognize octal strings" do
|
10
|
-
"012".
|
12
|
+
expect("012").to be_octal
|
11
13
|
end
|
12
14
|
|
13
15
|
it "should recognize upper-case hexadecimal strings" do
|
14
|
-
"2D".
|
16
|
+
expect("2D").to be_uppercase_hex
|
15
17
|
end
|
16
18
|
|
17
19
|
it "should recognize lower-case hexadecimal strings" do
|
18
|
-
"2d".
|
20
|
+
expect("2d").to be_lowercase_hex
|
19
21
|
end
|
20
22
|
|
21
23
|
it "should recognize hexadecimal strings" do
|
22
|
-
"2dE3".
|
24
|
+
expect("2dE3").to be_hex
|
23
25
|
end
|
24
26
|
|
25
27
|
it "should recognize upper-case alpha strings" do
|
26
|
-
"ABC".
|
28
|
+
expect("ABC").to be_uppercase_alpha
|
27
29
|
end
|
28
30
|
|
29
31
|
it "should recognize lower-case alpha strings" do
|
30
|
-
"abc".
|
32
|
+
expect("abc").to be_lowercase_alpha
|
31
33
|
end
|
32
34
|
|
33
35
|
it "should recognize alpha strings" do
|
34
|
-
"abcDEF".
|
36
|
+
expect("abcDEF").to be_alpha
|
35
37
|
end
|
36
38
|
|
37
39
|
it "should recognize alpha-numeric strings" do
|
38
|
-
"abc123".
|
40
|
+
expect("abc123").to be_alpha_numeric
|
39
41
|
end
|
40
42
|
|
41
43
|
it "should recognize punctuation strings" do
|
42
|
-
"[...]".
|
44
|
+
expect("[...]").to be_punctuation
|
43
45
|
end
|
44
46
|
|
45
47
|
it "should recognize symbolic strings" do
|
46
|
-
"++".
|
48
|
+
expect("++").to be_symbolic
|
47
49
|
end
|
48
50
|
|
49
51
|
it "should recognize space strings" do
|
50
|
-
" \t".
|
52
|
+
expect(" \t").to be_space
|
51
53
|
end
|
52
54
|
|
53
55
|
it "should recognize visible strings" do
|
54
|
-
"abc".
|
55
|
-
"ab c".
|
56
|
+
expect("abc").to be_visible
|
57
|
+
expect("ab c").to_not be_visible
|
56
58
|
end
|
57
59
|
|
58
60
|
it "should recognize printable strings" do
|
59
|
-
"abc, [123]\nDEF".
|
61
|
+
expect("abc, [123]\nDEF").to be_printable
|
60
62
|
end
|
61
63
|
|
62
64
|
it "should recognize control strings" do
|
63
|
-
"\b\b\a".
|
65
|
+
expect("\b\b\a").to be_control
|
64
66
|
end
|
65
67
|
|
66
68
|
it "should recognize signed ASCII strings" do
|
67
|
-
"lol\0".
|
69
|
+
expect("lol\0").to be_signed_ascii
|
68
70
|
end
|
69
71
|
|
70
72
|
it "should recognize ASCII strings" do
|
71
|
-
"\xff\xfe".
|
73
|
+
expect("\xff\xfe").to be_ascii
|
72
74
|
end
|
73
75
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,64 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Postmodern
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-12-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0
|
19
|
+
version: '2.0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '2.4'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '2.4'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: yard
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.7'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.7'
|
26
|
+
version: '2.0'
|
62
27
|
description: Chars is a Ruby library for working with various character sets, recognizing
|
63
28
|
text and generating random text from specific character sets.
|
64
29
|
email: postmodern.mod3@gmail.com
|
@@ -69,12 +34,14 @@ extra_rdoc_files:
|
|
69
34
|
- LICENSE.txt
|
70
35
|
- README.md
|
71
36
|
files:
|
72
|
-
- .document
|
73
|
-
- .gemspec
|
74
|
-
- .
|
75
|
-
- .
|
76
|
-
- .
|
37
|
+
- ".document"
|
38
|
+
- ".gemspec"
|
39
|
+
- ".github/workflows/ruby.yml"
|
40
|
+
- ".gitignore"
|
41
|
+
- ".rspec"
|
42
|
+
- ".yardopts"
|
77
43
|
- ChangeLog.md
|
44
|
+
- Gemfile
|
78
45
|
- LICENSE.txt
|
79
46
|
- README.md
|
80
47
|
- Rakefile
|
@@ -97,26 +64,24 @@ files:
|
|
97
64
|
homepage: https://github.com/postmodern/chars#readme
|
98
65
|
licenses:
|
99
66
|
- MIT
|
67
|
+
metadata: {}
|
100
68
|
post_install_message:
|
101
69
|
rdoc_options: []
|
102
70
|
require_paths:
|
103
71
|
- lib
|
104
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
73
|
requirements:
|
107
|
-
- -
|
74
|
+
- - ">="
|
108
75
|
- !ruby/object:Gem::Version
|
109
76
|
version: 1.8.7
|
110
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
78
|
requirements:
|
113
|
-
- -
|
79
|
+
- - ">="
|
114
80
|
- !ruby/object:Gem::Version
|
115
81
|
version: '0'
|
116
82
|
requirements: []
|
117
|
-
|
118
|
-
rubygems_version: 1.8.24
|
83
|
+
rubygems_version: 3.2.2
|
119
84
|
signing_key:
|
120
|
-
specification_version:
|
85
|
+
specification_version: 4
|
121
86
|
summary: A Ruby library for working with various character sets
|
122
87
|
test_files: []
|