fontlike 0.0.2 β†’ 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8110a1e42b85e8c40126b2a5062bc3279ceb9c93
4
- data.tar.gz: a9fa860e618c53fe52ffe38452062190b11e5853
3
+ metadata.gz: 0dc961edb323c585293476bf2505db7452df4a70
4
+ data.tar.gz: a5355b63f30dac4ecdce0c1a9858c4e03ab034e9
5
5
  SHA512:
6
- metadata.gz: 1d9fd4740c1d2c2ccba985dc91c0ff5a4bd15aa53560622b4869642562603c2c901f035305fd310e9ec43ab4abb9fabeda7fb7d156e4f03f0ff1ef6807126d45
7
- data.tar.gz: a7865b3f15e674b6d04299225d37dea5399995ea19a1a0b526d6d2c1221cc98e76d722173b39fa99791578a086b89b6f2b78531d30d06f31b17728143433a6cb
6
+ metadata.gz: 01a466767e33e6dc98b467ac9d3edb51c9ad05a343961e6bc2689110f90fc07485cb2e935cf355eabe74515b2caaf8c68fad0c8790718e868e6975c7dcd37912
7
+ data.tar.gz: 4cd5d4f09fdeadb69fe0dcd482d842d3c54fe2e273acd24c51bc9563ad739b0dc01e3046b5e70f4839015ccffd7a6f662b419ae38048ef7724f77d72894dd6ed
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  group :test do
4
4
  gem 'rspec'
5
+ gem 'unicode_utils'
5
6
  end
@@ -15,12 +15,11 @@ GEM
15
15
  diff-lcs (>= 1.2.0, < 2.0)
16
16
  rspec-support (~> 3.3.0)
17
17
  rspec-support (3.3.0)
18
+ unicode_utils (1.4.0)
18
19
 
19
20
  PLATFORMS
20
21
  ruby
21
22
 
22
23
  DEPENDENCIES
23
24
  rspec
24
-
25
- BUNDLED WITH
26
- 1.10.5
25
+ unicode_utils
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
@@ -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[:fancy] = f
11
+ options[:style] = :fancy
12
12
  end
13
13
 
14
14
  opts.on("-a", "--angry", "Get angry") do |s|
15
- options[:shout] = s
15
+ options[:style] = :shout
16
16
  end
17
17
 
18
18
  opts.on("-m", "--mono", "Get oldschool") do |m|
19
- options[:mono] = m
19
+ options[:style] = :mono
20
20
  end
21
21
 
22
22
  opts.on("-c", "--circle", "Get circled?") do |c|
23
- options[:circle] = c
23
+ options[:style] = :circle
24
24
  end
25
25
 
26
26
  opts.on("-s", "--sans-serif", "Get attractive") do |ss|
27
- options[:sans_serif] = ss
27
+ options[:style] = :sans_serif
28
28
  end
29
29
 
30
30
  opts.on("-ds", "--double-struck", "Get struck") do |ds|
31
- options[:double_struck] = ds
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
 
@@ -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[:fancy]
7
- self.upper_base = [0x1D4D0]
8
- self.lower_base = [0x1D4EA]
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
- self.upper_base = [120120]
23
- self.lower_base = [120146]
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
@@ -1,3 +1,3 @@
1
1
  module Fontlike
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -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) { { fancy: true } }
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) { { shout: true } }
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) { { mono: true } }
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) { { sans_serif: true } }
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) { { double_struck: true } }
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.2
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-08-24 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Fontlike bloats your ascii
14
14
  email: