flammarion_rails 0.2.1 → 0.2.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 +4 -4
- data/README.md +3 -1
- data/lib/flammarion/engraving.rb +14 -8
- data/lib/flammarion/revelator.rb +3 -12
- data/lib/flammarion_rails/version.rb +1 -1
- data/spec/dummy/bin/flammarion +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: c0980270558683db4a166526a1f22304ce585888
|
4
|
+
data.tar.gz: 1cf80fb2374d31c489ec00e370a35d947d8bf5ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3993f0c63e101013adb0fe1503a7f484f147e102b769bc60385ad6325d5a873527d2cd8e16916375f69c6451ec7b36a28db7c87a0ad2220626c3f52142f07cf6
|
7
|
+
data.tar.gz: c77d8b947c93e5007a573de543bcaeb793bc3db56ae302afc09451f776ffbe231039cded82aa2f389351b47899d0c9ff89f5f904a2509500a65c8888df25367e
|
data/README.md
CHANGED
data/lib/flammarion/engraving.rb
CHANGED
@@ -5,13 +5,13 @@ module Flammarion
|
|
5
5
|
|
6
6
|
attr_accessor :on_disconnect, :on_connect, :sockets, :request, :status, :headers, :response
|
7
7
|
|
8
|
+
PROTOCOL = /^.*:\/{2}(:\d{0,4})?/i
|
9
|
+
|
8
10
|
# Creates a new Engraving (i.e., a new display window)
|
9
11
|
# @option options [Proc] :on_connect Called when the display window is
|
10
12
|
# connected (i.e., displayed)
|
11
13
|
# @option options [Proc] :on_disconnect Called when the display windows is
|
12
14
|
# disconnected (i.e., closed)
|
13
|
-
# @option options [Boolean] :exit_on_disconnect (false) Will call +exit+
|
14
|
-
# when the widow is closed if this option is true.
|
15
15
|
# @raise {SetupError} if chrome is not set up correctly and
|
16
16
|
# and Flammarion is unable to display the engraving.
|
17
17
|
def initialize(**options)
|
@@ -19,7 +19,6 @@ module Flammarion
|
|
19
19
|
@sockets = []
|
20
20
|
@on_connect = options[:on_connect]
|
21
21
|
@on_disconnect = options[:on_disconnect]
|
22
|
-
@exit_on_disconnect = options.fetch(:exit_on_disconnect, false)
|
23
22
|
|
24
23
|
start_server
|
25
24
|
@window_id = @@server.register_window(self)
|
@@ -35,7 +34,7 @@ module Flammarion
|
|
35
34
|
|
36
35
|
def disconnect(ws)
|
37
36
|
@sockets.delete ws
|
38
|
-
exit 0
|
37
|
+
exit 0
|
39
38
|
@on_disconnect.call if @on_disconnect
|
40
39
|
end
|
41
40
|
|
@@ -45,7 +44,7 @@ module Flammarion
|
|
45
44
|
dispatch(params)
|
46
45
|
|
47
46
|
if status == 302
|
48
|
-
dispatch(url: headers['Location'].sub(
|
47
|
+
dispatch(url: headers['Location'].sub(PROTOCOL, ''), session: response.request.session)
|
49
48
|
render(action: 'page', body: response.body)
|
50
49
|
elsif headers['Content-Transfer-Encoding'] == 'binary'
|
51
50
|
filename = headers['Content-Disposition'].sub(/.*filename=/, '').gsub(/(^"|"$)/, '')
|
@@ -67,11 +66,12 @@ module Flammarion
|
|
67
66
|
url = params.delete(:url)
|
68
67
|
uri = URI.parse(url)
|
69
68
|
query_params = Rack::Utils.parse_nested_query(uri.query)
|
69
|
+
request_params = {}
|
70
70
|
|
71
71
|
if params.key?(:form)
|
72
72
|
params[:method] = 'post'
|
73
|
-
params
|
74
|
-
params.
|
73
|
+
request_params = Rack::Utils.parse_nested_query(params.delete(:form))
|
74
|
+
request_params[params.delete(:button)] = ''
|
75
75
|
end
|
76
76
|
if params.key?(:_method)
|
77
77
|
params[:method] = params[:_method]
|
@@ -88,9 +88,15 @@ module Flammarion
|
|
88
88
|
action = path_params[:action] || 'index'
|
89
89
|
request_env = {
|
90
90
|
'rack.input' => '',
|
91
|
+
'QUERY_STRING' => uri.query,
|
91
92
|
'REQUEST_METHOD' => http_method,
|
92
|
-
'
|
93
|
+
'REQUEST_PATH' => uri.path,
|
94
|
+
'REQUEST_URI' => url,
|
95
|
+
'PATH_INFO' => uri.path,
|
96
|
+
'action_dispatch.request.query_parameters' => query_params,
|
97
|
+
'action_dispatch.request.request_parameters' => request_params,
|
93
98
|
'action_dispatch.request.path_parameters' => path_params,
|
99
|
+
'action_dispatch.request.parameters' => params.merge!(request_params).merge!(path_params),
|
94
100
|
}
|
95
101
|
request_env['rack.session'] = session if session
|
96
102
|
self.request = ActionDispatch::Request.new(request_env)
|
data/lib/flammarion/revelator.rb
CHANGED
@@ -2,12 +2,8 @@ module Flammarion
|
|
2
2
|
class SetupError < StandardError; end
|
3
3
|
|
4
4
|
module Revelator
|
5
|
-
CHROME_PATH = ENV["FLAMMARION_REVELATOR_PATH"] || 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
|
6
|
-
|
7
5
|
def open_a_window(**options)
|
8
6
|
index_path = FlammarionRails::Engine.root.join('public', 'index.html')
|
9
|
-
index_path = `cygpath -w '#{index_path}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
|
10
|
-
|
11
7
|
url = "file://#{index_path}?" + { port: server.port, path: @window_id, boot: FlammarionRails.config.boot_path }.to_query
|
12
8
|
@browser_options = options.merge(url: url)
|
13
9
|
@requested_browser = ENV["FLAMMARION_BROWSER"] || options[:browser]
|
@@ -47,14 +43,9 @@ module Flammarion
|
|
47
43
|
|
48
44
|
browser :chrome_windows do |options|
|
49
45
|
return false unless RbConfig::CONFIG["host_os"] =~ /cygwin|mswin|mingw/
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
resource = "http://localhost:4567/" if options[:development_mode]
|
54
|
-
chrome_path = CHROME_PATH
|
55
|
-
chrome_path = `cygpath -u '#{CHROME_PATH}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
|
56
|
-
return false unless File.exist?(chrome_path)
|
57
|
-
Process.detach(spawn(chrome_path, %[--app=#{resource}?path=#{@window_id}&port=#{server.port}]))
|
46
|
+
executable = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
|
47
|
+
return false unless File.exist?(executable)
|
48
|
+
Process.detach(spawn(executable, %[--app=#{options[:url]}]))
|
58
49
|
end
|
59
50
|
|
60
51
|
browser :chrome do |options|
|
data/spec/dummy/bin/flammarion
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flammarion_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrice Lebel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|