fontlike 0.0.2 β 0.0.3
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 +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -3
- data/README.md +1 -1
- data/bin/fontlike +10 -6
- data/lib/fontlike/transmuter.rb +24 -19
- data/lib/fontlike/version.rb +1 -1
- data/spec/fontlike_spec.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dc961edb323c585293476bf2505db7452df4a70
|
4
|
+
data.tar.gz: a5355b63f30dac4ecdce0c1a9858c4e03ab034e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a466767e33e6dc98b467ac9d3edb51c9ad05a343961e6bc2689110f90fc07485cb2e935cf355eabe74515b2caaf8c68fad0c8790718e868e6975c7dcd37912
|
7
|
+
data.tar.gz: 4cd5d4f09fdeadb69fe0dcd482d842d3c54fe2e273acd24c51bc9563ad739b0dc01e3046b5e70f4839015ccffd7a6f662b419ae38048ef7724f77d72894dd6ed
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,7 @@ bloat your ascii - fun with extended character sets. text your friends things th
|
|
20
20
|
--> Copied "π¦π±πͺπ½ ππΈ ππΈπΎ π½π±π²π·π΄, πΆπ» π―πͺπ·π¬π πΉπͺπ·π½πΌ?" to clipboard
|
21
21
|
|
22
22
|
$ fontlike -s What do you think, mr fancy pants?
|
23
|
-
--> Copied "π½π πππ πππππ, ππ πΏπΊππΌπ ππΊπππ?" to clipboard
|
23
|
+
--> Copied "πΆππΊπ π½π πππ πππππ, ππ πΏπΊππΌπ ππΊπππ?" to clipboard
|
24
24
|
|
25
25
|
$ fontlike -a What do you think, mr fancy pants?
|
26
26
|
--> Copied "WHAT DO YOU THINK, MR FANCY PANTS?" to clipboard
|
data/bin/fontlike
CHANGED
@@ -8,27 +8,31 @@ OptionParser.new do |opts|
|
|
8
8
|
opts.banner = "Usage: circle [options]"
|
9
9
|
|
10
10
|
opts.on("-f", "--fancy", "Get fancy") do |f|
|
11
|
-
options[:
|
11
|
+
options[:style] = :fancy
|
12
12
|
end
|
13
13
|
|
14
14
|
opts.on("-a", "--angry", "Get angry") do |s|
|
15
|
-
options[:
|
15
|
+
options[:style] = :shout
|
16
16
|
end
|
17
17
|
|
18
18
|
opts.on("-m", "--mono", "Get oldschool") do |m|
|
19
|
-
options[:
|
19
|
+
options[:style] = :mono
|
20
20
|
end
|
21
21
|
|
22
22
|
opts.on("-c", "--circle", "Get circled?") do |c|
|
23
|
-
options[:
|
23
|
+
options[:style] = :circle
|
24
24
|
end
|
25
25
|
|
26
26
|
opts.on("-s", "--sans-serif", "Get attractive") do |ss|
|
27
|
-
options[:
|
27
|
+
options[:style] = :sans_serif
|
28
28
|
end
|
29
29
|
|
30
30
|
opts.on("-ds", "--double-struck", "Get struck") do |ds|
|
31
|
-
options[:
|
31
|
+
options[:style] = :double_struck
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("-r", "--random", "Get random") do |r|
|
35
|
+
options[:style] = :random
|
32
36
|
end
|
33
37
|
end.parse!
|
34
38
|
|
data/lib/fontlike/transmuter.rb
CHANGED
@@ -2,36 +2,41 @@ module Fontlike
|
|
2
2
|
class Transmuter
|
3
3
|
attr_accessor :upper_base, :lower_base
|
4
4
|
|
5
|
+
CHAR_BASE = {
|
6
|
+
fancy: {upper: [0x1D4D0], lower: [0x1D4EA]},
|
7
|
+
shout: {upper: ['A'.ord], lower: ['A'.ord]},
|
8
|
+
mono: {upper: [120432], lower: [120458]},
|
9
|
+
sans_serif: {upper: [120224], lower: [120250]},
|
10
|
+
circle: {upper: [0xFEFF, 0x24B6], lower: [0xFEFF, 0x24D0]},
|
11
|
+
double_struck: {upper: [120120], lower: [120146]},
|
12
|
+
}
|
13
|
+
|
14
|
+
DEFAULT_BASE = CHAR_BASE.fetch(:double_struck)
|
15
|
+
|
16
|
+
ALL_CHAR_BASE_UPPER = CHAR_BASE.values.map {|v| v.fetch(:upper)}
|
17
|
+
ALL_CHAR_BASE_LOWER = CHAR_BASE.values.map {|v| v.fetch(:lower)}
|
18
|
+
|
5
19
|
def initialize(options)
|
6
|
-
if options[:
|
7
|
-
self.upper_base =
|
8
|
-
self.lower_base =
|
9
|
-
elsif options[:shout]
|
10
|
-
self.upper_base = ['A'.ord]
|
11
|
-
self.lower_base = ['A'.ord]
|
12
|
-
elsif options[:mono]
|
13
|
-
self.upper_base = [120432]
|
14
|
-
self.lower_base = [120458]
|
15
|
-
elsif options[:sans_serif]
|
16
|
-
self.upper_base = [120224]
|
17
|
-
self.lower_base = [120250]
|
18
|
-
elsif options[:circle]
|
19
|
-
self.upper_base = [0xFEFF, 0x24B6]
|
20
|
-
self.lower_base = [0xFEFF, 0x24D0]
|
20
|
+
if options[:style] == :random
|
21
|
+
self.upper_base = lambda { ALL_CHAR_BASE_UPPER.sample }
|
22
|
+
self.lower_base = lambda { ALL_CHAR_BASE_LOWER.sample }
|
21
23
|
else
|
22
|
-
|
23
|
-
|
24
|
+
up = CHAR_BASE.fetch(options[:style], DEFAULT_BASE).fetch(:upper)
|
25
|
+
lw = CHAR_BASE.fetch(options[:style], DEFAULT_BASE).fetch(:lower)
|
26
|
+
|
27
|
+
self.upper_base = lambda { up }
|
28
|
+
self.lower_base = lambda { lw }
|
24
29
|
end
|
25
30
|
end
|
26
31
|
|
27
32
|
def transmute(str)
|
28
33
|
str.split("").map do |char|
|
29
34
|
if char.match(/[A-Z]/)
|
30
|
-
*prefix, suffix = upper_base
|
35
|
+
*prefix, suffix = upper_base.call
|
31
36
|
last = suffix + char.ord - 'A'.ord
|
32
37
|
[*prefix, last].pack('U*')
|
33
38
|
elsif char.match(/[a-z]/)
|
34
|
-
*prefix, suffix = lower_base
|
39
|
+
*prefix, suffix = lower_base.call
|
35
40
|
last = suffix + char.ord - 'a'.ord
|
36
41
|
[*prefix, last].pack('U*')
|
37
42
|
else
|
data/lib/fontlike/version.rb
CHANGED
data/spec/fontlike_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fontlike'
|
2
|
+
require 'unicode_utils'
|
2
3
|
|
3
4
|
INPUT = "What do you think, mr fancy pants?"
|
4
5
|
|
@@ -8,7 +9,7 @@ describe Fontlike::Transmuter do
|
|
8
9
|
let(:output) { transmuter.transmute(INPUT) }
|
9
10
|
|
10
11
|
describe 'with fancy flag' do
|
11
|
-
let(:opts) { {
|
12
|
+
let(:opts) { { style: :fancy } }
|
12
13
|
|
13
14
|
it 'outputs some fancy text' do
|
14
15
|
expect(output).to eq("π¦π±πͺπ½ ππΈ ππΈπΎ π½π±π²π·π΄, πΆπ» π―πͺπ·π¬π πΉπͺπ·π½πΌ?")
|
@@ -16,7 +17,7 @@ describe Fontlike::Transmuter do
|
|
16
17
|
end
|
17
18
|
|
18
19
|
describe 'with shout flag' do
|
19
|
-
let(:opts) { {
|
20
|
+
let(:opts) { { style: :shout } }
|
20
21
|
|
21
22
|
it 'outputs some shout text' do
|
22
23
|
expect(output).to eq("WHAT DO YOU THINK, MR FANCY PANTS?")
|
@@ -24,7 +25,7 @@ describe Fontlike::Transmuter do
|
|
24
25
|
end
|
25
26
|
|
26
27
|
describe 'with mono flag' do
|
27
|
-
let(:opts) { {
|
28
|
+
let(:opts) { { style: :mono } }
|
28
29
|
|
29
30
|
it 'outputs some mono text' do
|
30
31
|
expect(output).to eq("ππππ ππ π’ππ πππππ, ππ πππππ’ πππππ?")
|
@@ -32,7 +33,7 @@ describe Fontlike::Transmuter do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
describe 'with sans_serif flag' do
|
35
|
-
let(:opts) { {
|
36
|
+
let(:opts) { { style: :sans_serif } }
|
36
37
|
|
37
38
|
it 'outputs some sans_serif text' do
|
38
39
|
expect(output).to eq("πΆππΊπ π½π πππ πππππ, ππ πΏπΊππΌπ ππΊπππ?")
|
@@ -40,13 +41,21 @@ describe Fontlike::Transmuter do
|
|
40
41
|
end
|
41
42
|
|
42
43
|
describe 'with double_struck flag' do
|
43
|
-
let(:opts) { {
|
44
|
+
let(:opts) { { style: :double_struck } }
|
44
45
|
|
45
46
|
it 'outputs some double_struck text' do
|
46
47
|
expect(output).to eq("ππππ₯ ππ πͺπ π¦ π₯ππππ, ππ£ πππππͺ π‘πππ₯π€?")
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
51
|
+
describe 'with random flag' do
|
52
|
+
let(:opts) { { style: :random } }
|
53
|
+
|
54
|
+
it 'outputs some random text' do
|
55
|
+
expect(UnicodeUtils.display_width(output)).to eq(UnicodeUtils.display_width(INPUT))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
50
59
|
describe 'with no flag' do
|
51
60
|
it 'outputs some double_struck text' do
|
52
61
|
expect(output).to eq("ππππ₯ ππ πͺπ π¦ π₯ππππ, ππ£ πππππͺ π‘πππ₯π€?")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontlike
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Lahey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Fontlike bloats your ascii
|
14
14
|
email:
|