codebreaker_mats 0.1.1 → 0.1.6

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: '09050fec89126a3ab9c2c82ea1c896d333470bafcaba1caf2619f063528c5b82'
4
- data.tar.gz: 3654625e41217b5caf993637526a1a508c7e901da9efbf8a014e645bb7824fa5
3
+ metadata.gz: 0ff4627a58b422bfa3ddb12eb95895884b4ba4825f5902bc8d3120a94048ab5e
4
+ data.tar.gz: e290744852397fdc2d76c1490beb37946f2ce881b0e2d48f078b46e98eb68e14
5
5
  SHA512:
6
- metadata.gz: 709c26a51c13ce88544e3b9bd3f1484ca0f8db7f4234b559f1d51924bde451b7755423238aa9d95aba9cf6150f7f57896bb93e65af6f592391dec40742f0baf3
7
- data.tar.gz: f28b2fc04bf78b386a0a1c81831a2c9b0c79f52c9d6d54636d2d3b879671d58c7d0132fae157bf8c15f11d43c231981c37c12b227683614b29eefc86841bd87e
6
+ metadata.gz: 4483a224c17951f96461b18f6b76740889a88e1bffc648cd001039df5dc33ef40e8c3910a09085854f6a95e643d5b506f2605710fe80823b5ccda3d2058c6304
7
+ data.tar.gz: 4186fd5aedc97d2d626ad70072262b6487db3dc65268c8823b6188d14964678c52de4ada457f50ff68e8c92c556a8dbfca3cdc1ac0f3909d6e1326ae8176dce1
@@ -0,0 +1,70 @@
1
+ version: 2.1
2
+
3
+ executors:
4
+ default:
5
+ working_directory: ~/repo
6
+ description: The official CircleCI Ruby Docker image
7
+ docker:
8
+ - image: circleci/ruby:2.6.0-node
9
+ environment:
10
+ BUNDLER_VERSION: 2.1.4
11
+
12
+ caches:
13
+ - &bundle_cache_full v2-repo-{{ checksum "Gemfile.lock" }}
14
+ - &bundle_cache v2-repo-
15
+
16
+ commands:
17
+ defaults:
18
+ steps:
19
+ - checkout
20
+ - restore_cache:
21
+ keys:
22
+ - *bundle_cache_full
23
+ - *bundle_cache
24
+ - run:
25
+ name: Configure Bundler
26
+ command: |
27
+ gem update --system
28
+ gem install bundler
29
+ - run: bundle install --path vendor/bundle
30
+ - save_cache:
31
+ key: *bundle_cache_full
32
+ paths:
33
+ - vendor/bundle
34
+ run_linters:
35
+ description: command to start linters
36
+ steps:
37
+ - run:
38
+ name: rubocop
39
+ command: bundle exec rubocop
40
+
41
+ run_specs:
42
+ steps:
43
+ - run:
44
+ name: run specs
45
+ command: |
46
+ mkdir /tmp/test-results
47
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
48
+ bundle exec rspec --format progress \
49
+ --out /tmp/test-results/rspec.xml \
50
+ $TEST_FILES
51
+ jobs:
52
+ lintering:
53
+ executor: default
54
+ steps:
55
+ - defaults
56
+ - run_linters
57
+ run_specs:
58
+ executor: default
59
+ steps:
60
+ - defaults
61
+ - run_specs
62
+
63
+ workflows:
64
+ version: 2
65
+ build:
66
+ jobs:
67
+ - lintering
68
+ - run_specs:
69
+ requires:
70
+ - lintering
@@ -0,0 +1,19 @@
1
+ speedups:
2
+ rescue_vs_respond_to: true
3
+ module_eval: true
4
+ shuffle_first_vs_sample: true
5
+ for_loop_vs_each: true
6
+ each_with_index_vs_while: false
7
+ map_flatten_vs_flat_map: true
8
+ reverse_each_vs_reverse_each: true
9
+ select_first_vs_detect: true
10
+ sort_vs_sort_by: true
11
+ fetch_with_argument_vs_block: true
12
+ keys_each_vs_each_key: true
13
+ hash_merge_bang_vs_hash_brackets: true
14
+ block_vs_symbol_to_proc: true
15
+ proc_call_vs_yield: true
16
+ gsub_vs_tr: true
17
+ select_last_vs_reverse_detect: true
18
+ getter_vs_attr_reader: true
19
+ setter_vs_attr_writer: true
@@ -0,0 +1,14 @@
1
+ require: rubocop-rspec
2
+ Style:
3
+ Enabled: false
4
+ RSpec/FilePath:
5
+ Enabled: false
6
+ RSpec/MultipleExpectations:
7
+ Enabled: false
8
+ RSpec/MessageSpies:
9
+ Enabled: false
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - 'Rakefile'
13
+ - '**/*.rake'
14
+ - 'spec/**/*.rb'
data/Gemfile CHANGED
@@ -1,8 +1,11 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in codebreaker_mats.gemspec
4
4
  gemspec
5
5
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
8
- gem 'simplecov'
6
+ gem 'fasterer', '0.8.3'
7
+ gem 'rake', '~> 12.0'
8
+ gem 'rspec', '~> 3.0'
9
+ gem 'rubocop-rspec', require: false
10
+
11
+ gem 'simplecov'
@@ -1,14 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- codebreaker_mats (0.1.1)
4
+ codebreaker_mats (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ ast (2.4.1)
10
+ colorize (0.8.1)
9
11
  diff-lcs (1.4.4)
10
12
  docile (1.3.2)
13
+ fasterer (0.8.3)
14
+ colorize (~> 0.7)
15
+ ruby_parser (>= 3.14.1)
16
+ parallel (1.19.2)
17
+ parser (2.7.1.4)
18
+ ast (~> 2.4.1)
19
+ rainbow (3.0.0)
11
20
  rake (12.3.3)
21
+ regexp_parser (1.7.1)
22
+ rexml (3.2.4)
12
23
  rspec (3.9.0)
13
24
  rspec-core (~> 3.9.0)
14
25
  rspec-expectations (~> 3.9.0)
@@ -22,18 +33,38 @@ GEM
22
33
  diff-lcs (>= 1.2.0, < 2.0)
23
34
  rspec-support (~> 3.9.0)
24
35
  rspec-support (3.9.3)
36
+ rubocop (0.88.0)
37
+ parallel (~> 1.10)
38
+ parser (>= 2.7.1.1)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 1.7)
41
+ rexml
42
+ rubocop-ast (>= 0.1.0, < 1.0)
43
+ ruby-progressbar (~> 1.7)
44
+ unicode-display_width (>= 1.4.0, < 2.0)
45
+ rubocop-ast (0.2.0)
46
+ parser (>= 2.7.0.1)
47
+ rubocop-rspec (1.42.0)
48
+ rubocop (>= 0.87.0)
49
+ ruby-progressbar (1.10.1)
50
+ ruby_parser (3.14.2)
51
+ sexp_processor (~> 4.9)
52
+ sexp_processor (4.14.1)
25
53
  simplecov (0.18.5)
26
54
  docile (~> 1.1)
27
55
  simplecov-html (~> 0.11)
28
56
  simplecov-html (0.12.2)
57
+ unicode-display_width (1.7.0)
29
58
 
30
59
  PLATFORMS
31
60
  ruby
32
61
 
33
62
  DEPENDENCIES
34
63
  codebreaker_mats!
64
+ fasterer (= 0.8.3)
35
65
  rake (~> 12.0)
36
66
  rspec (~> 3.0)
67
+ rubocop-rspec
37
68
  simplecov
38
69
 
39
70
  BUNDLED WITH
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "codebreaker_mats"
3
+ require 'bundler/setup'
4
+ require 'codebreaker_mats'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "codebreaker_mats"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,26 +1,26 @@
1
1
  require_relative 'lib/codebreaker_mats/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = "codebreaker_mats"
4
+ spec.name = 'codebreaker_mats'
5
5
  spec.version = CodebreakerMats::VERSION
6
- spec.authors = ["Ivan"]
7
- spec.email = ["ivan.matsiyk18092002@gmail.com"]
6
+ spec.authors = ['Ivan']
7
+ spec.email = ['ivan.matsiyk18092002@gmail.com']
8
8
 
9
9
  spec.summary = 'codebreaker game'
10
10
  spec.description = 'The app provides core for codebreaker game'
11
11
  spec.homepage = 'https://github.com/Swooty18/codebreaker_mats.git'
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
14
 
15
- spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = 'https://github.com/Swooty18/codebreaker_mats.git'
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = 'https://github.com/Swooty18/codebreaker_mats.git'
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
22
  end
23
- spec.bindir = "exe"
23
+ spec.bindir = 'exe'
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ["lib"]
25
+ spec.require_paths = ['lib']
26
26
  end
@@ -7,7 +7,3 @@ require_relative 'codebreaker_mats/game'
7
7
  require_relative 'codebreaker_mats/exceptions/terminate_error'
8
8
 
9
9
  require_relative 'codebreaker_mats/markers/plus_minus_marker'
10
- require_relative 'codebreaker_mats/markers/classical_marker'
11
-
12
- require 'simplecov'
13
- SimpleCov.start
@@ -1,21 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Codebreaker
4
- # Game of bulls and cows.
5
2
  class Game
6
- attr_reader :storage, :matcher, :hints, :status, :secret_code
3
+ CODE_RANGE_MIN = 1
4
+ CODE_RANGE_MAX = 6
5
+ COUNT_OF_NUMBER = 4
6
+ attr_reader :matcher, :hints, :status
7
7
 
8
- attr_accessor :user, :number_of_attempts, :number_of_hints, :attempts_left, :hints_left, :difficulty
8
+ attr_accessor :user, :number_of_attempts, :number_of_hints, :attempts_left, :hints_left, :difficulty, :secret_code
9
9
  def initialize(matcher: Matcher.new)
10
- @storage = storage
11
10
  @matcher = matcher
12
11
  end
13
12
 
14
13
  def start
15
14
  generate_secret_code
16
15
  generate_hints
17
- @attempts_left = @number_of_attempts
18
- @hints_left = @number_of_hints
16
+ @attempts_left = @number_of_attempts = 0
17
+ @hints_left = @number_of_hints = 0
19
18
  matcher.secret_code = @secret_code
20
19
  @status = :in_progress
21
20
  @difficulty
@@ -66,14 +65,20 @@ module Codebreaker
66
65
  end
67
66
  end
68
67
 
68
+ def set_difficulty(diff, attempts, hints)
69
+ @number_of_attempts = @attempts_left = attempts
70
+ @number_of_hints = @hints_left = hints
71
+ @difficulty = diff
72
+ end
73
+
69
74
  private
70
75
 
71
76
  def generate_secret_code
72
- @secret_code = Array.new(4) { roll_dice }.join
77
+ @secret_code = Array.new(COUNT_OF_NUMBER) { roll_dice }.join
73
78
  end
74
79
 
75
80
  def roll_dice
76
- rand(1..6)
81
+ rand(CODE_RANGE_MIN..CODE_RANGE_MAX)
77
82
  end
78
83
 
79
84
  def generate_hints
@@ -2,11 +2,9 @@
2
2
 
3
3
  module Codebreaker
4
4
  module Markers
5
- # Marker that will interpret the number of bulls
6
- # and cows in a codebreaker plus-minus style.
7
5
  class PlusMinusMarker
8
- def mark(bulls, cows)
9
- '+' * bulls + '-' * cows
6
+ def mark(exact, non_exact)
7
+ '+' * exact + '-' * non_exact
10
8
  end
11
9
  end
12
10
  end
@@ -1,3 +1,3 @@
1
1
  module CodebreakerMats
2
- VERSION = "0.1.1"
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreaker_mats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: The app provides core for codebreaker game
14
14
  email:
@@ -17,9 +17,11 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".circleci/config.yml"
21
+ - ".faterer.yml"
20
22
  - ".gitignore"
21
23
  - ".rspec"
22
- - ".travis.yml"
24
+ - ".rubocop.yml"
23
25
  - CODE_OF_CONDUCT.md
24
26
  - Gemfile
25
27
  - Gemfile.lock
@@ -32,11 +34,9 @@ files:
32
34
  - lib/codebreaker_mats.rb
33
35
  - lib/codebreaker_mats/exceptions/terminate_error.rb
34
36
  - lib/codebreaker_mats/game.rb
35
- - lib/codebreaker_mats/markers/classical_marker.rb
36
37
  - lib/codebreaker_mats/markers/plus_minus_marker.rb
37
38
  - lib/codebreaker_mats/matcher.rb
38
39
  - lib/codebreaker_mats/version.rb
39
- - stat.yml
40
40
  homepage: https://github.com/Swooty18/codebreaker_mats.git
41
41
  licenses:
42
42
  - MIT
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubygems_version: 3.1.3
61
+ rubygems_version: 3.1.4
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: codebreaker game
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Codebreaker
4
- module Markers
5
- # Marker that will interpret the number of bulls
6
- # and cows in classical way.
7
- class ClassicalMarker
8
- def mark(bulls, cows)
9
- format('%d Bulls, %d Cows', bulls, cows)
10
- end
11
- end
12
- end
13
- end
data/stat.yml DELETED
File without changes