flammarion 0.1.0 → 0.1.1

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.
data/Readme.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/flammarion.svg)](https://badge.fury.io/rb/flammarion)
4
4
 
5
5
  * [Source](https://github.com/zach-capalbo/flammarion)
6
- * [Documentation](http://zach-capalbo.github.io/flammarion/doc/Flammarion)
6
+ * [Documentation](http://zach-capalbo.github.io/flammarion/doc/Flammarion.html)
7
7
 
8
8
  ## Overview
9
9
 
@@ -76,8 +76,8 @@ f.button("Click Here!!!") {f.puts "You clicked the button!"}
76
76
  f.input("Placeholder > ") {|msg| f.puts "You wrote: #{msg['text'].light_magenta}"}
77
77
  ```
78
78
 
79
- The [api documetaion](http://zach-capalbo.github.io/flammarion/doc/Flammarion)
80
- is available at <http://zach-capalbo.github.io/flammarion/doc/Flammarion>.
79
+ The [api documetaion](http://zach-capalbo.github.io/flammarion/doc/Flammarion.html)
80
+ is available at <http://zach-capalbo.github.io/flammarion/doc/Flammarion.html>.
81
81
 
82
82
  ## Screenshots / Samples
83
83
 
@@ -26,8 +26,10 @@ module Flammarion
26
26
  # @option options [Boolean] :close_on_exit (false) Will close the window
27
27
  # when the process exits if this is true. Otherwise, it will just stay
28
28
  # around, but not actually be interactive.
29
- # @opion options [String] :title The initial title of the engraving. If
29
+ # @option options [String] :title The initial title of the engraving. If
30
30
  # empty, a random title will be generated.
31
+ # @raise {SetupError} if neither chrome nor electron is set up correctly and
32
+ # and Flammarion is unable to display the engraving.
31
33
  def initialize(options = {})
32
34
  options = {:title => options} if options.is_a?(String)
33
35
  @chrome = OpenStruct.new
@@ -1,8 +1,19 @@
1
1
  module Flammarion
2
+ # Raised when flammarion cannot find any way to display an engraving.
3
+ # On Linux, Flammarion will first try to launch Electron using the command
4
+ # +electron+. If that fails, it will try common aliases of Google Chrome. If
5
+ # none of them execute succesfully, it will raise this error. On Windows, it
6
+ # will try to launch Google Chrome from Program Files (x86). If chrome has
7
+ # been installed somewhere else, the user can set the environment variable
8
+ # FLAMMARION_REVELATOR_PATH to point to +chrome.exe+.
9
+ # @see http://electron.atom.io/
10
+ # @see http://www.google.com/chrome/
11
+ class SetupError < StandardError; end
12
+
2
13
  # @api private
3
14
  # @todo This all needs a lot of clean up
4
15
  module Revelator
5
- CHROME_PATH = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
16
+ CHROME_PATH = ENV["FLAMMARION_REVELATOR_PATH"] || 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
6
17
  def open_a_window_on_windows(options)
7
18
  file_path = File.absolute_path(File.join(File.dirname(__FILE__), ".."))
8
19
  file_path = `cygpath -w '#{file_path}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
@@ -10,6 +21,7 @@ module Flammarion
10
21
  resource = "http://localhost:4567/" if ENV["FLAMMARION_DEVELOPMENT"] == "true"
11
22
  chrome_path = CHROME_PATH
12
23
  chrome_path = `cygpath -u '#{CHROME_PATH}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
24
+ raise SetupError.new("Cannot find #{chrome_path}. You need to install Google Chrome or set the environment variable FLAMMARION_REVELATOR_PATH to point to chrome.exe") unless File.exist?(chrome_path)
13
25
  Process.detach(spawn(chrome_path, %[--app=#{resource}?path=#{@window_id}&port=#{server.port}&title="#{options[:title] || "Flammarion%20Engraving"}"]))
14
26
  end
15
27
 
@@ -26,12 +38,13 @@ module Flammarion
26
38
  return
27
39
  end
28
40
 
29
- %w[google-chrome google-chrome-stable chromium chromium-browser chrome C:\Program\ Files\ (x86)\Google\Chrome\Application\chrome.exe].each do |executable|
41
+ %w[google-chrome google-chrome-stable chromium chromium-browser chrome].each do |executable|
42
+ next unless which(executable)
30
43
  @chrome.in, @chrome.out, @chrome.err, @chrome.thread = Open3.popen3("#{executable} --app='#{host}?path=#{@window_id}&port=#{server.port}&title=#{@expect_title}'")
31
44
  break if @chrome.in
32
45
  end
33
46
 
34
- raise StandardError.new("Cannot launch any browser") unless @chrome.in
47
+ raise SetupError.new("You must have either electron or google-chrome installed and accesible via your path.") unless @chrome.in
35
48
  end
36
49
 
37
50
  private
@@ -1,3 +1,3 @@
1
1
  module Flammarion
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -68,7 +68,7 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
68
68
  console.log("Path: " + ($qs.get("path")) + ", Port: " + ($qs.get("port")) + ", Host: " + host);
69
69
  this.ws = new WebSocket("ws://" + host + ":" + ($qs.get("port")) + "/" + ($qs.get("path")));
70
70
  this.actions["__parent"] = this;
71
- document.title = $qs.get("title") || "Flammarion Unconnected";
71
+ document.title = decodeURIComponent($qs.get("title")) || "Flammarion";
72
72
  this.ws.onopen = function(msg) {
73
73
  return $('body').addClass("connected");
74
74
  };
@@ -6689,7 +6689,7 @@ if (typeof module !== 'undefined') {
6689
6689
  console.log("Path: " + ($qs.get("path")) + ", Port: " + ($qs.get("port")) + ", Host: " + host);
6690
6690
  this.ws = new WebSocket("ws://" + host + ":" + ($qs.get("port")) + "/" + ($qs.get("path")));
6691
6691
  this.actions["__parent"] = this;
6692
- document.title = $qs.get("title") || "Flammarion Unconnected";
6692
+ document.title = decodeURIComponent($qs.get("title")) || "Flammarion";
6693
6693
  this.ws.onopen = function(msg) {
6694
6694
  return $('body').addClass("connected");
6695
6695
  };
@@ -68,7 +68,7 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
68
68
  console.log("Path: " + ($qs.get("path")) + ", Port: " + ($qs.get("port")) + ", Host: " + host);
69
69
  this.ws = new WebSocket("ws://" + host + ":" + ($qs.get("port")) + "/" + ($qs.get("path")));
70
70
  this.actions["__parent"] = this;
71
- document.title = $qs.get("title") || "Flammarion Unconnected";
71
+ document.title = decodeURIComponent($qs.get("title")) || "Flammarion";
72
72
  this.ws.onopen = function(msg) {
73
73
  return $('body').addClass("connected");
74
74
  };
@@ -68,7 +68,7 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
68
68
  console.log("Path: " + ($qs.get("path")) + ", Port: " + ($qs.get("port")) + ", Host: " + host);
69
69
  this.ws = new WebSocket("ws://" + host + ":" + ($qs.get("port")) + "/" + ($qs.get("path")));
70
70
  this.actions["__parent"] = this;
71
- document.title = $qs.get("title") || "Flammarion Unconnected";
71
+ document.title = decodeURIComponent($qs.get("title")) || "Flammarion";
72
72
  this.ws.onopen = function(msg) {
73
73
  return $('body').addClass("connected");
74
74
  };
@@ -68,7 +68,7 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
68
68
  console.log("Path: " + ($qs.get("path")) + ", Port: " + ($qs.get("port")) + ", Host: " + host);
69
69
  this.ws = new WebSocket("ws://" + host + ":" + ($qs.get("port")) + "/" + ($qs.get("path")));
70
70
  this.actions["__parent"] = this;
71
- document.title = $qs.get("title") || "Flammarion Unconnected";
71
+ document.title = decodeURIComponent($qs.get("title")) || "Flammarion";
72
72
  this.ws.onopen = function(msg) {
73
73
  return $('body').addClass("connected");
74
74
  };
@@ -7,7 +7,7 @@ class WSClient
7
7
  console.log "Path: #{$qs.get("path")}, Port: #{$qs.get("port")}, Host: #{host}"
8
8
  @ws = new WebSocket "ws://#{host}:#{$qs.get("port")}/#{$qs.get("path")}"
9
9
  @actions["__parent"] = this
10
- document.title = $qs.get("title") || "Flammarion Unconnected"
10
+ document.title = decodeURIComponent($qs.get("title")) || "Flammarion"
11
11
  @ws.onopen = (msg) ->
12
12
  $('body').addClass("connected")
13
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flammarion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-01 00:00:00.000000000 Z
12
+ date: 2016-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: em-websocket