funny_yubikey_generator 0.5.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 441a10e193ad1457a49322d1b2d30e95fe0cf58a7300bd6821d4ba91714eb72e
4
- data.tar.gz: 4b074be5dc27c6a43aacee06754ac065c678b01f93b53cf22e4288424c377b3c
3
+ metadata.gz: 8f94e1575011542434316ea096c95b2eb852ed6fdaea2f177251a750832f0084
4
+ data.tar.gz: 9fdf21bb2c6cd8fed50cb62d4827abb6c806467b99110364a4a5c2136b3057b6
5
5
  SHA512:
6
- metadata.gz: 87a1faa5547f637d746d7ecb937fd9d54d1cf53a662794a46e067855d10f538f7c09b56a96dfbaf01d497f9024dc98a0e08556ec68414a80ac999062e3abd5ce
7
- data.tar.gz: dd997e1ce8459a805dfc448d27ef45781b0dc55fa70fc34209afdf038b42d2194435ff973099f36ebc0a2f653d011d3b8cd535f40af3e7018a1b3156692ff10a
6
+ metadata.gz: 8c1ad4d33fa1a050aeef32e13e7a757b070365b32a319414e6572e73cbf041a0c3b6d2a073b3b3866d1e6f091e729d3a422fda872d1decb39fba68daf8570090
7
+ data.tar.gz: 208c116adf5cec9c0769ed0e6d54aba5c1c0410c959e359294c657deb4fb937cd053e87bd0f63db300eb37c3a1aacc92ca3a625e79c2317e66fec522654cbbdb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- funny_yubikey_generator (0.5.0)
4
+ funny_yubikey_generator (0.7.0)
5
5
  colorize (~> 0.8.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # FunnyYubikeyGenerator
2
2
 
3
+ [![Ruby CI](https://github.com/x4d3/funny_yubikey_generator/actions/workflows/main.yml/badge.svg)](https://github.com/x4d3/funny_yubikey_generator/actions/workflows/main.yml)
3
4
  [![Gem Version](https://badge.fury.io/rb/funny_yubikey_generator.svg)](https://badge.fury.io/rb/funny_yubikey_generator)
4
5
 
6
+
7
+
5
8
  Generate funny looking [yubikey OTP](https://developers.yubico.com/OTP/OTPs_Explained.html) containing words based on a dictionary.
6
9
 
7
10
  ## Installation
data/Rakefile CHANGED
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "funny_yubikey_generator"
3
4
  require "bundler/gem_tasks"
4
5
  require "rake/testtask"
5
6
  require "yaml"
7
+ require "standard/rake"
6
8
 
7
9
  Rake::TestTask.new(:test) do |t|
8
10
  t.libs << "test"
@@ -10,6 +12,9 @@ Rake::TestTask.new(:test) do |t|
10
12
  t.test_files = FileList["test/**/*_test.rb"]
11
13
  end
12
14
 
13
- require "standard/rake"
15
+ # rake "filter_words[lib/words.txt]" > lib/words2.txt
16
+ task :filter_words, [:path] do |_, args|
17
+ puts FunnyYubikeyGenerator.filter_words(File.read(args[:path])).join("\n")
18
+ end
14
19
 
15
20
  task default: %i[test standard]
@@ -4,10 +4,11 @@ require "optparse"
4
4
 
5
5
  colorize = false
6
6
  dictionary = nil
7
+ number = 1
7
8
 
8
9
  OptionParser.new do |opts|
9
10
  opts.banner = "Usage: generate_funny_yubikey [options]"
10
- opts.separator "Generate a yubikey TOP containing words"
11
+ opts.separator "Generate a yubikey TOP containing english words"
11
12
  opts.separator "Example: generate_funny_yubikey -c"
12
13
 
13
14
  opts.separator ""
@@ -20,16 +21,24 @@ OptionParser.new do |opts|
20
21
  opts.on("-c", "--color", "Output with colors") do
21
22
  colorize = true
22
23
  end
23
- opts.on("-d", "--dictionary[=DICTIONARY]", "path to the file containing the list of words that will be used") do |dico|
24
+ opts.on("-n [NUMBER]", "--number", Integer, "Generate NUMBER Yubikey TOP") do |n|
25
+ number = n if n
26
+ end
27
+ opts.on("-d [DICTIONARY]", "--dictionary", "Path to the file containing the list of words to pick from") do |dico|
24
28
  dictionary = dico
25
29
  end
26
30
  end.parse!
27
31
 
28
32
  generator = if dictionary
29
- raise "Could not find file #{dictionary}" unless File.exist?(dictionary)
30
- FunnyYubikeyGenerator.from_dictionary(File.read(dictionary))
33
+ path = File.expand_path(dictionary)
34
+ unless File.exist?(path)
35
+ warn("Could not find file: #{dictionary}")
36
+ exit 1
37
+ end
38
+ FunnyYubikeyGenerator.from_dictionary(File.read(path))
31
39
  else
32
40
  FunnyYubikeyGenerator.instance
33
41
  end
34
-
35
- puts generator.generate(colorize: colorize)
42
+ number.times do
43
+ puts generator.generate(colorize: colorize)
44
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "funny_yubikey_generator"
5
- spec.version = "0.5.0"
5
+ spec.version = "0.7.0"
6
6
  spec.authors = ["Xavier Delamotte"]
7
7
  spec.email = ["git@xade.eu"]
8
8
 
@@ -7,7 +7,7 @@ class FunnyYubikeyGenerator
7
7
  include Singleton
8
8
  COLORS = %i[red green yellow blue magenta cyan]
9
9
  LETTERS = "cbdefghijklnrtuv"
10
- WORD_REGEX = /^[#{Regexp.quote(LETTERS)}]+{4,}$/
10
+ WORD_REGEX = /[#{Regexp.quote(LETTERS)}]+{4,}$/m
11
11
  private_constant :COLORS
12
12
  private_constant :LETTERS
13
13
  private_constant :WORD_REGEX