funny_yubikey_generator 0.4.0 → 0.5.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/Rakefile +0 -4
- data/exe/generate_funny_yubikey +1 -1
- data/funny_yubikey_generator.gemspec +1 -1
- data/lib/funny_yubikey_generator.rb +10 -10
- data/lib/words.txt +7563 -0
- metadata +2 -2
- data/lib/indexed_words.yaml +0 -7577
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 441a10e193ad1457a49322d1b2d30e95fe0cf58a7300bd6821d4ba91714eb72e
|
4
|
+
data.tar.gz: 4b074be5dc27c6a43aacee06754ac065c678b01f93b53cf22e4288424c377b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87a1faa5547f637d746d7ecb937fd9d54d1cf53a662794a46e067855d10f538f7c09b56a96dfbaf01d497f9024dc98a0e08556ec68414a80ac999062e3abd5ce
|
7
|
+
data.tar.gz: dd997e1ce8459a805dfc448d27ef45781b0dc55fa70fc34209afdf038b42d2194435ff973099f36ebc0a2f653d011d3b8cd535f40af3e7018a1b3156692ff10a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -40,7 +40,7 @@ DICO
|
|
40
40
|
generator = FunnyYubikeyGenerator.from_dictionary(dictionary)
|
41
41
|
puts generator.generate(colorize: true)
|
42
42
|
|
43
|
-
generator = FunnyYubikeyGenerator.from_dictionary(File.
|
43
|
+
generator = FunnyYubikeyGenerator.from_dictionary(File.read("/usr/share/dict/words"))
|
44
44
|
puts generator.generate(colorize: false)
|
45
45
|
```
|
46
46
|
|
data/Rakefile
CHANGED
@@ -10,10 +10,6 @@ Rake::TestTask.new(:test) do |t|
|
|
10
10
|
t.test_files = FileList["test/**/*_test.rb"]
|
11
11
|
end
|
12
12
|
|
13
|
-
task :generate_index_words do
|
14
|
-
puts FunnyYubikeyGenerator.filter_and_index_words(File.open("/usr/share/dict/words")).to_yaml
|
15
|
-
end
|
16
|
-
|
17
13
|
require "standard/rake"
|
18
14
|
|
19
15
|
task default: %i[test standard]
|
data/exe/generate_funny_yubikey
CHANGED
@@ -27,7 +27,7 @@ end.parse!
|
|
27
27
|
|
28
28
|
generator = if dictionary
|
29
29
|
raise "Could not find file #{dictionary}" unless File.exist?(dictionary)
|
30
|
-
FunnyYubikeyGenerator.from_dictionary(File.
|
30
|
+
FunnyYubikeyGenerator.from_dictionary(File.read(dictionary))
|
31
31
|
else
|
32
32
|
FunnyYubikeyGenerator.instance
|
33
33
|
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require "singleton"
|
4
4
|
require "colorize"
|
5
|
-
require "set"
|
6
|
-
require "yaml"
|
7
5
|
|
8
6
|
class FunnyYubikeyGenerator
|
9
7
|
include Singleton
|
@@ -12,15 +10,16 @@ class FunnyYubikeyGenerator
|
|
12
10
|
WORD_REGEX = /^[#{Regexp.quote(LETTERS)}]+{4,}$/
|
13
11
|
private_constant :COLORS
|
14
12
|
private_constant :LETTERS
|
13
|
+
private_constant :WORD_REGEX
|
15
14
|
|
16
15
|
class << self
|
17
16
|
def from_dictionary(dictionary)
|
18
|
-
|
19
|
-
new(
|
17
|
+
words = filter_words(dictionary)
|
18
|
+
new(words: words)
|
20
19
|
end
|
21
20
|
|
22
|
-
def
|
23
|
-
dictionary.scan(WORD_REGEX)
|
21
|
+
def filter_words(dictionary)
|
22
|
+
dictionary.scan(WORD_REGEX)
|
24
23
|
end
|
25
24
|
|
26
25
|
def generate(colorize: false)
|
@@ -28,8 +27,8 @@ class FunnyYubikeyGenerator
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
|
-
def initialize(
|
32
|
-
@indexed_words =
|
30
|
+
def initialize(words: load_default_words)
|
31
|
+
@indexed_words = words.group_by(&:length)
|
33
32
|
end
|
34
33
|
|
35
34
|
def generate(colorize: false)
|
@@ -44,8 +43,9 @@ class FunnyYubikeyGenerator
|
|
44
43
|
|
45
44
|
private
|
46
45
|
|
47
|
-
def
|
48
|
-
|
46
|
+
def load_default_words
|
47
|
+
default_file_path = File.join(__dir__, "words.txt")
|
48
|
+
File.readlines(default_file_path, chomp: true)
|
49
49
|
end
|
50
50
|
|
51
51
|
def random_partition(target, word_lengths)
|