wordle_decoder 0.1.1 → 0.1.2

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: 19def1e6b5fe6f2513d21327fd4862c0a4e3db8d01775463633f9bd2eec03dd0
4
- data.tar.gz: 9a6e2f43a258eb186359491e5090f811ab27792cc945a93eca0ab5b714080af8
3
+ metadata.gz: dca5b9fbafa87be192d4a5768b878564412854bdb8838e1e9ac55d1eb0244d4a
4
+ data.tar.gz: b9ec7358da606b398da0f653fc62d4ac2c8f697fc91f6a43dcf478c77a7f68d2
5
5
  SHA512:
6
- metadata.gz: 0de9cbfba9ec0edaca95e4259e21efc79566979e9874841e4c1bd7a9f4462e60a41db6bf4881f15baca5d466b66a0043f74dcad2b2f2b2815b0c07f43373fc49
7
- data.tar.gz: 378f8d47d3b8a1043c197e3feb1652fdb8398102b51bfb690788a70cad7a1a2f3cccdfe12fcbd5b8051e39c52ff3a6bad1c632e98bf0579309ae3c93dd5d2305
6
+ metadata.gz: d2fb07120f3c105302ae4b251cd3f7df6a80be4ca5aadc81cae29410bf63137024c277c3c862337b4b10bf7e4bda9ad8901626f01de27309e9e189d8a22a172b
7
+ data.tar.gz: 9f21c02dc2d567e2e613482181ffe0a24b6d5e8b567f99333e76cc346d161dd67376c69a8615afc611754467da375380fd4282094e68cb452610afe8d568eff2
data/bin/wordle_decoder CHANGED
@@ -8,16 +8,28 @@ require "cli/ui"
8
8
 
9
9
  CLI::UI::StdoutRouter.enable
10
10
 
11
- print CLI::UI.fmt("\n\n Share your Wordle:\n\n {{blue:>}} ")
11
+ print CLI::UI.fmt("\n Share your wordle:\n\n{{blue:>}} ")
12
12
 
13
13
  input_lines = []
14
14
  until WordleDecoder::WordleShare.final_line?(input_line = gets)
15
15
  input_lines << input_line
16
+ if WordleDecoder::WordleShare.exit_program?(input_line)
17
+ puts "\n Goodbye!\n\n"
18
+ return
19
+ elsif WordleDecoder::WordleShare.needs_help?(input_line)
20
+ help_text = WordleDecoder::WordleShare.help_to_terminal
21
+ input_lines << "\n"
22
+ input_lines << help_text
23
+ input_lines << "\n"
24
+ print CLI::UI.fmt(help_text)
25
+ elsif input_lines.all? { |l| l.strip.empty? }
26
+ print CLI::UI.fmt("{{blue:>}} ")
27
+ end
16
28
  end
17
29
  input_lines << input_line
18
30
 
19
- clear_pasted_text_lines = input_lines.reverse_each.map { |line| "\033[A\r #{" " * line.length}" }
20
- clear_pasted_text_lines << "\033[A\r"
31
+ clear_pasted_text_lines = input_lines.reverse_each.map { |line| "\033[A\r #{" " * line.length}" }
32
+ clear_pasted_text_lines << "\033[A\r "
21
33
  puts clear_pasted_text_lines.join
22
34
 
23
35
  wordle_share = WordleDecoder::WordleShare.new(input_lines)
@@ -47,78 +59,84 @@ CLI::UI::Spinner.spin("Acting like I'm doing something.") do |spinner|
47
59
  end
48
60
  spinner.update_title("Fine, I'll do it")
49
61
 
50
- decoder.to_terminal
51
- spinner.update_title("\r I decoded your hints!}}")
62
+ if decoder.best_guess
63
+ spinner.update_title("\r I decoded your wordle hints!}}")
64
+ else
65
+ no_guess_messages = ["You stumped me!", "Are you messing with me?", "Are you sure that was the word of the day?"]
66
+ spinner.update_title("\r 🤨 #{no_guess_messages.sample}}}")
67
+ end
68
+ end
69
+
70
+ if decoder.best_guess
71
+ puts CLI::UI.fmt("\n {{blue:{{underline:Guesses}} {{underline:Confidence}}}}")
72
+ puts CLI::UI.fmt(decoder.to_terminal)
52
73
  end
53
74
 
54
- puts CLI::UI.fmt("\n\n {{blue:{{underline:Guesses}} {{underline:Confidence}}}}")
55
- puts CLI::UI.fmt(decoder.to_terminal)
56
-
57
- comments = ["Maybe some of those are your words!",
58
- "I tried!",
59
- "How'd I do?",
60
- "Did I get it?",
61
- "I'm also guessing you're great!",
62
- "Don't spill your coffee.",
63
- "Shout out to friends for sending me their wordles.",
64
- "Shout out to https://www.youtube.com/watch?v=v68zYyaEmEA for word frequency source.",
65
- "I hope you had a great time.",
66
- "Hope to see you again.",
67
- "Was great guessing you.",
68
- "Thinking about heading to sleep.",
69
- "Sometimes I just throw out mostly random stuff.",
70
- "I didn't mean to offend.",
71
- "I try not to be random...",
72
- "I'm open source :)",
73
- "I'd fork you to make me better.",
74
- "TLDR: Another programmer played wordle.",
75
- "How was I with my words?",
76
- "I'm written in Ruby and bite like a python.",
77
- "Here's an emoji ❤️",
78
- "🤔 🤨 🧐",
79
- "All my thinking to you.",
80
- "I've learned about wordle and your people.",
81
- "I'm not learning anything at the moment.",
82
- "I wish I had time to machine learn you ;)",
83
- "No, you have a great personality!",
84
- "This one might be weird, if it's your first.",
85
- "Is my strategy as good as yours?",
86
- "I'm biased, but so are you!",
87
- "I'd love to learn your strategy ;)",
88
- "I'd grow neurons for you.",
89
- "How well can you play without me guessing?",
90
- "If you're seeing this, we probably know each other.",
91
- "I hope things aren't getting too weird.",
92
- "❤️ ❤️ ❤️",
93
- "No, you're great!",
94
- "Do you decode often?",
95
- "All the best five-letter words to you!",
96
- "My friends call me the wordle decoder.",
97
- "Everything I am is written.",
98
- "May my written code speak truly.",
99
- "Who guessed better?",
100
- "No excuse, but my thoughts are in a constant array.",
101
- "Your words complete me.",
102
- "Like peering into a soul.",
103
- "I hope I didn't embarass myself.",
104
- "I hope I didn't embarrass myself.",
105
- "I hope I didn't embaras myself.",
106
- "Can you decode my five letter word?",
107
- "Sometimes I'm off by one...",
108
- "Something's fishy...",
109
- "Did you put something on me?",
110
- "I'm only wrong about five letter words...",
111
- "Your words are beautiful.",
112
- "You make this wordle a better place!",
113
- "What in the wordle was I thinking?",
114
- "Those words you gave me were so good.",
115
- "I truly enjoyed those words, thank you!",
116
- "What lovely words you have!",
117
- "I hope my words were as good as yours!",
118
- "Please enjoy the rest of your day!",
119
- "I may not be positive about your words, but I am about you!",
120
- "Thank you for spending time with me!",
121
- "I enjoyed our time together!"].freeze
122
-
123
- puts CLI::UI.fmt("\n #{comments.sample}\n " \
75
+ salutations = ["Maybe some of those are your words!",
76
+ "I tried!",
77
+ "How'd I do?",
78
+ "Did I get it?",
79
+ "I'm also guessing you're great!",
80
+ "Don't spill your coffee.",
81
+ "Shout out to friends for sending me their wordles.",
82
+ "Shout out to https://www.youtube.com/watch?v=v68zYyaEmEA for word frequency source.",
83
+ "I hope you had a great time.",
84
+ "Hope to see you again.",
85
+ "Was great guessing you.",
86
+ "Thinking about heading to sleep.",
87
+ "Sometimes I just throw out mostly random stuff.",
88
+ "I didn't mean to offend.",
89
+ "I try not to be random...",
90
+ "I'm open source :)",
91
+ "I'd fork you to make me better.",
92
+ "TLDR: Another programmer played wordle.",
93
+ "How was I with my words?",
94
+ "I'm written in Ruby and bite like a python.",
95
+ "Here's an emoji ❤️",
96
+ "🤔 🤨 🧐",
97
+ "All my thinking to you.",
98
+ "I've learned about wordle and your people.",
99
+ "I'm not learning anything at the moment.",
100
+ "I wish I had time to machine learn you ;)",
101
+ "No, you have a great personality!",
102
+ "This one might be weird, if it's your first.",
103
+ "Is my strategy as good as yours?",
104
+ "I'm biased, but so are you!",
105
+ "I'd love to learn your strategy ;)",
106
+ "I'd grow neurons for you.",
107
+ "How well can you play without me guessing?",
108
+ "If you're seeing this, we probably know each other.",
109
+ "I hope things aren't getting too weird.",
110
+ "❤️ ❤️ ❤️",
111
+ "No, you're great!",
112
+ "Do you decode often?",
113
+ "All the best five-letter words to you!",
114
+ "My friends call me the wordle decoder.",
115
+ "Everything I am is written.",
116
+ "May my written code speak truly.",
117
+ "Who guessed better?",
118
+ "No excuse, but my thoughts are in a constant array.",
119
+ "Your words complete me.",
120
+ "Like peering into a soul.",
121
+ "I hope I didn't embarass myself.",
122
+ "I hope I didn't embarrass myself.",
123
+ "I hope I didn't embaras myself.",
124
+ "Can you decode my five letter word?",
125
+ "Sometimes I'm off by one...",
126
+ "Something's fishy...",
127
+ "Did you put something on me?",
128
+ "I'm only wrong about five letter words...",
129
+ "Your words are beautiful.",
130
+ "You make this wordle a better place!",
131
+ "What in the wordle was I thinking?",
132
+ "Those words you gave me were so good.",
133
+ "I truly enjoyed those words, thank you!",
134
+ "What lovely words you have!",
135
+ "I hope my words were as good as yours!",
136
+ "Please enjoy the rest of your day!",
137
+ "I may not be positive about your words, but I am about you!",
138
+ "Thank you for spending time with me!",
139
+ "I enjoyed our time together!"].freeze
140
+
141
+ puts CLI::UI.fmt("\n\n #{salutations.sample}\n " \
124
142
  "{{blue:https://github.com/mattruzicka/wordle_decoder}}}}\n\n")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class WordleDecoder
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -8,6 +8,23 @@ class WordleDecoder
8
8
  ANSWER_LINES.any? { input_lines.include?(_1) }
9
9
  end
10
10
 
11
+ NEEDS_HELP_INPUTS = %w[help what wordle wat ? man okay yes no test].freeze
12
+
13
+ def self.needs_help?(input)
14
+ NEEDS_HELP_INPUTS.include?(input.strip.downcase)
15
+ end
16
+
17
+ EXIT_PROGRAM_INPUTS = %w[exit no nvm].freeze
18
+
19
+ def self.exit_program?(input)
20
+ EXIT_PROGRAM_INPUTS.include?(input.strip)
21
+ end
22
+
23
+ def self.help_to_terminal
24
+ "\n {{italic:Copy and paste those 🟨, 🟩, and ⬛" \
25
+ " emojis from your wordle share.}} \n\n{{blue:>}} "
26
+ end
27
+
11
28
  def self.wordle_answers
12
29
  @wordle_answers ||= load_worldle_ansers
13
30
  end
@@ -36,6 +53,8 @@ class WordleDecoder
36
53
 
37
54
  def find_answer
38
55
  title_line = input_lines.detect { |line| line.match?(GAME_DAY_REGEX) }
56
+ return unless title_line
57
+
39
58
  game_day = title_line.match(GAME_DAY_REGEX).captures.first&.to_i
40
59
  self.answer = self.class.wordle_answers[game_day]
41
60
  end
@@ -14,10 +14,6 @@ class WordleDecoder
14
14
  @wordle_share = wordle_share
15
15
  end
16
16
 
17
- def to_terminal
18
- @to_terminal ||= format_to_terminal
19
- end
20
-
21
17
  def best_guess
22
18
  @best_guess ||= guesses.first
23
19
  end
@@ -38,6 +34,14 @@ class WordleDecoder
38
34
  lines.join("\n")
39
35
  end
40
36
 
37
+ def to_terminal
38
+ str = +"\n"
39
+ best_guess.words_with_scores.reverse_each do |word, guess_score|
40
+ str << " #{word.to_terminal} #{word.confidence_score(guess_score)}\n"
41
+ end
42
+ str << " {{green:#{@wordle_share.answer}}}\n"
43
+ end
44
+
41
45
  private
42
46
 
43
47
  def initialize_and_sort_guesses
@@ -55,12 +59,4 @@ class WordleDecoder
55
59
  WordPosition.new(line, index, @wordle_share.answer_chars)
56
60
  end
57
61
  end
58
-
59
- def format_to_terminal
60
- str = +"\n"
61
- best_guess.words_with_scores.reverse_each do |word, guess_score|
62
- str << " #{word.to_terminal} #{word.confidence_score(guess_score)}\n"
63
- end
64
- str << " {{green:#{@wordle_share.answer}}}\n\n"
65
- end
66
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordle_decoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ruzicka