base_convert 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cdec0c0e2e6f861cdf6a3b1d76c0c0236d96fa2
4
- data.tar.gz: 92dac030b2644afc8713a7e2c528d22c704a1a0e
3
+ metadata.gz: 6257b71bda4550a74b03522240f2313a0033d6d8
4
+ data.tar.gz: 7cb3234969be8002ceccd826d631d8096b001b1d
5
5
  SHA512:
6
- metadata.gz: 5abcd99a6357e1b8cafd89c6085b905bbbd9f29739f1d906e16fae5d6c9bad598a4c714cf12bea1d0c088df75022538c3bb9a281899f07f36c199991e155c301
7
- data.tar.gz: e5fa9736608216d2e3ad1c88ecbec19fb9bd8592b8175a7a0ee2993a0573fe5a37832f62f30ab5a7609397e8293030b686757621edd1c83a1cb62bf8b90def2e
6
+ metadata.gz: 627175f20049ecea98ac7022e4fc737215a4068c1d3e1b211b4e1f6fe305fc6a139169a424b23b29c0b0016416e3484a0393cff4c046f3dff098542142491279
7
+ data.tar.gz: a1607a756ef907da773d40b9156cec8e0ad124e4ca0f92a72a0f79c334b03eaeb15580d24105d5957cb77ea8468a0c2615808657f44f57ae192f7680c60ee4e4
@@ -1,22 +1,20 @@
1
- = base_convert
1
+ # BaseConvert
2
2
 
3
- {<img src="https://badge.fury.io/rb/base_convert.svg" alt="Gem Version" />}[http://badge.fury.io/rb/base_convert]
3
+ * [github](https://www.github.com/carlosjhr64/base_convert)
4
+ * [rubygems](https://rubygems.org/gems/base_convert)
4
5
 
5
- github :: https://www.github.com/carlosjhr64/base_convert
6
- rubygems :: https://rubygems.org/gems/base_convert
6
+ ## DESCRIPTION:
7
7
 
8
- == DESCRIPTION:
9
-
10
- base_convert - Number base conversion.
8
+ BaseConvert - Number base conversion.
11
9
 
12
10
  Converts positive integers to different bases:
13
11
  Binary, octal, hexadecimal, decimal, or any arbitrary base.
14
- "Out of the box" handling of up to base 91.
12
+ "Out of the box" handling of up to base 94.
15
13
  Allows for arbitrary choice of alphabet(digits).
16
14
 
17
- See also Non-decimal_radices/Convert[http://rosettacode.org/wiki/Non-decimal_radices/Convert].
15
+ See also rosettacode.org's [Non-decimal radices convert](http://rosettacode.org/wiki/Non-decimal_radices/Convert).
18
16
 
19
- == SYNOPSIS:
17
+ ## SYNOPSIS:
20
18
 
21
19
  require 'base_convert'
22
20
  include BaseConvert
@@ -25,7 +23,7 @@ See also Non-decimal_radices/Convert[http://rosettacode.org/wiki/Non-decimal_rad
25
23
  a = h2o.convert('FFFF') #=> "177777"
26
24
  b = o2h.convert('177777') #=> "FFFF"
27
25
 
28
- == BUT WAIT, THERE'S MORE:
26
+ ## BUT WAIT, THERE'S MORE:
29
27
 
30
28
  Using `irb` to demonstrate the features.
31
29
  The components are scoped under `BaseConvert`:
@@ -53,9 +51,12 @@ You can work with arbitrary digits:
53
51
  to_integer('&&&&', base, digits) #=> 4095
54
52
  to_base(4095, base, digits) #=> "&&&&"
55
53
 
56
- For convenience, `base_convert` provides two sets of digits.
57
- `WORD` are the ASCII word characters except underscore[_].
58
- `QGRAPH` are the ASCII graph characters except quotes['"].
54
+ For convenience, `base_convert` provides some predefined sets of digits.
55
+ `GRAPH` are the ASCII graph characters.
56
+ `QGRAPH` are the ASCII graph characters except quotes: double-quote, single-quote, and back-tick.
57
+ `WORD_` are the ASCII word characters including underscore(_).
58
+ `WORD` are the ASCII word characters except underscore(_).
59
+ `UNAMBIGUOUS` are the characters in `WORD` without the `AMBIGUOUS` characters(B8G6I1l0OQDS5Z2).
59
60
 
60
61
  Configuration::WORD #=> "01...AB...ab...yz"
61
62
  Configuration::QGRAPH #=> "!#...01...AB...ab...}~"
@@ -71,7 +72,7 @@ For example, to convert from hexadecimal to octal, and back:
71
72
  o2h.convert('177777') #=> "FFFF"
72
73
 
73
74
  You can access the conversion alphabets via
74
- the accessors FromTo#from_digits and FromTo#to_digits.
75
+ the accessors `FromTo#from_digits` and `FromTo#to_digits`.
75
76
  By default, WORD is used for bases upto 62.
76
77
  For bigger bases upto 91, QGRAPH is used.
77
78
  You can have bigger bases, but
@@ -89,7 +90,6 @@ FromTo#base2integer and FromTo#integer2Base:
89
90
  h2o.base2integer('FFFF') #=> 65535
90
91
  h2o.integer2base(65535) #=> "177777"
91
92
 
92
- The above replaces #base2dec and #dec2base which are now aliases and are deprecated.
93
93
  The third way to convert is via the subclass of String, `BaseConvert::Number`:
94
94
 
95
95
  hexadecimal = Number.new('FFFF', 16, Configuration::WORD) #=> "FFFF"
@@ -105,11 +105,22 @@ The third way to convert is via the subclass of String, `BaseConvert::Number`:
105
105
  digits = ')!@#$%^&'
106
106
  decimal.to_base(8, digits) #=> "!&&&&&"
107
107
 
108
- == INSTALL:
108
+ ## New in 2.1.0
109
+
110
+ # GRAPH.length == 94
111
+ # !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
112
+
113
+ # WORD_.length == 63
114
+ # 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
115
+
116
+ # UNAMBIGUOUS.length == 47
117
+ # 3479ACEFHJKLMNPRTUVWXYabcdefghijkmnopqrstuvwxyz
118
+
119
+ ## INSTALL:
109
120
 
110
- $ sudo gem install base_convert
121
+ $ sudo gem install base_convert
111
122
 
112
- == LICENSE:
123
+ ## LICENSE:
113
124
 
114
125
  (The MIT License)
115
126
 
@@ -1,4 +1,6 @@
1
- require 'base_convert/version'
1
+ module BaseConvert
2
+ VERSION = '2.1.0'
3
+ end
2
4
  require 'base_convert/configuration'
3
5
  require 'base_convert/functions'
4
6
  require 'base_convert/helpers'
@@ -1,14 +1,22 @@
1
1
  module BaseConvert
2
2
  module Configuration
3
3
 
4
- QGRAPH = 0.upto(255).map{|i| i.chr}.select{|c| c=~/[[:graph:]]/ && c=~/[^`'"]/}.join.freeze
4
+ GRAPH = 0.upto(255).map{|i| i.chr}.select{|c| c=~/[[:graph:]]/}.join.freeze
5
+ QGRAPH = GRAPH.delete(%('"`)).freeze
5
6
 
6
- WORD = 0.upto(255).map{|i| i.chr}.select{|c| c=~/\w/ && c=~/[^_]/}.join.freeze # 0..9 a..z A..Z
7
+ WORD_ = 0.upto(255).map{|i| i.chr}.select{|c| c=~/\w/}.join.freeze
8
+ WORD = WORD_.delete('_').freeze
7
9
  INDEXa = WORD.index('a').freeze
8
10
 
11
+ AMBIGUOUS = 'B8G6I1l0OQDS5Z2'.freeze
12
+ UNAMBIGUOUS = WORD.delete(AMBIGUOUS).freeze
13
+
9
14
  BASE = {
10
- :word => WORD.length,
15
+ :graph => GRAPH.length,
11
16
  :qgraph => QGRAPH.length,
17
+ :word_ => WORD_.length,
18
+ :word => WORD.length,
19
+ :unambiguous => UNAMBIGUOUS.length,
12
20
  :hexadecimal => 16,
13
21
  :hex => 16,
14
22
  :decimal => 10,
metadata CHANGED
@@ -1,44 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base_convert
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2017-11-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
- base_convert - Number base conversion.
14
+ BaseConvert - Number base conversion.
15
15
 
16
16
  Converts positive integers to different bases:
17
17
  Binary, octal, hexadecimal, decimal, or any arbitrary base.
18
- "Out of the box" handling of up to base 91.
18
+ "Out of the box" handling of up to base 94.
19
19
  Allows for arbitrary choice of alphabet(digits).
20
20
  email: carlosjhr64@gmail.com
21
21
  executables: []
22
22
  extensions: []
23
- extra_rdoc_files:
24
- - README.rdoc
23
+ extra_rdoc_files: []
25
24
  files:
26
- - README.rdoc
25
+ - README.md
27
26
  - lib/base_convert.rb
28
27
  - lib/base_convert/configuration.rb
29
28
  - lib/base_convert/from_to.rb
30
29
  - lib/base_convert/functions.rb
31
30
  - lib/base_convert/helpers.rb
32
31
  - lib/base_convert/number.rb
33
- - lib/base_convert/version.rb
34
32
  homepage: https://github.com/carlosjhr64/base_convert
35
33
  licenses:
36
34
  - MIT
37
35
  metadata: {}
38
36
  post_install_message:
39
- rdoc_options:
40
- - "--main"
41
- - README.rdoc
37
+ rdoc_options: []
42
38
  require_paths:
43
39
  - lib
44
40
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -52,12 +48,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
48
  - !ruby/object:Gem::Version
53
49
  version: '0'
54
50
  requirements:
55
- - 'ruby: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]'
56
- - 'join: join (GNU coreutils) 8.21'
51
+ - 'ruby: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]'
57
52
  rubyforge_project:
58
- rubygems_version: 2.4.1
53
+ rubygems_version: 2.6.13
59
54
  signing_key:
60
55
  specification_version: 4
61
- summary: base_convert - Number base conversion.
56
+ summary: BaseConvert - Number base conversion.
62
57
  test_files: []
63
- has_rdoc:
@@ -1,3 +0,0 @@
1
- module BaseConvert
2
- VERSION = '2.0.0'
3
- end