ix-cli 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ix-cat +0 -0
  3. data/bin/ix-rot13 +7 -2
  4. data/bin/ix-rot5 +39 -0
  5. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43ba4c089dae9199af259e9f02a035744e7420962a118d853e0e676d2a5dd599
4
- data.tar.gz: 17d6460e0f39932ec59f1011638deb3df787239106bfac6616ab7355af18f9f7
3
+ metadata.gz: 72a2619cd73f53565d9ce416626d3a1427634740336b60c75d767f06cf7ae5f9
4
+ data.tar.gz: 273331403a44e58f3b16d51f40f284ef242b982e839d7c9470d8692673a477db
5
5
  SHA512:
6
- metadata.gz: 57bc28846bb606f482574a62e5a6b338b1f988ca9b6350929b71849732dec880e9a57f1d1649189cd802a9359a5a8ebe9ac27f080aef42fe62ceb3b448cfe679
7
- data.tar.gz: 47f05a70186b648cff3277a8cfb2a6df62e5949fe2053d0108ec8d2555e57576d55e1c5fa802236273daeb6093752e8be12c872d3ffcc7d3c36de9e42aaaacca
6
+ metadata.gz: 900fe154770e1b644b345629ac9f9f0f786d471705b6802f44f8d282e37bca6667eb6cf1b7a9f97b87ef87931ddeceafc08ffcdd4ed88cfbf343975debb810ae
7
+ data.tar.gz: c9be4dd356b33c16fcaa0d1df11d81c0e62f070047bbe90b032d8eefca255a30ff7a822d2215ba94e20d4141ee5470818531a44df84aed7d128717f00ac87688
data/bin/ix-cat CHANGED
File without changes
@@ -3,7 +3,12 @@
3
3
  normal = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
4
4
  rot13 = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
5
5
 
6
- STDIN.each_line do |line|
7
- puts line.tr!(normal, rot13)
6
+ STDIN.each_char do |char|
7
+ candidate = char.tr!(normal, rot13)
8
+ if candidate
9
+ print candidate
10
+ else
11
+ print char
12
+ end
8
13
  end
9
14
 
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'isna'
4
+
5
+ UNIVERSE = (0..9).to_a
6
+ ROT = 5
7
+ DIGIT_REGEX = /^\d$/
8
+
9
+ def resolve(set, candidate)
10
+ needle = set.index(candidate)
11
+ if (needle + ROT) > set.size
12
+ return (needle - set.size + ROT)
13
+ end
14
+ if (needle + ROT) < set.size
15
+ return needle + ROT
16
+ end
17
+ if (needle == 5)
18
+ return 0
19
+ end
20
+ end
21
+
22
+ STDIN.each_char do |char|
23
+ next if char.chomp == ''
24
+ unless char =~ DIGIT_REGEX
25
+ print char
26
+ next
27
+ end
28
+ rotation = resolve(UNIVERSE, char.to_i)
29
+ m = (0..9).to_a.map do |n|
30
+ if n.to_s == char
31
+ char.to_ansi.green.to_s
32
+ else
33
+ n.to_s
34
+ end
35
+ end
36
+ # puts "#{rotation.to_s.to_ansi.red.to_s} = [" + (m * ', ') + "]"
37
+ print rotation
38
+ end
39
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ix-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuyoshi Tlacaelel
@@ -217,6 +217,7 @@ executables:
217
217
  - ix-reverse
218
218
  - ix-right
219
219
  - ix-rm
220
+ - ix-rot5
220
221
  - ix-rot13
221
222
  - ix-rot3
222
223
  - ix-rps
@@ -497,6 +498,7 @@ files:
497
498
  - bin/ix-rm
498
499
  - bin/ix-rot13
499
500
  - bin/ix-rot3
501
+ - bin/ix-rot5
500
502
  - bin/ix-rps
501
503
  - bin/ix-ruby-constructor-arguments
502
504
  - bin/ix-ruby-methods