codebreakergem 0.1.9 → 0.1.10

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: cd9872a708d03902c8443257387f82370bdd1d1713738360267ab5e06fe6a560
4
- data.tar.gz: ad61ebe48ceaece6c526d408033b0abe1d644dd0b5cdfd0d92816122a267b137
3
+ metadata.gz: 8e00493dfc2cd29c26cba839e283dde2df410f546419a85c4937abe824c59ef5
4
+ data.tar.gz: a6a8ae95d6d0d8a75b5661c41c8d11f155d541892847f285b20efd02b09fed37
5
5
  SHA512:
6
- metadata.gz: dbe5b11c708a0bbc958c94ea2f2b6f7db606a39f38100b357a5d18905a71b0301bfa1440b32316181e2ab7743bf31ae237bc2dee832c38b954d9e69a96304c65
7
- data.tar.gz: 22b9563dfa2f796b37ad766b33b5762b852cd9fbd3128b21bb867d2ed37d57ad460fb14ff7c87d19bf7ac92008145d3dc9aedcadedcc9ddb0f6ed09004786971
6
+ metadata.gz: 94c28086deb97b77ea821f8f09818ccff171379786a814e214d0d0074649d7c73cfa7a3b7e0417893898925ed7507f1c8903ce91a82d764fa9face13c4739476
7
+ data.tar.gz: c3ed901152dcac6b78a6a40a436ee0192d44a2e1a83c32e6ad4683f62d9c5e6c75cb5a3837612369b865fc4baadff31539c82d49699b3d94de772cbc54b392ea
data/.gitignore CHANGED
@@ -1,11 +1,11 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -6,7 +6,3 @@ Style/RaiseArgs:
6
6
 
7
7
  Metrics/LineLength:
8
8
  Max: 120
9
-
10
- AllCops:
11
- Exclude:
12
- - 'main.rb'
@@ -1,7 +1,7 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.5
7
- before_install: gem install bundler -v 1.17.2
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 1.17.2
@@ -1,74 +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 sasha. 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 [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
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 sasha. 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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -1,70 +1,70 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- ast (2.4.0)
5
- byebug (9.1.0)
6
- coderay (1.1.2)
7
- colorize (0.8.1)
8
- diff-lcs (1.3)
9
- docile (1.1.5)
10
- fasterer (0.8.1)
11
- colorize (~> 0.7)
12
- ruby_parser (>= 3.14.1)
13
- i18n (0.7.0)
14
- jaro_winkler (1.5.4)
15
- json (2.3.0)
16
- method_source (0.8.2)
17
- parallel (1.19.1)
18
- parser (2.6.5.0)
19
- ast (~> 2.4.0)
20
- pry (0.10.4)
21
- coderay (~> 1.1.0)
22
- method_source (~> 0.8.1)
23
- slop (~> 3.4)
24
- rainbow (3.0.0)
25
- rspec (3.9.0)
26
- rspec-core (~> 3.9.0)
27
- rspec-expectations (~> 3.9.0)
28
- rspec-mocks (~> 3.9.0)
29
- rspec-core (3.9.0)
30
- rspec-support (~> 3.9.0)
31
- rspec-expectations (3.9.0)
32
- diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.9.0)
34
- rspec-mocks (3.9.0)
35
- diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.9.0)
37
- rspec-support (3.9.0)
38
- rubocop (0.76.0)
39
- jaro_winkler (~> 1.5.1)
40
- parallel (~> 1.10)
41
- parser (>= 2.6)
42
- rainbow (>= 2.2.2, < 4.0)
43
- ruby-progressbar (~> 1.7)
44
- unicode-display_width (>= 1.4.0, < 1.7)
45
- ruby-progressbar (1.10.1)
46
- ruby_parser (3.14.1)
47
- sexp_processor (~> 4.9)
48
- sexp_processor (4.13.0)
49
- simplecov (0.12.0)
50
- docile (~> 1.1.0)
51
- json (>= 1.8, < 3)
52
- simplecov-html (~> 0.10.0)
53
- simplecov-html (0.10.2)
54
- slop (3.6.0)
55
- unicode-display_width (1.6.0)
56
-
57
- PLATFORMS
58
- x64-mingw32
59
-
60
- DEPENDENCIES
61
- byebug (~> 9.0, >= 9.0.6)
62
- fasterer (~> 0.8.0)
63
- i18n (~> 0.7.0)
64
- pry (~> 0.10.3)
65
- rspec (~> 3.9)
66
- rubocop (~> 0.76.0)
67
- simplecov (~> 0.12.0)
68
-
69
- BUNDLED WITH
70
- 1.17.2
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ ast (2.4.0)
5
+ byebug (9.1.0)
6
+ coderay (1.1.2)
7
+ colorize (0.8.1)
8
+ diff-lcs (1.3)
9
+ docile (1.1.5)
10
+ fasterer (0.8.1)
11
+ colorize (~> 0.7)
12
+ ruby_parser (>= 3.14.1)
13
+ i18n (0.7.0)
14
+ jaro_winkler (1.5.4)
15
+ json (2.3.0)
16
+ method_source (0.8.2)
17
+ parallel (1.19.1)
18
+ parser (2.6.5.0)
19
+ ast (~> 2.4.0)
20
+ pry (0.10.4)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.8.1)
23
+ slop (~> 3.4)
24
+ rainbow (3.0.0)
25
+ rspec (3.9.0)
26
+ rspec-core (~> 3.9.0)
27
+ rspec-expectations (~> 3.9.0)
28
+ rspec-mocks (~> 3.9.0)
29
+ rspec-core (3.9.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-expectations (3.9.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.9.0)
34
+ rspec-mocks (3.9.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.9.0)
37
+ rspec-support (3.9.0)
38
+ rubocop (0.76.0)
39
+ jaro_winkler (~> 1.5.1)
40
+ parallel (~> 1.10)
41
+ parser (>= 2.6)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 1.4.0, < 1.7)
45
+ ruby-progressbar (1.10.1)
46
+ ruby_parser (3.14.1)
47
+ sexp_processor (~> 4.9)
48
+ sexp_processor (4.13.0)
49
+ simplecov (0.12.0)
50
+ docile (~> 1.1.0)
51
+ json (>= 1.8, < 3)
52
+ simplecov-html (~> 0.10.0)
53
+ simplecov-html (0.10.2)
54
+ slop (3.6.0)
55
+ unicode-display_width (1.6.0)
56
+
57
+ PLATFORMS
58
+ x64-mingw32
59
+
60
+ DEPENDENCIES
61
+ byebug (~> 9.0, >= 9.0.6)
62
+ fasterer (~> 0.8.0)
63
+ i18n (~> 0.7.0)
64
+ pry (~> 0.10.3)
65
+ rspec (~> 3.9)
66
+ rubocop (~> 0.76.0)
67
+ simplecov (~> 0.12.0)
68
+
69
+ BUNDLED WITH
70
+ 1.17.2
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 Sasha
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.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Sasha
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 CHANGED
@@ -1,43 +1,43 @@
1
- # Codebreakergem
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/codebreakergem`. 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 'codebreakergem'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install codebreakergem
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]/codebreakergem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
- ## License
38
-
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Codebreakergem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/codebreakergem/blob/master/CODE_OF_CONDUCT.md).
1
+ # Codebreakergem
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/codebreakergem`. 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 'codebreakergem'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install codebreakergem
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]/codebreakergem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Codebreakergem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/codebreakergem/blob/master/CODE_OF_CONDUCT.md).
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Codebreakergem
4
+ class Difficulty
5
+ attr_reader :title, :order
6
+ attr_accessor :attempts, :hints
7
+
8
+ def initialize
9
+ raise NotImplementedError
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Codebreakergem
4
+ class Easy < Difficulty
5
+ def initialize
6
+ @title = 'Easy'
7
+ @attempts = 15
8
+ @hints = 2
9
+ @order = 3
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Codebreakergem
4
+ class Hell < Difficulty
5
+ def initialize
6
+ @title = 'Hell'
7
+ @attempts = 5
8
+ @hints = 1
9
+ @order = 1
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Codebreakergem
4
+ class Medium < Difficulty
5
+ def initialize
6
+ @title = 'Medium'
7
+ @attempts = 10
8
+ @hints = 1
9
+ @order = 2
10
+ end
11
+ end
12
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Codebreakergem
4
4
  class FileWorker
5
- PERMITTED_CLASSES = [Statistic, Difficulty]
6
-
5
+ PERMITTED_CLASSES = [Statistic, Difficulty, Easy, Medium, Hell].freeze
6
+
7
7
  class << self
8
8
  def read_from_file(filename)
9
9
  return nil unless File.file?(Game::FILE)
@@ -5,9 +5,7 @@ module Codebreakergem
5
5
  include Checker
6
6
 
7
7
  DIGIT_NUMBER = 4
8
- DIFFICULTIES = [Difficulty.new(name: 'Easy', attempts: 15, hints: 2, order: 3),
9
- Difficulty.new(name: 'Medium', attempts: 10, hints: 1, order: 2),
10
- Difficulty.new(name: 'Hell', attempts: 5, hints: 1, order: 1)].freeze
8
+ DIFFICULTIES = [Easy.new, Medium.new, Hell.new].freeze
11
9
  COMMANDS = %w[hint exit].freeze
12
10
  GUESS_PLACE = '+'
13
11
  GUESS_PRESENCE = '-'
@@ -22,10 +20,12 @@ module Codebreakergem
22
20
  end
23
21
 
24
22
  def show_hint
25
- return I18n.t(:no_hints) unless difficulty.hints.positive?
26
-
27
- difficulty.hints -= 1
28
- secret_code[difficulty.hints]
23
+ if difficulty.hints.positive?
24
+ difficulty.hints -= 1
25
+ secret_code[difficulty.hints]
26
+ else
27
+ I18n.t(:no_hints)
28
+ end
29
29
  end
30
30
 
31
31
  def try_guess(guess)
@@ -48,7 +48,7 @@ module Codebreakergem
48
48
  end
49
49
 
50
50
  def save
51
- source_difficulty = DIFFICULTIES.find { |item| item.name == difficulty.name }
51
+ source_difficulty = DIFFICULTIES.find { |item| item.title == difficulty.title }
52
52
  statistic = Statistic.new(name: user.name, difficulty: difficulty, attempts_total: source_difficulty.attempts,
53
53
  hints_total: source_difficulty.hints)
54
54
  File.file?(FILE) ? FileWorker.add_to_file(FILE, statistic) : FileWorker.write_to_file(FILE, statistic)
@@ -63,7 +63,7 @@ module Codebreakergem
63
63
  index = 0
64
64
  result = I18n.t(:stats_header)
65
65
  data = Array(FileWorker.read_from_file(FILE))
66
- return I18n.t(:no_file) if data.empty?
66
+ return result unless data
67
67
 
68
68
  sorted_data = data.sort_by { |item| [item.difficulty.order, item.attempts_used, item.hints_used] }
69
69
  sorted_data.each { |item| result += stats_constructor(index += 1, item) }
@@ -73,7 +73,7 @@ module Codebreakergem
73
73
  private
74
74
 
75
75
  def stats_constructor(index, item)
76
- "#{index}\t #{item.name}\t #{item.difficulty.name}\t #{item.attempts_total}\t " \
76
+ "#{index}\t #{item.name}\t #{item.difficulty.title}\t #{item.attempts_total}\t " \
77
77
  "#{item.attempts_used}\t #{item.hints_total}\t #{item.hints_used}\n"
78
78
  end
79
79
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Codebreakergem
4
4
  class Statistic
5
- attr_reader :name, :difficulty, :attempts_total,
5
+ attr_accessor :name, :difficulty, :attempts_total,
6
6
  :attempts_used, :hints_total, :hints_used
7
7
 
8
8
  def initialize(name:, difficulty:, attempts_total:, hints_total:)
@@ -3,13 +3,16 @@
3
3
  require 'yaml'
4
4
  require 'i18n'
5
5
  require 'pry'
6
- require './lib/modules/check_module.rb'
7
- require './lib/classes/difficulty.rb'
8
- require './lib/classes/user.rb'
9
- require './lib/classes/game.rb'
10
- require './lib/classes/statistic.rb'
11
- require './lib/classes/file_worker.rb'
12
- require './lib/config.rb'
6
+ require 'modules/check_module.rb'
7
+ require 'classes/difficulties/difficulty.rb'
8
+ require 'classes/difficulties/Easy.rb'
9
+ require 'classes/difficulties/Medium.rb'
10
+ require 'classes/difficulties/Hell.rb'
11
+ require 'classes/user.rb'
12
+ require 'classes/game.rb'
13
+ require 'classes/statistic.rb'
14
+ require 'classes/file_worker'
15
+ require 'config.rb'
13
16
  require 'codebreakergem/version.rb'
14
17
 
15
18
  module Codebreakergem
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Codebreakergem
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.10'
5
5
  end
@@ -1,8 +1,14 @@
1
1
  en:
2
+ class_error: 'Wrong type of variable'
2
3
  length_error: 'Length of the string is not in allowed range'
3
4
  no_hints: 'You have no more hints'
4
- no_file: 'File does not exist'
5
+ hello_message: 'Hello player! Welcome to codebreaker'
5
6
  stats_header: "Rating Name Difficulty Attempts Total Attempts Used Hints Total Hints Used\n"
7
+ menu: "Chose action:\n
8
+ 1) Start\n
9
+ 2) Rules\n
10
+ 3) Stats\n
11
+ 4) Exit\n"
6
12
  victory_message: 'Congratulations!!! YOU WON!!!'
7
13
  out_of_attempts: 'Unfortunately you have no more attempts'
8
14
  rules: " ____________________________________________________________________________________________\n
@@ -38,14 +44,3 @@ en:
38
44
  | * Codebreaker also has some number of hints(depends on chosen difficulty). If a user |\n
39
45
  | takes a hint - he receives back a separate digit of the secret code. |\n
40
46
  |____________________________________________________________________________________________|"
41
- hello_message: 'Hello player! Welcome to codebreaker'
42
- menu: "Chose action:\n
43
- 1) Start\n
44
- 2) Rules\n
45
- 3) Stats\n
46
- 4) Exit\n"
47
- victory_message: 'Congratulations!!! YOU WON!!!'
48
- goodbye_message: "Thank you for playing\nSee you next time"
49
- input_name: "Input player's name:"
50
- difficulty: 'Chose difficulty'
51
- invalid_command: 'You have passed unexpected command. Please choose one from listed commands'
@@ -5,10 +5,7 @@ module Codebreakergem
5
5
  ALLOWED_LENGTH = (3..21).freeze
6
6
 
7
7
  def validate_string_length(incoming_string)
8
- return true if ALLOWED_LENGTH.include? incoming_string.to_s.length
9
-
10
- puts I18n.t(:length_error)
11
- false
8
+ ALLOWED_LENGTH.include?(incoming_string.to_s.length) ? true : false
12
9
  end
13
10
  end
14
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreakergem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sasha
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-30 00:00:00.000000000 Z
11
+ date: 2020-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,11 +73,11 @@ files:
73
73
  - Rakefile
74
74
  - bin/console
75
75
  - bin/setup
76
- - codebreakergem-0.1.6.gem
77
- - codebreakergem-0.1.7.gem
78
- - codebreakergem-0.1.8.gem
79
76
  - codebreakergem.gemspec
80
- - lib/classes/difficulty.rb
77
+ - lib/classes/difficulties/difficulty.rb
78
+ - lib/classes/difficulties/easy.rb
79
+ - lib/classes/difficulties/hell.rb
80
+ - lib/classes/difficulties/medium.rb
81
81
  - lib/classes/file_worker.rb
82
82
  - lib/classes/game.rb
83
83
  - lib/classes/statistic.rb
@@ -86,12 +86,9 @@ files:
86
86
  - lib/codebreakergem/version.rb
87
87
  - lib/config.rb
88
88
  - lib/data/.gitkeep
89
- - lib/data/data.yml
90
89
  - lib/locales/en.yml
91
90
  - lib/locales/ru.yml
92
91
  - lib/modules/check_module.rb
93
- - main.rb
94
- - test.rb
95
92
  homepage: https://github.com/SashaZhuravskiy/CodebreakerGemRepo/
96
93
  licenses:
97
94
  - MIT
Binary file
Binary file
Binary file
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Codebreakergem
4
- class Difficulty
5
- attr_reader :name, :order
6
- attr_accessor :attempts, :hints
7
-
8
- def initialize(name:, attempts:, hints:, order:)
9
- @name = name
10
- @attempts = attempts
11
- @hints = hints
12
- @order = order
13
- end
14
- end
15
- end
@@ -1,23 +0,0 @@
1
- ---
2
- - !ruby/object:Codebreakergem::Statistic
3
- name: Alex
4
- difficulty: !ruby/object:Codebreakergem::Difficulty
5
- name: Easy
6
- attempts: 8
7
- hints: 1
8
- order: 3
9
- attempts_total: 15
10
- attempts_used: 7
11
- hints_total: 2
12
- hints_used: 1
13
- - !ruby/object:Codebreakergem::Statistic
14
- name: Alex
15
- difficulty: !ruby/object:Codebreakergem::Difficulty
16
- name: Medium
17
- attempts: 5
18
- hints: 1
19
- order: 2
20
- attempts_total: 10
21
- attempts_used: 5
22
- hints_total: 1
23
- hints_used: 0
data/main.rb DELETED
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require './lib/codebreakergem.rb'
4
- include Codebreakergem
5
-
6
- def hello_message
7
- puts 'Hello'
8
- end
9
-
10
- def menu
11
- puts "Chose action:\n 1) Start\n 2) Rules\n 3) Stats\n 4) Exit\n"
12
- end
13
-
14
- def goodbye_message
15
- puts "Thank you for playing\nSee you next time"
16
- end
17
-
18
- def play_game
19
- user = nil
20
- user_input = ''
21
- puts "Input player's name:"
22
-
23
- loop do
24
- user = User.new(gets.chomp)
25
- break if user.validate?
26
- end
27
- game = Game.new(user)
28
-
29
- difficulties = Game::DIFFICULTIES.map(&:name)
30
-
31
- loop do
32
- puts "Chose difficulty"
33
- difficulties.each {|key| puts " -#{key}"}
34
- user_input = gets.chomp
35
- break if difficulties.include? user_input
36
- puts "Input one of proposed options"
37
- end
38
- game.difficulty = Game::DIFFICULTIES.find{|item| item.name == user_input}.dup
39
-
40
-
41
- while game.difficulty.attempts.positive? do
42
- puts 'Input your guess:'
43
- user_input = gets.chomp
44
- next unless game.validate_guess(user_input)
45
- if user_input == "hint"
46
- puts game.show_hint
47
- elsif user_input == "exit"
48
- break
49
- else
50
- puts game.try_guess(user_input)
51
- end
52
- end
53
- end
54
-
55
- def game_process
56
- hello_message
57
- loop do
58
- menu
59
- case gets.chomp
60
- when "Start" then play_game
61
- when "Rules" then puts Game.rules
62
- when "Stats" then puts Game.stats
63
- when "Exit" then break
64
- else puts "You have passed unexpected command. Please choose one from listed commands"
65
- end
66
- end
67
- goodbye_message
68
- end
69
-
70
- game_process
data/test.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'i18n'
2
- I18n.load_path = Dir[File.expand_path(__dir__ + '/lib/locales') + '/*.yml']
3
- puts File.expand_path(__dir__ + '/lib/locales') + '/*.yml'
4
- I18n.config.available_locales = :en
5
- I18n.locale = :en
6
-
7
- puts I18n.t(:no_hints)