acme-base64_hexagrams 0.0.1
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 +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +7 -0
- data/acme-base64_hexagrams.gemspec +28 -0
- data/lib/acme/base64_hexagrams.rb +27 -0
- data/lib/acme/base64_hexagrams/version.rb +5 -0
- data/spec/acme/base64_hexagrams_spec.rb +30 -0
- data/spec/spec_helper.rb +2 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31fbaf46175f161be3a928fa5ea30f182395ef3e
|
4
|
+
data.tar.gz: bf27dfca66691b792b802569f0a3a3f87c0b1355
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b7f09fec3bd757842b80bda28900acbc617df2bc50398036d88bbb34a0e7ac71a66461ae5d1e317caaee4cbe6f47a08c1e2aee2c9080e0189546f213c443d4d
|
7
|
+
data.tar.gz: 9a57cc0f50ca4812b3bf67a9c81953c42ea188c38981147cc3319f83516cc36b356794c1b80da80d09c8d34f1b17210bd25436d97f4324760ce9d30ba403422a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 nullkal
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Acme::Base64Hexagrams
|
2
|
+
|
3
|
+
If you were to be an onmyoji (an yin-yang exorcist), this gem would help your work.
|
4
|
+
|
5
|
+
This gem provides the functions that encodes/decodes Base64 written in hexagrams, the figures used in I Ching.
|
6
|
+
The API is compatible with the Base64 library in the Ruby Standard Library, so it is very easy to make your application more yin-yang-ful.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'acme-base64_hexagrams'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install acme-base64_hexagrams
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
p Acme::Base64Hexagrams.encode64("きつねかわいい!!") #=> "䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪\n"
|
27
|
+
p Acme::Base64Hexagrams.decode64("䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪\n").force_encoding("utf-8") #=> "きつねかわいい!!"
|
28
|
+
|
29
|
+
p Acme::Base64Hexagrams.strict_encode64("きつねかわいい!!") #=> "䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪"
|
30
|
+
p Acme::Base64Hexagrams.strict_decode64("䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪").force_encoding("utf-8") #=> "きつねかわいい!!"
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( https://github.com/nullkal/acme-base64_hexagrams/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'acme/base64_hexagrams/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "acme-base64_hexagrams"
|
8
|
+
spec.version = Acme::Base64Hexagrams::VERSION
|
9
|
+
spec.authors = ["nullkal"]
|
10
|
+
spec.email = ["nullkal@nil.nu"]
|
11
|
+
spec.summary = %q{Encodes/decodes Base64 written in hexagrams, the figures used in I Ching.}
|
12
|
+
spec.description = %q{
|
13
|
+
If you were to be an onmyoji (an yin-yang exorcist), this gem would help your work.
|
14
|
+
|
15
|
+
This gem provides the functions that encodes/decodes Base64 written in hexagrams, the figures used in I Ching.
|
16
|
+
The API is compatible with the Base64 library in the Ruby Standard Library, so it is very easy to make your application more yin-yang-ful.}
|
17
|
+
spec.homepage = "https://github.com/nullkal/acme-base64_hexagrams"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0")
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require "acme/base64_hexagrams/version"
|
4
|
+
require "base64"
|
5
|
+
|
6
|
+
module Acme
|
7
|
+
module Base64Hexagrams
|
8
|
+
NORMAL_BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
|
9
|
+
HEXAGRAMS_BASE64 = "䷀䷪䷍䷡䷈䷄䷙䷊䷉䷹䷥䷵䷼䷻䷨䷒䷌䷰䷝䷶䷤䷾䷕䷣䷘䷐䷔䷲䷩䷂䷚䷗䷫䷛䷱䷟䷸䷯䷑䷭䷅䷮䷿䷧䷺䷜䷃䷆䷠䷞䷷䷽䷴䷦䷳䷎䷋䷬䷢䷏䷓䷇䷖䷁"
|
10
|
+
|
11
|
+
def self.decode64(str)
|
12
|
+
Base64.decode64(str.tr(HEXAGRAMS_BASE64, NORMAL_BASE64))
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.encode64(bin)
|
16
|
+
Base64.encode64(bin).tr(NORMAL_BASE64, HEXAGRAMS_BASE64)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.strict_decode64(str)
|
20
|
+
Base64.strict_decode64(str.tr(HEXAGRAMS_BASE64, NORMAL_BASE64))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.strict_encode64(bin)
|
24
|
+
Base64.strict_encode64(bin).tr(NORMAL_BASE64, HEXAGRAMS_BASE64)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'acme/base64_hexagrams'
|
5
|
+
|
6
|
+
describe Acme::Base64Hexagrams do
|
7
|
+
it 'has a version number' do
|
8
|
+
expect(Acme::Base64Hexagrams::VERSION).not_to be nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'encodes data correctly in Acme::Base64Hexagrams.encode64' do
|
12
|
+
expect(Acme::Base64Hexagrams.encode64("きつねかわいい!!")).to eq("䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪\n")
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'decodes data correctly in Acme::Base64Hexagrams.decode64' do
|
16
|
+
expect(Acme::Base64Hexagrams.decode64("䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪\n").force_encoding("utf-8")).to eq("きつねかわいい!!")
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'encodes data correctly in Acme::Base64Hexagrams.strict_encode64' do
|
20
|
+
expect(Acme::Base64Hexagrams.strict_encode64("きつねかわいい!!")).to eq("䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪")
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'decodes data correctly in Acme::Base64Hexagrams.strict_decode64' do
|
24
|
+
expect(Acme::Base64Hexagrams.strict_decode64("䷋䷋䷙䷻䷋䷋䷙䷸䷋䷋䷙䷜䷋䷋䷙䷵䷋䷋䷥䷒䷋䷋䷙䷈䷋䷋䷙䷈䷏䷏䷷䷪䷏䷏䷷䷪").force_encoding("utf-8")).to eq("きつねかわいい!!")
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'raises an error when Acme::Base64Hexagrams.strict_decode64 gets an invalid value' do
|
28
|
+
expect{Acme::Base64Hexagrams.strict_decode64("きつねかわいい!!")}.to raise_error(ArgumentError)
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acme-base64_hexagrams
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nullkal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-04 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: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: |2-
|
56
|
+
|
57
|
+
If you were to be an onmyoji (an yin-yang exorcist), this gem would help your work.
|
58
|
+
|
59
|
+
This gem provides the functions that encodes/decodes Base64 written in hexagrams, the figures used in I Ching.
|
60
|
+
The API is compatible with the Base64 library in the Ruby Standard Library, so it is very easy to make your application more yin-yang-ful.
|
61
|
+
email:
|
62
|
+
- nullkal@nil.nu
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- ".gitignore"
|
68
|
+
- ".rspec"
|
69
|
+
- ".travis.yml"
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- acme-base64_hexagrams.gemspec
|
75
|
+
- lib/acme/base64_hexagrams.rb
|
76
|
+
- lib/acme/base64_hexagrams/version.rb
|
77
|
+
- spec/acme/base64_hexagrams_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
homepage: https://github.com/nullkal/acme-base64_hexagrams
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.4.5
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Encodes/decodes Base64 written in hexagrams, the figures used in I Ching.
|
103
|
+
test_files:
|
104
|
+
- spec/acme/base64_hexagrams_spec.rb
|
105
|
+
- spec/spec_helper.rb
|