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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 799d4f49abd9be97d1c508b3b1ec3f3f3e603b274148e4c2474c476a43e63ea2
4
- data.tar.gz: 5cf0cf34b755af1a5aa8dd71a19bc04a7b7a90e45f7c983c73eda0a5b0c2b8d8
3
+ metadata.gz: 435767b1df359b965f3d3b0f93311d24f1662ceea9d2bf092bc29f16d56681ee
4
+ data.tar.gz: a9894cacc72c053cf47cc7b1cff2271a2bc697e2b03918c68c12a8fe75638e30
5
5
  SHA512:
6
- metadata.gz: 1645d38d18512010ee19adf04217ee0b3b9725636a3e565ee5da0e3c47864007209ec7bda17bc3d6de5e4a00534fb41851b348fc357c294709de70b9fc9ae1e1
7
- data.tar.gz: 994f43db763377fadebf036ed4fab608064f9c11df670a9251e4debcde193380e97f0d6c168f293472ddc16f26b782e8eba591c8e98aafd419bad07efe35d6bc
6
+ metadata.gz: c0b4be341a2262844dac9c8167ce2b9c1e2c31df650b3e63597905564de327a8f6b63abbe7f63cd507ff1e852e5927ffeb4236b3145ef13cc615d3c180cebf37
7
+ data.tar.gz: 583414aa304ced16afebae113d9c0b4f18ca00680ec509970a11762b661c9a71018da69dea0fd7fdb2d63682d5098be568e7de4cc1b8f228f2770b081ddce360
@@ -11,7 +11,7 @@ module Codebreaker
11
11
  YES = 'y'.freeze
12
12
  EMPTY_INPUT = ''.freeze
13
13
 
14
- attr_reader :game, :storage_path, :scores
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
- @storage_path = File.expand_path('./data/scores.yml', File.dirname(__FILE__))
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? && external_path
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Codebreaker
2
- VERSION = '0.3.0.2'
2
+ VERSION = '0.3.1.0'
3
3
  end
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.2
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-17 00:00:00.000000000 Z
11
+ date: 2018-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize