bottom 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/tests.yaml +22 -0
- data/.gitignore +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +21 -0
- data/LICENSE +9 -0
- data/README.md +52 -0
- data/Rakefile +10 -0
- data/bottom.gemspec +28 -0
- data/lib/bottom.rb +73 -0
- data/lib/bottom/version.rb +3 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29d58c235766388de547887977eda2d70348a4fd33586efd348bc5a0c5a91977
|
4
|
+
data.tar.gz: ea9b477612d6e90761ce4159a84255ae96a40a1ed7a3ee32d47666d52d385fcc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3d7d04e54308ea5a3124962c3232a5075cc9a725e7bff5352963bddb4875643c6bdd2cd147057cbc2224dcde8ff537788bb44e7dc17888420f51592ee1a854d1
|
7
|
+
data.tar.gz: f331a53c13c0df4c6275502c96fbe669b992244cd6aac1dd23e533e06944377f3167502795abd23685f8fa7dca026cb3a55b966d19362432ebec08ced073ab6e
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Bottom Tester
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- name: Set up Ruby 2.6
|
13
|
+
uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.6
|
16
|
+
- name: Build and test with Rake
|
17
|
+
run: |
|
18
|
+
sudo apt-get -yqq install libpq-dev
|
19
|
+
gem install bundler
|
20
|
+
bundle install --jobs 4 --retry 3
|
21
|
+
bundle exec rake install
|
22
|
+
bundle exec rake test
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bottom (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
minitest (5.14.3)
|
10
|
+
rake (12.3.2)
|
11
|
+
|
12
|
+
PLATFORMS
|
13
|
+
ruby
|
14
|
+
|
15
|
+
DEPENDENCIES
|
16
|
+
bottom!
|
17
|
+
minitest (~> 5.0)
|
18
|
+
rake (~> 12.0)
|
19
|
+
|
20
|
+
BUNDLED WITH
|
21
|
+
1.17.2
|
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright © 2021 <copyright holders>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Bottom-Ruby
|
2
|
+
|
3
|
+
An implementation of the bottom spec in ruby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bottom'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```shell
|
16
|
+
bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
gem install bottom
|
23
|
+
```
|
24
|
+
|
25
|
+
## Useage
|
26
|
+
|
27
|
+
Simple Encode
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'bottom'
|
31
|
+
encoded = Bottom.encode("hello world")
|
32
|
+
puts encoded
|
33
|
+
```
|
34
|
+
|
35
|
+
Decoding Encoded Bottom
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'bottom'
|
39
|
+
encoded = Bottom.encode("hello world")
|
40
|
+
decoded = Bottom.encode(encoded)
|
41
|
+
puts decoded
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests.
|
47
|
+
|
48
|
+
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 then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bottom.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'bottom/version'
|
4
|
+
readme = File.open('README.md')
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bottom"
|
8
|
+
spec.version = "0.1.0"
|
9
|
+
spec.authors = ["Daggy1234"]
|
10
|
+
|
11
|
+
spec.summary = "an implementation of the bottom spec in ruby"
|
12
|
+
spec.description = "An easy to use pure ruby implementation of the bottom spec in ruby. Check out https://github.com/bottom-software-foundation/bottom-ruby for more info"
|
13
|
+
spec.homepage = "https://github.com/bottom-software-foundation/bottom-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/bottom-software-foundation/bottom-ruby"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
end
|
data/lib/bottom.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require "bottom/version"
|
2
|
+
module Bottom
|
3
|
+
|
4
|
+
class DecodeError < StandardError
|
5
|
+
attr_reader :object
|
6
|
+
def initialize(message, object)
|
7
|
+
super(message)
|
8
|
+
@object = object
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
##
|
13
|
+
# @param {String} bottomt: text to decode to human speak
|
14
|
+
def Bottom.decode(bottom)
|
15
|
+
seperator = "👉👈"
|
16
|
+
out = ""
|
17
|
+
bottom_chars = "🫂💖✨🥺,❤️"
|
18
|
+
bottom.strip!
|
19
|
+
rev_character_map = Hash[
|
20
|
+
"🫂" => 200,
|
21
|
+
"💖" => 50,
|
22
|
+
"✨" => 10,
|
23
|
+
"🥺" => 5,
|
24
|
+
"," => 1,
|
25
|
+
"❤️" => 0
|
26
|
+
]
|
27
|
+
dup = bottom.gsub(seperator,'')
|
28
|
+
dup.each_char { |c|
|
29
|
+
if not bottom_chars.include? c
|
30
|
+
raise DecodeError.new("Inavlid Character Found: " + c, c)
|
31
|
+
end
|
32
|
+
|
33
|
+
}
|
34
|
+
bottom.split(seperator).each { |subc|
|
35
|
+
counter = 0
|
36
|
+
subc.each_char{ |emoji|
|
37
|
+
counter = counter + "#{rev_character_map[emoji]}".to_i
|
38
|
+
}
|
39
|
+
out = out + counter.chr
|
40
|
+
}
|
41
|
+
return out
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# @param {String} text: text to encode to bottom
|
46
|
+
def Bottom.encode(text)
|
47
|
+
empty = ""
|
48
|
+
seperator = "👉👈"
|
49
|
+
character_map = Hash[
|
50
|
+
200 => "🫂",
|
51
|
+
50 => "💖",
|
52
|
+
10 => "✨",
|
53
|
+
5 => "🥺",
|
54
|
+
1 => ",",
|
55
|
+
0 => "❤️"
|
56
|
+
]
|
57
|
+
text.each_char{ |letter|
|
58
|
+
char = letter.ord
|
59
|
+
while char != 0 do
|
60
|
+
character_map.each_key{ |key|
|
61
|
+
value = "#{character_map[key]}"
|
62
|
+
if char >= key
|
63
|
+
char = char - key
|
64
|
+
empty = empty + value
|
65
|
+
break
|
66
|
+
end
|
67
|
+
}
|
68
|
+
end
|
69
|
+
empty = empty + seperator
|
70
|
+
}
|
71
|
+
return empty
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bottom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daggy1234
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: An easy to use pure ruby implementation of the bottom spec in ruby. Check
|
14
|
+
out https://github.com/bottom-software-foundation/bottom-ruby for more info
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".github/workflows/tests.yaml"
|
21
|
+
- ".gitignore"
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- bottom.gemspec
|
28
|
+
- lib/bottom.rb
|
29
|
+
- lib/bottom/version.rb
|
30
|
+
homepage: https://github.com/bottom-software-foundation/bottom-ruby
|
31
|
+
licenses:
|
32
|
+
- MIT
|
33
|
+
metadata:
|
34
|
+
homepage_uri: https://github.com/bottom-software-foundation/bottom-ruby
|
35
|
+
source_code_uri: https://github.com/bottom-software-foundation/bottom-ruby
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.3.0
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.0.3
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: an implementation of the bottom spec in ruby
|
55
|
+
test_files: []
|