wordle 0.4.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 +4 -4
- data/.tool-versions +1 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +30 -31
- data/README.md +13 -2
- data/lib/integer.rb +13 -0
- data/lib/string.rb +8 -0
- data/lib/wordle/game.rb +38 -17
- data/lib/wordle/guess_analyzer.rb +57 -19
- data/lib/wordle/guess_validator.rb +46 -7
- data/lib/wordle/legend.rb +24 -10
- data/lib/wordle/list.rb +10 -4
- data/lib/wordle/options.rb +33 -0
- data/lib/wordle/result_builder.rb +68 -0
- data/lib/wordle/version.rb +1 -1
- data/lib/wordle.rb +10 -5
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fa86fa80e845caca00f5128d21a4c569996441d57b9367862a1a634067052d3
|
4
|
+
data.tar.gz: a3965aea2dba04cf9abfd4a8bc1e1760980630200f576d60bf7b14319aace3a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f1772bbf2e003583cf25ee27af46f2911ff584dfa4c4e2533aafeaa411ba877db690d4f4789242a50e9c54a070beea66e3db966ed4aa0a84075b431977be10c
|
7
|
+
data.tar.gz: 87f7b5e53311ee0e15f1cacf56f2eaae014ea1a78ce0363f590ee9a4c273b4717bf13f748864dbe67ab567d0862c881fe69f62b2adec8a1c579921b451d9aa74
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.1.1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [0.7.0] - 2022-04-15
|
2
|
+
|
3
|
+
- Adds high color contrast mode.
|
4
|
+
|
5
|
+
## [0.6.0] - 2022-04-14
|
6
|
+
|
7
|
+
- Adds hard mode.
|
8
|
+
|
9
|
+
## [0.5.0] - 2022-02-02
|
10
|
+
|
11
|
+
- Prints outs squares for sharing at the end of a game.
|
12
|
+
- Sharing prints out unique hash for word that was played, which can be passed
|
13
|
+
to -i option so you can play the same word as a friend.
|
14
|
+
|
1
15
|
## [0.4.0] - 2022-01-14
|
2
16
|
|
3
17
|
- Fixes bug where too many letters would get marked as yellow. Resolves
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,71 +1,70 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wordle (0.
|
4
|
+
wordle (0.7.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
|
-
debug (1.
|
10
|
+
debug (1.5.0)
|
11
11
|
irb (>= 1.3.6)
|
12
12
|
reline (>= 0.2.7)
|
13
13
|
diff-lcs (1.5.0)
|
14
14
|
io-console (0.5.11)
|
15
15
|
irb (1.4.1)
|
16
16
|
reline (>= 0.3.0)
|
17
|
-
parallel (1.
|
18
|
-
parser (3.1.
|
17
|
+
parallel (1.22.1)
|
18
|
+
parser (3.1.2.0)
|
19
19
|
ast (~> 2.4.1)
|
20
|
-
rainbow (3.
|
20
|
+
rainbow (3.1.1)
|
21
21
|
rake (13.0.6)
|
22
|
-
regexp_parser (2.
|
22
|
+
regexp_parser (2.3.0)
|
23
23
|
reline (0.3.1)
|
24
24
|
io-console (~> 0.5)
|
25
25
|
rexml (3.2.5)
|
26
|
-
rspec (3.
|
27
|
-
rspec-core (~> 3.
|
28
|
-
rspec-expectations (~> 3.
|
29
|
-
rspec-mocks (~> 3.
|
30
|
-
rspec-core (3.
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-expectations (3.
|
26
|
+
rspec (3.11.0)
|
27
|
+
rspec-core (~> 3.11.0)
|
28
|
+
rspec-expectations (~> 3.11.0)
|
29
|
+
rspec-mocks (~> 3.11.0)
|
30
|
+
rspec-core (3.11.0)
|
31
|
+
rspec-support (~> 3.11.0)
|
32
|
+
rspec-expectations (3.11.0)
|
33
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-mocks (3.
|
34
|
+
rspec-support (~> 3.11.0)
|
35
|
+
rspec-mocks (3.11.1)
|
36
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-support (3.
|
39
|
-
rubocop (1.
|
37
|
+
rspec-support (~> 3.11.0)
|
38
|
+
rspec-support (3.11.0)
|
39
|
+
rubocop (1.27.0)
|
40
40
|
parallel (~> 1.10)
|
41
|
-
parser (>= 3.
|
41
|
+
parser (>= 3.1.0.0)
|
42
42
|
rainbow (>= 2.2.2, < 4.0)
|
43
43
|
regexp_parser (>= 1.8, < 3.0)
|
44
44
|
rexml
|
45
|
-
rubocop-ast (>= 1.
|
45
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
46
46
|
ruby-progressbar (~> 1.7)
|
47
47
|
unicode-display_width (>= 1.4.0, < 3.0)
|
48
|
-
rubocop-ast (1.
|
49
|
-
parser (>= 3.
|
50
|
-
rubocop-performance (1.13.
|
48
|
+
rubocop-ast (1.17.0)
|
49
|
+
parser (>= 3.1.1.0)
|
50
|
+
rubocop-performance (1.13.3)
|
51
51
|
rubocop (>= 1.7.0, < 2.0)
|
52
52
|
rubocop-ast (>= 0.4.0)
|
53
53
|
ruby-progressbar (1.11.0)
|
54
|
-
standard (1.
|
55
|
-
rubocop (= 1.
|
56
|
-
rubocop-performance (= 1.13.
|
54
|
+
standard (1.10.0)
|
55
|
+
rubocop (= 1.27.0)
|
56
|
+
rubocop-performance (= 1.13.3)
|
57
57
|
unicode-display_width (2.1.0)
|
58
58
|
|
59
59
|
PLATFORMS
|
60
60
|
x86_64-darwin-21
|
61
|
-
x86_64-linux
|
62
61
|
|
63
62
|
DEPENDENCIES
|
64
63
|
debug (>= 1.0.0)
|
65
|
-
rake
|
66
|
-
rspec
|
67
|
-
standard
|
64
|
+
rake
|
65
|
+
rspec
|
66
|
+
standard
|
68
67
|
wordle!
|
69
68
|
|
70
69
|
BUNDLED WITH
|
71
|
-
2.3.
|
70
|
+
2.3.7
|
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
Ruby implementation of [Wordle](https://www.powerlanguage.co.uk/wordle/).
|
4
4
|
|
5
|
-
<img width="
|
5
|
+
<img width="869" alt="Screen Shot 2022-02-02 at 10 32 02 PM" src="https://user-images.githubusercontent.com/22665228/152292863-33743039-d9f4-4afa-a321-684d7b67cdb3.png">
|
6
|
+
|
7
|
+
[](https://github.com/JonathanWThom/wordle/actions/workflows/build.yml)
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
@@ -12,6 +14,15 @@ Ruby implementation of [Wordle](https://www.powerlanguage.co.uk/wordle/).
|
|
12
14
|
|
13
15
|
Just run `wordle` from the command line.
|
14
16
|
|
17
|
+
This version will pull a new word at random every time you run it from a very weird and long list. It's much more difficult than the original due to some of the words being a bit uncommon.
|
18
|
+
|
19
|
+
```
|
20
|
+
Usage: wordle [options]
|
21
|
+
-i, --identifier=IDENTIFIER Pass word identifer to target a specific word that someone else has played. Identifier gets printed at the end of the game to share with a friend.
|
22
|
+
-d, --difficult Hard mode. Any revealed hints must be used in subsequent guesses.
|
23
|
+
-c, --contrast High contrast mode. Matched letters will be orange. Included letters will be blue.
|
24
|
+
```
|
25
|
+
|
15
26
|
## Development
|
16
27
|
|
17
28
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -24,7 +35,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/Jonath
|
|
24
35
|
|
25
36
|
## Acknowledgements
|
26
37
|
|
27
|
-
I cribbed my word list from the Wordle site itself. I have no association with the site
|
38
|
+
I cribbed my word list from the Wordle site itself. I have no association with the site, its creator, or the New York Times - I'm just a fan!
|
28
39
|
|
29
40
|
## License
|
30
41
|
|
data/lib/integer.rb
ADDED
data/lib/string.rb
CHANGED
data/lib/wordle/game.rb
CHANGED
@@ -2,57 +2,78 @@
|
|
2
2
|
|
3
3
|
module Wordle
|
4
4
|
class Game
|
5
|
-
def self.play
|
6
|
-
new.play
|
5
|
+
def self.play(*args)
|
6
|
+
new(*args).play
|
7
7
|
end
|
8
8
|
|
9
|
-
def initialize
|
9
|
+
def initialize(options_reader = Options.new)
|
10
10
|
@list = List.new
|
11
|
+
@options = options_reader.read
|
11
12
|
@target_word = generate_word
|
13
|
+
@result_builder = ResultBuilder.new(@options[:contrast])
|
12
14
|
end
|
13
15
|
|
14
|
-
# print letters that have already been used?
|
15
|
-
# compare to real words
|
16
|
-
|
17
16
|
def play
|
18
17
|
winner = false
|
19
|
-
attempts = 0
|
20
18
|
|
21
|
-
Legend.print
|
19
|
+
Legend.print(@result_builder)
|
22
20
|
puts "Guess a 5 letter word: "
|
21
|
+
guesses = []
|
22
|
+
must_include = []
|
23
|
+
must_match = Array.new(5)
|
23
24
|
|
24
|
-
while
|
25
|
+
while guesses.length < 6 && !winner
|
25
26
|
guess = gets.chomp
|
26
27
|
|
27
|
-
validator = GuessValidator.new(
|
28
|
+
validator = GuessValidator.new(
|
29
|
+
guess,
|
30
|
+
@list,
|
31
|
+
@options[:difficult],
|
32
|
+
must_include,
|
33
|
+
must_match
|
34
|
+
)
|
28
35
|
if validator.invalid?
|
29
36
|
puts validator.error
|
30
37
|
next
|
31
38
|
end
|
32
39
|
|
33
|
-
analyzer = GuessAnalyzer.new(
|
40
|
+
analyzer = GuessAnalyzer.new(
|
41
|
+
@target_word,
|
42
|
+
guess,
|
43
|
+
@result_builder
|
44
|
+
)
|
34
45
|
puts analyzer.colors
|
46
|
+
guesses << analyzer.squares
|
47
|
+
if @options[:difficult]
|
48
|
+
must_include = analyzer.must_include(must_include)
|
49
|
+
must_match = analyzer.must_match(must_match)
|
50
|
+
end
|
35
51
|
|
36
52
|
if analyzer.match?
|
37
53
|
winner = true
|
38
54
|
break
|
39
55
|
end
|
40
|
-
|
41
|
-
attempts += 1
|
42
56
|
end
|
43
57
|
|
58
|
+
hash = Digest::SHA2.hexdigest(@target_word)[..5]
|
44
59
|
if winner
|
45
|
-
puts "
|
60
|
+
puts "\nWordle Gem #{hash} #{guesses.length}/6\n\n"
|
46
61
|
else
|
47
|
-
puts "
|
48
|
-
puts "
|
62
|
+
puts "\nWord was: #{@target_word}\n"
|
63
|
+
puts "\nWordle Gem #{hash} X/6*\n\n"
|
49
64
|
end
|
65
|
+
|
66
|
+
puts guesses
|
50
67
|
end
|
51
68
|
|
52
69
|
private
|
53
70
|
|
54
71
|
def generate_word
|
55
|
-
@
|
72
|
+
if @options[:identifier]
|
73
|
+
@list.by_hash(@options[:identifier])
|
74
|
+
else
|
75
|
+
@list.random
|
76
|
+
end
|
56
77
|
end
|
57
78
|
end
|
58
79
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "../string"
|
4
|
-
|
5
3
|
module Wordle
|
6
4
|
class GuessAnalyzer
|
7
|
-
def initialize(target_word, guess)
|
5
|
+
def initialize(target_word, guess, result_builder = ResultBuilder.new)
|
8
6
|
@target_word = target_word
|
9
7
|
@guess = guess
|
8
|
+
@result_builder = result_builder
|
10
9
|
end
|
11
10
|
|
12
11
|
def match?
|
@@ -14,28 +13,67 @@ module Wordle
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def colors
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
raw_results.each_with_index.map do |result, i|
|
17
|
+
guess_letters[i].send(@result_builder.text_color(result))
|
18
|
+
end.join("")
|
19
|
+
end
|
20
|
+
|
21
|
+
def squares
|
22
|
+
raw_results.each_with_index.map do |result, i|
|
23
|
+
@result_builder.square(result)
|
24
|
+
end.join("")
|
25
|
+
end
|
26
|
+
|
27
|
+
def must_include(prev_must_include)
|
28
|
+
raw_results.each_with_index do |result, i|
|
29
|
+
if @result_builder.included?(result) && !prev_must_include.include?(guess_letters[i])
|
30
|
+
prev_must_include << guess_letters[i]
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
prev_must_include
|
35
|
+
end
|
36
|
+
|
37
|
+
def must_match(prev_must_match)
|
38
|
+
raw_results.each_with_index do |result, i|
|
39
|
+
if @result_builder.match?(result)
|
40
|
+
prev_must_match[i] = guess_letters[i]
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
|
-
|
44
|
+
prev_must_match
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def guess_letters
|
50
|
+
@_guess_letters ||= @guess.chars
|
51
|
+
end
|
52
|
+
|
53
|
+
def raw_results
|
54
|
+
@_raw_results ||= begin
|
55
|
+
target_letters = @target_word.chars
|
56
|
+
results = []
|
57
|
+
|
58
|
+
guess_letters.each_with_index do |letter, i|
|
59
|
+
if letter == target_letters[i]
|
60
|
+
results[i] = @result_builder.match
|
61
|
+
target_letters[i] = nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
guess_letters.each_with_index do |letter, i|
|
66
|
+
if results[i].nil?
|
67
|
+
results[i] = if target_letters.include?(letter)
|
68
|
+
@result_builder.included
|
69
|
+
else
|
70
|
+
@result_builder.miss
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
results
|
76
|
+
end
|
39
77
|
end
|
40
78
|
end
|
41
79
|
end
|
@@ -2,23 +2,62 @@
|
|
2
2
|
|
3
3
|
module Wordle
|
4
4
|
class GuessValidator
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
def initialize(
|
6
|
+
guess,
|
7
|
+
list,
|
8
|
+
difficult,
|
9
|
+
must_include,
|
10
|
+
must_match
|
11
|
+
)
|
8
12
|
@guess = guess
|
9
13
|
@list = list
|
14
|
+
@difficult = difficult
|
15
|
+
@must_include = must_include
|
16
|
+
@must_match = must_match
|
17
|
+
@validated = false
|
10
18
|
end
|
11
19
|
|
12
20
|
def invalid?
|
21
|
+
!error.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
def error
|
25
|
+
validate if !@validated
|
26
|
+
|
27
|
+
@error
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def validate
|
33
|
+
validate_normal_mode
|
34
|
+
validate_hard_mode if @difficult
|
35
|
+
@validated = true
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate_normal_mode
|
13
39
|
if @guess.length != 5
|
14
40
|
@error = "Guess must be 5 letters long"
|
15
|
-
return true
|
16
41
|
elsif @list.invalid?(@guess)
|
17
|
-
@error = "Guess
|
18
|
-
|
42
|
+
@error = "Guess not in word list"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate_hard_mode
|
47
|
+
@must_include.each do |letter|
|
48
|
+
if !@guess.include?(letter)
|
49
|
+
@error = "Guess must include #{letter}"
|
50
|
+
break
|
51
|
+
end
|
19
52
|
end
|
20
53
|
|
21
|
-
|
54
|
+
@guess.each_char.with_index do |letter, i|
|
55
|
+
match = @must_match[i]
|
56
|
+
if match && match != letter
|
57
|
+
@error = "#{(i + 1).ordinalize} letter must be #{match}"
|
58
|
+
break
|
59
|
+
end
|
60
|
+
end
|
22
61
|
end
|
23
62
|
end
|
24
63
|
end
|
data/lib/wordle/legend.rb
CHANGED
@@ -2,27 +2,41 @@
|
|
2
2
|
|
3
3
|
module Wordle
|
4
4
|
class Legend
|
5
|
-
def self.print
|
6
|
-
new.print
|
5
|
+
def self.print(*args)
|
6
|
+
new(*args).print
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(result_builder = ResultBuilder.new)
|
10
|
+
@result_builder = result_builder
|
7
11
|
end
|
8
12
|
|
9
13
|
def print
|
10
|
-
puts
|
11
|
-
puts
|
12
|
-
puts
|
14
|
+
puts match_example
|
15
|
+
puts included_example
|
16
|
+
puts miss_example
|
17
|
+
puts "\nRestart and add -i flag to target a specific word by hash, for example:"
|
18
|
+
puts "$ wordle -i ed541a\n\n"
|
13
19
|
end
|
14
20
|
|
15
21
|
private
|
16
22
|
|
17
|
-
def
|
18
|
-
|
23
|
+
def match_color
|
24
|
+
@result_builder.match_text_color
|
25
|
+
end
|
26
|
+
|
27
|
+
def included_color
|
28
|
+
@result_builder.included_text_color
|
29
|
+
end
|
30
|
+
|
31
|
+
def match_example
|
32
|
+
"#{"w".send(match_color)}eary - The letter w is in the word and in the correct spot."
|
19
33
|
end
|
20
34
|
|
21
|
-
def
|
22
|
-
"p#{"i".
|
35
|
+
def included_example
|
36
|
+
"p#{"i".send(included_color)}lls - The letter i is in the word but in the wrong spot."
|
23
37
|
end
|
24
38
|
|
25
|
-
def
|
39
|
+
def miss_example
|
26
40
|
"vag#{"u".gray}e - The letter u is not in the word in any spot."
|
27
41
|
end
|
28
42
|
end
|
data/lib/wordle/list.rb
CHANGED
@@ -2,14 +2,20 @@
|
|
2
2
|
|
3
3
|
module Wordle
|
4
4
|
class List
|
5
|
-
def initialize(length = 5)
|
6
|
-
@length = length
|
7
|
-
end
|
8
|
-
|
9
5
|
def random
|
10
6
|
list.sample.downcase.strip
|
11
7
|
end
|
12
8
|
|
9
|
+
def by_hash(hash)
|
10
|
+
word = list.detect do |word|
|
11
|
+
Digest::SHA2.hexdigest(word.downcase.strip)[..5] == hash
|
12
|
+
end
|
13
|
+
|
14
|
+
raise Wordle::Error, "Invalid word identifier, are you sure you copied it correctly?" if word.nil?
|
15
|
+
|
16
|
+
word
|
17
|
+
end
|
18
|
+
|
13
19
|
def invalid?(word)
|
14
20
|
!list.include?(word)
|
15
21
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Wordle
|
4
|
+
class Options
|
5
|
+
def read
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
parser = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: wordle [options]"
|
10
|
+
|
11
|
+
opts.on("-iIDENTIFIER", "--identifier=IDENTIFIER", "Pass word identifer to target a specific word that someone else has played. Identifier gets printed at the end of the game to share with a friend.") do |i|
|
12
|
+
options[:identifier] = i
|
13
|
+
end
|
14
|
+
|
15
|
+
opts.on("-d", "--difficult", "Hard mode. Any revealed hints must be used in subsequent guesses.") do |d|
|
16
|
+
options[:difficult] = d
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-c", "--contrast", "High contrast mode. Matched letters will be orange. Included letters will be blue.") do |c|
|
20
|
+
options[:contrast] = c
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
parser.parse!
|
26
|
+
rescue OptionParser::InvalidOption
|
27
|
+
puts "Option not recognized"
|
28
|
+
end
|
29
|
+
|
30
|
+
options
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Wordle
|
4
|
+
class ResultBuilder
|
5
|
+
MATCH = :match
|
6
|
+
INCLUDED = :included
|
7
|
+
MISS = :miss
|
8
|
+
|
9
|
+
DEFAULT_OPTIONS = {
|
10
|
+
MATCH => {text: :green, square: "🟩"},
|
11
|
+
INCLUDED => {text: :yellow, square: "🟨"},
|
12
|
+
MISS => {text: :gray, square: "⬛️"}
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
CONTRAST_OPTIONS = {
|
16
|
+
MATCH => {text: :orange, square: "🟧"},
|
17
|
+
INCLUDED => {text: :blue, square: "🟦"},
|
18
|
+
MISS => {text: :gray, square: "⬛️"}
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
def initialize(contrast = false)
|
22
|
+
@contrast = contrast
|
23
|
+
end
|
24
|
+
|
25
|
+
def match?(result)
|
26
|
+
result == MATCH
|
27
|
+
end
|
28
|
+
|
29
|
+
def included?(result)
|
30
|
+
result == INCLUDED
|
31
|
+
end
|
32
|
+
|
33
|
+
def match
|
34
|
+
MATCH
|
35
|
+
end
|
36
|
+
|
37
|
+
def included
|
38
|
+
INCLUDED
|
39
|
+
end
|
40
|
+
|
41
|
+
def miss
|
42
|
+
MISS
|
43
|
+
end
|
44
|
+
|
45
|
+
def match_text_color
|
46
|
+
options[match][:text]
|
47
|
+
end
|
48
|
+
|
49
|
+
def included_text_color
|
50
|
+
options[included][:text]
|
51
|
+
end
|
52
|
+
|
53
|
+
def text_color(result)
|
54
|
+
options[result][:text]
|
55
|
+
end
|
56
|
+
|
57
|
+
def square(result)
|
58
|
+
options[result][:square]
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def options
|
64
|
+
return DEFAULT_OPTIONS if !@contrast
|
65
|
+
@_options ||= CONTRAST_OPTIONS
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/wordle/version.rb
CHANGED
data/lib/wordle.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "digest"
|
4
|
+
require "optparse"
|
5
|
+
require_relative "integer"
|
3
6
|
require_relative "string"
|
4
|
-
require_relative "wordle/
|
5
|
-
require_relative "wordle/source"
|
6
|
-
require_relative "wordle/list"
|
7
|
-
require_relative "wordle/guess_validator"
|
7
|
+
require_relative "wordle/game"
|
8
8
|
require_relative "wordle/guess_analyzer"
|
9
|
+
require_relative "wordle/guess_validator"
|
9
10
|
require_relative "wordle/legend"
|
10
|
-
require_relative "wordle/
|
11
|
+
require_relative "wordle/list"
|
12
|
+
require_relative "wordle/options"
|
13
|
+
require_relative "wordle/result_builder"
|
14
|
+
require_relative "wordle/source"
|
15
|
+
require_relative "wordle/version"
|
11
16
|
|
12
17
|
module Wordle
|
13
18
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Thom
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|
@@ -34,6 +34,7 @@ extra_rdoc_files: []
|
|
34
34
|
files:
|
35
35
|
- ".rspec"
|
36
36
|
- ".standard.yml"
|
37
|
+
- ".tool-versions"
|
37
38
|
- CHANGELOG.md
|
38
39
|
- CODE_OF_CONDUCT.md
|
39
40
|
- Gemfile
|
@@ -44,6 +45,7 @@ files:
|
|
44
45
|
- bin/console
|
45
46
|
- bin/setup
|
46
47
|
- exe/wordle
|
48
|
+
- lib/integer.rb
|
47
49
|
- lib/string.rb
|
48
50
|
- lib/wordle.rb
|
49
51
|
- lib/wordle/game.rb
|
@@ -51,6 +53,8 @@ files:
|
|
51
53
|
- lib/wordle/guess_validator.rb
|
52
54
|
- lib/wordle/legend.rb
|
53
55
|
- lib/wordle/list.rb
|
56
|
+
- lib/wordle/options.rb
|
57
|
+
- lib/wordle/result_builder.rb
|
54
58
|
- lib/wordle/source.rb
|
55
59
|
- lib/wordle/version.rb
|
56
60
|
- wordle.gemspec
|
@@ -77,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
81
|
- !ruby/object:Gem::Version
|
78
82
|
version: '0'
|
79
83
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
84
|
+
rubygems_version: 3.3.7
|
81
85
|
signing_key:
|
82
86
|
specification_version: 4
|
83
87
|
summary: Wordle CLI in Ruby
|