bs62 0.1.0-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/lib/bs62/3.1/bs62.bundle +0 -0
- data/lib/bs62/3.2/bs62.bundle +0 -0
- data/lib/bs62/extension.rb +14 -0
- data/lib/bs62/version.rb +5 -0
- data/lib/bs62.rb +26 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6d6263ad453095967e93e6cc220ca42c575bcf111b2fbbea06a26678e44f0271
|
4
|
+
data.tar.gz: 32bd37469f102b5fda66eb482329f0d88c71214a33ee98e577edc388c3e929c8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba713be64fdd49e53f18328f61f8caecddca242315363f6a69a12f5a05a2f75a6d6cf5131deffa06b53f65df6cabd868875f6b96f44df53567ca1f4cb2886bcb
|
7
|
+
data.tar.gz: 7ed65e79baa5b1bb86d87b49bfcc0a757299cdefce138f2f7081c40c3889f6745e667c246aff658fa7ac384815598310ad3af072e7fac687954c93f11792ce6a
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Garen J. Torikian
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Bs62
|
2
|
+
|
3
|
+
Quick and easy Base62 encoder and decoder. The difference between this gem and many others is that it operates on an
|
4
|
+
array of bytes.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Install the gem and add to the application's Gemfile by executing:
|
9
|
+
|
10
|
+
$ bundle add bs62
|
11
|
+
|
12
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
13
|
+
|
14
|
+
$ gem install bs62
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
Call `encode` to encode an array of bytes into Base62:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require "bs62"
|
22
|
+
|
23
|
+
bytes = SecureRandom.hex(4).bytes # [99, 56, 97, 54, 57, 101, 54, 97]
|
24
|
+
|
25
|
+
Bs62.encode(bytes) # "jY45tzXOpUU"
|
26
|
+
```
|
27
|
+
|
28
|
+
Similarly, call `decode` to convert a Base62 string to an array of bytes:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require "bs62"
|
32
|
+
|
33
|
+
str = "jY45tzXOpUU"
|
34
|
+
|
35
|
+
Bs62.decode(str) # [99, 56, 97, 54, 57, 101, 54, 97]
|
36
|
+
```
|
37
|
+
|
38
|
+
## Development
|
39
|
+
|
40
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake compile test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
41
|
+
|
42
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and merge that change into `main`.
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gjtorikian/bs62.
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
Binary file
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
# native precompiled gems package shared libraries in <gem_dir>/lib/bs62/<ruby_version>
|
5
|
+
# load the precompiled extension file
|
6
|
+
ruby_version = /\d+\.\d+/.match(RUBY_VERSION)
|
7
|
+
require_relative "#{ruby_version}/bs62"
|
8
|
+
rescue LoadError
|
9
|
+
# fall back to the extension compiled upon installation.
|
10
|
+
# use "require" instead of "require_relative" because non-native gems will place C extension files
|
11
|
+
# in Gem::BasicSpecification#extension_dir after compilation (during normal installation), which
|
12
|
+
# is in $LOAD_PATH but not necessarily relative to this file (see nokogiri#2300)
|
13
|
+
require "bs62/bs62"
|
14
|
+
end
|
data/lib/bs62/version.rb
ADDED
data/lib/bs62.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "bs62/extension"
|
4
|
+
|
5
|
+
require "bs62/version"
|
6
|
+
|
7
|
+
if ENV.fetch("DEBUG", false)
|
8
|
+
require "amazing_print"
|
9
|
+
require "debug"
|
10
|
+
end
|
11
|
+
|
12
|
+
class Bs62
|
13
|
+
class << self
|
14
|
+
def encode(bytes)
|
15
|
+
raise TypeError, "argument must be an array of bytes; got a #{bytes.class}!" unless bytes.is_a?(Array)
|
16
|
+
|
17
|
+
Bs62.perform_encode(bytes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def decode(str)
|
21
|
+
raise TypeError, "argument must be a String; got a #{str.class}!" unless str.is_a?(String)
|
22
|
+
|
23
|
+
Bs62.perform_decode(str)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bs62
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: x86_64-darwin
|
6
|
+
authors:
|
7
|
+
- Garen J. Torikian
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
description: Base62 encoding and decoding with a focus on simplicity and performance.
|
42
|
+
Currently wraps the bs62 Rust crate.
|
43
|
+
email:
|
44
|
+
- gjtorikian@users.noreply.github.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- lib/bs62.rb
|
52
|
+
- lib/bs62/3.1/bs62.bundle
|
53
|
+
- lib/bs62/3.2/bs62.bundle
|
54
|
+
- lib/bs62/extension.rb
|
55
|
+
- lib/bs62/version.rb
|
56
|
+
homepage: https://github.com/gjtorikian/bs62
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata:
|
60
|
+
allowed_push_host: https://rubygems.org
|
61
|
+
funding_uri: https://github.com/sponsors/gjtorikian/
|
62
|
+
source_code_uri: https://github.com/gjtorikian/bs62
|
63
|
+
rubygems_mfa_required: 'true'
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '3.1'
|
73
|
+
- - "<"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.3.dev
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 3.3.22
|
81
|
+
requirements: []
|
82
|
+
rubygems_version: 3.4.4
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Fast and lightweight Base62 encoder/decoder. Written in Rust, wrapped in
|
86
|
+
Ruby.
|
87
|
+
test_files: []
|