chars 0.1.1 → 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/.document +4 -0
- data/.gemspec +0 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +68 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +98 -0
- data/Rakefile +9 -11
- data/benchmarks/compare.rb +16 -0
- data/benchmarks/strings_in.rb +23 -0
- data/chars.gemspec +60 -0
- data/gemspec.yml +16 -0
- data/lib/chars/char_set.rb +390 -93
- data/lib/chars/chars.rb +98 -31
- data/lib/chars/extensions/integer.rb +168 -15
- data/lib/chars/extensions/string.rb +159 -0
- data/lib/chars/version.rb +2 -2
- data/spec/char_set_spec.rb +125 -97
- data/spec/chars_spec.rb +17 -68
- data/spec/{integer_spec.rb → extensions/integer_spec.rb} +25 -17
- data/spec/{string_spec.rb → extensions/string_spec.rb} +26 -16
- data/spec/spec_helper.rb +1 -4
- metadata +61 -58
- data/History.txt +0 -28
- data/Manifest.txt +0 -18
- data/README.txt +0 -104
- data/TODO.txt +0 -13
- data/tasks/spec.rb +0 -9
data/spec/chars_spec.rb
CHANGED
@@ -1,107 +1,56 @@
|
|
1
|
-
require 'chars/chars'
|
2
|
-
|
3
1
|
require 'spec_helper'
|
2
|
+
require 'chars/chars'
|
4
3
|
|
5
4
|
describe Chars do
|
6
|
-
before(:all) do
|
7
|
-
@numeric_string = Chars.numeric.random_string(10)
|
8
|
-
@octal_string = Chars.octal.random_string(10)
|
9
|
-
@uppercase_hex_string = Chars.uppercase_hexadecimal.random_string(10)
|
10
|
-
@lowercase_hex_string = Chars.lowercase_hexadecimal.random_string(10)
|
11
|
-
@hex_string = Chars.hexadecimal.random_string(10)
|
12
|
-
@uppercase_alpha_string = Chars.uppercase_alpha.random_string(10)
|
13
|
-
@lowercase_alpha_string = Chars.lowercase_alpha.random_string(10)
|
14
|
-
@alpha_string = Chars.alpha.random_string(10)
|
15
|
-
@alpha_numeric_string = Chars.alpha_numeric.random_string(10)
|
16
|
-
@space_string = Chars.space.random_string(10)
|
17
|
-
@punctuation_string = Chars.punctuation.random_string(10)
|
18
|
-
@symbols_string = Chars.symbols.random_string(10)
|
19
|
-
@control_string = Chars.control.random_string(10)
|
20
|
-
@ascii_string = Chars.ascii.random_string(10)
|
21
|
-
@all_string = Chars.all.random_string(10)
|
22
|
-
end
|
23
|
-
|
24
5
|
it "should provide a numeric CharSet" do
|
25
|
-
|
26
|
-
@numeric_string.each_byte do |b|
|
27
|
-
Chars::NUMERIC.include?(b).should == true
|
28
|
-
end
|
6
|
+
expect(described_class::NUMERIC).to be =~ '0123456789'
|
29
7
|
end
|
30
8
|
|
31
9
|
it "should provide an octal CharSet" do
|
32
|
-
|
33
|
-
@octal_string.each_byte do |b|
|
34
|
-
Chars::OCTAL.include?(b).should == true
|
35
|
-
end
|
10
|
+
expect(described_class::OCTAL).to be =~ "01234567"
|
36
11
|
end
|
37
12
|
|
38
13
|
it "should provide an upper-case hexadecimal CharSet" do
|
39
|
-
|
40
|
-
@uppercase_hex_string.each_byte do |b|
|
41
|
-
Chars::UPPERCASE_HEXADECIMAL.include?(b).should == true
|
42
|
-
end
|
14
|
+
expect(described_class::UPPERCASE_HEXADECIMAL).to be =~ "0123456789ABCDEF"
|
43
15
|
end
|
44
16
|
|
45
17
|
it "should provide a lower-case hexadecimal CharSet" do
|
46
|
-
|
47
|
-
@lowercase_hex_string.each_byte do |b|
|
48
|
-
Chars::LOWERCASE_HEXADECIMAL.include?(b).should == true
|
49
|
-
end
|
18
|
+
expect(described_class::LOWERCASE_HEXADECIMAL).to be =~ "0123456789abcdef"
|
50
19
|
end
|
51
20
|
|
52
21
|
it "should provide a hexadecimal CharSet" do
|
53
|
-
|
54
|
-
@hex_string.each_byte do |b|
|
55
|
-
Chars::HEXADECIMAL.include?(b).should == true
|
56
|
-
end
|
22
|
+
expect(described_class::HEXADECIMAL).to be =~ "0123456789ABCDEFabcdef"
|
57
23
|
end
|
58
24
|
|
59
25
|
it "should provide an upper-case alpha CharSet" do
|
60
|
-
|
61
|
-
@uppercase_alpha_string.each_byte do |b|
|
62
|
-
Chars::UPPERCASE_ALPHA.include?(b).should == true
|
63
|
-
end
|
26
|
+
expect(described_class::UPPERCASE_ALPHA).to be =~ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
64
27
|
end
|
65
28
|
|
66
29
|
it "should provide a lower-case alpha CharSet" do
|
67
|
-
|
68
|
-
@lowercase_alpha_string.each_byte do |b|
|
69
|
-
Chars::LOWERCASE_ALPHA.include?(b).should == true
|
70
|
-
end
|
30
|
+
expect(described_class::LOWERCASE_ALPHA).to be =~ "abcdefghijklmnopqrstuvwxyz"
|
71
31
|
end
|
72
32
|
|
73
33
|
it "should provide an alpha CharSet" do
|
74
|
-
|
75
|
-
@alpha_string.each_byte do |b|
|
76
|
-
Chars::ALPHA.include?(b).should == true
|
77
|
-
end
|
34
|
+
expect(described_class::ALPHA).to be =~ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
78
35
|
end
|
79
36
|
|
80
37
|
it "should provide an alpha-numeric CharSet" do
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
38
|
+
expect(described_class::ALPHA_NUMERIC).to be =~ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should provide a visible CharSet" do
|
42
|
+
expect(described_class::VISIBLE).to be =~ "!\"\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
85
43
|
end
|
86
44
|
|
87
45
|
it "should provide a space CharSet" do
|
88
|
-
|
89
|
-
@space_string.each_byte do |b|
|
90
|
-
Chars::SPACE.include?(b).should == true
|
91
|
-
end
|
46
|
+
expect(described_class::SPACE).to be =~ "\t\n\v\f\r "
|
92
47
|
end
|
93
48
|
|
94
49
|
it "should provide a punctuation CharSet" do
|
95
|
-
|
96
|
-
@punctuation_string.each_byte do |b|
|
97
|
-
Chars::PUNCTUATION.include?(b).should == true
|
98
|
-
end
|
50
|
+
expect(described_class::PUNCTUATION).to be =~ " !\"'(),-.:;?[]`{}~"
|
99
51
|
end
|
100
52
|
|
101
53
|
it "should provide a symbols CharSet" do
|
102
|
-
|
103
|
-
@symbols_string.each_byte do |b|
|
104
|
-
Chars::SYMBOLS.include?(b).should == true
|
105
|
-
end
|
54
|
+
expect(described_class::SYMBOLS).to be =~ " !\"\#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
|
106
55
|
end
|
107
56
|
end
|
@@ -1,65 +1,73 @@
|
|
1
|
-
require 'chars/extensions/integer'
|
2
|
-
|
3
1
|
require 'spec_helper'
|
2
|
+
require 'chars/extensions/integer'
|
4
3
|
|
5
4
|
describe Integer do
|
6
5
|
it "should recognize numeric bytes" do
|
7
|
-
0x39.
|
6
|
+
expect(0x39).to be_numeric
|
8
7
|
end
|
9
8
|
|
10
9
|
it "should recognize octal bytes" do
|
11
|
-
0x30.
|
10
|
+
expect(0x30).to be_octal
|
12
11
|
end
|
13
12
|
|
14
13
|
it "should recognize upper-case hexadecimal bytes" do
|
15
|
-
0x44.
|
14
|
+
expect(0x44).to be_uppercase_hex
|
16
15
|
end
|
17
16
|
|
18
17
|
it "should recognize lower-case hexadecimal bytes" do
|
19
|
-
0x61.
|
18
|
+
expect(0x61).to be_lowercase_hex
|
20
19
|
end
|
21
20
|
|
22
21
|
it "should recognize hexadecimal bytes" do
|
23
|
-
0x63.
|
22
|
+
expect(0x63).to be_hex
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should recognize upper-case alpha bytes" do
|
27
|
-
0x4c.
|
26
|
+
expect(0x4c).to be_uppercase_alpha
|
28
27
|
end
|
29
28
|
|
30
29
|
it "should recognize lower-case alpha bytes" do
|
31
|
-
0x71.
|
30
|
+
expect(0x71).to be_lowercase_alpha
|
32
31
|
end
|
33
32
|
|
34
33
|
it "should recognize alpha bytes" do
|
35
|
-
0x7a.
|
34
|
+
expect(0x7a).to be_alpha
|
36
35
|
end
|
37
36
|
|
38
37
|
it "should recognize alpha-numeric bytes" do
|
39
|
-
0x69.
|
38
|
+
expect(0x69).to be_alpha_numeric
|
40
39
|
end
|
41
40
|
|
42
41
|
it "should recognize punctuation bytes" do
|
43
|
-
0x60.
|
42
|
+
expect(0x60).to be_punctuation
|
44
43
|
end
|
45
44
|
|
46
45
|
it "should recognize symbolic bytes" do
|
47
|
-
0x26.
|
46
|
+
expect(0x26).to be_symbolic
|
48
47
|
end
|
49
48
|
|
50
49
|
it "should recognize space bytes" do
|
51
|
-
0x20.
|
50
|
+
expect(0x20).to be_space
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should recognize visible bytes" do
|
54
|
+
expect(0x41).to be_visible
|
55
|
+
expect(0x20).to_not be_visible
|
52
56
|
end
|
53
57
|
|
54
58
|
it "should recognize printable bytes" do
|
55
|
-
0x3f.
|
59
|
+
expect(0x3f).to be_printable
|
56
60
|
end
|
57
61
|
|
58
62
|
it "should recognize control bytes" do
|
59
|
-
0x1b.
|
63
|
+
expect(0x1b).to be_control
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should recognize signed ASCII bytes" do
|
67
|
+
expect(0x00).to be_signed_ascii
|
60
68
|
end
|
61
69
|
|
62
70
|
it "should recognize ASCII bytes" do
|
63
|
-
|
71
|
+
expect(0x80).to be_ascii
|
64
72
|
end
|
65
73
|
end
|
@@ -1,65 +1,75 @@
|
|
1
|
-
|
1
|
+
# encoding: US-ASCII
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'chars/extensions/string'
|
4
5
|
|
5
6
|
describe String do
|
6
7
|
it "should recognize numeric strings" do
|
7
|
-
"0987".
|
8
|
+
expect("0987").to be_numeric
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should recognize octal strings" do
|
11
|
-
"012".
|
12
|
+
expect("012").to be_octal
|
12
13
|
end
|
13
14
|
|
14
15
|
it "should recognize upper-case hexadecimal strings" do
|
15
|
-
"2D".
|
16
|
+
expect("2D").to be_uppercase_hex
|
16
17
|
end
|
17
18
|
|
18
19
|
it "should recognize lower-case hexadecimal strings" do
|
19
|
-
"2d".
|
20
|
+
expect("2d").to be_lowercase_hex
|
20
21
|
end
|
21
22
|
|
22
23
|
it "should recognize hexadecimal strings" do
|
23
|
-
"2dE3".
|
24
|
+
expect("2dE3").to be_hex
|
24
25
|
end
|
25
26
|
|
26
27
|
it "should recognize upper-case alpha strings" do
|
27
|
-
"ABC".
|
28
|
+
expect("ABC").to be_uppercase_alpha
|
28
29
|
end
|
29
30
|
|
30
31
|
it "should recognize lower-case alpha strings" do
|
31
|
-
"abc".
|
32
|
+
expect("abc").to be_lowercase_alpha
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should recognize alpha strings" do
|
35
|
-
"abcDEF".
|
36
|
+
expect("abcDEF").to be_alpha
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should recognize alpha-numeric strings" do
|
39
|
-
"abc123".
|
40
|
+
expect("abc123").to be_alpha_numeric
|
40
41
|
end
|
41
42
|
|
42
43
|
it "should recognize punctuation strings" do
|
43
|
-
"[...]".
|
44
|
+
expect("[...]").to be_punctuation
|
44
45
|
end
|
45
46
|
|
46
47
|
it "should recognize symbolic strings" do
|
47
|
-
"++".
|
48
|
+
expect("++").to be_symbolic
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should recognize space strings" do
|
51
|
-
" \t".
|
52
|
+
expect(" \t").to be_space
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should recognize visible strings" do
|
56
|
+
expect("abc").to be_visible
|
57
|
+
expect("ab c").to_not be_visible
|
52
58
|
end
|
53
59
|
|
54
60
|
it "should recognize printable strings" do
|
55
|
-
"abc, [123]\nDEF".
|
61
|
+
expect("abc, [123]\nDEF").to be_printable
|
56
62
|
end
|
57
63
|
|
58
64
|
it "should recognize control strings" do
|
59
|
-
"\b\b\a".
|
65
|
+
expect("\b\b\a").to be_control
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should recognize signed ASCII strings" do
|
69
|
+
expect("lol\0").to be_signed_ascii
|
60
70
|
end
|
61
71
|
|
62
72
|
it "should recognize ASCII strings" do
|
63
|
-
"
|
73
|
+
expect("\xff\xfe").to be_ascii
|
64
74
|
end
|
65
75
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,45 +1,54 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: chars
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
date: 2020-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
17
20
|
type: :development
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - "
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
24
|
-
|
25
|
-
|
26
|
-
email:
|
27
|
-
- postmodern.mod3@gmail.com
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
description: Chars is a Ruby library for working with various character sets, recognizing
|
28
|
+
text and generating random text from specific character sets.
|
29
|
+
email: postmodern.mod3@gmail.com
|
28
30
|
executables: []
|
29
|
-
|
30
31
|
extensions: []
|
31
|
-
|
32
|
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
32
|
+
extra_rdoc_files:
|
33
|
+
- ChangeLog.md
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
files:
|
37
|
+
- ".document"
|
38
|
+
- ".gemspec"
|
39
|
+
- ".github/workflows/ruby.yml"
|
40
|
+
- ".gitignore"
|
41
|
+
- ".rspec"
|
42
|
+
- ".yardopts"
|
43
|
+
- ChangeLog.md
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE.txt
|
46
|
+
- README.md
|
42
47
|
- Rakefile
|
48
|
+
- benchmarks/compare.rb
|
49
|
+
- benchmarks/strings_in.rb
|
50
|
+
- chars.gemspec
|
51
|
+
- gemspec.yml
|
43
52
|
- lib/chars.rb
|
44
53
|
- lib/chars/char_set.rb
|
45
54
|
- lib/chars/chars.rb
|
@@ -47,38 +56,32 @@ files:
|
|
47
56
|
- lib/chars/extensions/integer.rb
|
48
57
|
- lib/chars/extensions/string.rb
|
49
58
|
- lib/chars/version.rb
|
50
|
-
- tasks/spec.rb
|
51
|
-
- spec/spec_helper.rb
|
52
59
|
- spec/char_set_spec.rb
|
53
60
|
- spec/chars_spec.rb
|
54
|
-
- spec/integer_spec.rb
|
55
|
-
- spec/string_spec.rb
|
56
|
-
|
57
|
-
homepage:
|
61
|
+
- spec/extensions/integer_spec.rb
|
62
|
+
- spec/extensions/string_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
homepage: https://github.com/postmodern/chars#readme
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
58
68
|
post_install_message:
|
59
|
-
rdoc_options:
|
60
|
-
|
61
|
-
- README.txt
|
62
|
-
require_paths:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
63
71
|
- lib
|
64
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
66
74
|
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
|
70
|
-
|
71
|
-
requirements:
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.8.7
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
72
79
|
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version:
|
75
|
-
version:
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
76
82
|
requirements: []
|
77
|
-
|
78
|
-
rubyforge_project: chars
|
79
|
-
rubygems_version: 1.3.1
|
83
|
+
rubygems_version: 3.2.2
|
80
84
|
signing_key:
|
81
|
-
specification_version:
|
82
|
-
summary:
|
85
|
+
specification_version: 4
|
86
|
+
summary: A Ruby library for working with various character sets
|
83
87
|
test_files: []
|
84
|
-
|