codebreaker_kub 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 +7 -0
- data/.fasterer.yml +19 -0
- data/.gitignore +2 -0
- data/.overcommit.yml +33 -0
- data/.rspec_status +30 -0
- data/.rubocop.yml +15 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +73 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/codebreaker.gemspec +34 -0
- data/lib/codebreaker.rb +7 -0
- data/lib/codebreaker/data/difficulties.yml +9 -0
- data/lib/codebreaker/data/locales/en.yml +29 -0
- data/lib/codebreaker/game.rb +85 -0
- data/lib/codebreaker/loader.rb +24 -0
- data/lib/codebreaker/output.rb +77 -0
- data/lib/codebreaker/validation.rb +11 -0
- data/lib/codebreaker/version.rb +3 -0
- data/pkg/codebreaker_kub-0.0.1.gem +0 -0
- metadata +140 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: '00487c62abc4952a11b6642171dbf979e0c2fb332caadc94cc4ac33a8fe44d3e'
|
|
4
|
+
data.tar.gz: 3e2317e7d2a990423f1b29fb913b5e9bf1dc389c452af61d83c34ba986133f7e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7f35577693fd2bf9737ddb14339c5ea4bd77b7ab711c1dae80b4cac497f8743c6cf715e8d77f800a0933d9dab91048d188fa7aca7cdf8b68339b652576392e1d
|
|
7
|
+
data.tar.gz: 39b6c0b237fa522fac0cfdf5f17fe3cd9a6810b755365238b70131e53be19ef6963f9711586ff464275e2f1d107f1e45d9ccb842ad69d6bbab05e3343f3dc562
|
data/.fasterer.yml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
speedups:
|
|
2
|
+
rescue_vs_respond_to: true
|
|
3
|
+
module_eval: true
|
|
4
|
+
shuffle_first_vs_sample: true
|
|
5
|
+
for_loop_vs_each: true
|
|
6
|
+
each_with_index_vs_while: false
|
|
7
|
+
map_flatten_vs_flat_map: true
|
|
8
|
+
reverse_each_vs_reverse_each: true
|
|
9
|
+
select_first_vs_detect: true
|
|
10
|
+
sort_vs_sort_by: true
|
|
11
|
+
fetch_with_argument_vs_block: true
|
|
12
|
+
keys_each_vs_each_key: true
|
|
13
|
+
hash_merge_bang_vs_hash_brackets: true
|
|
14
|
+
block_vs_symbol_to_proc: true
|
|
15
|
+
proc_call_vs_yield: true
|
|
16
|
+
gsub_vs_tr: true
|
|
17
|
+
select_last_vs_reverse_detect: true
|
|
18
|
+
getter_vs_attr_reader: true
|
|
19
|
+
setter_vs_attr_writer: true
|
data/.gitignore
ADDED
data/.overcommit.yml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
|
2
|
+
# extend the default configuration defined in:
|
|
3
|
+
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
|
4
|
+
#
|
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
|
9
|
+
#
|
|
10
|
+
# For a complete list of hooks, see:
|
|
11
|
+
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
|
12
|
+
#
|
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
|
14
|
+
# https://github.com/sds/overcommit#configuration
|
|
15
|
+
#
|
|
16
|
+
# Uncomment the following lines to make the configuration take effect.
|
|
17
|
+
|
|
18
|
+
#PreCommit:
|
|
19
|
+
# RuboCop:
|
|
20
|
+
# enabled: true
|
|
21
|
+
# on_warn: fail # Treat all warnings as failures
|
|
22
|
+
#
|
|
23
|
+
# TrailingWhitespace:
|
|
24
|
+
# enabled: true
|
|
25
|
+
# exclude:
|
|
26
|
+
# - '**/db/structure.sql' # Ignore trailing whitespace in generated files
|
|
27
|
+
#
|
|
28
|
+
#PostCheckout:
|
|
29
|
+
# ALL: # Special hook name that customizes all hooks of this type
|
|
30
|
+
# quiet: true # Change all post-checkout hooks to only display output on failure
|
|
31
|
+
#
|
|
32
|
+
# IndexTags:
|
|
33
|
+
# enabled: true # Generate a tags file with `ctags` each time HEAD changes
|
data/.rspec_status
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
example_id | status | run_time |
|
|
2
|
+
------------------------------------------ | ------ | --------------- |
|
|
3
|
+
./spec/codebreaker/game_spec.rb[1:1] | passed | 0.00066 seconds |
|
|
4
|
+
./spec/codebreaker/game_spec.rb[1:2] | passed | 0.00069 seconds |
|
|
5
|
+
./spec/codebreaker/game_spec.rb[1:3] | passed | 0.00095 seconds |
|
|
6
|
+
./spec/codebreaker/game_spec.rb[1:4] | passed | 0.00124 seconds |
|
|
7
|
+
./spec/codebreaker/game_spec.rb[1:5] | passed | 0.00033 seconds |
|
|
8
|
+
./spec/codebreaker/game_spec.rb[1:6] | passed | 0.0052 seconds |
|
|
9
|
+
./spec/codebreaker/game_spec.rb[1:7] | passed | 0.00059 seconds |
|
|
10
|
+
./spec/codebreaker/game_spec.rb[1:8] | passed | 0.00034 seconds |
|
|
11
|
+
./spec/codebreaker/game_spec.rb[1:9] | passed | 0.00029 seconds |
|
|
12
|
+
./spec/codebreaker/game_spec.rb[1:10:1] | passed | 0.00059 seconds |
|
|
13
|
+
./spec/codebreaker/game_spec.rb[1:10:2] | passed | 0.00028 seconds |
|
|
14
|
+
./spec/codebreaker/game_spec.rb[1:10:3] | passed | 0.00026 seconds |
|
|
15
|
+
./spec/codebreaker/game_spec.rb[1:10:4] | passed | 0.00025 seconds |
|
|
16
|
+
./spec/codebreaker/game_spec.rb[1:10:5] | passed | 0.00027 seconds |
|
|
17
|
+
./spec/codebreaker/game_spec.rb[1:10:6] | passed | 0.00026 seconds |
|
|
18
|
+
./spec/codebreaker/game_spec.rb[1:10:7] | passed | 0.00026 seconds |
|
|
19
|
+
./spec/codebreaker/game_spec.rb[1:10:8] | passed | 0.00027 seconds |
|
|
20
|
+
./spec/codebreaker/game_spec.rb[1:10:9] | passed | 0.00038 seconds |
|
|
21
|
+
./spec/codebreaker/game_spec.rb[1:10:10] | passed | 0.00036 seconds |
|
|
22
|
+
./spec/codebreaker/game_spec.rb[1:10:11] | passed | 0.00034 seconds |
|
|
23
|
+
./spec/codebreaker/loader_spec.rb[1:1] | passed | 0.00079 seconds |
|
|
24
|
+
./spec/codebreaker/validation_spec.rb[1:1] | passed | 0.00023 seconds |
|
|
25
|
+
./spec/codebreaker/validation_spec.rb[1:2] | passed | 0.00014 seconds |
|
|
26
|
+
./spec/codebreaker/validation_spec.rb[1:3] | passed | 0.00013 seconds |
|
|
27
|
+
./spec/codebreaker/validation_spec.rb[1:4] | passed | 0.00008 seconds |
|
|
28
|
+
./spec/codebreaker/validation_spec.rb[1:5] | passed | 0.00009 seconds |
|
|
29
|
+
./spec/codebreaker/validation_spec.rb[1:6] | passed | 0.00013 seconds |
|
|
30
|
+
./spec/codebreaker_spec.rb[1:1] | passed | 0.00009 seconds |
|
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.7.0
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at katiakub@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: https://contributor-covenant.org
|
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
codebreaker_kub (0.0.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.1)
|
|
10
|
+
colorize (0.8.1)
|
|
11
|
+
concurrent-ruby (1.1.6)
|
|
12
|
+
diff-lcs (1.4.4)
|
|
13
|
+
docile (1.3.2)
|
|
14
|
+
fasterer (0.8.3)
|
|
15
|
+
colorize (~> 0.7)
|
|
16
|
+
ruby_parser (>= 3.14.1)
|
|
17
|
+
i18n (1.8.3)
|
|
18
|
+
concurrent-ruby (~> 1.0)
|
|
19
|
+
parallel (1.19.2)
|
|
20
|
+
parser (2.7.1.4)
|
|
21
|
+
ast (~> 2.4.1)
|
|
22
|
+
rainbow (3.0.0)
|
|
23
|
+
rake (12.3.3)
|
|
24
|
+
regexp_parser (1.7.1)
|
|
25
|
+
rexml (3.2.4)
|
|
26
|
+
rspec (3.9.0)
|
|
27
|
+
rspec-core (~> 3.9.0)
|
|
28
|
+
rspec-expectations (~> 3.9.0)
|
|
29
|
+
rspec-mocks (~> 3.9.0)
|
|
30
|
+
rspec-core (3.9.2)
|
|
31
|
+
rspec-support (~> 3.9.3)
|
|
32
|
+
rspec-expectations (3.9.2)
|
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
34
|
+
rspec-support (~> 3.9.0)
|
|
35
|
+
rspec-mocks (3.9.1)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.9.0)
|
|
38
|
+
rspec-support (3.9.3)
|
|
39
|
+
rubocop (0.87.1)
|
|
40
|
+
parallel (~> 1.10)
|
|
41
|
+
parser (>= 2.7.1.1)
|
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
43
|
+
regexp_parser (>= 1.7)
|
|
44
|
+
rexml
|
|
45
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
|
46
|
+
ruby-progressbar (~> 1.7)
|
|
47
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
48
|
+
rubocop-ast (0.1.0)
|
|
49
|
+
parser (>= 2.7.0.1)
|
|
50
|
+
ruby-progressbar (1.10.1)
|
|
51
|
+
ruby_parser (3.14.2)
|
|
52
|
+
sexp_processor (~> 4.9)
|
|
53
|
+
sexp_processor (4.15.0)
|
|
54
|
+
simplecov (0.18.5)
|
|
55
|
+
docile (~> 1.1)
|
|
56
|
+
simplecov-html (~> 0.11)
|
|
57
|
+
simplecov-html (0.12.2)
|
|
58
|
+
unicode-display_width (1.7.0)
|
|
59
|
+
|
|
60
|
+
PLATFORMS
|
|
61
|
+
ruby
|
|
62
|
+
|
|
63
|
+
DEPENDENCIES
|
|
64
|
+
codebreaker_kub!
|
|
65
|
+
fasterer (~> 0.8)
|
|
66
|
+
i18n (~> 1.8)
|
|
67
|
+
rake (~> 12.0)
|
|
68
|
+
rspec (~> 3.0)
|
|
69
|
+
rubocop (~> 0.87)
|
|
70
|
+
simplecov (~> 0.18)
|
|
71
|
+
|
|
72
|
+
BUNDLED WITH
|
|
73
|
+
2.1.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 katia kub
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Codebreaker
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/codebreaker`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'codebreaker'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle install
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install codebreaker
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/codebreaker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/codebreaker/blob/master/CODE_OF_CONDUCT.md).
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
41
|
+
|
|
42
|
+
## Code of Conduct
|
|
43
|
+
|
|
44
|
+
Everyone interacting in the Codebreaker project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/codebreaker/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'codebreaker'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require 'irb'
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/codebreaker.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative 'lib/codebreaker/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = 'codebreaker_kub'
|
|
5
|
+
spec.version = Codebreaker::VERSION
|
|
6
|
+
spec.authors = ['katia kub']
|
|
7
|
+
spec.email = ['katiakub@gmail.com']
|
|
8
|
+
|
|
9
|
+
spec.summary = 'Codebreaker'
|
|
10
|
+
spec.description = 'Codebreaker gem'
|
|
11
|
+
spec.homepage = 'https://github.com/katiakub/gCodebreaker'
|
|
12
|
+
spec.license = 'MIT'
|
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
|
14
|
+
|
|
15
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/katiakub/gCodebreaker'
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
spec.bindir = 'exe'
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ['lib']
|
|
28
|
+
|
|
29
|
+
spec.add_development_dependency 'fasterer', '~>0.8'
|
|
30
|
+
spec.add_development_dependency 'i18n', '~>1.8'
|
|
31
|
+
spec.add_development_dependency 'rspec', '~>3.9'
|
|
32
|
+
spec.add_development_dependency 'rubocop', '~>0.87'
|
|
33
|
+
spec.add_development_dependency 'simplecov', '~>0.18'
|
|
34
|
+
end
|
data/lib/codebreaker.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
:en:
|
|
2
|
+
hey: "Welcome to gCodebreaker!\n You can:
|
|
3
|
+
- Start new game - puts 'start'\n
|
|
4
|
+
- Check the rules - puts 'rules'\n
|
|
5
|
+
- Load game statistics - puts 'stats'\n
|
|
6
|
+
- Exit from game - puts 'exit'\n"
|
|
7
|
+
goodbye: "Bye bye!\n"
|
|
8
|
+
rules: "GAME RULES:\n
|
|
9
|
+
# Codebreaker is a logic game in which a code-breaker tries to break a secret code created by a code-maker. The\n codemaker, which will be played by the application we’re going to write, creates a secret code.\n
|
|
10
|
+
# The codebreaker gets some number of chances to break the code (depends on chosen difficulty). In each turn, the\n codebreaker makes a guess. The codemaker then marks the guess with special symbols.\n
|
|
11
|
+
Number of minuses - 2 (second and fourth position)\n
|
|
12
|
+
# If codebreaker inputs the exact number as a secret number - codebreaker wins the game. If all attempts are spent - codebreaker loses.\n
|
|
13
|
+
# Codebreaker also has some number of hints(depends on chosen difficulty). If a user takes a hint - he receives back a\n
|
|
14
|
+
separate digit of the secret code.\n
|
|
15
|
+
# Good luck!"
|
|
16
|
+
choose_name: "Enter you name: "
|
|
17
|
+
wrong_name: "Enter valid name, please! Name must be min 3 and max 20 characters.\n"
|
|
18
|
+
choose_difficulty: "Choose difficulty: 'easy', 'medium', 'hell'"
|
|
19
|
+
wrong_difficulty: "There is no such level. Select from available, please"
|
|
20
|
+
get_hint: "You can choose get hint - puts 'hint'"
|
|
21
|
+
no_hints: "You have no hints"
|
|
22
|
+
wrong_input: "Your input is invalid or there is no such command."
|
|
23
|
+
win: "YOU WIN!"
|
|
24
|
+
lose: "You lose, sorry("
|
|
25
|
+
code: "The code was: "
|
|
26
|
+
no_stats: "Sorry, you have not any statistic yet"
|
|
27
|
+
save_result: "Do you want to save result y/n"
|
|
28
|
+
game_over: "GAME OVER"
|
|
29
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Codebreaker
|
|
2
|
+
class Game
|
|
3
|
+
attr_accessor :input_code, :code, :name, :difficulties, :difficulty, :hints_left, :attempts_left
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
@difficulties = Codebreaker::Loader.load('difficulties')
|
|
7
|
+
@code = generate_code
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def game_option(name, difficulty)
|
|
11
|
+
@name = name
|
|
12
|
+
@difficulty = difficulty
|
|
13
|
+
@attempts_left = difficulty_option[:attempts]
|
|
14
|
+
@hints_left = difficulty_option[:hints]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def hint
|
|
18
|
+
return unless hints_left?
|
|
19
|
+
|
|
20
|
+
@hints_left -= 1
|
|
21
|
+
generate_hint
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def hints_left?
|
|
25
|
+
@hints_left.positive?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def input_operation(input_code)
|
|
29
|
+
@input_code = input_code
|
|
30
|
+
return unless attempts_left?
|
|
31
|
+
|
|
32
|
+
@attempts_left -= 1
|
|
33
|
+
check_input
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def attempts_left?
|
|
37
|
+
@attempts_left.positive?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def win?
|
|
41
|
+
@input_code == @code
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def save
|
|
45
|
+
Codebreaker::Loader.save(to_h, 'stat')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def check_input(code = @code.chars)
|
|
51
|
+
input = @input_code.chars
|
|
52
|
+
minuses = (code & input).map { |element| [code.count(element), input.count(element)].min }.sum
|
|
53
|
+
result = '-' * minuses
|
|
54
|
+
input.each.with_index do |element, index|
|
|
55
|
+
result.sub!('-', '+') if element == code[index]
|
|
56
|
+
end
|
|
57
|
+
result
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def generate_code
|
|
61
|
+
Array.new(4) { rand(1..6) }.join
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def generate_hint
|
|
65
|
+
@code.chars.shuffle.pop
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def difficulty_option
|
|
69
|
+
@difficulties[@difficulty]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def to_h
|
|
73
|
+
{
|
|
74
|
+
name: @name,
|
|
75
|
+
difficulty: @difficulty,
|
|
76
|
+
attempts: difficulty_option[:attempts],
|
|
77
|
+
hints: difficulty_option[:hints],
|
|
78
|
+
code: @code,
|
|
79
|
+
attempts_left: @attempts_left,
|
|
80
|
+
hints_left: @hints_left,
|
|
81
|
+
win: win?
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Codebreaker
|
|
2
|
+
module Loader
|
|
3
|
+
PATH = 'lib/codebreaker/data/'.freeze
|
|
4
|
+
EXTENCTION = '.yml'.freeze
|
|
5
|
+
def self.load(file_name)
|
|
6
|
+
file_name = PATH + file_name + EXTENCTION.to_s
|
|
7
|
+
if File.exist?(file_name)
|
|
8
|
+
YAML.load_file(file_name)
|
|
9
|
+
else
|
|
10
|
+
File.new(file_name, 'w')
|
|
11
|
+
[]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.save(obj, file_name)
|
|
16
|
+
file_name = PATH + file_name + EXTENCTION.to_s
|
|
17
|
+
stats = File.file?(file_name) && !File.zero?(file_name) ? YAML.load_file(file_name) : []
|
|
18
|
+
stats << obj
|
|
19
|
+
file = File.open(file_name, 'w')
|
|
20
|
+
file.write(stats.to_yaml)
|
|
21
|
+
file.close
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module Codebreaker
|
|
2
|
+
class Output
|
|
3
|
+
def initialize
|
|
4
|
+
I18n.load_path << Dir[File.expand_path('./lib/codebreaker/data/locales') + '/*.yml']
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def greeting
|
|
8
|
+
puts I18n.t(:hey)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def choose_name
|
|
12
|
+
puts I18n.t(:choose_name)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def wrong_name
|
|
16
|
+
puts I18n.t(:wrong_name)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def rules
|
|
20
|
+
puts I18n.t(:rules)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def show_stats
|
|
24
|
+
stats.each do |game|
|
|
25
|
+
puts "Hey, #{game[:name]}
|
|
26
|
+
Chosen difficulty: #{game[:difficulty]}
|
|
27
|
+
Attempts: #{game[:attempts]}
|
|
28
|
+
Hints: #{game[:hints]}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def no_stats
|
|
33
|
+
puts I18n.t(:no_stats)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def show_hint
|
|
37
|
+
puts I18n.t(:get_hint)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def no_hints
|
|
41
|
+
puts I18n.t(:no_hints)
|
|
42
|
+
puts I18n.t(:code)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def choose_difficulty
|
|
46
|
+
puts I18n.t(:choose_difficulty)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def wrong_difficulty
|
|
50
|
+
puts I18n.t(:wrong_difficulty)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def wrong_input
|
|
54
|
+
puts I18n.t(:wrong_input)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def win
|
|
58
|
+
puts I18n.t(:win)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def lose
|
|
62
|
+
puts I18n.t(:lose)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def save_result
|
|
66
|
+
puts I18n.t(:save_result)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def goodbye
|
|
70
|
+
I18n(:goodbye)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def game_over
|
|
74
|
+
puts I18n.t(:game_over)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: codebreaker_kub
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- katia kub
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-07-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: fasterer
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.8'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.8'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: i18n
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.8'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.8'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.9'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.9'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0.87'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0.87'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: simplecov
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0.18'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0.18'
|
|
83
|
+
description: Codebreaker gem
|
|
84
|
+
email:
|
|
85
|
+
- katiakub@gmail.com
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".fasterer.yml"
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".overcommit.yml"
|
|
93
|
+
- ".rspec_status"
|
|
94
|
+
- ".rubocop.yml"
|
|
95
|
+
- ".ruby-version"
|
|
96
|
+
- CODE_OF_CONDUCT.md
|
|
97
|
+
- Gemfile
|
|
98
|
+
- Gemfile.lock
|
|
99
|
+
- LICENSE.txt
|
|
100
|
+
- README.md
|
|
101
|
+
- Rakefile
|
|
102
|
+
- bin/console
|
|
103
|
+
- bin/setup
|
|
104
|
+
- codebreaker.gemspec
|
|
105
|
+
- lib/codebreaker.rb
|
|
106
|
+
- lib/codebreaker/data/difficulties.yml
|
|
107
|
+
- lib/codebreaker/data/locales/en.yml
|
|
108
|
+
- lib/codebreaker/game.rb
|
|
109
|
+
- lib/codebreaker/loader.rb
|
|
110
|
+
- lib/codebreaker/output.rb
|
|
111
|
+
- lib/codebreaker/validation.rb
|
|
112
|
+
- lib/codebreaker/version.rb
|
|
113
|
+
- pkg/codebreaker_kub-0.0.1.gem
|
|
114
|
+
homepage: https://github.com/katiakub/gCodebreaker
|
|
115
|
+
licenses:
|
|
116
|
+
- MIT
|
|
117
|
+
metadata:
|
|
118
|
+
allowed_push_host: https://rubygems.org
|
|
119
|
+
homepage_uri: https://github.com/katiakub/gCodebreaker
|
|
120
|
+
source_code_uri: https://github.com/katiakub/gCodebreaker
|
|
121
|
+
post_install_message:
|
|
122
|
+
rdoc_options: []
|
|
123
|
+
require_paths:
|
|
124
|
+
- lib
|
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: 2.7.0
|
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
|
+
requirements:
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: '0'
|
|
135
|
+
requirements: []
|
|
136
|
+
rubygems_version: 3.1.2
|
|
137
|
+
signing_key:
|
|
138
|
+
specification_version: 4
|
|
139
|
+
summary: Codebreaker
|
|
140
|
+
test_files: []
|