reachy 1.1 → 1.2

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
  SHA1:
3
- metadata.gz: 08b598e9df22e627af1198a45436f0883644347b
4
- data.tar.gz: c2005872367ba2345d1462c0a3bba7c046003cee
3
+ metadata.gz: c151c647ac1a0ac4c6560347b8e8de1d317e9277
4
+ data.tar.gz: 0cb0660a434f4a658db5942a9ef7fe75ed6e4828
5
5
  SHA512:
6
- metadata.gz: b7cd060809d5ef86258ca046328fd40cfe3ea75dbb08da932aa38eb1a842192f3e3f615b74a061ad80e613fe9169b33869c37abc79b62308381691ec2f4044ac
7
- data.tar.gz: f8dc5d0ee3560fb31ee171e4954dfb9af7901f83164190e48228835b17df858b66ca1a815027d3de3e66907f67320645855ae615d6c474a4dc5518cd21c86944
6
+ metadata.gz: 155bc30602a00dddceed04690d34a7e252832e3ca857041639ed107a6d1d404a3258ca7757a0f860cb1808692059d4b84e5308744b524aa5dcbb4e5235044372
7
+ data.tar.gz: afa84eb2e02e83d81482a421d83043248bb43d4c56fcc80ab5a5d5e3492cf5eb6012d5c87ad32afb073a8919bd5b87a5a12a45d38415bbb51241100158407dca
@@ -3,6 +3,12 @@
3
3
  ##############################################
4
4
  module Reachy
5
5
 
6
+ # Path
7
+ APP_NAME = "reachy"
8
+ ROOT_PATH = Dir.home + "/." + APP_NAME + "/"
9
+ DATA_PATH = ROOT_PATH + "data/"
10
+ TRASH_PATH = DATA_PATH + "trash/"
11
+
6
12
  # Scoreboard formatting
7
13
  COL_SPACING = 15
8
14
 
@@ -83,7 +83,7 @@ module Reachy
83
83
 
84
84
  # Read JSON database file and repopulate object
85
85
  def read_data(filename)
86
- filepath = File.expand_path("../../../data/" + filename, __FILE__)
86
+ filepath = DATA_PATH + filename
87
87
  file = File.read(filepath)
88
88
  db = JSON.parse(file)
89
89
  self.populate(db)
@@ -93,7 +93,7 @@ module Reachy
93
93
  def write_data
94
94
  @last_updated = DateTime.now
95
95
  hash = self.to_h
96
- filepath = File.expand_path("../../../data/" + @filename, __FILE__)
96
+ filepath = DATA_PATH + @filename
97
97
  File.open(filepath, "w") do |f|
98
98
  f.write(JSON.pretty_generate(hash))
99
99
  end
@@ -134,8 +134,8 @@ module Reachy
134
134
 
135
135
  # Move data file of this game to trash
136
136
  def delete_from_disk
137
- FileUtils.mv(File.expand_path("../../../data/" + @filename, __FILE__),
138
- File.expand_path("../../../data/trash/" + @filename, __FILE__))
137
+ FileUtils.mv(DATA_PATH + @filename,
138
+ TRASH_PATH + @filename)
139
139
  end
140
140
 
141
141
  # Validate players input
@@ -39,7 +39,7 @@ module Reachy
39
39
  # Read all games in data dir, and store in @games array
40
40
  def self.read_all_games
41
41
  @games = []
42
- Dir.foreach(File.expand_path("../../../data/", __FILE__)) do |filename|
42
+ Dir.foreach(DATA_PATH) do |filename|
43
43
  # Skip . and .. dir entries, and trash dir
44
44
  next if filename == '.' or filename == '..' or filename == "trash"
45
45
 
@@ -82,11 +82,14 @@ module Reachy
82
82
 
83
83
  # Ensure that the data and data/trash directory exist, if not create them
84
84
  def self.ensure_data_dir
85
- if not File.directory?(File.expand_path("../../../data/", __FILE__))
86
- Dir.mkdir File.expand_path("../../../data/", __FILE__)
85
+ if not File.directory?(ROOT_PATH)
86
+ Dir.mkdir ROOT_PATH
87
87
  end
88
- if not File.directory?(File.expand_path("../../../data/trash/", __FILE__))
89
- Dir.mkdir File.expand_path("../../../data/trash/", __FILE__)
88
+ if not File.directory?(DATA_PATH)
89
+ Dir.mkdir DATA_PATH
90
+ end
91
+ if not File.directory?(TRASH_PATH)
92
+ Dir.mkdir TRASH_PATH
90
93
  end
91
94
  end
92
95
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reachy
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thao Truong (Kainu)
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-17 00:00:00.000000000 Z
12
+ date: 2016-07-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: someone@nowhere.com