remoto 0.0.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.
Files changed (7) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +40 -0
  3. data/bin/remoto +19 -0
  4. data/lib/remoto.rb +64 -0
  5. data/makefile +2 -0
  6. data/test/remoto_test.rb +39 -0
  7. metadata +87 -0
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 Michel Martens
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ Remoto
2
+ ======
3
+
4
+ Remote control for browsers
5
+
6
+ Description
7
+ -----------
8
+
9
+ Remoto controls browsers that accept javascript via TCP, like Firefox
10
+ with the [Remote Control][rc] add-on.
11
+
12
+ It brings up a webserver on port `5450` (you can change it), and binds
13
+ it to `0.0.0.0`. You can then access it with any mobile device, like
14
+ an iPod, and use it to remote control a browser in the host computer.
15
+
16
+ A few assumptions: Remoto takes for granted that the browser will know
17
+ what to do with the `prev()` and `next()` javascript functions. It is
18
+ the way [Filmo][filmo] works, and you can adapt any other presentation
19
+ tool to make sense of these two functions.
20
+
21
+ [rc]: https://addons.mozilla.org/en-US/firefox/addon/remote-control/
22
+ [filmo]: http://files.soveran.com/filmo
23
+
24
+ ## Usage
25
+
26
+ ```
27
+ $ remoto [-p port] [-b browser-port]
28
+ ```
29
+
30
+ The default value for port is `5450`, and the default value for
31
+ browser-port is `32000`, which happens to be the default in the
32
+ [Remote Control] Firefox add-on.
33
+
34
+ ## Installation
35
+
36
+ As usual, you can install it using rubygems.
37
+
38
+ ```
39
+ $ gem install remoto
40
+ ```
data/bin/remoto ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/remoto"
4
+
5
+ require "clap"
6
+
7
+ extra = Clap.run ARGV,
8
+ "-p" => lambda { |p| Remoto::OPTIONS[:port] = p },
9
+ "-b" => lambda { |b| Remoto::OPTIONS[:brow] = b }
10
+
11
+ if extra.any?
12
+ puts "Usage: remoto [-p port] [-b browser-port]"
13
+ exit(1)
14
+ end
15
+
16
+ Rack::Server.start \
17
+ :app => Remoto,
18
+ :Port => Remoto::OPTIONS[:port],
19
+ :Host => "0.0.0.0"
data/lib/remoto.rb ADDED
@@ -0,0 +1,64 @@
1
+ require "cuba"
2
+
3
+ class Remoto < Cuba
4
+ OPTIONS = Hash.new
5
+ OPTIONS[:port] = 5450
6
+ OPTIONS[:brow] = 32000
7
+
8
+ PAGE = <<-EOS
9
+ <!DOCTYPE html>
10
+ <html lang="en">
11
+ <head>
12
+ <meta charset="UTF-8" />
13
+ <style>
14
+ body {
15
+ font-family: sans-serif;
16
+ background: yellow;
17
+ margin: 0;
18
+ padding: 0;
19
+ }
20
+
21
+ a {
22
+ display: block;
23
+ color: #f00;
24
+ text-decoration: none;
25
+ }
26
+ </style>
27
+
28
+ <title>Remoto</title>
29
+ </head>
30
+ <body>
31
+ <a id="next" href="/next">Next</span></a>
32
+ <a id="prev" href="/prev">Prev</span></a>
33
+ </body>
34
+ <script type="text/javascript">
35
+ n = document.getElementById("next");
36
+ n.style.fontSize = window.innerHeight * 0.8 + "px";
37
+
38
+ p = document.getElementById("prev");
39
+ p.style.fontSize = window.innerHeight * 0.2 + "px";
40
+ </script>
41
+ </html>
42
+ EOS
43
+
44
+ module Slides
45
+ def self.browser
46
+ TCPSocket.new("localhost", OPTIONS[:brow])
47
+ end
48
+
49
+ def self.show(page)
50
+ browser.tap do |socket|
51
+ socket.write("#{page}()")
52
+ socket.close
53
+ end
54
+ end
55
+ end
56
+
57
+ define do
58
+ res.write PAGE
59
+
60
+ on "(prev|next)" do |page|
61
+ Slides.show(page)
62
+ end
63
+ end
64
+ end
data/makefile ADDED
@@ -0,0 +1,2 @@
1
+ all:
2
+ cutest test/remoto_test.rb
@@ -0,0 +1,39 @@
1
+ require "socket"
2
+ require "cutest"
3
+
4
+ require_relative "../lib/remoto"
5
+
6
+ def expect(port, str)
7
+ server = TCPServer.new('localhost', port)
8
+
9
+ s = server.accept
10
+
11
+ msg = s.read
12
+
13
+ assert_equal msg, str
14
+
15
+ s.write("{}")
16
+ s.close
17
+ end
18
+
19
+ def check(port, str)
20
+ t = Thread.new { expect(port, "#{str}()") }
21
+
22
+ env = { "PATH_INFO" => "/#{str}", "SCRIPT_NAME" => "/" }
23
+
24
+ Remoto::OPTIONS[:brow] = port
25
+
26
+ _, _, resp = Remoto.call(env)
27
+
28
+ body = resp.join
29
+
30
+ assert body[/Remoto/]
31
+ assert body[/Next/]
32
+
33
+ t.join
34
+ end
35
+
36
+ test "commands" do
37
+ check 32001, "prev"
38
+ check 32002, "next"
39
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remoto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michel Martens
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: clap
16
+ requirement: &2156257900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2156257900
25
+ - !ruby/object:Gem::Dependency
26
+ name: cuba
27
+ requirement: &2156257040 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2156257040
36
+ - !ruby/object:Gem::Dependency
37
+ name: cutest
38
+ requirement: &2156256040 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2156256040
47
+ description: Remoto controls browsers that accept javascript via TCP, like Firefox
48
+ with the RemoteControl add-on.
49
+ email:
50
+ - michel@soveran.com
51
+ executables:
52
+ - remoto
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - README.md
57
+ - LICENSE
58
+ - bin/remoto
59
+ - lib/remoto.rb
60
+ - test/remoto_test.rb
61
+ - makefile
62
+ homepage: http://soveran.com/
63
+ licenses:
64
+ - MIT
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.11
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Remote control for browsers
87
+ test_files: []