alex_codebreaker 0.1.9 → 0.1.10
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/README.md +2 -0
- data/lib/alex_codebreaker/configuration.rb +19 -0
- data/lib/alex_codebreaker/modules/files.rb +7 -0
- data/lib/alex_codebreaker/players_rating.rb +2 -2
- data/lib/alex_codebreaker/session.rb +1 -1
- data/lib/alex_codebreaker/version.rb +1 -1
- data/lib/alex_codebreaker.rb +1 -1
- metadata +4 -3
- data/lib/alex_codebreaker/files_config.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eac53e89210dc8e710691351eef152cd30cc56779342f8d7b350f801301dca5c
|
4
|
+
data.tar.gz: 8e9ded59bae4d0aa6613891d010794f1ee12a06d1867b76c1180451e3e7d3708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b054b230250ac5a3bded46e2e14bb3e32bb2b8d25fda06925b8922b8323e51b421242a7e0a523870ce77674f082c695fafa1882c8f256a8400fbde46e3f0c0c
|
7
|
+
data.tar.gz: ed7d6cd1dc2874782ba6910ce70855922ba6b7e64876505374b77f800c2f40d9734e55cf69248ba888197088adeeb42a8fae4a53310a2667d9faece2202c8334
|
data/README.md
CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
To config storage path add this to your app config `AlexCodebreaker.configure { |config| config.storage_path = 'your/path.yml' }`
|
24
|
+
|
23
25
|
Use this gem for creating amazing version of codebreaker game!
|
24
26
|
|
25
27
|
## Development
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module AlexCodebreaker
|
2
|
+
class Configuration
|
3
|
+
DEFAULT_PATH = 'stats.yml'.freeze
|
4
|
+
|
5
|
+
attr_accessor :storage_path
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@storage_path = DEFAULT_PATH
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
yield configuration
|
18
|
+
end
|
19
|
+
end
|
@@ -10,14 +10,14 @@ module AlexCodebreaker
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def load_and_sort_stats
|
13
|
-
return unless File.exist?(AlexCodebreaker
|
13
|
+
return unless File.exist?(AlexCodebreaker.configuration.storage_path)
|
14
14
|
|
15
15
|
load_stats
|
16
16
|
sort_stats
|
17
17
|
end
|
18
18
|
|
19
19
|
def load_stats
|
20
|
-
File.open(AlexCodebreaker
|
20
|
+
File.open(AlexCodebreaker.configuration.storage_path) do |file|
|
21
21
|
@stats = Array.new(YAML.load_stream(file))
|
22
22
|
end
|
23
23
|
end
|
@@ -37,7 +37,7 @@ module AlexCodebreaker
|
|
37
37
|
|
38
38
|
def save_statistic
|
39
39
|
@time = Time.new
|
40
|
-
File.open(AlexCodebreaker
|
40
|
+
File.open(AlexCodebreaker.configuration.storage_path, 'a') { |file| file.write(to_yaml) }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
data/lib/alex_codebreaker.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
|
3
|
+
require_relative 'alex_codebreaker/configuration'
|
3
4
|
require_relative 'alex_codebreaker/version'
|
4
5
|
require_relative 'alex_codebreaker/modules/settings'
|
5
6
|
require_relative 'alex_codebreaker/modules/difficulty_levels'
|
6
7
|
require_relative 'alex_codebreaker/modules/validators'
|
7
8
|
require_relative 'alex_codebreaker/modules/arguments_validation'
|
8
|
-
require_relative 'alex_codebreaker/files_config'
|
9
9
|
require_relative 'alex_codebreaker/secret_code_generator'
|
10
10
|
require_relative 'alex_codebreaker/comparison'
|
11
11
|
require_relative 'alex_codebreaker/players_rating'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alex_codebreaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleksandr Loza
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -161,10 +161,11 @@ files:
|
|
161
161
|
- README.md
|
162
162
|
- lib/alex_codebreaker.rb
|
163
163
|
- lib/alex_codebreaker/comparison.rb
|
164
|
-
- lib/alex_codebreaker/
|
164
|
+
- lib/alex_codebreaker/configuration.rb
|
165
165
|
- lib/alex_codebreaker/game.rb
|
166
166
|
- lib/alex_codebreaker/modules/arguments_validation.rb
|
167
167
|
- lib/alex_codebreaker/modules/difficulty_levels.rb
|
168
|
+
- lib/alex_codebreaker/modules/files.rb
|
168
169
|
- lib/alex_codebreaker/modules/settings.rb
|
169
170
|
- lib/alex_codebreaker/modules/validators.rb
|
170
171
|
- lib/alex_codebreaker/players_rating.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module AlexCodebreaker
|
2
|
-
class FilesConfig
|
3
|
-
# rubocop:disable Style/ClassVars
|
4
|
-
DEFAULT_PATH = 'stats.yml'.freeze
|
5
|
-
|
6
|
-
def default_path
|
7
|
-
@@default_path ||= DEFAULT_PATH
|
8
|
-
end
|
9
|
-
|
10
|
-
def default_path=(path)
|
11
|
-
@@default_path = path
|
12
|
-
end
|
13
|
-
# rubocop:enable Style/ClassVars
|
14
|
-
end
|
15
|
-
end
|