retroflix 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/workers.rb +17 -0
- data/retroflix.yml +3 -3
- data/server.rb +14 -5
- data/site.rb +5 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdc73a4acea12ab2f44d6c9f4daabb30204cfbe6
|
4
|
+
data.tar.gz: 8c48e0b7022e3c10b454ff68a5207d6d3e225873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00cb7fe2563a3c14192cb79e45de77bb7d1856e72d881714def3e6a15b252580c9d2027bcc493df9e37f3e7e768faf0e50b6b4296d70a47c8847e97a55f3b81f
|
7
|
+
data.tar.gz: 89742cb8c83cc59c7e8fa1140553790c7fbddf47ba41f3b8e5eaa680dce8754c741fd169c0b0cb51faf72be82b90018a800b888c6e015ebd7b44c371283418d0
|
data/lib/workers.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Background job workers
|
2
|
+
# Part of RetroFlix
|
3
|
+
|
4
|
+
require 'workers'
|
5
|
+
|
6
|
+
RFPool = Workers::Pool.new
|
7
|
+
|
8
|
+
module RetroFlix
|
9
|
+
def self.background_job(&bl)
|
10
|
+
RFPool.perform &bl
|
11
|
+
end
|
12
|
+
end # module RetroFlix
|
13
|
+
|
14
|
+
at_exit do
|
15
|
+
# 3 seconds to cleanup
|
16
|
+
RFPool.dispose(3)
|
17
|
+
end
|
data/retroflix.yml
CHANGED
@@ -22,9 +22,9 @@ databases:
|
|
22
22
|
desc: "//div[contains(@id, 'game-descriptions')]/div[contains(@class, 'description-text')]"
|
23
23
|
dl: "//a[contains(@id, 'download-link')]"
|
24
24
|
omit:
|
25
|
-
- "
|
26
|
-
- "
|
27
|
-
- "
|
25
|
+
- "\\[BIOS\\].*"
|
26
|
+
- "\\[Program\\].*"
|
27
|
+
- "\\[SegaNet\\].*"
|
28
28
|
|
29
29
|
# TODO coolroms, other dbs
|
30
30
|
|
data/server.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
# Main sinatra application.
|
3
3
|
# Part of RetroFlix
|
4
4
|
|
5
|
+
# require workers module initially so as
|
6
|
+
# to register global process hooks
|
7
|
+
require_relative './lib/workers'
|
8
|
+
|
5
9
|
require 'sinatra'
|
6
10
|
require_relative './lib/conf'
|
7
11
|
require_relative './lib/library'
|
@@ -48,7 +52,8 @@ get "/system/:system" do
|
|
48
52
|
|
49
53
|
else
|
50
54
|
doc.text " - "
|
51
|
-
doc.a(:href => dl_path, :class => "dl_link"
|
55
|
+
doc.a(:href => dl_path, :class => "dl_link",
|
56
|
+
:onclick => dl_link_onclick(game)).text "[D]"
|
52
57
|
end
|
53
58
|
}
|
54
59
|
}
|
@@ -151,7 +156,9 @@ get "/game/:system/:game" do
|
|
151
156
|
doc.a(:href => "#{delete_path}", :class => "delete_link").text "[Delete]"
|
152
157
|
|
153
158
|
else
|
154
|
-
doc.a(:href
|
159
|
+
doc.a(:href => "#{dl_path}",
|
160
|
+
:class => "dl_link",
|
161
|
+
:onclick => dl_link_onclick(game)).text "Download"
|
155
162
|
end
|
156
163
|
}
|
157
164
|
|
@@ -196,9 +203,11 @@ get "/download/:system/:game" do
|
|
196
203
|
|
197
204
|
puts "Downloading #{game} for #{system}"
|
198
205
|
|
199
|
-
|
200
|
-
|
201
|
-
RetroFlix.
|
206
|
+
RetroFlix::background_job do
|
207
|
+
downloaded = RetroFlix::download(system.intern, game)
|
208
|
+
name, extracted = *RetroFlix.extract_archive(downloaded)
|
209
|
+
RetroFlix.write_game(system, game, name, extracted)
|
210
|
+
end
|
202
211
|
|
203
212
|
redirect "/game/#{system}/#{URI.encode(game)}"
|
204
213
|
end
|
data/site.rb
CHANGED
@@ -74,3 +74,8 @@ def validate_num!(params)
|
|
74
74
|
num = params[:num]
|
75
75
|
Integer(num) # raises ArgumentError if invalid int
|
76
76
|
end
|
77
|
+
|
78
|
+
# Generate javascript invoked when download link is clicked
|
79
|
+
def dl_link_onclick(game)
|
80
|
+
"alert(\"Downloading #{game}, refresh page momentarily to play...\")"
|
81
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retroflix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mo Morsi
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.9.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: workers
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.6'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.6'
|
69
83
|
description: Retro Game Library Manager
|
70
84
|
email: mo@morsi.org
|
71
85
|
executables:
|
@@ -82,6 +96,7 @@ files:
|
|
82
96
|
- lib/emulator.rb
|
83
97
|
- lib/library.rb
|
84
98
|
- lib/scrape.rb
|
99
|
+
- lib/workers.rb
|
85
100
|
- random.rb
|
86
101
|
- retroflix.yml
|
87
102
|
- server.rb
|