zalgor 1.0.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 +7 -0
- data/CHANGELOG.md +2 -0
- data/README.md +76 -0
- data/lib/zalgor/combining_chars.rb +133 -0
- data/lib/zalgor/handler.rb +56 -0
- data/lib/zalgor/string.rb +13 -0
- data/lib/zalgor/version.rb +3 -0
- data/lib/zalgor.rb +3 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4b3a69a05f82d14b61fbec2e224d4acb29da7069e8fb04dd068109defde4a0dd
|
4
|
+
data.tar.gz: da1da7a3a1ad0aeeea6ba4cf88a31e678a1485cf2512b564d19f99bfa63db5b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a59af9898a9065e246ad6eb8e1f732ef2119c223d735c4a83bee77e31816c1b0a3c79f1213df430bf418ead0ec668879718c1d6fdff138791faf6f7c0d4bd97
|
7
|
+
data.tar.gz: 492d13975f204342e5a51505553d8746f9935aeaf95dc637d962514e940195d1a4363ed1cf563e44de84ee83f088fade5a2fb3f20584ac7b0e40a9736ffc1936
|
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
DESCRIPTION
|
2
|
+
-----------
|
3
|
+
|
4
|
+
Zalgo text is digital text that has been modified with combining characters (Unicode symbols that are generally used to stack diacritics above and below letters) to appear creepy or glitchy.
|
5
|
+
see: https://en.wikipedia.org/wiki/Zalgo_text
|
6
|
+
|
7
|
+
INSTALLATION
|
8
|
+
------------
|
9
|
+
|
10
|
+
```
|
11
|
+
# gem install zalgor
|
12
|
+
```
|
13
|
+
|
14
|
+
USAGE
|
15
|
+
-----
|
16
|
+
|
17
|
+
Simple transformation:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'zalgor'
|
21
|
+
|
22
|
+
# transform a string
|
23
|
+
str = 'Hello World'
|
24
|
+
puts Zalgor.transform str
|
25
|
+
```
|
26
|
+
|
27
|
+
Simple purification:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'zalgor'
|
31
|
+
|
32
|
+
# purify a string
|
33
|
+
|
34
|
+
str = 'Hello World'
|
35
|
+
str = Zalgor.transform(str)
|
36
|
+
puts str
|
37
|
+
# exemple : H̵͉̣̀̀̊è̖̻͒̎͘ļ̵̙̥̐̽l̸̡̖̠̿ͫŏ̸̭̲̑͡ ̷̱̃͑͡ͅẀ̘͙̐͞͡o͠҉̻̮ͬ̌r̨͔̜͂̈̕l͏̴̪̙̏̎d̴̡ͮ͛
|
38
|
+
|
39
|
+
str = Zalgor.purify(str)
|
40
|
+
puts str
|
41
|
+
# 'Hello World'
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
Simple transformation directly in String class:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'zalgor/string'
|
49
|
+
|
50
|
+
# String has "to_zalgo" instance method
|
51
|
+
puts 'Hello World'.to_zalgo
|
52
|
+
```
|
53
|
+
|
54
|
+
Transformation options:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
# Zalgor.transform(string, **options)
|
58
|
+
# options can be:
|
59
|
+
# down: Integer, the number of down combining chars
|
60
|
+
# mid: Integer, the number of mid combining chars
|
61
|
+
# up: Integer, the number of up combining chars
|
62
|
+
# random: Boolean, random each options (0..down|mid|up)
|
63
|
+
# default options if not specified
|
64
|
+
str = 'Hello World'
|
65
|
+
|
66
|
+
# with options
|
67
|
+
Zalgor.transform(str, down: 10, mid: 5, up: 1, random: true)
|
68
|
+
|
69
|
+
# with default options
|
70
|
+
Zalgor.transform(str)
|
71
|
+
```
|
72
|
+
|
73
|
+
LICENSE
|
74
|
+
-------
|
75
|
+
|
76
|
+
MIT
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zalgor
|
4
|
+
# CHARS = %W[\u0300 \u0301 \u0302 \u0303 \u0304 \u0305 \u0306 \u0307 \u0308 \u0309 \u030a \u030b \u030c \u030d \u030e \u030f \u0310 \u0311 \u0312 \u0313 \u0314 \u0315 \u0316 \u0317 \u0318 \u0319 \u031a \u031b \u031c \u031d \u031e \u031f \u0320 \u0321 \u0322 \u0323 \u0324 \u0325 \u0326 \u0327 \u0328 \u0329 \u032a \u032b \u032c \u032d \u032e \u032f \u0330 \u0331 \u0332 \u0333 \u0334 \u0335 \u0336 \u0337 \u0338 \u0339 \u033a \u033b \u033c \u033d \u033e \u033f \u0340 \u0341 \u0342 \u0343 \u0344 \u0345 \u0346 \u0347 \u0348 \u0349 \u034a \u034b \u034c \u034d \u034e \u034f \u0350 \u0351 \u0353 \u0354 \u0355 \u0356 \u0357 \u0358 \u0359 \u035a \u035b \u035c \u035d \u035e \u035f \u0360 \u0361 \u0362 \u0363 \u0364 \u0365 \u0366 \u0367 \u0368 \u0369 \u036a \u036b \u036c \u036d \u036e \u036f \u0489 ].freeze
|
5
|
+
|
6
|
+
##
|
7
|
+
# The all combining unicode chars
|
8
|
+
# see : https://en.wikipedia.org/wiki/Zalgo_text
|
9
|
+
# inspired by : https://eeemo.net/
|
10
|
+
COMBINING_CHARS = {
|
11
|
+
down: [
|
12
|
+
"\u0316", # ̖
|
13
|
+
"\u0317", # ̗
|
14
|
+
"\u0318", # ̘
|
15
|
+
"\u0319", # ̙
|
16
|
+
"\u031c", # ̜
|
17
|
+
"\u031d", # ̝
|
18
|
+
"\u031e", # ̞
|
19
|
+
"\u031f", # ̟
|
20
|
+
"\u0320", # ̠
|
21
|
+
"\u0324", # ̤
|
22
|
+
"\u0325", # ̥
|
23
|
+
"\u0326", # ̦
|
24
|
+
"\u0329", # ̩
|
25
|
+
"\u032a", # ̪
|
26
|
+
"\u032b", # ̫
|
27
|
+
"\u032c", # ̬
|
28
|
+
"\u032d", # ̭
|
29
|
+
"\u032e", # ̮
|
30
|
+
"\u032f", # ̯
|
31
|
+
"\u0330", # ̰
|
32
|
+
"\u0331", # ̱
|
33
|
+
"\u0332", # ̲
|
34
|
+
"\u0333", # ̳
|
35
|
+
"\u0339", # ̹
|
36
|
+
"\u033a", # ̺
|
37
|
+
"\u033b", # ̻
|
38
|
+
"\u033c", # ̼
|
39
|
+
"\u0345", # ͅ
|
40
|
+
"\u0347", # ͇
|
41
|
+
"\u0348", # ͈
|
42
|
+
"\u0349", # ͉
|
43
|
+
"\u034d", # ͍
|
44
|
+
"\u034e", # ͎
|
45
|
+
"\u0353", # ͓
|
46
|
+
"\u0354", # ͔
|
47
|
+
"\u0355", # ͕
|
48
|
+
"\u0356", # ͖
|
49
|
+
"\u0359", # ͙
|
50
|
+
"\u035a", # ͚
|
51
|
+
"\u0323" # ̣
|
52
|
+
].freeze,
|
53
|
+
|
54
|
+
mid: [
|
55
|
+
"\u0315", # ̕
|
56
|
+
"\u031b", # ̛
|
57
|
+
"\u0340", # ̀
|
58
|
+
"\u0341", # ́
|
59
|
+
"\u0358", # ͘
|
60
|
+
"\u0321", # ̡
|
61
|
+
"\u0322", # ̢
|
62
|
+
"\u0327", # ̧
|
63
|
+
"\u0328", # ̨
|
64
|
+
"\u0334", # ̴
|
65
|
+
"\u0335", # ̵
|
66
|
+
"\u0336", # ̶
|
67
|
+
"\u034f", # ͏
|
68
|
+
"\u035c", # ͜
|
69
|
+
"\u035d", # ͝
|
70
|
+
"\u035e", # ͞
|
71
|
+
"\u035f", # ͟
|
72
|
+
"\u0360", # ͠
|
73
|
+
"\u0362", # ͢
|
74
|
+
"\u0338", # ̸
|
75
|
+
"\u0337", # ̷
|
76
|
+
"\u0361", # ͡
|
77
|
+
"\u0489" # ҉_
|
78
|
+
].freeze,
|
79
|
+
|
80
|
+
up: [
|
81
|
+
"\u030d", # ̍
|
82
|
+
"\u030e", # ̎
|
83
|
+
"\u0304", # ̄
|
84
|
+
"\u0305", # ̅
|
85
|
+
"\u033f", # ̿
|
86
|
+
"\u0311", # ̑
|
87
|
+
"\u0306", # ̆
|
88
|
+
"\u0310", # ̐
|
89
|
+
"\u0352", # ͒
|
90
|
+
"\u0357", # ͗
|
91
|
+
"\u0351", # ͑
|
92
|
+
"\u0307", # ̇
|
93
|
+
"\u0308", # ̈
|
94
|
+
"\u030a", # ̊
|
95
|
+
"\u0342", # ͂
|
96
|
+
"\u0343", # ̓
|
97
|
+
"\u0344", # ̈́
|
98
|
+
"\u034a", # ͊
|
99
|
+
"\u034b", # ͋
|
100
|
+
"\u034c", # ͌
|
101
|
+
"\u0303", # ̃
|
102
|
+
"\u0302", # ̂
|
103
|
+
"\u030c", # ̌
|
104
|
+
"\u0350", # ͐
|
105
|
+
"\u0300", # ̀
|
106
|
+
"\u0301", # ́
|
107
|
+
"\u030b", # ̋
|
108
|
+
"\u030f", # ̏
|
109
|
+
"\u0312", # ̒
|
110
|
+
"\u0313", # ̓
|
111
|
+
"\u0314", # ̔
|
112
|
+
"\u033d", # ̽
|
113
|
+
"\u0309", # ̉
|
114
|
+
"\u0363", # ͣ
|
115
|
+
"\u0364", # ͤ
|
116
|
+
"\u0365", # ͥ
|
117
|
+
"\u0366", # ͦ
|
118
|
+
"\u0367", # ͧ
|
119
|
+
"\u0368", # ͨ
|
120
|
+
"\u0369", # ͩ
|
121
|
+
"\u036a", # ͪ
|
122
|
+
"\u036b", # ͫ
|
123
|
+
"\u036c", # ͬ
|
124
|
+
"\u036d", # ͭ
|
125
|
+
"\u036e", # ͮ
|
126
|
+
"\u036f", # ͯ
|
127
|
+
"\u033e", # ̾
|
128
|
+
"\u035b", # ͛
|
129
|
+
"\u0346", # ͆
|
130
|
+
"\u031a" # ̚
|
131
|
+
].freeze
|
132
|
+
}.freeze
|
133
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'combining_chars'
|
4
|
+
|
5
|
+
module Zalgor
|
6
|
+
class << self
|
7
|
+
##
|
8
|
+
# The default options to transform the text.
|
9
|
+
#
|
10
|
+
DEFAULT_OPTIONS = {
|
11
|
+
down: 2,
|
12
|
+
mid: 2,
|
13
|
+
up: 2,
|
14
|
+
random: false
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
##
|
18
|
+
# Transform a string to zalgo string.
|
19
|
+
#
|
20
|
+
def transform(string, **options)
|
21
|
+
down = options[:down] || DEFAULT_OPTIONS[:down]
|
22
|
+
mid = options[:mid] || DEFAULT_OPTIONS[:mid]
|
23
|
+
up = options[:up] || DEFAULT_OPTIONS[:up]
|
24
|
+
random = options[:random] || DEFAULT_OPTIONS[:random]
|
25
|
+
|
26
|
+
'' +
|
27
|
+
string.chars.map do |char|
|
28
|
+
set_combining_chars('', down, COMBINING_CHARS[:down], random) +
|
29
|
+
set_combining_chars(char, mid, COMBINING_CHARS[:mid], random) +
|
30
|
+
set_combining_chars('', up, COMBINING_CHARS[:up], random)
|
31
|
+
end.join
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Purify a zalgo String to normale string.
|
36
|
+
#
|
37
|
+
def purify(string)
|
38
|
+
combining_chars = (COMBINING_CHARS[:down] + COMBINING_CHARS[:mid] + COMBINING_CHARS[:up])
|
39
|
+
string.chars.map do |char|
|
40
|
+
next if combining_chars.include? char
|
41
|
+
|
42
|
+
char
|
43
|
+
end.join
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def set_combining_chars(char, num, combining_chars, random)
|
49
|
+
num = rand(num).to_i if random
|
50
|
+
num.times do
|
51
|
+
char += combining_chars.sample
|
52
|
+
end
|
53
|
+
char
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/zalgor.rb
ADDED
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zalgor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Kranich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: " Zalgor (Zalgo Ruby) uses combining chars to create creepy and insane
|
14
|
+
string.\n"
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- README.md
|
22
|
+
- lib/zalgor.rb
|
23
|
+
- lib/zalgor/combining_chars.rb
|
24
|
+
- lib/zalgor/handler.rb
|
25
|
+
- lib/zalgor/string.rb
|
26
|
+
- lib/zalgor/version.rb
|
27
|
+
homepage: https://github.com/kurukuruk
|
28
|
+
licenses:
|
29
|
+
- MIT
|
30
|
+
metadata: {}
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubygems_version: 3.0.3.1
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: A string destroyer with combining chars.
|
50
|
+
test_files: []
|