alex_codebreaker 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b42bfc988ef8ade864e625c862c36ee20fdade8fd37f92c1974fbdcc7c553b8c
4
- data.tar.gz: 57af7561c129740d4fd3fd51c3b0fc40346f02ec962f42093fc77674df9a49d6
3
+ metadata.gz: eac53e89210dc8e710691351eef152cd30cc56779342f8d7b350f801301dca5c
4
+ data.tar.gz: 8e9ded59bae4d0aa6613891d010794f1ee12a06d1867b76c1180451e3e7d3708
5
5
  SHA512:
6
- metadata.gz: a424f27bcf19ab3e415e27fc572e4e90adac5c764c60e80a53b1edb699886a098d4d96e9929ba104f764302fa07efcebca6224585ee837e18221a2a9f780efe7
7
- data.tar.gz: 00a7561303ffe5e343461aaaae15f637cd8aefd476300879a4248202649389e365b7b35839a08b63c54df683557aeb0e431bbe9ea3a0d23f97971cb02fd350bb
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
@@ -0,0 +1,7 @@
1
+ module AlexCodebreaker
2
+ module Modules
3
+ module Files
4
+ STATS_FILE = 'stats.yml'.freeze
5
+ end
6
+ end
7
+ 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::FilesConfig.new.default_path)
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::FilesConfig.new.default_path) do |file|
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::FilesConfig.new.default_path, 'a') { |file| file.write(to_yaml) }
40
+ File.open(AlexCodebreaker.configuration.storage_path, 'a') { |file| file.write(to_yaml) }
41
41
  end
42
42
  end
43
43
  end
@@ -1,5 +1,5 @@
1
1
  module AlexCodebreaker
2
2
  module Version
3
- VERSION = '0.1.9'.freeze
3
+ VERSION = '0.1.10'.freeze
4
4
  end
5
5
  end
@@ -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.9
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-23 00:00:00.000000000 Z
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/files_config.rb
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