whimsy_str 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/LICENSE +24 -0
- data/README.md +49 -0
- data/bin/sponge +7 -0
- data/bin/wavy +7 -0
- data/lib/whimsy_str/core_ext.rb +9 -0
- data/lib/whimsy_str/sponge.rb +29 -0
- data/lib/whimsy_str/version.rb +3 -0
- data/lib/whimsy_str/wavy.rb +16 -0
- data/lib/whimsy_str.rb +6 -0
- data/whimsy_str.gemspec +19 -0
- metadata +57 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1007c18e93f374c7f55721290cee57cf80efff09dc0874a77253c8a607418584
|
4
|
+
data.tar.gz: 726737088736c96d840e26bf17581bb376af97a9d4f808353eb109871c3328fd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49725d1c482c7c1cf31c2f7dff8cf36b8dc34a9bc9334ee6bb26471daeac208c3738596364614ff743dd16f479f5e5dcae2fa9298342b354706cbc9dd298c735
|
7
|
+
data.tar.gz: 8ab461aba6c32865749c8bf9af834d56718510d8fd25a446c81b2369bc3d5f71db266a03ff61cd4e29aedfead1330b1d3d541da9a35d0102ac079bb310e2bbcc
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
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 NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# whimsy_str
|
2
|
+
A simple rubygem to inject some whimsicality into your strings.
|
3
|
+
|
4
|
+
## Motivations
|
5
|
+
I've had a couple of command-line utilities for these floating around on my
|
6
|
+
personal machines for a while, and figured it would be great to put them out
|
7
|
+
there in an easily-consumable format.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```sh
|
12
|
+
gem install whimsy_str
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
`whimsy_str` provides some extensions to the built-in `String` class, allowing
|
17
|
+
easy transformations into popular meme formats.
|
18
|
+
|
19
|
+
#### Code Sample
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'whimsy_str'
|
23
|
+
puts "Sounds like a lot of \n#{'hooplah'.wavify}\nover one small krabby patty"
|
24
|
+
puts "Nobody wants to work anymore".spongify
|
25
|
+
```
|
26
|
+
|
27
|
+
Console output:
|
28
|
+
```
|
29
|
+
Sounds like a lot of
|
30
|
+
h o o p l a h
|
31
|
+
over one small krabby patty
|
32
|
+
NOBOdY WAnTS To wORK AnYmOrE
|
33
|
+
```
|
34
|
+
|
35
|
+
#### Executables
|
36
|
+
`whimsy_str` provides command-line executables for these functionalities, as
|
37
|
+
well. For example:
|
38
|
+
|
39
|
+
```sh
|
40
|
+
$ wavy incredible
|
41
|
+
i n c r e d i b l e
|
42
|
+
$ sponge 'wow this is so cool'
|
43
|
+
wow thiS is sO coOl
|
44
|
+
$
|
45
|
+
```
|
46
|
+
|
47
|
+
## Development
|
48
|
+
### Requirements
|
49
|
+
- Ruby >= 2.7
|
data/bin/sponge
ADDED
data/bin/wavy
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'byebug'
|
4
|
+
|
5
|
+
module WhimsyStr
|
6
|
+
module Sponge
|
7
|
+
# Transform a string by randomly upcasing/downcasing each character in it.
|
8
|
+
# @param chance_of_upcase [Float] - value between 0 and 1 indicating how
|
9
|
+
# @param block [Proc] - Optional block to pass, which will execute for each
|
10
|
+
# character. The block should return a boolean where `true` means the
|
11
|
+
# yielded character will be upcased, and `false` means it will be downcased.
|
12
|
+
#
|
13
|
+
# @return [String] - a modified string in the style of the Spongbob 'mocking
|
14
|
+
# text' meme format.
|
15
|
+
def spongify(chance_of_upcase = 0.5)
|
16
|
+
return self unless chance_of_upcase.positive?
|
17
|
+
|
18
|
+
random = Random.new(Float(chance_of_upcase))
|
19
|
+
chars.map.with_index do |char, index|
|
20
|
+
will_upcase = if block_given?
|
21
|
+
yield char, index
|
22
|
+
else
|
23
|
+
random.rand > chance_of_upcase
|
24
|
+
end
|
25
|
+
will_upcase ? char.upcase : char.downcase
|
26
|
+
end.join
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WhimsyStr
|
4
|
+
module Wavy
|
5
|
+
# Transforms a string by inserting the specified number of spaces between
|
6
|
+
# each character in the original.
|
7
|
+
# @param num_spaces [Integer] - the number of spaces to insert between each
|
8
|
+
# character of the original string.
|
9
|
+
# @return [String] - a modified string in the 'vaporwave' aesthetic.
|
10
|
+
def wavify(num_spaces = 1)
|
11
|
+
return self unless num_spaces.positive?
|
12
|
+
|
13
|
+
chars.join(' ' * Integer(num_spaces))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/whimsy_str.rb
ADDED
data/whimsy_str.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/whimsy_str/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'whimsy_str'
|
7
|
+
gem.version = VERSION
|
8
|
+
gem.summary = 'Whimsical string transformations.'
|
9
|
+
gem.description = <<~DESC
|
10
|
+
A collection of whimsical methods for modifying strings.
|
11
|
+
DESC
|
12
|
+
gem.authors = ['Tony Von Wolfe']
|
13
|
+
gem.email = ['tonyvonwolfe@gmail.com']
|
14
|
+
gem.files = %w[whimsy_str.gemspec README.md LICENSE] + `git ls-files | grep -E '^(bin|lib)'`.split("\n")
|
15
|
+
gem.executables = %w[sponge wavy]
|
16
|
+
gem.homepage = 'https://github.com/tvonwolfe/whimsy_str'
|
17
|
+
gem.license = 'Unlicense'
|
18
|
+
gem.required_ruby_version = '>= 2.7.0'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whimsy_str
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tony Von Wolfe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: 'A collection of whimsical methods for modifying strings.
|
14
|
+
|
15
|
+
'
|
16
|
+
email:
|
17
|
+
- tonyvonwolfe@gmail.com
|
18
|
+
executables:
|
19
|
+
- sponge
|
20
|
+
- wavy
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- bin/sponge
|
27
|
+
- bin/wavy
|
28
|
+
- lib/whimsy_str.rb
|
29
|
+
- lib/whimsy_str/core_ext.rb
|
30
|
+
- lib/whimsy_str/sponge.rb
|
31
|
+
- lib/whimsy_str/version.rb
|
32
|
+
- lib/whimsy_str/wavy.rb
|
33
|
+
- whimsy_str.gemspec
|
34
|
+
homepage: https://github.com/tvonwolfe/whimsy_str
|
35
|
+
licenses:
|
36
|
+
- Unlicense
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.7.0
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubygems_version: 3.3.26
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: Whimsical string transformations.
|
57
|
+
test_files: []
|