rg-codebreaker-gem. 0.0.1
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/.circleci/config.yml +72 -0
- data/.fasterer.yml +23 -0
- data/.gitignore +11 -0
- data/.overcommit.yml +24 -0
- data/.rspec +3 -0
- data/.rubocop.yml +16 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/codebreaker/game.rb +82 -0
- data/lib/codebreaker/version.rb +3 -0
- data/lib/difficulty.rb +19 -0
- data/lib/errors/code_length_error.rb +9 -0
- data/lib/errors/code_range_error.rb +9 -0
- data/lib/errors/include_error.rb +9 -0
- data/lib/errors/length_error.rb +9 -0
- data/lib/locale_config.rb +3 -0
- data/lib/messages/en.yml +5 -0
- data/lib/storage.rb +21 -0
- data/lib/user.rb +12 -0
- data/lib/validate.rb +22 -0
- data/rg-codebreaker-gem.gemspec +46 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: eddb59c7a754ea1541652e3b5fee8aba95638cc16c288f7a3a2945bbd92ff9fa
|
4
|
+
data.tar.gz: c1e1b898f02d8ee0110095a0eccde50e14c7180bc68c7e0f88dff4de45819cb5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cf912eaf3dece3d3aacb73c5e885fcff1752c41f311dfb71b85b6ba8771043e11b2b14fa0eb24aec3ad738c681271ab8ad3ce85a02030162692618017a408831
|
7
|
+
data.tar.gz: 3f746d4ee6234b90f7d95a3f76aa5cdd92cb7d3dd67c4d570e3826045611030a64e41c4095ef07af7bb9bc495d14f1e633aa06b3004ac854c2cb545085c0dce4
|
@@ -0,0 +1,72 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
executors:
|
4
|
+
default:
|
5
|
+
working_directory: ~/codebreaker
|
6
|
+
description: Codebreaker gem
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.6.3
|
9
|
+
|
10
|
+
caches:
|
11
|
+
- &bundle_cache_full v1-codebreaker-{{ checksum "Gemfile.lock" }}
|
12
|
+
- &bundle_cache v1-codebreaker
|
13
|
+
|
14
|
+
commands:
|
15
|
+
setup_environment:
|
16
|
+
steps:
|
17
|
+
- checkout
|
18
|
+
- restore_cache:
|
19
|
+
keys:
|
20
|
+
- *bundle_cache_full
|
21
|
+
- *bundle_cache
|
22
|
+
- run:
|
23
|
+
name: Force Bundler Version
|
24
|
+
command: bundle install --path vendor/bundle
|
25
|
+
- save_cache:
|
26
|
+
paths:
|
27
|
+
- vendor/bundle
|
28
|
+
key: *bundle_cache_full
|
29
|
+
run_linters:
|
30
|
+
description: Start lintering
|
31
|
+
steps:
|
32
|
+
- run:
|
33
|
+
name: rubocop
|
34
|
+
command: bundle exec rubocop
|
35
|
+
- run:
|
36
|
+
name: fasterer
|
37
|
+
command: bundle exec fasterer
|
38
|
+
run_specs:
|
39
|
+
description: Run specs
|
40
|
+
steps:
|
41
|
+
- run:
|
42
|
+
name: run spec
|
43
|
+
command: |
|
44
|
+
mkdir /tmp/test-results
|
45
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
46
|
+
bundle exec rspec --format progress \
|
47
|
+
--out /tmp/test-results/rspec.xml \
|
48
|
+
$TEST_FILES
|
49
|
+
- store_artifacts:
|
50
|
+
path: coverage
|
51
|
+
|
52
|
+
jobs:
|
53
|
+
lintering:
|
54
|
+
executor: default
|
55
|
+
steps:
|
56
|
+
- setup_environment
|
57
|
+
- run_linters
|
58
|
+
run_specs:
|
59
|
+
executor: default
|
60
|
+
steps:
|
61
|
+
- setup_environment
|
62
|
+
- run_specs
|
63
|
+
|
64
|
+
workflows:
|
65
|
+
version: 2
|
66
|
+
build:
|
67
|
+
jobs:
|
68
|
+
- lintering
|
69
|
+
- run_specs:
|
70
|
+
requires:
|
71
|
+
- lintering
|
72
|
+
|
data/.fasterer.yml
ADDED
@@ -0,0 +1,23 @@
|
|
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
|
20
|
+
|
21
|
+
exclude_paths:
|
22
|
+
- "vendor/**/*.rb"
|
23
|
+
|
data/.gitignore
ADDED
data/.overcommit.yml
ADDED
@@ -0,0 +1,24 @@
|
|
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
|
22
|
+
|
23
|
+
TrailingWhitespace:
|
24
|
+
enabled: true
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
Style/FrozenStringLiteralComment:
|
4
|
+
Enabled: false
|
5
|
+
|
6
|
+
RSpec/LeakyConstantDeclaration:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Style/Documentation:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Exclude:
|
14
|
+
- 'Rakefile'
|
15
|
+
- '**/*.rake'
|
16
|
+
- 'spec/**/*.rb'
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rg-codebreaker-gem. (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.1)
|
10
|
+
childprocess (4.0.0)
|
11
|
+
colorize (0.8.1)
|
12
|
+
concurrent-ruby (1.1.6)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
docile (1.3.2)
|
15
|
+
fasterer (0.8.3)
|
16
|
+
colorize (~> 0.7)
|
17
|
+
ruby_parser (>= 3.14.1)
|
18
|
+
i18n (1.8.5)
|
19
|
+
concurrent-ruby (~> 1.0)
|
20
|
+
iniparse (1.5.0)
|
21
|
+
overcommit (0.55.0)
|
22
|
+
childprocess (>= 0.6.3, < 5)
|
23
|
+
iniparse (~> 1.4)
|
24
|
+
parallel (1.19.2)
|
25
|
+
parser (2.7.1.4)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
rainbow (3.0.0)
|
28
|
+
rake (10.5.0)
|
29
|
+
regexp_parser (1.7.1)
|
30
|
+
rexml (3.2.4)
|
31
|
+
rspec (3.9.0)
|
32
|
+
rspec-core (~> 3.9.0)
|
33
|
+
rspec-expectations (~> 3.9.0)
|
34
|
+
rspec-mocks (~> 3.9.0)
|
35
|
+
rspec-core (3.9.2)
|
36
|
+
rspec-support (~> 3.9.3)
|
37
|
+
rspec-expectations (3.9.2)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.9.0)
|
40
|
+
rspec-mocks (3.9.1)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.9.0)
|
43
|
+
rspec-support (3.9.3)
|
44
|
+
rubocop (0.88.0)
|
45
|
+
parallel (~> 1.10)
|
46
|
+
parser (>= 2.7.1.1)
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.7)
|
49
|
+
rexml
|
50
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
51
|
+
ruby-progressbar (~> 1.7)
|
52
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
53
|
+
rubocop-ast (0.2.0)
|
54
|
+
parser (>= 2.7.0.1)
|
55
|
+
rubocop-rspec (1.42.0)
|
56
|
+
rubocop (>= 0.87.0)
|
57
|
+
ruby-progressbar (1.10.1)
|
58
|
+
ruby_parser (3.14.2)
|
59
|
+
sexp_processor (~> 4.9)
|
60
|
+
sexp_processor (4.15.0)
|
61
|
+
simplecov (0.18.5)
|
62
|
+
docile (~> 1.1)
|
63
|
+
simplecov-html (~> 0.11)
|
64
|
+
simplecov-html (0.12.2)
|
65
|
+
terminal-table (1.8.0)
|
66
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
67
|
+
unicode-display_width (1.7.0)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bundler (~> 1.17)
|
74
|
+
fasterer
|
75
|
+
i18n
|
76
|
+
overcommit
|
77
|
+
rake (~> 10.0)
|
78
|
+
rg-codebreaker-gem.!
|
79
|
+
rspec (~> 3.0)
|
80
|
+
rubocop
|
81
|
+
rubocop-rspec
|
82
|
+
simplecov
|
83
|
+
terminal-table
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 TODO: Write your name
|
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
|
+
# 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 'rg-codebreaker-gem'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rg-codebreaker-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 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 [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 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
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'psych'
|
2
|
+
require 'i18n'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'validate.rb'
|
5
|
+
require 'locale_config.rb'
|
6
|
+
require 'errors/code_length_error.rb'
|
7
|
+
require 'errors/code_range_error.rb'
|
8
|
+
require 'errors/include_error.rb'
|
9
|
+
require 'errors/length_error.rb'
|
10
|
+
require 'storage.rb'
|
11
|
+
require 'user.rb'
|
12
|
+
require 'difficulty.rb'
|
13
|
+
require 'codebreaker/version'
|
14
|
+
|
15
|
+
module Codebreaker
|
16
|
+
class Error < StandardError; end
|
17
|
+
|
18
|
+
class Game
|
19
|
+
include Errors
|
20
|
+
attr_reader :user, :count_minus, :count_plus, :difficulty, :attempts, :hints, :secret_hash
|
21
|
+
|
22
|
+
LENGTH_CODE = 4
|
23
|
+
RANGE_SECRET_NUMBER = 6
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@secret_hash = generate_secret
|
27
|
+
@number_for_hint = @secret_hash.values.shuffle
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_secret
|
31
|
+
Hash[(0...LENGTH_CODE).zip Array.new(LENGTH_CODE) { rand(1...RANGE_SECRET_NUMBER) }]
|
32
|
+
end
|
33
|
+
|
34
|
+
def change_secret_hash(hash)
|
35
|
+
@secret_hash = hash
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_user(name)
|
39
|
+
@user = User.new(name)
|
40
|
+
end
|
41
|
+
|
42
|
+
def choose_difficulty(difficulty)
|
43
|
+
@difficulty = Difficulty.new(difficulty)
|
44
|
+
@attempts = @difficulty.attempts
|
45
|
+
@hints = @difficulty.hints
|
46
|
+
end
|
47
|
+
|
48
|
+
def hint!
|
49
|
+
return false if @hints.zero?
|
50
|
+
|
51
|
+
@hints -= 1
|
52
|
+
@number_for_hint.pop
|
53
|
+
end
|
54
|
+
|
55
|
+
def check_attempt(user_string)
|
56
|
+
Validate.code_length?(user_string)
|
57
|
+
Validate.code_range?(user_string)
|
58
|
+
@user_hash = Hash[(0..LENGTH_CODE).zip user_string.split('').map(&:to_i)]
|
59
|
+
@attempts -= 1
|
60
|
+
compare_hashes(@secret_hash)
|
61
|
+
end
|
62
|
+
|
63
|
+
def compare_hashes(secret_hash)
|
64
|
+
@count_plus = 0
|
65
|
+
@count_minus = 0
|
66
|
+
secret_hash.merge(@user_hash) do |_k, o, n|
|
67
|
+
@user_hash.reject! { |_key, val| val == n } && @count_plus += 1 if o == n
|
68
|
+
end
|
69
|
+
secret_hash.select { |_, value| @user_hash.value? value }.size.times { @count_minus += 1 }
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_h
|
73
|
+
{ name: @user.name, difficult: @difficulty.title,
|
74
|
+
total_attempts: @difficulty.attempts, attempts: @attempts,
|
75
|
+
total_hints: @difficulty.hints, hints: @hints }
|
76
|
+
end
|
77
|
+
|
78
|
+
def save
|
79
|
+
Storage.new.save_to_file(to_h)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/lib/difficulty.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Codebreaker
|
2
|
+
class Difficulty
|
3
|
+
attr_reader :title, :attempts, :hints, :difficulty
|
4
|
+
|
5
|
+
LIST = {
|
6
|
+
easy: { attempts: 15, hints: 2, title: 'easy' },
|
7
|
+
medium: { attempts: 10, hints: 1, title: 'medium' },
|
8
|
+
hell: { attempts: 5, hints: 1, title: 'hell' }
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def initialize(difficulty)
|
12
|
+
Validate.include?(LIST.keys, difficulty.to_sym)
|
13
|
+
difficulty = LIST[difficulty.to_sym]
|
14
|
+
@attempts = difficulty[:attempts]
|
15
|
+
@hints = difficulty[:hints]
|
16
|
+
@title = difficulty[:title]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/messages/en.yml
ADDED
data/lib/storage.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Codebreaker
|
2
|
+
class Storage
|
3
|
+
PATH_TO_FILE = 'db/statistics.yml'.freeze
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
Dir.mkdir(File.dirname(PATH_TO_FILE)) && File.new(PATH_TO_FILE, 'w') unless file_exist?
|
7
|
+
end
|
8
|
+
|
9
|
+
def save_to_file(data)
|
10
|
+
File.open(PATH_TO_FILE, 'a') { |file| file.write(data.to_yaml) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def file_exist?
|
14
|
+
File.exist?(PATH_TO_FILE)
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_from_file
|
18
|
+
Psych.load_stream(File.read(PATH_TO_FILE))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/user.rb
ADDED
data/lib/validate.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Codebreaker
|
2
|
+
class Validate
|
3
|
+
def self.length?(verifiable_value, minimum, maximum)
|
4
|
+
raise Codebreaker::Errors::LengthError unless verifiable_value.size.between?(minimum, maximum)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.include?(check_values, verifiable_value)
|
8
|
+
error = Codebreaker::Errors::IncludeError.new(check_values, verifiable_value)
|
9
|
+
raise error unless check_values.include?(verifiable_value)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.code_length?(user_string)
|
13
|
+
length_code = Codebreaker::Game::LENGTH_CODE
|
14
|
+
raise Codebreaker::Errors::CodeLengthError unless user_string.size.between?(length_code, length_code)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.code_range?(user_string)
|
18
|
+
range = (1..Codebreaker::Game::RANGE_SECRET_NUMBER)
|
19
|
+
raise Codebreaker::Errors::CodeRangeError unless user_string.chars.all? { |number| range.include?(number.to_i) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'codebreaker/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'rg-codebreaker-gem.'
|
7
|
+
spec.version = Codebreaker::VERSION
|
8
|
+
spec.authors = ['Anastasiia04']
|
9
|
+
spec.email = ['anastasiamoskalenko04@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'This gem help to create a guessing game.'
|
12
|
+
spec.homepage = 'https://github.com/Anastasiia04/rg-codebreaker-gem.'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
# if spec.respond_to?(:metadata)
|
18
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
19
|
+
|
20
|
+
# spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
# spec.metadata['source_code_uri'] = 'https://github.com/Anastasiia04/codebreaker'
|
22
|
+
# else
|
23
|
+
# raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
|
+
# 'public gem pushes.'
|
25
|
+
# end
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = 'exe'
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ['lib']
|
35
|
+
|
36
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
37
|
+
spec.add_development_dependency 'fasterer'
|
38
|
+
spec.add_development_dependency 'i18n'
|
39
|
+
spec.add_development_dependency 'overcommit'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
+
spec.add_development_dependency 'rubocop'
|
43
|
+
spec.add_development_dependency 'rubocop-rspec'
|
44
|
+
spec.add_development_dependency 'simplecov'
|
45
|
+
spec.add_development_dependency 'terminal-table'
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rg-codebreaker-gem.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anastasiia04
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-04 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: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
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: i18n
|
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: overcommit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: terminal-table
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description:
|
154
|
+
email:
|
155
|
+
- anastasiamoskalenko04@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".circleci/config.yml"
|
161
|
+
- ".fasterer.yml"
|
162
|
+
- ".gitignore"
|
163
|
+
- ".overcommit.yml"
|
164
|
+
- ".rspec"
|
165
|
+
- ".rubocop.yml"
|
166
|
+
- ".travis.yml"
|
167
|
+
- Gemfile
|
168
|
+
- Gemfile.lock
|
169
|
+
- LICENSE.txt
|
170
|
+
- README.md
|
171
|
+
- Rakefile
|
172
|
+
- bin/console
|
173
|
+
- bin/setup
|
174
|
+
- lib/codebreaker/game.rb
|
175
|
+
- lib/codebreaker/version.rb
|
176
|
+
- lib/difficulty.rb
|
177
|
+
- lib/errors/code_length_error.rb
|
178
|
+
- lib/errors/code_range_error.rb
|
179
|
+
- lib/errors/include_error.rb
|
180
|
+
- lib/errors/length_error.rb
|
181
|
+
- lib/locale_config.rb
|
182
|
+
- lib/messages/en.yml
|
183
|
+
- lib/storage.rb
|
184
|
+
- lib/user.rb
|
185
|
+
- lib/validate.rb
|
186
|
+
- rg-codebreaker-gem.gemspec
|
187
|
+
homepage: https://github.com/Anastasiia04/rg-codebreaker-gem.
|
188
|
+
licenses:
|
189
|
+
- MIT
|
190
|
+
metadata: {}
|
191
|
+
post_install_message:
|
192
|
+
rdoc_options: []
|
193
|
+
require_paths:
|
194
|
+
- lib
|
195
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
requirements: []
|
206
|
+
rubygems_version: 3.0.3
|
207
|
+
signing_key:
|
208
|
+
specification_version: 4
|
209
|
+
summary: This gem help to create a guessing game.
|
210
|
+
test_files: []
|