matrext 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/bin/matrext +23 -7
- data/lib/matrext/core.rb +41 -32
- data/lib/matrext/version.rb +1 -1
- data/lib/matrext.rb +2 -2
- data/matrext.gemspec +3 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed118740c8d1f66e6b02837afb7ba932e9447185
|
4
|
+
data.tar.gz: 7f51f399543a3b71c09421163bd898591bf0ce96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba01fc75bd3c3d546f13a47b56a76a48ccfc446d601b8c99c219ac74ef843df4d0d1e3afa9f3b199d22a84d66bbfd1ed0705da4ba797df9b21cc5069dfdc8094
|
7
|
+
data.tar.gz: ff06557e71c889f82cfa30b15f6dea7ed674c79d74df94b97ddc8df6ed50022a7e2ea46f8b5cf70a1de0cc8dfa57c5f4f080d03c6251f1ae16d44c08154b7153
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/matrext
CHANGED
@@ -8,40 +8,56 @@ require_relative '../lib/matrext/version'
|
|
8
8
|
BINARY_NAME = $PROGRAM_NAME.split('/').last
|
9
9
|
|
10
10
|
def parse_options
|
11
|
-
options = {
|
11
|
+
options = {
|
12
|
+
oneline: false,
|
13
|
+
speed: nil,
|
14
|
+
alpha: true,
|
15
|
+
numeric: true,
|
16
|
+
random: true,
|
17
|
+
color: nil,
|
18
|
+
background: nil
|
19
|
+
}
|
12
20
|
|
13
21
|
optparse = OptionParser.new do |opts|
|
14
|
-
opts.banner = 'usage: matrext "phrase" [-o] [-s insane|fast|slow] [-a true|false] [-n true|false] [-r true|false]'
|
22
|
+
opts.banner = 'usage: matrext "phrase" [-o] [-s insane|fast|slow] [-a true|false] [-n true|false] [-r true|false] [-c color_symbol] [-b background_symbol]'
|
15
23
|
|
16
24
|
opts.on('-s', '--speed SPEED', 'Speed at which the text decodes') do |speed|
|
17
25
|
options[:speed] = speed
|
18
26
|
end
|
19
|
-
|
27
|
+
|
20
28
|
opts.on('-o', '--oneline', 'Display text on one line, along with anything before or after') do
|
21
29
|
options[:oneline] = true
|
22
30
|
end
|
23
|
-
|
31
|
+
|
24
32
|
opts.on('-a', '--alpha BOOLEAN', 'Whether to include alphabetical characters') do |alpha|
|
25
33
|
case alpha
|
26
34
|
when 'false', 'f'
|
27
35
|
options[:alpha] = false
|
28
36
|
end
|
29
37
|
end
|
30
|
-
|
38
|
+
|
31
39
|
opts.on('-n', '--numeric BOOLEAN', 'Whether to include numeric characters') do |numeric|
|
32
40
|
case numeric
|
33
41
|
when 'false', 'f'
|
34
42
|
options[:numeric] = false
|
35
43
|
end
|
36
44
|
end
|
37
|
-
|
45
|
+
|
38
46
|
opts.on('-r', '--random BOOLEAN', 'Whether to include non-alphanumeric random characters') do |random|
|
39
47
|
case random
|
40
48
|
when 'false', 'f'
|
41
49
|
options[:random] = false
|
42
50
|
end
|
43
51
|
end
|
44
|
-
|
52
|
+
|
53
|
+
opts.on('-c', '--color COLOR', 'Colorize symbol for color of text') do |color|
|
54
|
+
options[:color] = color.to_sym
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on('-b', '--background BACKGROUND', 'Colorize symbol for background color of text') do |background|
|
58
|
+
options[:background] = background.to_sym
|
59
|
+
end
|
60
|
+
|
45
61
|
opts.on('-v', '--version', 'Display version number and exit') do
|
46
62
|
puts "#{BINARY_NAME} #{Matrext::VERSION}"
|
47
63
|
exit
|
data/lib/matrext/core.rb
CHANGED
@@ -1,25 +1,32 @@
|
|
1
1
|
# lib/matrext/core.rb
|
2
2
|
# The core processing unit
|
3
3
|
|
4
|
+
require 'colorize'
|
5
|
+
|
4
6
|
module Matrext
|
5
7
|
NOISE_MIN_DEFAULT = 4
|
6
8
|
NOISE_MAX_DEFAULT = 6
|
7
9
|
DELAY_MIN_DEFAULT = 0.009
|
8
10
|
DELAY_MAX_DEFAULT = 0.012
|
9
|
-
|
11
|
+
|
10
12
|
attr_accessor :alpha_chars, :numeric_chars, :random_chars
|
11
13
|
|
12
14
|
def self.process(options = {})
|
13
|
-
defaults = {
|
15
|
+
defaults = {
|
16
|
+
oneline: false,
|
17
|
+
alpha: true,
|
18
|
+
numeric: true,
|
19
|
+
random: true,
|
20
|
+
color: nil,
|
21
|
+
background: nil
|
22
|
+
}
|
14
23
|
options = defaults.merge(options)
|
15
|
-
|
16
|
-
character_pool =
|
24
|
+
|
25
|
+
character_pool = create_character_pool(options)
|
17
26
|
|
18
27
|
letters = options[:phrase]
|
19
28
|
|
20
|
-
unless options[:speed].nil?
|
21
|
-
speed = options[:speed].to_sym
|
22
|
-
end
|
29
|
+
speed = options[:speed].to_sym unless options[:speed].nil?
|
23
30
|
|
24
31
|
case speed
|
25
32
|
when :insane
|
@@ -47,50 +54,52 @@ module Matrext
|
|
47
54
|
letters.each_char do |l|
|
48
55
|
letter_noise = rand(noise_min..noise_max)
|
49
56
|
letter_delay = rand(delay_min..delay_max)
|
50
|
-
|
51
|
-
(0..letter_noise).each do
|
52
|
-
print get_random_letter(character_pool)
|
57
|
+
|
58
|
+
(0..letter_noise).each do
|
59
|
+
print get_random_letter(character_pool).colorize(color: options[:color], background: options[:background])
|
53
60
|
sleep(letter_delay)
|
54
61
|
print "\b"
|
55
62
|
end
|
56
|
-
|
63
|
+
|
64
|
+
if options[:color].nil?
|
65
|
+
print l.upcase
|
66
|
+
else
|
67
|
+
print l.upcase.colorize(color: options[:color], background: options[:background])
|
68
|
+
end
|
69
|
+
|
57
70
|
sleep(letter_delay)
|
58
71
|
end
|
59
72
|
|
60
|
-
|
61
|
-
puts
|
62
|
-
end
|
73
|
+
puts unless options[:oneline].equal? true
|
63
74
|
end
|
64
|
-
|
75
|
+
|
65
76
|
private
|
66
|
-
|
77
|
+
|
67
78
|
def self.alpha_chars
|
68
|
-
((65..90).map
|
79
|
+
((65..90).map(&:chr) | (97..122).map(&:chr))
|
69
80
|
end
|
70
|
-
|
81
|
+
|
71
82
|
def self.numeric_chars
|
72
|
-
(48..57).map
|
83
|
+
(48..57).map(&:chr)
|
73
84
|
end
|
74
|
-
|
85
|
+
|
75
86
|
def self.random_chars
|
76
|
-
((33..47).map
|
87
|
+
((33..47).map(&:chr) | (91..96).map(&:chr) | (123..126).map(&:chr))
|
77
88
|
end
|
78
89
|
|
79
90
|
def self.create_character_pool(options)
|
80
91
|
chars = []
|
81
92
|
|
82
|
-
chars
|
83
|
-
chars
|
84
|
-
chars
|
85
|
-
|
86
|
-
|
93
|
+
chars |= alpha_chars if options[:alpha]
|
94
|
+
chars |= numeric_chars if options[:numeric]
|
95
|
+
chars |= random_chars if options[:random]
|
96
|
+
|
97
|
+
chars
|
87
98
|
end
|
88
|
-
|
99
|
+
|
89
100
|
def self.get_random_letter(chars)
|
90
|
-
if chars.length <= 0
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
chars[rand(0..chars.length-1)]
|
101
|
+
chars = ['X'] if chars.length <= 0
|
102
|
+
|
103
|
+
chars[rand(0..chars.length - 1)]
|
95
104
|
end
|
96
105
|
end
|
data/lib/matrext/version.rb
CHANGED
data/lib/matrext.rb
CHANGED
data/matrext.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ['Michael Chadwick']
|
11
11
|
spec.email = ['mike@codana.me']
|
12
12
|
spec.homepage = 'http://rubygems.org/gems/matrext'
|
13
|
-
spec.summary = 'Make text
|
13
|
+
spec.summary = 'Make text look like it\'s being decoded, Matrix-style'
|
14
14
|
spec.description = 'Matrext takes a string input and then prints it back to the console, one letter at a time after "searching" through character noise, as if it was decoding the string itself.'
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split("\n")
|
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
spec.license = 'MIT'
|
21
21
|
|
22
|
+
spec.add_runtime_dependency 'colorize', '~> 0.7.7'
|
23
|
+
|
22
24
|
spec.add_development_dependency 'bundler', '~> 1.9'
|
23
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
26
|
spec.add_development_dependency 'pry-byebug', '~> 3.0'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matrext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Chadwick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.7
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,5 +113,5 @@ rubyforge_project:
|
|
99
113
|
rubygems_version: 2.4.8
|
100
114
|
signing_key:
|
101
115
|
specification_version: 4
|
102
|
-
summary: Make text
|
116
|
+
summary: Make text look like it's being decoded, Matrix-style
|
103
117
|
test_files: []
|