codebreaker2018 0.3.5.0 → 0.3.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dca7ce839552d295a6587fb5d5e703b6ec3c1674ca5f60fb9a788f5fd4d36a6
4
- data.tar.gz: 95b0e18db1f01ae31966029a0f2bfda348e95b4845dac8720a1f678f9bb622e5
3
+ metadata.gz: 7253bad10a3b25e352ce1f7426bdae6ad6da7c096b79a9a240837bfcd56cd96d
4
+ data.tar.gz: 955a190aaca6ae68ccf17ecd52b87f751d631f4d7753c38ef2fd659e245122a8
5
5
  SHA512:
6
- metadata.gz: b19c1d28ddd7a30fb854492ccd65510b7df1095426aa84e0c780fc5b6722090297d7117e79ccb99968ee0ad6fa7cbacc05968a548e6ce3d36786e89f7640366f
7
- data.tar.gz: e436a6851a7e1fafa8bb2be30d7d59afba0186afc7c8a4f12e4e55a721896418adaa8ee355f0936dd8edf7f033fb3a7cd406d45dd46927d8fe49fe652ed6bf4f
6
+ metadata.gz: '049804bb13d92830f52f940593a6e015df471fa514432a41758aa4c2cc35ed42cbdbb30e6fef48efdeeec390a54a68719e1d694b89ecee31113269b0d6185f49'
7
+ data.tar.gz: fd448d971e3cbc5d3076c5c1737ae933420884374aba213d0019bfb2205535fa94abe871e7c11186bdf9f803be3688e642ab7b9d48a23ac61d8a57bdfd3a21f0
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ require: rubocop-rspec
2
+
3
+ Style/FrozenStringLiteralComment:
4
+ Enabled: false
5
+
6
+ Style/StringLiterals:
7
+ EnforcedStyle: single_quotes
8
+ SupportedStyles:
9
+ - single_quotes
10
+ - double_quotes
11
+
12
+ Style/ParallelAssignment:
13
+ Enabled: false
14
+
15
+ Metrics/ClassLength:
16
+ Max: 200
17
+
18
+ Metrics/LineLength:
19
+ Max: 120
20
+
21
+ Documentation:
22
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.1
4
- before_install: gem install bundler -v 1.11.2
3
+ - 2.5.0
4
+ script: 'bundle exec rspec'
data/Gemfile CHANGED
@@ -1,5 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
3
- gem 'rspec'
3
+
4
4
  gem 'colorize'
5
- gem 'simplecov', require: false, group: :test
5
+
6
+ group :development, :test do
7
+ gem 'rspec'
8
+ gem 'simplecov', '~> 0.13.0'
9
+ gem 'rspec_file_chef'
10
+ gem 'codeclimate-test-reporter'
11
+ end
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
- # Codebreaker [![Gem Version](https://badge.fury.io/rb/codebreaker2018.svg)](https://badge.fury.io/rb/codebreaker2018)
1
+ # codebreaker2018
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/6901f8941feb809fdaf6/maintainability)](https://codeclimate.com/github/bestwebua/codebreaker/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/6901f8941feb809fdaf6/test_coverage)](https://codeclimate.com/github/bestwebua/codebreaker/test_coverage) [![Gem Version](https://badge.fury.io/rb/codebreaker2018.svg)](https://badge.fury.io/rb/codebreaker2018) [![Build Status](https://travis-ci.org/bestwebua/codebreaker.svg?branch=master)](https://travis-ci.org/bestwebua/codebreaker)
2
3
 
3
- Codebreaker is a logic game in which the code-breaker tries to break a secret code created by a code-maker. The code-maker, which will be played by the application we’re going to write, creates a secret code of four numbers between 1 and 6.
4
+ Codebreaker is a logic game in which the code-breaker tries to break a secret code created by a code-maker. The code-maker, which will be played by the application we’re going to write, creates a secret code of four numbers between 1 and 6. This is new terminal version of a game represented as Ruby gem.
5
+
6
+ Codebreaker2018 Rack version: https://github.com/bestwebua/codebreaker-web
4
7
 
5
8
  ## Installation ##
6
9
 
@@ -45,6 +48,7 @@ Codebreaker::Console.new
45
48
  - Autoload localizations from locale dir
46
49
  - Default language
47
50
  - Ability to change locale
51
+ - Ability to use custom locale location
48
52
 
49
53
  ### Score features ###
50
54
  - Date
@@ -53,6 +57,12 @@ Codebreaker::Console.new
53
57
  - Level
54
58
  - Score
55
59
 
60
+ ### Data saving ###
61
+ - Ability to use custom game-data location
62
+
63
+ ### Testing ###
64
+ - RSpec tests have 100% code coverage
65
+
56
66
  ### Detail sample of Codebreaker usage ###
57
67
 
58
68
  ```ruby
@@ -104,8 +114,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
104
114
 
105
115
  ## Contributing
106
116
 
107
- Bug reports and pull requests are welcome on GitHub at https://github.com/bestwebua/homework-04-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.
108
-
117
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bestwebua/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.
109
118
 
110
119
  ## License
111
120
 
data/codebreaker.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = %q{Codebreaker}
12
12
  spec.description = %q{New version of logic terminal game with English and Russian localizations. For demo mode just use: Codebreaker::Console.new}
13
- spec.homepage = 'https://github.com/bestwebua/homework-04-codebreaker'
13
+ spec.homepage = 'https://github.com/bestwebua/codebreaker'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.required_ruby_version = '>= 2.5.0'
@@ -22,7 +22,7 @@ module Codebreaker
22
22
  end
23
23
 
24
24
  def start_game
25
- puts message['alerts']['welcome'].colorize(:background => :blue)
25
+ puts message['alerts']['welcome'].colorize(background: :blue)
26
26
  puts message['alerts']['hint_info']
27
27
  submit_answer
28
28
  end
@@ -47,6 +47,8 @@ module Codebreaker
47
47
 
48
48
  private
49
49
 
50
+ attr_reader :result, :secret_code
51
+
50
52
  def check_configuration
51
53
  levels = [SIMPLE_LEVEL, MIDDLE_LEVEL, HARD_LEVEL]
52
54
  raise message['errors']['fail_configuration'] if configuration.any?(&:nil?)
@@ -71,18 +73,10 @@ module Codebreaker
71
73
  create_instance_vars
72
74
  end
73
75
 
74
- def result
75
- @result
76
- end
77
-
78
76
  def generate_secret_code
79
77
  @secret_code = (1..4).map { rand(1..6) }
80
78
  end
81
79
 
82
- def secret_code
83
- @secret_code
84
- end
85
-
86
80
  def fancy_algo(guess, secret_code)
87
81
  guessed_indexes, guess = [], guess.chars.map(&:to_i)
88
82
 
@@ -95,21 +89,21 @@ module Codebreaker
95
89
  secret_code.reject.with_index do |_, guessed_index|
96
90
  guessed_indexes.include?(guessed_index)
97
91
  end
98
-
99
92
  case
100
- when item == secret_code[index] then RIGHT_ANSWER
101
- when not_guessed_secret_nums.include?(item) then RIGHT_ANSWER_DIFF_INDEX
102
- else WRONG_ANSWER
93
+ when item == secret_code[index] then RIGHT_ANSWER
94
+ when not_guessed_secret_nums.include?(item) then RIGHT_ANSWER_DIFF_INDEX
95
+ else WRONG_ANSWER
103
96
  end
104
97
  end.join
105
98
  end
106
99
 
107
100
  def calculate_score
108
- level_rates = case configuration.level
101
+ level_rates =
102
+ case configuration.level
109
103
  when SIMPLE_LEVEL then [TEN_POINTS, ZERO_POINTS]
110
104
  when MIDDLE_LEVEL then [TWENTY_POINTS, TWENTY_POINTS]
111
105
  else [FIFTY_POINTS, ONE_HUNDRED_POINTS]
112
- end
106
+ end
113
107
 
114
108
  attempt_rate, hint_rate = level_rates
115
109
  guessed = result.count(RIGHT_ANSWER)
@@ -27,7 +27,7 @@ module Codebreaker
27
27
  if external_path && Dir.glob("#{external_path}/*/*.yml").empty?
28
28
  raise ArgumentError, 'Invalid external path.'
29
29
  end
30
- @external_path = external_path ? external_path : false
30
+ @external_path = external_path || false
31
31
  end
32
32
 
33
33
  def localizations_dir
@@ -7,16 +7,15 @@ module Codebreaker
7
7
  private
8
8
 
9
9
  def apply_external_path(external_path = false)
10
+ raise ArgumentError, 'Invalid external path.' if external_path && !Dir.exist?(external_path)
10
11
  yml_file = 'scores.yml'
11
- if external_path && !Dir.exist?(external_path)
12
- raise ArgumentError, 'Invalid external path.'
13
- end
12
+
14
13
  @storage_path =
15
- if external_path
16
- "#{external_path}/#{yml_file}"
17
- else
18
- File.expand_path("./data/#{yml_file}", File.dirname(__FILE__))
19
- end
14
+ if external_path
15
+ "#{external_path}/#{yml_file}"
16
+ else
17
+ File.expand_path("./data/#{yml_file}", File.dirname(__FILE__))
18
+ end
20
19
  end
21
20
 
22
21
  def load_game_data
@@ -1,3 +1,3 @@
1
1
  module Codebreaker
2
- VERSION = '0.3.5.0'
2
+ VERSION = '0.3.5.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codebreaker2018
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5.0
4
+ version: 0.3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-01 00:00:00.000000000 Z
11
+ date: 2018-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
+ - ".rubocop.yml"
79
80
  - ".ruby-version"
80
81
  - ".travis.yml"
81
82
  - Gemfile
@@ -100,7 +101,7 @@ files:
100
101
  - lib/codebreaker/storage.rb
101
102
  - lib/codebreaker/user_score.rb
102
103
  - lib/codebreaker/version.rb
103
- homepage: https://github.com/bestwebua/homework-04-codebreaker
104
+ homepage: https://github.com/bestwebua/codebreaker
104
105
  licenses:
105
106
  - MIT
106
107
  metadata: {}