codebreaker_volkova 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +36 -0
- data/.fasterer.yml +24 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/codebreaker_volkova.gemspec +39 -0
- data/lib/codebreaker_volkova.rb +20 -0
- data/lib/codebreaker_volkova/errors/difficulty_error.rb +11 -0
- data/lib/codebreaker_volkova/errors/empty_string_error.rb +11 -0
- data/lib/codebreaker_volkova/errors/guess_error.rb +11 -0
- data/lib/codebreaker_volkova/errors/guess_length_error.rb +11 -0
- data/lib/codebreaker_volkova/errors/nil_string_error.rb +11 -0
- data/lib/codebreaker_volkova/errors/user_name_error.rb +11 -0
- data/lib/codebreaker_volkova/errors/wrong_class_error.rb +11 -0
- data/lib/codebreaker_volkova/game_business_logic.rb +51 -0
- data/lib/codebreaker_volkova/game_progress.rb +110 -0
- data/lib/codebreaker_volkova/validation/validator.rb +44 -0
- data/lib/codebreaker_volkova/version.rb +5 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29f994ae2e63cc47ef1ee2311f5c49959df71c9cdcbe9bc6596f3ea87a5373b9
|
4
|
+
data.tar.gz: 5066170cabbfbae65d6e1d5e60bd89248404a9d762a53b1d6f03b26d5ad7e007
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2aa0ddcfe87bed78759c0712947f68cc11b03eb25f7c4a2a37ff52416867ed1dc48129b0ae389a3dab0a7427a65a03b0f6ffbe782c505afa5ee31614be5588e
|
7
|
+
data.tar.gz: 3d6bffccb565699505b3b7a1cba5c454163065b7200c3036c9892c253c221e7240d2659e77275309bbdaf960a830aabc78ae39dc4281703a074a00b1d4ef4645
|
@@ -0,0 +1,36 @@
|
|
1
|
+
version: 2.1
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.6.3
|
6
|
+
|
7
|
+
steps:
|
8
|
+
- checkout
|
9
|
+
|
10
|
+
- restore_cache:
|
11
|
+
keys:
|
12
|
+
- gem-cache-v1-{{ checksum "Gemfile.lock" }}
|
13
|
+
- gem-cache-v1-
|
14
|
+
|
15
|
+
- run:
|
16
|
+
name: Install dependencies
|
17
|
+
command: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --path vendor/bundle
|
20
|
+
- save_cache:
|
21
|
+
key: gem-cache-v1-{{ checksum "Gemfile.lock" }}
|
22
|
+
paths:
|
23
|
+
- vendor/bundle
|
24
|
+
|
25
|
+
- run:
|
26
|
+
name: Run tests
|
27
|
+
command: bundle exec rspec
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: Run rubocop
|
31
|
+
command: bundle exec rubocop
|
32
|
+
|
33
|
+
- run:
|
34
|
+
name: Run fasterer
|
35
|
+
command: bundle exec fasterer
|
36
|
+
|
data/.fasterer.yml
ADDED
@@ -0,0 +1,24 @@
|
|
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: true
|
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
|
20
|
+
|
21
|
+
exclude_paths:
|
22
|
+
- spec/**/*.rb
|
23
|
+
- 'vendor/**/*.rb'
|
24
|
+
- 'db/schema.rb'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
Style/Documentation:
|
3
|
+
Enabled: false
|
4
|
+
|
5
|
+
Metrics/LineLength:
|
6
|
+
Max: 120
|
7
|
+
|
8
|
+
Style/FrozenStringLiteralComment:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
ExcludedMethods: ['describe','context']
|
13
|
+
|
14
|
+
Layout/DefEndAlignment:
|
15
|
+
AutoCorrect: true
|
16
|
+
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
codebreaker_volkova (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
colorize (0.8.1)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
docile (1.3.2)
|
13
|
+
fasterer (0.5.1)
|
14
|
+
colorize (~> 0.7)
|
15
|
+
ruby_parser (>= 3.13.0)
|
16
|
+
jaro_winkler (1.5.4)
|
17
|
+
json (2.3.0)
|
18
|
+
parallel (1.19.1)
|
19
|
+
parser (2.6.5.0)
|
20
|
+
ast (~> 2.4.0)
|
21
|
+
rainbow (3.0.0)
|
22
|
+
rake (10.5.0)
|
23
|
+
rspec (3.9.0)
|
24
|
+
rspec-core (~> 3.9.0)
|
25
|
+
rspec-expectations (~> 3.9.0)
|
26
|
+
rspec-mocks (~> 3.9.0)
|
27
|
+
rspec-core (3.9.0)
|
28
|
+
rspec-support (~> 3.9.0)
|
29
|
+
rspec-expectations (3.9.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.9.0)
|
32
|
+
rspec-mocks (3.9.0)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.9.0)
|
35
|
+
rspec-support (3.9.0)
|
36
|
+
rubocop (0.77.0)
|
37
|
+
jaro_winkler (~> 1.5.1)
|
38
|
+
parallel (~> 1.10)
|
39
|
+
parser (>= 2.6)
|
40
|
+
rainbow (>= 2.2.2, < 4.0)
|
41
|
+
ruby-progressbar (~> 1.7)
|
42
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
43
|
+
ruby-progressbar (1.10.1)
|
44
|
+
ruby_parser (3.14.1)
|
45
|
+
sexp_processor (~> 4.9)
|
46
|
+
sexp_processor (4.13.0)
|
47
|
+
simplecov (0.17.1)
|
48
|
+
docile (~> 1.1)
|
49
|
+
json (>= 1.8, < 3)
|
50
|
+
simplecov-html (~> 0.10.0)
|
51
|
+
simplecov-html (0.10.2)
|
52
|
+
unicode-display_width (1.6.0)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
bundler (~> 2.0)
|
59
|
+
codebreaker_volkova!
|
60
|
+
fasterer (~> 0.5.1)
|
61
|
+
rake (~> 10.0)
|
62
|
+
rspec (~> 3.0)
|
63
|
+
rubocop
|
64
|
+
simplecov
|
65
|
+
|
66
|
+
BUNDLED WITH
|
67
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 AnastasiusW
|
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,39 @@
|
|
1
|
+
# CodebreakerVolkova
|
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_volkova`. 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_volkova'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install codebreaker_volkova
|
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_volkova.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
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 'codebreaker_volkova'
|
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,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'codebreaker_volkova/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'codebreaker_volkova'
|
9
|
+
spec.version = CodebreakerVolkova::VERSION
|
10
|
+
spec.authors = ['AnastasiusW']
|
11
|
+
spec.email = ['repositoryanastasiia@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Codebraker is game'
|
14
|
+
spec.description = 'Task for rubyGarage'
|
15
|
+
spec.homepage = 'https://github.com/AnastasiusW'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
|
+
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/AnastasiusW'
|
22
|
+
spec.metadata['changelog_uri'] = 'https://github.com/AnastasiusW'
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = 'exe'
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ['lib']
|
32
|
+
|
33
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
34
|
+
spec.add_development_dependency 'fasterer', '~> 0.5.1'
|
35
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
+
spec.add_development_dependency 'rubocop'
|
38
|
+
spec.add_development_dependency 'simplecov'
|
39
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'codebreaker_volkova/version'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
require_relative 'codebreaker_volkova/errors/difficulty_error'
|
7
|
+
require_relative 'codebreaker_volkova/errors/empty_string_error'
|
8
|
+
require_relative 'codebreaker_volkova/errors/guess_error'
|
9
|
+
require_relative 'codebreaker_volkova/errors/guess_length_error'
|
10
|
+
require_relative 'codebreaker_volkova/errors/nil_string_error'
|
11
|
+
require_relative 'codebreaker_volkova/errors/user_name_error'
|
12
|
+
require_relative 'codebreaker_volkova/errors/wrong_class_error'
|
13
|
+
require_relative 'codebreaker_volkova/game_business_logic'
|
14
|
+
require_relative 'codebreaker_volkova/validation/validator'
|
15
|
+
require_relative 'codebreaker_volkova/game_progress'
|
16
|
+
|
17
|
+
module CodebreakerVolkova
|
18
|
+
class Error < StandardError; end
|
19
|
+
# Your code goes here...
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CodebreakerVolkova
|
4
|
+
module GameBusinessLogic
|
5
|
+
DIFFICULTIES = {
|
6
|
+
easy: {
|
7
|
+
attempts: 15,
|
8
|
+
hints: 2,
|
9
|
+
level: 3
|
10
|
+
},
|
11
|
+
medium: {
|
12
|
+
attempts: 10,
|
13
|
+
hints: 1,
|
14
|
+
level: 2
|
15
|
+
},
|
16
|
+
hell: {
|
17
|
+
attempts: 5,
|
18
|
+
hints: 1,
|
19
|
+
level: 1
|
20
|
+
}
|
21
|
+
}.freeze
|
22
|
+
|
23
|
+
RESULT_MINUS = '-'
|
24
|
+
RESULT_PLUS = '+'
|
25
|
+
|
26
|
+
def take_attempt(difficulty)
|
27
|
+
DIFFICULTIES.dig(difficulty.to_sym, :attempts)
|
28
|
+
end
|
29
|
+
|
30
|
+
def take_hint(difficulty)
|
31
|
+
DIFFICULTIES.dig(difficulty.to_sym, :hints)
|
32
|
+
end
|
33
|
+
|
34
|
+
def take_pluses(secret_code, input_code)
|
35
|
+
secret_code.zip(input_code).count { |a, b| a == b }
|
36
|
+
end
|
37
|
+
|
38
|
+
def take_result(secret_code, input_code)
|
39
|
+
overlap = (secret_code & input_code).map do |value|
|
40
|
+
[secret_code.count(value), input_code.count(value)].min
|
41
|
+
end
|
42
|
+
pluses = take_pluses(secret_code, input_code)
|
43
|
+
minuses = overlap.sum - pluses
|
44
|
+
RESULT_PLUS * pluses + RESULT_MINUS * minuses
|
45
|
+
end
|
46
|
+
|
47
|
+
def take_level_of_difficulty(difficulty)
|
48
|
+
DIFFICULTIES.dig(difficulty.to_sym, :level)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CodebreakerVolkova
|
4
|
+
class Game
|
5
|
+
include GameBusinessLogic
|
6
|
+
include Validator
|
7
|
+
|
8
|
+
attr_reader :username, :difficulty, :hints, :attempts, :attempts_total,
|
9
|
+
:hints_total, :secret_code, :game_over
|
10
|
+
|
11
|
+
FILENAME = 'store.yml'
|
12
|
+
SIGN_CONSTANT = 4
|
13
|
+
NUMBER_CONSTANT = 6
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@game_over = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def start
|
20
|
+
@secret_code = generate_secret_number
|
21
|
+
@hints_code = @secret_code.dup.shuffle
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_name(name)
|
25
|
+
validate_name(name)
|
26
|
+
@username = name
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_difficulty(difficulty)
|
30
|
+
validate_difficulty(difficulty)
|
31
|
+
@difficulty = difficulty
|
32
|
+
@attempts_total = take_attempt(difficulty)
|
33
|
+
@attempts = @attempts_total
|
34
|
+
@hints_total = take_hint(difficulty)
|
35
|
+
@hints = @hints_total
|
36
|
+
end
|
37
|
+
|
38
|
+
def check_result(guess)
|
39
|
+
validate_guess(guess)
|
40
|
+
guess = guess.each_char.map(&:to_i)
|
41
|
+
result = take_result(@secret_code, guess)
|
42
|
+
@game_over = true if result == GameBusinessLogic::RESULT_PLUS * 4
|
43
|
+
@attempts -= 1
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
def attempts?
|
48
|
+
@attempts.positive?
|
49
|
+
end
|
50
|
+
|
51
|
+
def hints?
|
52
|
+
return false unless @hints.positive?
|
53
|
+
|
54
|
+
@hints -= 1
|
55
|
+
@hints_code.pop
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_secret_number(sign = SIGN_CONSTANT, number = NUMBER_CONSTANT)
|
59
|
+
Array.new(sign) { rand(1..number) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def save_stats(filename_path = FILENAME)
|
63
|
+
File.open(filename_path, 'a') do |file|
|
64
|
+
file.write(convert_to_hash.to_yaml)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def convert_to_hash
|
69
|
+
{
|
70
|
+
name: @username,
|
71
|
+
difficulty: @difficulty,
|
72
|
+
attempts_total: @attempts_total,
|
73
|
+
attempts_used: @attempts_total - @attempts,
|
74
|
+
hints_total: @hints_total,
|
75
|
+
hints_used: @hints_total - @hints
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def load_stats(filename_path = FILENAME)
|
80
|
+
return false unless File.exist?(filename_path)
|
81
|
+
return false if File.zero?(filename_path)
|
82
|
+
|
83
|
+
documents = YAML.load_stream(File.open(filename_path))
|
84
|
+
documents.map.sort_by do |item|
|
85
|
+
[take_level_of_difficulty(item[:difficulty]), item[:attempts_used], item[:hints_used]]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def validate_name(name)
|
92
|
+
instance?(String, name)
|
93
|
+
not_empty?(name)
|
94
|
+
check_length_name?(name)
|
95
|
+
end
|
96
|
+
|
97
|
+
def validate_guess(guess)
|
98
|
+
instance?(Integer, guess.to_i)
|
99
|
+
not_empty?(guess)
|
100
|
+
check_length_guess?(guess)
|
101
|
+
check_constituents_guess?(guess)
|
102
|
+
end
|
103
|
+
|
104
|
+
def validate_difficulty(difficulty)
|
105
|
+
instance?(String, difficulty)
|
106
|
+
not_empty?(difficulty)
|
107
|
+
check_constituents_difficulty?(difficulty)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CodebreakerVolkova
|
4
|
+
module Validator
|
5
|
+
include Errors
|
6
|
+
|
7
|
+
VALID_NAME_LENGTH = (3..20).freeze
|
8
|
+
VALID_NUMBERS = (1..6).freeze
|
9
|
+
VALID_GUESS_LENGTH = 4
|
10
|
+
LEVEL_OF_GAME = %w[easy medium hell].freeze
|
11
|
+
|
12
|
+
def not_empty?(*args)
|
13
|
+
args.each do |arg|
|
14
|
+
raise NilStringError if arg.nil?
|
15
|
+
raise EmptyStringError if arg.empty?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def instance?(main_class, *args)
|
20
|
+
args.each do |object|
|
21
|
+
raise NilStringError if object.nil?
|
22
|
+
raise WrongClassError unless object.instance_of?(main_class)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def check_length_name?(arg)
|
27
|
+
raise UserNameError unless VALID_NAME_LENGTH.include?(arg.length)
|
28
|
+
end
|
29
|
+
|
30
|
+
def check_length_guess?(guess)
|
31
|
+
raise GuessLengthError unless guess.length == VALID_GUESS_LENGTH
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_constituents_guess?(guess)
|
35
|
+
raise GuessError unless guess.each_char.map(&:to_i).all? do |num|
|
36
|
+
VALID_NUMBERS.include?(num)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def check_constituents_difficulty?(difficulty)
|
41
|
+
raise DifficultyError unless LEVEL_OF_GAME.include? difficulty
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codebreaker_volkova
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- AnastasiusW
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.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.5.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.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: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
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: Task for rubyGarage
|
98
|
+
email:
|
99
|
+
- repositoryanastasiia@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".circleci/config.yml"
|
105
|
+
- ".fasterer.yml"
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".rubocop.yml"
|
109
|
+
- ".travis.yml"
|
110
|
+
- Gemfile
|
111
|
+
- Gemfile.lock
|
112
|
+
- LICENSE.txt
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/console
|
116
|
+
- bin/setup
|
117
|
+
- codebreaker_volkova.gemspec
|
118
|
+
- lib/codebreaker_volkova.rb
|
119
|
+
- lib/codebreaker_volkova/errors/difficulty_error.rb
|
120
|
+
- lib/codebreaker_volkova/errors/empty_string_error.rb
|
121
|
+
- lib/codebreaker_volkova/errors/guess_error.rb
|
122
|
+
- lib/codebreaker_volkova/errors/guess_length_error.rb
|
123
|
+
- lib/codebreaker_volkova/errors/nil_string_error.rb
|
124
|
+
- lib/codebreaker_volkova/errors/user_name_error.rb
|
125
|
+
- lib/codebreaker_volkova/errors/wrong_class_error.rb
|
126
|
+
- lib/codebreaker_volkova/game_business_logic.rb
|
127
|
+
- lib/codebreaker_volkova/game_progress.rb
|
128
|
+
- lib/codebreaker_volkova/validation/validator.rb
|
129
|
+
- lib/codebreaker_volkova/version.rb
|
130
|
+
homepage: https://github.com/AnastasiusW
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata:
|
134
|
+
allowed_push_host: https://rubygems.org
|
135
|
+
homepage_uri: https://github.com/AnastasiusW
|
136
|
+
source_code_uri: https://github.com/AnastasiusW
|
137
|
+
changelog_uri: https://github.com/AnastasiusW
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubygems_version: 3.0.3
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Codebraker is game
|
157
|
+
test_files: []
|