icodebreaker_gem 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9d9622a8db1d947dc547773bc5dcbf654bc0ad1c18b988ca794334b026a3ec00
4
+ data.tar.gz: 38735f987b4667dcfb146b1b73242a4fd6a3c1e4160a6cf7b760c6fb9d36e4cf
5
+ SHA512:
6
+ metadata.gz: dbf0773f9a7b463a27645be4ea7773d238559bd1c02dd2ead8c28f680a04762a7f28d098123b928c0503c472f79cd417b7719640bcfb20ee844662cc5d69d7e6
7
+ data.tar.gz: 25233a18a435faf6ad2dbd9a776acefea3acfbbc7ea0ee7b4cbe1b7b34642588ecbd66aec9de2be18b659a57d0a2ffe2292ed6159647e905f7d90899f0b21433
data/.fasterer.yml ADDED
@@ -0,0 +1,3 @@
1
+
2
+ exclude_paths:
3
+ - 'vendor/**/*.rb'
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rspec_status ADDED
@@ -0,0 +1,30 @@
1
+ example_id | status | run_time |
2
+ ------------------------------------ | ------ | --------------- |
3
+ ./spec/game_core_spec.rb[1:1] | passed | 0.00038 seconds |
4
+ ./spec/game_core_spec.rb[1:2] | passed | 0.00089 seconds |
5
+ ./spec/game_core_spec.rb[1:3:1] | passed | 0.00064 seconds |
6
+ ./spec/game_core_spec.rb[1:4:1] | passed | 0.00078 seconds |
7
+ ./spec/game_core_spec.rb[1:5:1:1] | passed | 0.00011 seconds |
8
+ ./spec/game_core_spec.rb[1:5:1:2] | passed | 0.0001 seconds |
9
+ ./spec/game_core_spec.rb[1:5:1:3] | passed | 0.00011 seconds |
10
+ ./spec/game_core_spec.rb[1:5:1:4] | passed | 0.00015 seconds |
11
+ ./spec/game_core_spec.rb[1:5:1:5] | passed | 0.00005 seconds |
12
+ ./spec/game_core_spec.rb[1:5:1:6] | passed | 0.00007 seconds |
13
+ ./spec/game_core_spec.rb[1:5:1:7] | passed | 0.00004 seconds |
14
+ ./spec/game_core_spec.rb[1:5:2:1] | passed | 0.00005 seconds |
15
+ ./spec/game_core_spec.rb[1:5:2:2] | passed | 0.00005 seconds |
16
+ ./spec/game_core_spec.rb[1:5:3:1] | passed | 0.00005 seconds |
17
+ ./spec/game_core_spec.rb[1:5:3:2] | passed | 0.00006 seconds |
18
+ ./spec/game_core_spec.rb[1:5:3:3] | passed | 0.00004 seconds |
19
+ ./spec/game_spec.rb[1:1:1] | passed | 0.00012 seconds |
20
+ ./spec/game_spec.rb[1:2:1] | passed | 0.00025 seconds |
21
+ ./spec/game_spec.rb[1:2:2] | passed | 0.00007 seconds |
22
+ ./spec/game_spec.rb[1:2:3] | passed | 0.00008 seconds |
23
+ ./spec/game_spec.rb[1:2:4] | passed | 0.00007 seconds |
24
+ ./spec/game_spec.rb[1:2:5] | passed | 0.00008 seconds |
25
+ ./spec/game_spec.rb[1:3:1] | passed | 0.00058 seconds |
26
+ ./spec/game_spec.rb[1:3:2] | passed | 0.0002 seconds |
27
+ ./spec/game_spec.rb[1:3:3] | passed | 0.00014 seconds |
28
+ ./spec/game_spec.rb[1:4:1] | passed | 0.00012 seconds |
29
+ ./spec/game_spec.rb[1:5:1] | passed | 0.0014 seconds |
30
+ ./spec/icodebreaker_gem_spec.rb[1:1] | passed | 0.0001 seconds |
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - spec/**/*
7
+
8
+ Metrics/ModuleLength:
9
+ Exclude:
10
+ - spec/**/*
11
+
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-09-9
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at vanstrelok@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in icodebreaker_gem.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ icodebreaker_gem (0.1.0)
5
+ rake (~> 13.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ coderay (1.1.3)
12
+ colorize (0.8.1)
13
+ diff-lcs (1.4.4)
14
+ docile (1.4.0)
15
+ fasterer (0.9.0)
16
+ colorize (~> 0.7)
17
+ ruby_parser (>= 3.14.1)
18
+ method_source (1.0.0)
19
+ parallel (1.21.0)
20
+ parser (3.0.2.0)
21
+ ast (~> 2.4.1)
22
+ pry (0.14.1)
23
+ coderay (~> 1.1)
24
+ method_source (~> 1.0)
25
+ rainbow (3.0.0)
26
+ rake (13.0.6)
27
+ regexp_parser (2.1.1)
28
+ rexml (3.2.5)
29
+ rspec (3.10.0)
30
+ rspec-core (~> 3.10.0)
31
+ rspec-expectations (~> 3.10.0)
32
+ rspec-mocks (~> 3.10.0)
33
+ rspec-core (3.10.1)
34
+ rspec-support (~> 3.10.0)
35
+ rspec-expectations (3.10.1)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.10.0)
38
+ rspec-mocks (3.10.2)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-support (3.10.2)
42
+ rubocop (1.21.0)
43
+ parallel (~> 1.10)
44
+ parser (>= 3.0.0.0)
45
+ rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml
48
+ rubocop-ast (>= 1.9.1, < 2.0)
49
+ ruby-progressbar (~> 1.7)
50
+ unicode-display_width (>= 1.4.0, < 3.0)
51
+ rubocop-ast (1.11.0)
52
+ parser (>= 3.0.1.1)
53
+ ruby-progressbar (1.11.0)
54
+ ruby_parser (3.17.0)
55
+ sexp_processor (~> 4.15, >= 4.15.1)
56
+ sexp_processor (4.15.3)
57
+ simplecov (0.21.2)
58
+ docile (~> 1.1)
59
+ simplecov-html (~> 0.11)
60
+ simplecov_json_formatter (~> 0.1)
61
+ simplecov-html (0.12.3)
62
+ simplecov_json_formatter (0.1.3)
63
+ unicode-display_width (2.0.0)
64
+
65
+ PLATFORMS
66
+ x86_64-linux
67
+
68
+ DEPENDENCIES
69
+ fasterer
70
+ icodebreaker_gem!
71
+ pry
72
+ rspec (~> 3.0)
73
+ rubocop (~> 1.7)
74
+ simplecov
75
+
76
+ BUNDLED WITH
77
+ 2.2.26
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 JohnnyGsy
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,43 @@
1
+ # IcodebreakerGem
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/icodebreaker_gem`. 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 'icodebreaker_gem'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install icodebreaker_gem
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 the created tag, 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]/icodebreaker_gem. 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]/icodebreaker_gem/blob/master/CODE_OF_CONDUCT.md).
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 IcodebreakerGem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/icodebreaker_gem/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'icodebreaker_gem'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +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
data/lib/config.rb ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ require 'yaml'
5
+
6
+ require 'modules/validation'
7
+ require 'modules/storage'
8
+
9
+ require 'game_core'
10
+ require 'game'
11
+ require 'icodebreaker_gem/version'
12
+ require 'icodebreaker_gem'
13
+ require 'constants'
data/lib/constants.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IcodebreakerGem
4
+ STATUS = %i[go_on over].freeze
5
+ RESULT = %i[win lose].freeze
6
+ DIFFICULTIES = {
7
+ easy: {
8
+ attempts_total: 15,
9
+ hints_total: 2
10
+ },
11
+ medium: {
12
+ attempts_total: 10,
13
+ hints_total: 1
14
+ },
15
+ hell: {
16
+ attempts_total: 5,
17
+ hints_total: 1
18
+ }
19
+ }.freeze
20
+ end
data/lib/game.rb ADDED
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IcodebreakerGem
4
+ class Game
5
+ include Validation
6
+ include Storage
7
+
8
+ attr_reader :name, :difficulty, :attempts_used, :hints_used, :status, :result
9
+
10
+ def initialize(name = 'User1', difficulty = :easy, secret = GameCore.random)
11
+ validate_name name
12
+ validate_difficulty difficulty
13
+
14
+ @name = name.to_s
15
+ @difficulty = difficulty.to_sym
16
+
17
+ @attempts_used = 0
18
+ @hints_used = 0
19
+
20
+ @status = :go_on
21
+ @result = nil
22
+
23
+ @code = GameCore.new(secret)
24
+ end
25
+
26
+ def attempts_total
27
+ DIFFICULTIES[difficulty][:attempts_total]
28
+ end
29
+
30
+ def hints_total
31
+ DIFFICULTIES[difficulty][:hints_total]
32
+ end
33
+
34
+ def attempt(attempt_code)
35
+ case @status
36
+ when :go_on
37
+ @attempts_used += 1
38
+ answer = @code.compare(attempt_code)
39
+ check_win(answer)
40
+ check_lose
41
+ answer
42
+ when :over
43
+ 'The game is over.'
44
+ end
45
+ end
46
+
47
+ def hint
48
+ case @status
49
+ when :go_on
50
+ return 'No hints left.' if @hints_used >= hints_total
51
+
52
+ @hints_used += 1
53
+ @code.hint
54
+ when :over
55
+ 'The game is over.'
56
+ end
57
+ end
58
+
59
+ def game_data
60
+ {
61
+
62
+ name: name,
63
+ difficulty: difficulty.to_s,
64
+ attempts_total: attempts_total,
65
+ attempts_used: attempts_used,
66
+ hints_total: hints_total,
67
+ hints_used: hints_used
68
+ }
69
+ end
70
+
71
+ private
72
+
73
+ def check_win(answer)
74
+ return unless answer.eql?('++++')
75
+
76
+ @status = :over
77
+ @result = :win
78
+ end
79
+
80
+ def check_lose
81
+ return unless @attempts_used >= attempts_total
82
+
83
+ @status = :over
84
+ @result = :lose
85
+ end
86
+ end
87
+ end
data/lib/game_core.rb ADDED
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IcodebreakerGem
4
+ class GameCore
5
+ include Validation
6
+
7
+ attr_reader :secret
8
+
9
+ def initialize(secret)
10
+ validate_code secret
11
+
12
+ @secret = secret.to_s
13
+ @shuffle = @secret.each_char.to_a.shuffle
14
+ @hint_idx = 0
15
+ end
16
+
17
+ def compare(guess)
18
+ return '++++' if @secret == guess
19
+ return '' if (@secret.each_char.to_a & guess.each_char.to_a).empty?
20
+
21
+ pluses1, minuses1 = pluses_and_minuses(@secret, guess)
22
+
23
+ pluses2, minuses2 = pluses_and_minuses(guess, @secret)
24
+
25
+ '+' * [pluses1, pluses2].min + '-' * [minuses1, minuses2].min
26
+ end
27
+
28
+ def hint
29
+ result = @shuffle[@hint_idx]
30
+ @hint_idx += 1
31
+ @hint_idx = 0 if @hint_idx >= @shuffle.size
32
+ result
33
+ end
34
+
35
+ def self.random
36
+ (0..3).map { rand(1..6) }.map(&:to_s).join
37
+ end
38
+
39
+ private
40
+
41
+ def pluses_and_minuses(word1, word2)
42
+ pluses = minuses = 0
43
+ word1.each_char.to_a.each_index do |index|
44
+ if word2[index] == word1[index]
45
+ pluses += 1
46
+ elsif word2.include? word1[index]
47
+ minuses += 1
48
+ end
49
+ end
50
+ [pluses, minuses]
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IcodebreakerGem
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'icodebreaker_gem/version'
4
+
5
+ module IcodebreakerGem
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IcodebreakerGem
4
+ module Storage
5
+ DATA_FILE = 'codebreakers.yml'
6
+ STORAGE_PATH = './storage/'
7
+ def save_storage(game)
8
+ create_storage
9
+ games = load_storage
10
+ games << game
11
+ File.open(data_path, 'w') do |file|
12
+ YAML.dump(games, file)
13
+ end
14
+ end
15
+
16
+ def load_storage
17
+ create_storage
18
+ YAML.load(File.read(data_path)) || []
19
+ end
20
+
21
+ def sort_codebreakers
22
+ load_storage.sort_by do |statistic|
23
+ [statistic[:attempts_total], statistic[:attempts_used], statistic[:hints_used]]
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def data_path
30
+ STORAGE_PATH + DATA_FILE
31
+ end
32
+
33
+ def create_storage
34
+ Dir.mkdir(STORAGE_PATH) unless File.exist?(STORAGE_PATH)
35
+ File.open(data_path, 'w') unless File.exist?(data_path)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IcodebreakerGem
4
+ module Validation
5
+ def validate_name(name)
6
+ raise ArgumentError, 'Incorrect username' unless name.to_s.match?(/^[0-9a-zA-Z]{3,20}$/)
7
+ end
8
+
9
+ def validate_code(code)
10
+ raise ArgumentError, 'Incorrect code' unless code.to_s.match?(/^[1-6]{4}$/)
11
+ end
12
+
13
+ def validate_difficulty(difficulty)
14
+ raise ArgumentError, 'No such difficulty' unless %i[easy medium hell].include? difficulty.to_s.to_sym
15
+ end
16
+ end
17
+ end
data/reek.yml ADDED
@@ -0,0 +1,2 @@
1
+ exclude_paths:
2
+ - vendor
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icodebreaker_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - JohnnyGsy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fasterer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Guess the secret code
98
+ email:
99
+ - vanstrelok@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".fasterer.yml"
105
+ - ".rspec"
106
+ - ".rspec_status"
107
+ - ".rubocop.yml"
108
+ - ".ruby-version"
109
+ - CHANGELOG.md
110
+ - CODE_OF_CONDUCT.md
111
+ - Gemfile
112
+ - Gemfile.lock
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - bin/console
117
+ - bin/setup
118
+ - lib/config.rb
119
+ - lib/constants.rb
120
+ - lib/game.rb
121
+ - lib/game_core.rb
122
+ - lib/icodebreaker_gem.rb
123
+ - lib/icodebreaker_gem/version.rb
124
+ - lib/modules/storage.rb
125
+ - lib/modules/validation.rb
126
+ - reek.yml
127
+ homepage: https://github.com/JohnnyGsy/icodebreaker_gem
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 2.7.0
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubygems_version: 3.2.26
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: The codebreaker game.
150
+ test_files: []