zalgor 1.0.0 → 1.0.2

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
  SHA256:
3
- metadata.gz: 4b3a69a05f82d14b61fbec2e224d4acb29da7069e8fb04dd068109defde4a0dd
4
- data.tar.gz: da1da7a3a1ad0aeeea6ba4cf88a31e678a1485cf2512b564d19f99bfa63db5b0
3
+ metadata.gz: 79459ba54708782c6c5550488b7a44492105e98e42d321bece657b896741acc0
4
+ data.tar.gz: 1ca979f49240521a5a5c88094935a49f99167f339e2a545cf6eae3c93c07393b
5
5
  SHA512:
6
- metadata.gz: 7a59af9898a9065e246ad6eb8e1f732ef2119c223d735c4a83bee77e31816c1b0a3c79f1213df430bf418ead0ec668879718c1d6fdff138791faf6f7c0d4bd97
7
- data.tar.gz: 492d13975f204342e5a51505553d8746f9935aeaf95dc637d962514e940195d1a4363ed1cf563e44de84ee83f088fade5a2fb3f20584ac7b0e40a9736ffc1936
6
+ metadata.gz: 97e5b145f89a22783f3fcab1fb9fa795cc9bef80a2cd825706453d9e2b96ed98836ef11b9275e61b0e436b890d66c43d014e594c08cfc123fe7813c6de1b9907
7
+ data.tar.gz: 32f868497e0d4391b87d3da1a1922d0c5acd746bab8facef951ad0b9719f6a5448cbefe72bf2b8944e2d93870b7418b61b1f1b3810a28bef790b5422c8829c8f
data/lib/zalgor/string.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'handler'
3
+ require_relative 'zalgo'
4
4
 
5
5
  class String
6
6
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Zalgor
2
- VERSION = '1.0.0'
4
+ VERSION = '1.0.2'
3
5
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zalgor
4
+ extend self
5
+
6
+ ##
7
+ # The default options to transform the text.
8
+ #
9
+ DEFAULT_OPTIONS = {
10
+ down: 2,
11
+ mid: 2,
12
+ up: 2,
13
+ random: false
14
+ }.freeze
15
+
16
+ ##
17
+ # Transform a string to zalgo string.
18
+ #
19
+ def transform(string, **options)
20
+ down = options[:down] || DEFAULT_OPTIONS[:down]
21
+ mid = options[:mid] || DEFAULT_OPTIONS[:mid]
22
+ up = options[:up] || DEFAULT_OPTIONS[:up]
23
+ random = options[:random] || DEFAULT_OPTIONS[:random]
24
+
25
+ string.chars.map do |char|
26
+ set_combining_chars('', down, COMBINING_CHARS[:down], random) +
27
+ set_combining_chars(char, mid, COMBINING_CHARS[:mid], random) +
28
+ set_combining_chars('', up, COMBINING_CHARS[:up], random)
29
+ end.join
30
+ end
31
+
32
+ ##
33
+ # Purify a zalgo String to normale string.
34
+ #
35
+ def purify(string)
36
+ combining_chars = (COMBINING_CHARS[:down] + COMBINING_CHARS[:mid] + COMBINING_CHARS[:up])
37
+ string.chars.map do |char|
38
+ next if combining_chars.include? char
39
+
40
+ char
41
+ end.join
42
+ end
43
+
44
+ private
45
+
46
+ def set_combining_chars(char, num, combining_chars, random)
47
+ num = rand(num).to_i if random
48
+ num.times do
49
+ char += combining_chars.sample
50
+ end
51
+ char
52
+ end
53
+ end
data/lib/zalgor.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'zalgor/handler'
3
+ require_relative 'zalgor/combining_chars'
4
+ require_relative 'zalgor/zalgo'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zalgor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Kranich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-30 00:00:00.000000000 Z
11
+ date: 2022-10-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " Zalgor (Zalgo Ruby) uses combining chars to create creepy and insane
14
14
  string.\n"
@@ -21,10 +21,10 @@ files:
21
21
  - README.md
22
22
  - lib/zalgor.rb
23
23
  - lib/zalgor/combining_chars.rb
24
- - lib/zalgor/handler.rb
25
24
  - lib/zalgor/string.rb
26
25
  - lib/zalgor/version.rb
27
- homepage: https://github.com/kurukuruk
26
+ - lib/zalgor/zalgo.rb
27
+ homepage: https://github.com/kurukuruk/zalgor
28
28
  licenses:
29
29
  - MIT
30
30
  metadata: {}
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  requirements: []
46
- rubygems_version: 3.0.3.1
46
+ rubygems_version: 3.1.6
47
47
  signing_key:
48
48
  specification_version: 4
49
49
  summary: A string destroyer with combining chars.
@@ -1,56 +0,0 @@
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