parker 0.1.2 → 0.2.0

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
  SHA1:
3
- metadata.gz: e9a0e2f5823d20a7eed47c6824b0e977ef380011
4
- data.tar.gz: 66dad29bd63a27cc7bdbf795c923940b0d5a3c4a
3
+ metadata.gz: e6b3d51c383bb6974823917dd10513689ac3797a
4
+ data.tar.gz: 78dcc1a3f3f3500856b0f8926161d78c57b7c211
5
5
  SHA512:
6
- metadata.gz: d9c87dc5adc1febd6016bd4a49de66b72dce779db8efa87b6ecfb7d6cd442c9a5e4c147f87c37b47ccd8611c08e5f2989ae8050b3f07d9c7129d2447fcb8c3c3
7
- data.tar.gz: 3ef9efa29f3db9c7cc8c9f4b76a0a5074fbcbf32f2ffb84de2c62381a96780aadb27d4838dca5477f8b5350b5d945dace0fac96a5c13a3f44cb149e07663094f
6
+ metadata.gz: d49768e3885a97d26f79e9df40502b7f1119956668baf4707054f9451ba5d2f1c69e88de5048f1c933a88d1d48c95601966e2f99f49a1cb7f682417b806f844e
7
+ data.tar.gz: 02ab2d5533de7a4a170bc91a1ac88390ba914dc01b6314bb8a25eb940f92c03dfd2c5b644f69c280f4812737b57354fe05fe6f31f8827cbc407fb99f26a83c22
data/bin/parker CHANGED
@@ -37,17 +37,24 @@ Trollop.educate if ARGV.empty?
37
37
  platforms = []
38
38
 
39
39
  Dir.glob(File.join(source_directory, 'platforms', '*.json')).each do |path|
40
- platform_name = File.basename(path, File.extname(path)).capitalize
41
-
42
- if (platform_klass = Object.const_get("Parker::Platform::#{platform_name}"))
43
- platform_data = JSON.parse(File.read(path))
44
-
45
- platforms << platform_klass.new(
46
- platform_data['name'] || platform_name,
47
- platform_data['source_path'],
48
- platform_data['games'] || {}
49
- )
50
- end
40
+ klass = case File.basename(path, File.extname(path)).to_sym
41
+ when :ps4
42
+ 'PS4'
43
+ when :switch
44
+ 'Switch'
45
+ when :steam
46
+ 'Steam'
47
+ end
48
+
49
+ next if klass.nil?
50
+
51
+ platform_config = JSON.parse(File.read(path))
52
+
53
+ platforms << Object.const_get("Parker::Platform::#{klass}").new(
54
+ platform_config['name'],
55
+ platform_config['source_path'],
56
+ platform_config['games']
57
+ )
51
58
  end
52
59
 
53
60
  if platforms.empty?
data/lib/parker.rb CHANGED
@@ -9,6 +9,6 @@ require 'parker/game'
9
9
  require 'parker/screenshot'
10
10
 
11
11
  require 'parker/platform/base'
12
- require 'parker/platform/playstation'
12
+ require 'parker/platform/ps4'
13
13
  require 'parker/platform/steam'
14
14
  require 'parker/platform/switch'
data/lib/parker/game.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  module Parker
2
2
  class Game
3
- attr_accessor :name, :screenshots
3
+ attr_accessor :identifier, :name, :screenshots
4
4
 
5
- def initialize(name)
5
+ def initialize(identifier, name)
6
+ @identifier = identifier
6
7
  @name = name
7
8
  @screenshots = []
8
9
  end
@@ -16,7 +17,7 @@ module Parker
16
17
 
17
18
  next if File.exist?(new_file_path)
18
19
 
19
- FileUtils.mkdir(platform_path) unless Dir.exist?(platform_path)
20
+ FileUtils.mkdir_p(platform_path) unless Dir.exist?(platform_path)
20
21
  FileUtils.cp(screenshot.path, new_file_path)
21
22
 
22
23
  copied_screenshots += 1
@@ -5,12 +5,14 @@ module Parker
5
5
  attr_accessor :games
6
6
 
7
7
  def initialize(name, source_path, game_data)
8
- @name = name
8
+ @name = name || self.class.name.split('::').last
9
9
  @source_path = source_path
10
10
  @games = {}
11
11
 
12
- game_data.map do |identifier, name|
13
- @games[identifier] = Game.new(name)
12
+ unless game_data.nil?
13
+ game_data.map do |identifier, name|
14
+ @games[identifier] = Game.new(identifier, name)
15
+ end
14
16
  end
15
17
 
16
18
  scan_games
@@ -2,7 +2,7 @@ require 'digest'
2
2
 
3
3
  module Parker
4
4
  module Platform
5
- class Playstation < Base
5
+ class PS4 < Base
6
6
  def scan_games
7
7
  screenshots_path = File.join(source_path, '*', File::SEPARATOR, '*.jpg')
8
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parker
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bogan
@@ -34,10 +34,9 @@ extra_rdoc_files: []
34
34
  files:
35
35
  - bin/parker
36
36
  - lib/parker.rb
37
- - lib/parker/README.md
38
37
  - lib/parker/game.rb
39
38
  - lib/parker/platform/base.rb
40
- - lib/parker/platform/playstation.rb
39
+ - lib/parker/platform/ps4.rb
41
40
  - lib/parker/platform/steam.rb
42
41
  - lib/parker/platform/switch.rb
43
42
  - lib/parker/screenshot.rb
data/lib/parker/README.md DELETED
@@ -1,46 +0,0 @@
1
- # Parker
2
-
3
- This is a very simple tool for organising your video game screenshots. I _love_ my game screenshots, and like to have them neatly sorted by platform and game, but I might just be weird.
4
-
5
- It currently supports 3 platforms: Steam, the Nintendo Switch, and the PS4. Please note: you'll still have to, y'know, actually copy them onto a disk somewhere yourself before running Parker. I wish this wasn't still a painful experience, but here we are.
6
-
7
- ## Installation
8
-
9
- Parker is built in Ruby as a gem, and thus:
10
-
11
- > gem install parker
12
-
13
- And done.
14
-
15
- ## Usage
16
-
17
- It's a very simple command-line tool - by default, Parker will try to copy your screenshots into the current directory, though you can provide an alternative with the `-d` option.
18
-
19
- It will look for JSON configuration files with a name matching each game platform in its `~/.config/parker` directory:
20
-
21
- - `~/.config/parker/steam.json`
22
- - `~/.config/parker/switch.json`
23
- - `~/.config/parker/playstation.json`
24
-
25
- All config files share the same format:
26
-
27
- ```json
28
- {
29
- "source_path": "/path/to/game/screenshots/",
30
- "name": "My Steam Screenshots",
31
- "games": {
32
- "game_id_1": "Awesome Game",
33
- "game_id_2": "Awesome Game 2: More Awesomer"
34
- }
35
- }
36
- ```
37
-
38
- Your config _must_ have a `source_path`, or Parker won't know where to look for screenshots, and that would be bad.
39
-
40
- The optional `name` value will be used to name the parent directory housing each game (and so in the above example, if you were telling Parker to use `~/Pictures/Screenshots`, the above would copy games into `~/Pictures/Screenshots/My Steam Screenshots/Awesome Game`, etc. If left out, it defaults to a capitalised version of the platform name.
41
-
42
- The key/value in the `games` section is required for every platform _except_ the Playstation (due to the layout of the screenshots on disk coming off the console, we can pull the game name for you). You can determine the game ID for Steam and Switch games based on the ID in the screenshot path, or the ending hash of the filename, respectively. This is less than ideal, but hey, it works for now.
43
-
44
- It's possible that eventually I'd either add a way to look these up or keep a giant database of the mappings locally. Maybe.
45
-
46
- And that's pretty much it. This is mostly for me, really, but I'd love to know if someone else finds it useful.