parker 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/parker +15 -15
- data/lib/parker.rb +1 -1
- data/lib/parker/game.rb +4 -1
- data/lib/parker/platform/base.rb +7 -6
- data/lib/parker/platform/ps4.rb +7 -4
- data/lib/parker/platform/steam.rb +10 -2
- data/lib/parker/platform/switch.rb +5 -2
- data/lib/parker/screenshot.rb +7 -2
- data/lib/parker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6140e492f8266e3ee41d4469b399277ea94b69c
|
4
|
+
data.tar.gz: fcf9872e68727c46c18664a41b1c07ff2c3b7c42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3e9f6940aa89ccee818dbca691bda029c2ab9446937412c8587aa32c918531466a49ad49f32acf4771e46f2cfa57f7d60231a096421873242217ad002470e23
|
7
|
+
data.tar.gz: bd32a4526d1d5ed7ffe5a7c5f3fc762f20b89e8785cad04a62e89904f79e9e69105ef7a1202b3fa7848bcaadcf2b59392f7ba55e9beb320194d8a9d18b3e638e
|
data/bin/parker
CHANGED
@@ -15,15 +15,15 @@ end
|
|
15
15
|
|
16
16
|
source_directory = File.expand_path(File.join('~/', '.config', 'parker'))
|
17
17
|
|
18
|
-
|
18
|
+
Trollop.options do
|
19
19
|
version "parker v#{Parker::VERSION}"
|
20
|
-
banner <<-
|
20
|
+
banner <<-BANNER
|
21
21
|
A ridiculous tool for organising game screenshots.
|
22
22
|
|
23
23
|
Usage:
|
24
24
|
parker [output directory]
|
25
25
|
Options:
|
26
|
-
|
26
|
+
BANNER
|
27
27
|
end
|
28
28
|
|
29
29
|
unless Dir.exist?(source_directory)
|
@@ -58,30 +58,30 @@ Dir.glob(File.join(source_directory, 'platforms', '*.json')).each do |path|
|
|
58
58
|
end
|
59
59
|
|
60
60
|
if platforms.empty?
|
61
|
-
puts
|
61
|
+
puts 'Nothing to do (no platforms found).'
|
62
62
|
exit
|
63
63
|
end
|
64
64
|
|
65
65
|
output_path = File.expand_path(ARGV[0])
|
66
66
|
FileUtils.mkdir_p(output_path) unless Dir.exist?(output_path)
|
67
67
|
|
68
|
-
puts
|
68
|
+
puts 'Scanning...'
|
69
69
|
|
70
70
|
platforms.each do |platform|
|
71
71
|
platform.games.each_value do |game|
|
72
|
-
|
73
|
-
print "- #{game.name} (#{platform.name}): "
|
72
|
+
next unless game.screenshots.count.positive?
|
74
73
|
|
75
|
-
|
76
|
-
copied_count = game.copy_screenshots(platform_path)
|
74
|
+
print "- #{game.name} (#{platform.name}): "
|
77
75
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
platform_path = File.join(output_path, platform.name)
|
77
|
+
copied_count = game.copy_screenshots(platform_path)
|
78
|
+
|
79
|
+
if copied_count.positive?
|
80
|
+
puts "Copied #{copied_count} new screenshot#{'s' if copied_count != 1}."
|
81
|
+
else
|
82
|
+
puts '✓'
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
puts "\nDone!"
|
87
|
+
puts "\nDone!"
|
data/lib/parker.rb
CHANGED
data/lib/parker/game.rb
CHANGED
data/lib/parker/platform/base.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Parker
|
2
4
|
module Platform
|
5
|
+
# A base class for all platforms.
|
3
6
|
class Base
|
4
7
|
attr_reader :name, :source_path
|
5
8
|
attr_accessor :games
|
@@ -9,13 +12,11 @@ module Parker
|
|
9
12
|
@source_path = source_path
|
10
13
|
@games = {}
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
@games[identifier] = Game.new(identifier, name)
|
15
|
-
end
|
15
|
+
game_data&.map do |game_identifier, game_name|
|
16
|
+
@games[game_identifier] = Game.new(game_identifier, game_name)
|
16
17
|
end
|
17
18
|
|
18
|
-
scan_games
|
19
|
+
scan_games if Dir.exist?(@source_path)
|
19
20
|
end
|
20
21
|
|
21
22
|
def scan_games
|
@@ -23,4 +24,4 @@ module Parker
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
26
|
-
end
|
27
|
+
end
|
data/lib/parker/platform/ps4.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'digest'
|
2
4
|
|
3
5
|
module Parker
|
4
6
|
module Platform
|
7
|
+
# A class that models the PlayStation 4 platform.
|
5
8
|
class PS4 < Base
|
6
9
|
def scan_games
|
7
10
|
screenshots_path = File.join(source_path, '*', File::SEPARATOR, '*.jpg')
|
8
11
|
|
9
12
|
Dir.glob(screenshots_path).each do |path|
|
10
|
-
next if (
|
13
|
+
next if path.match?(/\_\d.jpg$/)
|
11
14
|
|
12
|
-
|
15
|
+
game_name = File.basename(path, File.extname(path)).split('_')[0]
|
13
16
|
game_id = Digest::SHA1.hexdigest(game_name)[0..9]
|
14
17
|
|
15
|
-
games[game_id] ||= Game.new(game_name.sub('™', '').sub('_', ' -'))
|
18
|
+
games[game_id] ||= Game.new(game_id, game_name.sub('™', '').sub('_', ' -'))
|
16
19
|
games[game_id].screenshots << Screenshot.new(path)
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
21
|
-
end
|
24
|
+
end
|
@@ -1,9 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Parker
|
2
4
|
module Platform
|
5
|
+
# A class that models the Steam platform.
|
3
6
|
class Steam < Base
|
4
7
|
def scan_games
|
5
8
|
games.each do |identifier, game|
|
6
|
-
screenshot_path = File.join(
|
9
|
+
screenshot_path = File.join(
|
10
|
+
source_path,
|
11
|
+
identifier.to_s,
|
12
|
+
'screenshots',
|
13
|
+
'*.jpg'
|
14
|
+
)
|
7
15
|
|
8
16
|
Dir.glob(screenshot_path).each do |path|
|
9
17
|
game.screenshots << Screenshot.new(path)
|
@@ -12,4 +20,4 @@ module Parker
|
|
12
20
|
end
|
13
21
|
end
|
14
22
|
end
|
15
|
-
end
|
23
|
+
end
|
@@ -1,14 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Parker
|
2
4
|
module Platform
|
5
|
+
# A class that models the Nintendo Switch platform.
|
3
6
|
class Switch < Base
|
4
7
|
def scan_games
|
5
8
|
screenshot_path = File.join(source_path, '**', '*.jpg')
|
6
9
|
|
7
10
|
Dir.glob(screenshot_path).each do |path|
|
8
11
|
game_id = File.basename(path, File.extname(path)).split('-')[-1]
|
9
|
-
games[game_id].screenshots << Screenshot.new(path)
|
12
|
+
(games[game_id].screenshots ||= {}) << Screenshot.new(path)
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
14
|
-
end
|
17
|
+
end
|
data/lib/parker/screenshot.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Parker
|
4
|
+
# A class that models a single game screenshot.
|
2
5
|
class Screenshot
|
3
6
|
attr_reader :path
|
4
7
|
attr_accessor :filename
|
@@ -6,8 +9,10 @@ module Parker
|
|
6
9
|
def initialize(path)
|
7
10
|
@path = path
|
8
11
|
|
9
|
-
|
12
|
+
name_pattern = /(\d{4})(\d{2})(\d{2})(\d+).+(\.[a-z]{3})/
|
13
|
+
parts = File.basename(@path).match(name_pattern)
|
14
|
+
|
10
15
|
@filename = parts.to_a[1..-2].join('-') << parts[-1]
|
11
16
|
end
|
12
17
|
end
|
13
|
-
end
|
18
|
+
end
|
data/lib/parker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bogan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|