codebreaker_kub 0.1.2 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +57 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/codebreaker/data/locales/en.yml +1 -1
- data/lib/codebreaker/game.rb +2 -2
- data/lib/codebreaker/loader.rb +4 -7
- data/lib/codebreaker/output.rb +23 -5
- data/lib/codebreaker/version.rb +1 -1
- metadata +3 -3
- data/.rspec_status +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 368897134f5e57306064d5dcc9b5ad197a11e77070d3b1923b8c9250160af688
|
4
|
+
data.tar.gz: 918822ffa12cd59fa3744487b0b22415d98fc09c2e38d6f4e6fb7dbfd9d9daa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2caf1d95e69d331e6de3d39f65007d5d3402388f550475cda78a53b8504a1d65f65ed3e63d72380a199163a4d731d4906c46c57de31443bb2cc0b6cb83d2dba6
|
7
|
+
data.tar.gz: 58b74baba40482c14d058334ba18cc57b490c468c97e68f7c39dacc0ef52b22dda652637dc37724a291a697970e02e485bd3e966893fbd5fff70c26adc17b030
|
@@ -0,0 +1,57 @@
|
|
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.7.0
|
9
|
+
caches:
|
10
|
+
- &bundle_cache v1-repo-{{ checksum "Gemfile.lock" }}
|
11
|
+
commands:
|
12
|
+
run_linters:
|
13
|
+
description: command to start linters
|
14
|
+
steps:
|
15
|
+
- run:
|
16
|
+
name: rubocop
|
17
|
+
command: bundle exec rubocop
|
18
|
+
run_specs:
|
19
|
+
steps:
|
20
|
+
- run:
|
21
|
+
name: run specs
|
22
|
+
command: |
|
23
|
+
mkdir /tmp/test-results
|
24
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
25
|
+
bundle exec rspec --format progress \
|
26
|
+
--out /tmp/test-results/rspec.xml \
|
27
|
+
$TEST_FILES
|
28
|
+
setup_environment:
|
29
|
+
steps:
|
30
|
+
- checkout
|
31
|
+
- restore_cache:
|
32
|
+
key: *bundle_cache
|
33
|
+
- run: bundle install --path vendor/bundle
|
34
|
+
- save_cache:
|
35
|
+
key: *bundle_cache
|
36
|
+
paths:
|
37
|
+
- vendor/bundle
|
38
|
+
jobs:
|
39
|
+
lintering:
|
40
|
+
executor: default
|
41
|
+
steps:
|
42
|
+
- setup_environment
|
43
|
+
- run_linters
|
44
|
+
run_specs:
|
45
|
+
executor: default
|
46
|
+
steps:
|
47
|
+
- setup_environment
|
48
|
+
- run_specs
|
49
|
+
|
50
|
+
workflows:
|
51
|
+
version: 2
|
52
|
+
build:
|
53
|
+
jobs:
|
54
|
+
- lintering
|
55
|
+
- run_specs:
|
56
|
+
requires:
|
57
|
+
- lintering
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,10 +5,10 @@
|
|
5
5
|
- Load game statistics - puts 'stats'\n
|
6
6
|
- Exit from game - puts 'exit'\n"
|
7
7
|
goodbye: "Bye bye!\n"
|
8
|
+
available_commands: "Enter 'start', 'rules', 'stats' or 'exit'"
|
8
9
|
rules: "GAME RULES:\n
|
9
10
|
# Codebreaker is a logic game in which a code-breaker tries to break a secret code created by a code-maker. The\n codemaker, which will be played by the application we’re going to write, creates a secret code.\n
|
10
11
|
# The codebreaker gets some number of chances to break the code (depends on chosen difficulty). In each turn, the\n codebreaker makes a guess. The codemaker then marks the guess with special symbols.\n
|
11
|
-
Number of minuses - 2 (second and fourth position)\n
|
12
12
|
# If codebreaker inputs the exact number as a secret number - codebreaker wins the game. If all attempts are spent - codebreaker loses.\n
|
13
13
|
# Codebreaker also has some number of hints(depends on chosen difficulty). If a user takes a hint - he receives back a\n
|
14
14
|
separate digit of the secret code.\n
|
data/lib/codebreaker/game.rb
CHANGED
@@ -76,8 +76,8 @@ module Codebreaker
|
|
76
76
|
attempts: difficulty_option[:attempts],
|
77
77
|
hints: difficulty_option[:hints],
|
78
78
|
code: @code,
|
79
|
-
|
80
|
-
|
79
|
+
used_attempts: difficulty_option[:attempts] - @attempts_left,
|
80
|
+
used_hints: difficulty_option[:hints] - @hints_left,
|
81
81
|
win: win?
|
82
82
|
}
|
83
83
|
end
|
data/lib/codebreaker/loader.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
module Codebreaker
|
2
2
|
module Loader
|
3
|
-
PATH = '
|
3
|
+
PATH = File.join(File.dirname(__FILE__), 'data/').freeze
|
4
4
|
EXTENCTION = '.yml'.freeze
|
5
5
|
def self.load(file_name)
|
6
6
|
file_name = PATH + file_name + EXTENCTION.to_s
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
File.new(file_name, 'w')
|
11
|
-
[]
|
12
|
-
end
|
7
|
+
raise LoadError, 'No such file to load' unless File.exist?(file_name)
|
8
|
+
|
9
|
+
YAML.load_file(file_name)
|
13
10
|
end
|
14
11
|
|
15
12
|
def self.save(obj, file_name)
|
data/lib/codebreaker/output.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
module Codebreaker
|
2
2
|
class Output
|
3
|
+
attr_reader :stats
|
3
4
|
def initialize
|
4
|
-
I18n.load_path << Dir[File.expand_path('
|
5
|
+
I18n.load_path << Dir[File.expand_path(File.join(File.dirname(__FILE__), 'data/locales/')) + '/*.yml']
|
6
|
+
I18n.config.available_locales = :en
|
7
|
+
@stats = Codebreaker::Loader.load('stat')
|
5
8
|
end
|
6
9
|
|
7
10
|
def greeting
|
8
11
|
puts I18n.t(:hey)
|
9
12
|
end
|
10
13
|
|
14
|
+
def available_commands
|
15
|
+
puts I18n.t(:available_commands)
|
16
|
+
end
|
17
|
+
|
11
18
|
def choose_name
|
12
19
|
puts I18n.t(:choose_name)
|
13
20
|
end
|
@@ -20,12 +27,23 @@ module Codebreaker
|
|
20
27
|
puts I18n.t(:rules)
|
21
28
|
end
|
22
29
|
|
30
|
+
def sort_stats
|
31
|
+
@stats = @stats.sort_by do |game|
|
32
|
+
[game[:attempts], game[:used_attempts],
|
33
|
+
game[:used_hints]]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
23
37
|
def show_stats
|
24
|
-
|
38
|
+
sort_stats
|
39
|
+
@stats.each_with_index do |game, index|
|
25
40
|
puts "Hey, #{game[:name]}
|
26
|
-
|
41
|
+
Rating: #{index + 1}
|
27
42
|
Attempts: #{game[:attempts]}
|
28
|
-
Hints: #{game[:hints]}
|
43
|
+
Hints: #{game[:hints]}
|
44
|
+
Chosen difficulty: #{game[:difficulty]}
|
45
|
+
Used attempts: #{game[:used_attempts]}
|
46
|
+
Used hints: #{game[:used_hints]}"
|
29
47
|
end
|
30
48
|
end
|
31
49
|
|
@@ -67,7 +85,7 @@ module Codebreaker
|
|
67
85
|
end
|
68
86
|
|
69
87
|
def goodbye
|
70
|
-
I18n(:goodbye)
|
88
|
+
puts I18n.t(:goodbye)
|
71
89
|
end
|
72
90
|
|
73
91
|
def game_over
|
data/lib/codebreaker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebreaker_kub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- katia kub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fasterer
|
@@ -87,10 +87,10 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
+
- ".circleci/config.yml"
|
90
91
|
- ".fasterer.yml"
|
91
92
|
- ".gitignore"
|
92
93
|
- ".overcommit.yml"
|
93
|
-
- ".rspec_status"
|
94
94
|
- ".rubocop.yml"
|
95
95
|
- ".ruby-version"
|
96
96
|
- CODE_OF_CONDUCT.md
|
data/.rspec_status
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
------------------------------------------ | ------ | --------------- |
|
3
|
-
./spec/codebreaker/game_spec.rb[1:1] | passed | 0.00066 seconds |
|
4
|
-
./spec/codebreaker/game_spec.rb[1:2] | passed | 0.00069 seconds |
|
5
|
-
./spec/codebreaker/game_spec.rb[1:3] | passed | 0.00095 seconds |
|
6
|
-
./spec/codebreaker/game_spec.rb[1:4] | passed | 0.00124 seconds |
|
7
|
-
./spec/codebreaker/game_spec.rb[1:5] | passed | 0.00033 seconds |
|
8
|
-
./spec/codebreaker/game_spec.rb[1:6] | passed | 0.0052 seconds |
|
9
|
-
./spec/codebreaker/game_spec.rb[1:7] | passed | 0.00059 seconds |
|
10
|
-
./spec/codebreaker/game_spec.rb[1:8] | passed | 0.00034 seconds |
|
11
|
-
./spec/codebreaker/game_spec.rb[1:9] | passed | 0.00029 seconds |
|
12
|
-
./spec/codebreaker/game_spec.rb[1:10:1] | passed | 0.00059 seconds |
|
13
|
-
./spec/codebreaker/game_spec.rb[1:10:2] | passed | 0.00028 seconds |
|
14
|
-
./spec/codebreaker/game_spec.rb[1:10:3] | passed | 0.00026 seconds |
|
15
|
-
./spec/codebreaker/game_spec.rb[1:10:4] | passed | 0.00025 seconds |
|
16
|
-
./spec/codebreaker/game_spec.rb[1:10:5] | passed | 0.00027 seconds |
|
17
|
-
./spec/codebreaker/game_spec.rb[1:10:6] | passed | 0.00026 seconds |
|
18
|
-
./spec/codebreaker/game_spec.rb[1:10:7] | passed | 0.00026 seconds |
|
19
|
-
./spec/codebreaker/game_spec.rb[1:10:8] | passed | 0.00027 seconds |
|
20
|
-
./spec/codebreaker/game_spec.rb[1:10:9] | passed | 0.00038 seconds |
|
21
|
-
./spec/codebreaker/game_spec.rb[1:10:10] | passed | 0.00036 seconds |
|
22
|
-
./spec/codebreaker/game_spec.rb[1:10:11] | passed | 0.00034 seconds |
|
23
|
-
./spec/codebreaker/loader_spec.rb[1:1] | passed | 0.00079 seconds |
|
24
|
-
./spec/codebreaker/validation_spec.rb[1:1] | passed | 0.00023 seconds |
|
25
|
-
./spec/codebreaker/validation_spec.rb[1:2] | passed | 0.00014 seconds |
|
26
|
-
./spec/codebreaker/validation_spec.rb[1:3] | passed | 0.00013 seconds |
|
27
|
-
./spec/codebreaker/validation_spec.rb[1:4] | passed | 0.00008 seconds |
|
28
|
-
./spec/codebreaker/validation_spec.rb[1:5] | passed | 0.00009 seconds |
|
29
|
-
./spec/codebreaker/validation_spec.rb[1:6] | passed | 0.00013 seconds |
|
30
|
-
./spec/codebreaker_spec.rb[1:1] | passed | 0.00009 seconds |
|