icodebreaker_gem 0.3.0 → 0.3.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 +4 -4
- data/.rspec_status +20 -20
- data/Gemfile.lock +8 -4
- data/config/locales/en.yml +4 -0
- data/lib/config.rb +4 -2
- data/lib/game.rb +20 -3
- data/lib/game_core.rb +1 -1
- data/lib/icodebreaker_gem/version.rb +1 -1
- data/lib/modules/storage.rb +1 -1
- data/lib/modules/validation.rb +5 -2
- metadata +21 -7
- data/lib/constants.rb +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ec00c184eee22be479150d458bd2e837d1389a781e329871b602a7fae6d372a
|
|
4
|
+
data.tar.gz: b2e5a88f71f41108dbd41eb57cedc617c8da2c1b477968ca53583db505737632
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee4e2181cfe8dce5f2a084c85e7830631c3e9c34983af65ce1fd6302f356454c11fb61a6f03e42b77247c819206073df3b4092699cc5cc1696eb0f7865539105
|
|
7
|
+
data.tar.gz: cb30f180e4f4d41031f6b5849f57c63291481fc36623302971d0fbb2a194f835c2fbd49abb7c6d47df141cf8e7f4662bac607a2a6b2aecc8d2d64f2a47023c3a
|
data/.rspec_status
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
example_id | status | run_time |
|
|
2
2
|
------------------------------------ | ------ | --------------- |
|
|
3
3
|
./spec/game_core_spec.rb[1:1] | passed | 0.00023 seconds |
|
|
4
|
-
./spec/game_core_spec.rb[1:2] | passed | 0.
|
|
5
|
-
./spec/game_core_spec.rb[1:3:1] | passed | 0.
|
|
6
|
-
./spec/game_core_spec.rb[1:4:1] | passed | 0.
|
|
7
|
-
./spec/game_core_spec.rb[1:5:1:1] | passed | 0.
|
|
8
|
-
./spec/game_core_spec.rb[1:5:1:2] | passed | 0.
|
|
9
|
-
./spec/game_core_spec.rb[1:5:1:3] | passed | 0.
|
|
4
|
+
./spec/game_core_spec.rb[1:2] | passed | 0.00074 seconds |
|
|
5
|
+
./spec/game_core_spec.rb[1:3:1] | passed | 0.00038 seconds |
|
|
6
|
+
./spec/game_core_spec.rb[1:4:1] | passed | 0.00054 seconds |
|
|
7
|
+
./spec/game_core_spec.rb[1:5:1:1] | passed | 0.00006 seconds |
|
|
8
|
+
./spec/game_core_spec.rb[1:5:1:2] | passed | 0.00007 seconds |
|
|
9
|
+
./spec/game_core_spec.rb[1:5:1:3] | passed | 0.0001 seconds |
|
|
10
10
|
./spec/game_core_spec.rb[1:5:1:4] | passed | 0.00006 seconds |
|
|
11
|
-
./spec/game_core_spec.rb[1:5:1:5] | passed | 0.
|
|
11
|
+
./spec/game_core_spec.rb[1:5:1:5] | passed | 0.00006 seconds |
|
|
12
12
|
./spec/game_core_spec.rb[1:5:1:6] | passed | 0.00006 seconds |
|
|
13
|
-
./spec/game_core_spec.rb[1:5:1:7] | passed | 0.
|
|
13
|
+
./spec/game_core_spec.rb[1:5:1:7] | passed | 0.00008 seconds |
|
|
14
14
|
./spec/game_core_spec.rb[1:5:2:1] | passed | 0.00005 seconds |
|
|
15
|
-
./spec/game_core_spec.rb[1:5:2:2] | passed | 0.
|
|
16
|
-
./spec/game_core_spec.rb[1:5:3:1] | passed | 0.
|
|
17
|
-
./spec/game_core_spec.rb[1:5:3:2] | passed | 0.
|
|
15
|
+
./spec/game_core_spec.rb[1:5:2:2] | passed | 0.00005 seconds |
|
|
16
|
+
./spec/game_core_spec.rb[1:5:3:1] | passed | 0.00007 seconds |
|
|
17
|
+
./spec/game_core_spec.rb[1:5:3:2] | passed | 0.00005 seconds |
|
|
18
18
|
./spec/game_core_spec.rb[1:5:3:3] | passed | 0.00004 seconds |
|
|
19
|
-
./spec/game_spec.rb[1:1:1] | passed | 0.
|
|
20
|
-
./spec/game_spec.rb[1:2:1] | passed | 0.
|
|
19
|
+
./spec/game_spec.rb[1:1:1] | passed | 0.00012 seconds |
|
|
20
|
+
./spec/game_spec.rb[1:2:1] | passed | 0.00019 seconds |
|
|
21
21
|
./spec/game_spec.rb[1:2:2] | passed | 0.00008 seconds |
|
|
22
22
|
./spec/game_spec.rb[1:2:3] | passed | 0.00007 seconds |
|
|
23
|
-
./spec/game_spec.rb[1:2:4] | passed | 0.
|
|
23
|
+
./spec/game_spec.rb[1:2:4] | passed | 0.00009 seconds |
|
|
24
24
|
./spec/game_spec.rb[1:2:5] | passed | 0.00005 seconds |
|
|
25
|
-
./spec/game_spec.rb[1:3:1] | passed | 0.
|
|
26
|
-
./spec/game_spec.rb[1:3:2] | passed | 0.
|
|
27
|
-
./spec/game_spec.rb[1:3:3] | passed | 0.
|
|
28
|
-
./spec/game_spec.rb[1:4:1] | passed | 0.
|
|
29
|
-
./spec/game_spec.rb[1:5:1] | passed | 0.
|
|
30
|
-
./spec/icodebreaker_gem_spec.rb[1:1] | passed | 0.
|
|
25
|
+
./spec/game_spec.rb[1:3:1] | passed | 0.00039 seconds |
|
|
26
|
+
./spec/game_spec.rb[1:3:2] | passed | 0.00015 seconds |
|
|
27
|
+
./spec/game_spec.rb[1:3:3] | passed | 0.00015 seconds |
|
|
28
|
+
./spec/game_spec.rb[1:4:1] | passed | 0.00268 seconds |
|
|
29
|
+
./spec/game_spec.rb[1:5:1] | passed | 0.0009 seconds |
|
|
30
|
+
./spec/icodebreaker_gem_spec.rb[1:1] | passed | 0.00014 seconds |
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
icodebreaker_gem (0.3.
|
|
4
|
+
icodebreaker_gem (0.3.1)
|
|
5
5
|
rake (~> 13.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -10,11 +10,14 @@ GEM
|
|
|
10
10
|
ast (2.4.2)
|
|
11
11
|
coderay (1.1.3)
|
|
12
12
|
colorize (0.8.1)
|
|
13
|
+
concurrent-ruby (1.1.9)
|
|
13
14
|
diff-lcs (1.4.4)
|
|
14
15
|
docile (1.4.0)
|
|
15
16
|
fasterer (0.9.0)
|
|
16
17
|
colorize (~> 0.7)
|
|
17
18
|
ruby_parser (>= 3.14.1)
|
|
19
|
+
i18n (1.8.10)
|
|
20
|
+
concurrent-ruby (~> 1.0)
|
|
18
21
|
method_source (1.0.0)
|
|
19
22
|
parallel (1.21.0)
|
|
20
23
|
parser (3.0.2.0)
|
|
@@ -66,12 +69,13 @@ PLATFORMS
|
|
|
66
69
|
x86_64-linux
|
|
67
70
|
|
|
68
71
|
DEPENDENCIES
|
|
69
|
-
fasterer
|
|
72
|
+
fasterer (>= 0.9.0)
|
|
73
|
+
i18n
|
|
70
74
|
icodebreaker_gem!
|
|
71
|
-
pry
|
|
75
|
+
pry (>= 0.14.1)
|
|
72
76
|
rspec (~> 3.0)
|
|
73
77
|
rubocop (~> 1.7)
|
|
74
|
-
simplecov
|
|
78
|
+
simplecov (>= 0.21.2)
|
|
75
79
|
|
|
76
80
|
BUNDLED WITH
|
|
77
81
|
2.2.26
|
data/lib/config.rb
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'yaml'
|
|
4
|
-
|
|
4
|
+
require 'i18n'
|
|
5
|
+
require 'psych'
|
|
5
6
|
require_relative 'modules/validation'
|
|
6
7
|
require_relative 'modules/storage'
|
|
7
8
|
|
|
@@ -9,4 +10,5 @@ require_relative 'game_core'
|
|
|
9
10
|
require_relative 'game'
|
|
10
11
|
require_relative 'icodebreaker_gem/version'
|
|
11
12
|
require_relative 'icodebreaker_gem'
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
I18n.load_path << Dir[['config', 'locales', '**', '*.yml'].join('/')]
|
data/lib/game.rb
CHANGED
|
@@ -5,6 +5,23 @@ module IcodebreakerGem
|
|
|
5
5
|
include Validation
|
|
6
6
|
include Storage
|
|
7
7
|
|
|
8
|
+
STATUS = %i[go_on over].freeze
|
|
9
|
+
RESULT = %i[win lose].freeze
|
|
10
|
+
DIFFICULTIES = {
|
|
11
|
+
easy: {
|
|
12
|
+
attempts_total: 15,
|
|
13
|
+
hints_total: 2
|
|
14
|
+
},
|
|
15
|
+
medium: {
|
|
16
|
+
attempts_total: 10,
|
|
17
|
+
hints_total: 1
|
|
18
|
+
},
|
|
19
|
+
hell: {
|
|
20
|
+
attempts_total: 5,
|
|
21
|
+
hints_total: 1
|
|
22
|
+
}
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
8
25
|
attr_reader :name, :difficulty, :attempts_used, :hints_used, :status, :result
|
|
9
26
|
|
|
10
27
|
def initialize(name = 'User1', difficulty = :easy, secret = GameCore.random)
|
|
@@ -40,19 +57,19 @@ module IcodebreakerGem
|
|
|
40
57
|
check_lose
|
|
41
58
|
answer
|
|
42
59
|
when :over
|
|
43
|
-
'
|
|
60
|
+
I18n.t('message.lose')
|
|
44
61
|
end
|
|
45
62
|
end
|
|
46
63
|
|
|
47
64
|
def hint
|
|
48
65
|
case @status
|
|
49
66
|
when :go_on
|
|
50
|
-
return '
|
|
67
|
+
return I18n.t('message.no_hints') if @hints_used >= hints_total
|
|
51
68
|
|
|
52
69
|
@hints_used += 1
|
|
53
70
|
@code.hint
|
|
54
71
|
when :over
|
|
55
|
-
'
|
|
72
|
+
I18n.t('message.lose')
|
|
56
73
|
end
|
|
57
74
|
end
|
|
58
75
|
|
data/lib/game_core.rb
CHANGED
data/lib/modules/storage.rb
CHANGED
data/lib/modules/validation.rb
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
module IcodebreakerGem
|
|
4
4
|
module Validation
|
|
5
|
+
USERNAME = /^[0-9a-zA-Z]{3,20}$/.freeze
|
|
6
|
+
CODE = /^[1-6]{4}$/.freeze
|
|
7
|
+
|
|
5
8
|
def validate_name(name)
|
|
6
|
-
raise ArgumentError, 'Incorrect username' unless name.to_s.match?(
|
|
9
|
+
raise ArgumentError, 'Incorrect username' unless name.to_s.match?(USERNAME)
|
|
7
10
|
end
|
|
8
11
|
|
|
9
12
|
def validate_code(code)
|
|
10
|
-
raise ArgumentError, 'Incorrect code' unless code.to_s.match?(
|
|
13
|
+
raise ArgumentError, 'Incorrect code' unless code.to_s.match?(CODE)
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
def validate_difficulty(difficulty)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: icodebreaker_gem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- JohnnyGsy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -26,6 +26,20 @@ dependencies:
|
|
|
26
26
|
version: '13.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: fasterer
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.9.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.9.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: i18n
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
30
44
|
requirements:
|
|
31
45
|
- - ">="
|
|
@@ -44,14 +58,14 @@ dependencies:
|
|
|
44
58
|
requirements:
|
|
45
59
|
- - ">="
|
|
46
60
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
61
|
+
version: 0.14.1
|
|
48
62
|
type: :development
|
|
49
63
|
prerelease: false
|
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
65
|
requirements:
|
|
52
66
|
- - ">="
|
|
53
67
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
68
|
+
version: 0.14.1
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: rspec
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,14 +100,14 @@ dependencies:
|
|
|
86
100
|
requirements:
|
|
87
101
|
- - ">="
|
|
88
102
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
103
|
+
version: 0.21.2
|
|
90
104
|
type: :development
|
|
91
105
|
prerelease: false
|
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
107
|
requirements:
|
|
94
108
|
- - ">="
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
|
-
version:
|
|
110
|
+
version: 0.21.2
|
|
97
111
|
description: Guess the secret code
|
|
98
112
|
email:
|
|
99
113
|
- vanstrelok@gmail.com
|
|
@@ -115,8 +129,8 @@ files:
|
|
|
115
129
|
- Rakefile
|
|
116
130
|
- bin/console
|
|
117
131
|
- bin/setup
|
|
132
|
+
- config/locales/en.yml
|
|
118
133
|
- lib/config.rb
|
|
119
|
-
- lib/constants.rb
|
|
120
134
|
- lib/game.rb
|
|
121
135
|
- lib/game_core.rb
|
|
122
136
|
- lib/icodebreaker_gem.rb
|
data/lib/constants.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module IcodebreakerGem
|
|
4
|
-
STATUS = %i[go_on over].freeze
|
|
5
|
-
RESULT = %i[win lose].freeze
|
|
6
|
-
DIFFICULTIES = {
|
|
7
|
-
easy: {
|
|
8
|
-
attempts_total: 15,
|
|
9
|
-
hints_total: 2
|
|
10
|
-
},
|
|
11
|
-
medium: {
|
|
12
|
-
attempts_total: 10,
|
|
13
|
-
hints_total: 1
|
|
14
|
-
},
|
|
15
|
-
hell: {
|
|
16
|
-
attempts_total: 5,
|
|
17
|
-
hints_total: 1
|
|
18
|
-
}
|
|
19
|
-
}.freeze
|
|
20
|
-
end
|