codebreaker2018 0.3.0.2 → 0.3.1.0
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/lib/codebreaker/console.rb +2 -2
- data/lib/codebreaker/localization.rb +1 -1
- data/lib/codebreaker/storage.rb +13 -0
- data/lib/codebreaker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 435767b1df359b965f3d3b0f93311d24f1662ceea9d2bf092bc29f16d56681ee
|
4
|
+
data.tar.gz: a9894cacc72c053cf47cc7b1cff2271a2bc697e2b03918c68c12a8fe75638e30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0b4be341a2262844dac9c8167ce2b9c1e2c31df650b3e63597905564de327a8f6b63abbe7f63cd507ff1e852e5927ffeb4236b3145ef13cc615d3c180cebf37
|
7
|
+
data.tar.gz: 583414aa304ced16afebae113d9c0b4f18ca00680ec509970a11762b661c9a71018da69dea0fd7fdb2d63682d5098be568e7de4cc1b8f228f2770b081ddce360
|
data/lib/codebreaker/console.rb
CHANGED
@@ -11,7 +11,7 @@ module Codebreaker
|
|
11
11
|
YES = 'y'.freeze
|
12
12
|
EMPTY_INPUT = ''.freeze
|
13
13
|
|
14
|
-
attr_reader :game, :
|
14
|
+
attr_reader :game, :scores
|
15
15
|
|
16
16
|
def initialize(game = DEMO)
|
17
17
|
@locale = Localization.new(:console)
|
@@ -40,7 +40,7 @@ module Codebreaker
|
|
40
40
|
@game = game
|
41
41
|
@locale.lang = game.configuration.lang
|
42
42
|
@game_config_snapshot = game.configuration.clone
|
43
|
-
|
43
|
+
apply_external_path
|
44
44
|
@scores = load_game_data
|
45
45
|
end
|
46
46
|
|
@@ -20,7 +20,7 @@ module Codebreaker
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def apply_external_path(external_path)
|
23
|
-
if Dir.glob("#{external_path}/*/*.yml").empty?
|
23
|
+
if external_path && Dir.glob("#{external_path}/*/*.yml").empty?
|
24
24
|
raise ArgumentError, 'Invalid external path.'
|
25
25
|
end
|
26
26
|
@external_path = external_path ? external_path : false
|
data/lib/codebreaker/storage.rb
CHANGED
@@ -2,7 +2,20 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Codebreaker
|
4
4
|
module Storage
|
5
|
+
attr_reader :storage_path
|
5
6
|
private
|
7
|
+
def apply_external_path(external_path = false)
|
8
|
+
yml_file = 'scores.yml'
|
9
|
+
if external_path && !Dir.exists?(external_path)
|
10
|
+
raise ArgumentError, 'Invalid external path.'
|
11
|
+
end
|
12
|
+
@storage_path = if external_path
|
13
|
+
"#{external_path}/#{yml_file}"
|
14
|
+
else
|
15
|
+
File.expand_path("./data/#{yml_file}", File.dirname(__FILE__))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
6
19
|
def load_game_data
|
7
20
|
YAML.load(File.open(storage_path, 'r')) rescue []
|
8
21
|
end
|
data/lib/codebreaker/version.rb
CHANGED
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.0
|
4
|
+
version: 0.3.1.0
|
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-06-
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|