retroflix 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/lib/workers.rb +17 -0
  3. data/retroflix.yml +3 -3
  4. data/server.rb +14 -5
  5. data/site.rb +5 -0
  6. metadata +16 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d92944f606f69c813af81701e7d52e820c0dbb9
4
- data.tar.gz: 94dc77c7a5c6cbe88cb0b1f0c747e656b438a325
3
+ metadata.gz: cdc73a4acea12ab2f44d6c9f4daabb30204cfbe6
4
+ data.tar.gz: 8c48e0b7022e3c10b454ff68a5207d6d3e225873
5
5
  SHA512:
6
- metadata.gz: eaf6241347ddbcda5353d3e81e3ced4185469de262e848ce8962ddc2497cfd10a23bfc5b253452dc3b961042d0e5dccb22d7d6c80672fa9b89493831e76a58b5
7
- data.tar.gz: 68e930eb461522a5ae63f1b35372cbe81c3d33dae6aa252f5dc0193b13273797700468e831b5106754cdbcbec3ee7fbf142319bc54f28f1cd32ea08f1dda5882
6
+ metadata.gz: 00cb7fe2563a3c14192cb79e45de77bb7d1856e72d881714def3e6a15b252580c9d2027bcc493df9e37f3e7e768faf0e50b6b4296d70a47c8847e97a55f3b81f
7
+ data.tar.gz: 89742cb8c83cc59c7e8fa1140553790c7fbddf47ba41f3b8e5eaa680dce8754c741fd169c0b0cb51faf72be82b90018a800b888c6e015ebd7b44c371283418d0
@@ -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
@@ -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
- - "/\\[BIOS\\].*/"
26
- - "/\\[Program\\].*/"
27
- - "/\\[SegaNet\\].*/"
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").text "[D]"
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 => "#{dl_path}", :class => "dl_link").text "Download"
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
- downloaded = RetroFlix::download(system.intern, game)
200
- name, extracted = *RetroFlix.extract_archive(downloaded)
201
- RetroFlix.write_game(system, game, name, extracted)
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.3
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