ruku 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 (55) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +96 -0
  3. data/Rakefile +33 -0
  4. data/bin/ruku +50 -0
  5. data/lib/ruku/clients/simple.rb +232 -0
  6. data/lib/ruku/clients/tk.rb +36 -0
  7. data/lib/ruku/clients/web.rb +117 -0
  8. data/lib/ruku/clients/web_static/css/ruku.css +196 -0
  9. data/lib/ruku/clients/web_static/images/box-medium.png +0 -0
  10. data/lib/ruku/clients/web_static/images/box-small.png +0 -0
  11. data/lib/ruku/clients/web_static/images/remote/back-over.png +0 -0
  12. data/lib/ruku/clients/web_static/images/remote/back.png +0 -0
  13. data/lib/ruku/clients/web_static/images/remote/down-over.png +0 -0
  14. data/lib/ruku/clients/web_static/images/remote/down.png +0 -0
  15. data/lib/ruku/clients/web_static/images/remote/fwd-over.png +0 -0
  16. data/lib/ruku/clients/web_static/images/remote/fwd.png +0 -0
  17. data/lib/ruku/clients/web_static/images/remote/home-over.png +0 -0
  18. data/lib/ruku/clients/web_static/images/remote/home.png +0 -0
  19. data/lib/ruku/clients/web_static/images/remote/left-over.png +0 -0
  20. data/lib/ruku/clients/web_static/images/remote/left.png +0 -0
  21. data/lib/ruku/clients/web_static/images/remote/pause-over.png +0 -0
  22. data/lib/ruku/clients/web_static/images/remote/pause.png +0 -0
  23. data/lib/ruku/clients/web_static/images/remote/right-over.png +0 -0
  24. data/lib/ruku/clients/web_static/images/remote/right.png +0 -0
  25. data/lib/ruku/clients/web_static/images/remote/select-over.png +0 -0
  26. data/lib/ruku/clients/web_static/images/remote/select.png +0 -0
  27. data/lib/ruku/clients/web_static/images/remote/space1.png +0 -0
  28. data/lib/ruku/clients/web_static/images/remote/space2.png +0 -0
  29. data/lib/ruku/clients/web_static/images/remote/space3.png +0 -0
  30. data/lib/ruku/clients/web_static/images/remote/up-over.png +0 -0
  31. data/lib/ruku/clients/web_static/images/remote/up.png +0 -0
  32. data/lib/ruku/clients/web_static/images/spacer.gif +0 -0
  33. data/lib/ruku/clients/web_static/index.html +203 -0
  34. data/lib/ruku/clients/web_static/js/jquery-1.4.2.js +154 -0
  35. data/lib/ruku/clients/web_static/js/ruku.js +447 -0
  36. data/lib/ruku/remote.rb +138 -0
  37. data/lib/ruku/remotes.rb +78 -0
  38. data/lib/ruku/storage.rb +77 -0
  39. data/lib/ruku.rb +5 -0
  40. data/ruku.gemspec +31 -0
  41. data/test/helper.rb +11 -0
  42. data/test/js/qunit.css +119 -0
  43. data/test/js/qunit.js +1069 -0
  44. data/test/js/runner.html +29 -0
  45. data/test/js/test_remote.js +37 -0
  46. data/test/js/test_remote_manager.js +186 -0
  47. data/test/js/test_remote_menu.js +208 -0
  48. data/test/js/test_util.js +15 -0
  49. data/test/test_remote.rb +89 -0
  50. data/test/test_remotes.rb +144 -0
  51. data/test/test_simple_client.rb +166 -0
  52. data/test/test_simple_storage.rb +70 -0
  53. data/test/test_web_client.rb +46 -0
  54. data/test/test_yaml_storage.rb +54 -0
  55. metadata +156 -0
@@ -0,0 +1,77 @@
1
+ module Ruku
2
+ class Storage
3
+ FILE_NAME = '.ruku-boxes'
4
+ attr_accessor :storage_path
5
+
6
+ def initialize(path=nil)
7
+ @storage_path = path
8
+ if not @storage_path
9
+ home = ENV['HOME']
10
+ home = ENV['USERPROFILE'] if not home
11
+ if !home && (ENV['HOMEDRIVE'] && ENV['HOMEPATH'])
12
+ home = File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH'])
13
+ end
14
+ home = File.expand_path('~') if not home
15
+ home = 'C:/' if !home && RUBY_PLATFORM =~ /mswin|mingw/
16
+
17
+ raise "Could not find user HOME directory" if not home
18
+
19
+ @storage_path = File.join(home, FILE_NAME)
20
+ end
21
+ end
22
+ end
23
+
24
+ # Stores Roku box information on disk in a plain text file, one box per
25
+ # line, in the format:
26
+ #
27
+ # HOSTNAME:BOX_NAME
28
+ #
29
+ # HOSTNAME is the hostname or IP address of a Roku box. This is the only
30
+ # required portion of the box configuration line. You may also include an
31
+ # optional, more readable box name.
32
+ #
33
+ # Examples of valid box config lines include:
34
+ #
35
+ # 192.168.1.7
36
+ # 192.168.1.8:Living Room
37
+ # NP-20F8A0003472:Bedroom
38
+ class SimpleStorage < Storage
39
+
40
+ def store(remotes)
41
+ File.open(@storage_path, 'w') do |f|
42
+ remotes.each {|r| f.puts "#{r.host}#{r.name ? ':'+r.name : ''}" }
43
+ end
44
+ end
45
+
46
+ def load
47
+ if File.exist? @storage_path
48
+ remotes = Remotes.new
49
+ IO.read(@storage_path).split("\n").each do |line|
50
+ host, name = line.split(':')
51
+ remotes.boxes << Remote.new(host, name)
52
+ end
53
+ remotes
54
+ else
55
+ Remotes.new
56
+ end
57
+ end
58
+ end
59
+
60
+ # Stores Roku box information on disk in YAML
61
+ class YAMLStorage < Storage
62
+
63
+ def store(manager)
64
+ File.open(@storage_path, 'w') do |out|
65
+ YAML.dump(manager, out)
66
+ end
67
+ end
68
+
69
+ def load
70
+ if File.exist? @storage_path
71
+ YAML.load_file(@storage_path)
72
+ else
73
+ Remotes.new
74
+ end
75
+ end
76
+ end
77
+ end
data/lib/ruku.rb ADDED
@@ -0,0 +1,5 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ %w[remote remotes storage].each do |lib|
4
+ require "ruku/#{lib}"
5
+ end
data/ruku.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'ruku'
3
+ s.version = '0.1'
4
+ s.date = '2011-2-1'
5
+ s.platform = Gem::Platform::RUBY
6
+
7
+ s.description = 'Roku™ set-top box remote control, command line and web interfaces'
8
+ s.summary = 'Ruku provides command line and web remote control interfaces for ' +
9
+ 'controlling all your Roku™ set-top boxes over a network.'
10
+
11
+ s.authors = ['Aaron Royer']
12
+ s.email = 'aaronroyer@gmail.com'
13
+
14
+ s.files = Dir['{bin/*,lib/**/*,test/**/*}'] +
15
+ %w[README.rdoc MIT-LICENSE ruku.gemspec Rakefile]
16
+
17
+ s.executables << 'ruku'
18
+
19
+ s.test_files = s.files.select {|path| path =~ /^test\/test_.*\.rb/}
20
+
21
+ s.has_rdoc = true
22
+ s.extra_rdoc_files = ['MIT-LICENSE']
23
+ s.homepage = 'http://github.com/aaronroyer/ruku'
24
+ s.rdoc_options = ["--line-numbers", "--inline-source"]
25
+ s.require_paths = ['lib']
26
+
27
+
28
+ s.add_runtime_dependency('json_pure', ['>= 1.4.6'])
29
+
30
+ s.add_development_dependency('mocha', ['>= 0.9.9'])
31
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'mocha'
4
+
5
+ begin
6
+ require 'redgreen' unless ENV['TM_MODE']
7
+ rescue LoadError
8
+ end
9
+
10
+ require File.join(File.dirname(__FILE__), *%w[.. lib ruku])
11
+ include Ruku
data/test/js/qunit.css ADDED
@@ -0,0 +1,119 @@
1
+
2
+ ol#qunit-tests {
3
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
4
+ margin:0;
5
+ padding:0;
6
+ list-style-position:inside;
7
+
8
+ font-size: smaller;
9
+ }
10
+ ol#qunit-tests li{
11
+ padding:0.4em 0.5em 0.4em 2.5em;
12
+ border-bottom:1px solid #fff;
13
+ font-size:small;
14
+ list-style-position:inside;
15
+ }
16
+ ol#qunit-tests li ol{
17
+ box-shadow: inset 0px 2px 13px #999;
18
+ -moz-box-shadow: inset 0px 2px 13px #999;
19
+ -webkit-box-shadow: inset 0px 2px 13px #999;
20
+ margin-top:0.5em;
21
+ margin-left:0;
22
+ padding:0.5em;
23
+ background-color:#fff;
24
+ border-radius:15px;
25
+ -moz-border-radius: 15px;
26
+ -webkit-border-radius: 15px;
27
+ }
28
+ ol#qunit-tests li li{
29
+ border-bottom:none;
30
+ margin:0.5em;
31
+ background-color:#fff;
32
+ list-style-position: inside;
33
+ padding:0.4em 0.5em 0.4em 0.5em;
34
+ }
35
+
36
+ ol#qunit-tests li li.pass{
37
+ border-left:26px solid #C6E746;
38
+ background-color:#fff;
39
+ color:#5E740B;
40
+ }
41
+ ol#qunit-tests li li.fail{
42
+ border-left:26px solid #EE5757;
43
+ background-color:#fff;
44
+ color:#710909;
45
+ }
46
+ ol#qunit-tests li.pass{
47
+ background-color:#D2E0E6;
48
+ color:#528CE0;
49
+ }
50
+ ol#qunit-tests li.fail{
51
+ background-color:#EE5757;
52
+ color:#000;
53
+ }
54
+ ol#qunit-tests li strong {
55
+ cursor:pointer;
56
+ }
57
+ h1#qunit-header{
58
+ background-color:#0d3349;
59
+ margin:0;
60
+ padding:0.5em 0 0.5em 1em;
61
+ color:#fff;
62
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
63
+ border-top-right-radius:15px;
64
+ border-top-left-radius:15px;
65
+ -moz-border-radius-topright:15px;
66
+ -moz-border-radius-topleft:15px;
67
+ -webkit-border-top-right-radius:15px;
68
+ -webkit-border-top-left-radius:15px;
69
+ text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
70
+ }
71
+ h2#qunit-banner{
72
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
73
+ height:5px;
74
+ margin:0;
75
+ padding:0;
76
+ }
77
+ h2#qunit-banner.qunit-pass{
78
+ background-color:#C6E746;
79
+ }
80
+ h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar {
81
+ background-color:#EE5757;
82
+ }
83
+ #qunit-testrunner-toolbar {
84
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
85
+ padding:0;
86
+ /*width:80%;*/
87
+ padding:0em 0 0.5em 2em;
88
+ font-size: small;
89
+ }
90
+ h2#qunit-userAgent {
91
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
92
+ background-color:#2b81af;
93
+ margin:0;
94
+ padding:0;
95
+ color:#fff;
96
+ font-size: small;
97
+ padding:0.5em 0 0.5em 2.5em;
98
+ text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
99
+ }
100
+ p#qunit-testresult{
101
+ font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
102
+ margin:0;
103
+ font-size: small;
104
+ color:#2b81af;
105
+ border-bottom-right-radius:15px;
106
+ border-bottom-left-radius:15px;
107
+ -moz-border-radius-bottomright:15px;
108
+ -moz-border-radius-bottomleft:15px;
109
+ -webkit-border-bottom-right-radius:15px;
110
+ -webkit-border-bottom-left-radius:15px;
111
+ background-color:#D2E0E6;
112
+ padding:0.5em 0.5em 0.5em 2.5em;
113
+ }
114
+ strong b.fail{
115
+ color:#710909;
116
+ }
117
+ strong b.pass{
118
+ color:#5E740B;
119
+ }