rhcp 0.1.6 → 0.1.7
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/bin/http_test_server.rb +70 -0
- data/{rhcp_test_server.sh → bin/rhcp_test_server.sh} +0 -0
- data/lib/rhcp.rb +1 -1
- data/lib/rhcp/broker.rb +3 -3
- data/lib/rhcp/client/http_broker.rb +1 -2
- data/lib/rhcp/http_exporter.rb +1 -0
- metadata +26 -61
- data/History.txt +0 -6
- data/Manifest.txt +0 -39
- data/README.txt +0 -46
- data/Rakefile +0 -83
- data/build_gem.sh +0 -21
- data/docroot/builder.js +0 -136
- data/docroot/controls.js +0 -965
- data/docroot/dragdrop.js +0 -975
- data/docroot/effects.js +0 -1130
- data/docroot/index.html +0 -176
- data/docroot/prototype.js +0 -4320
- data/docroot/scriptaculous.js +0 -60
- data/docroot/slider.js +0 -275
- data/docroot/sound.js +0 -55
- data/docroot/unittest.js +0 -568
@@ -0,0 +1,70 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
2
|
+
|
3
|
+
require 'rhcp'
|
4
|
+
|
5
|
+
require 'net/http'
|
6
|
+
require 'logger'
|
7
|
+
|
8
|
+
$logger = Logger.new($stdout)
|
9
|
+
|
10
|
+
broker = RHCP::Broker.new()
|
11
|
+
broker.register_command(RHCP::Command.new("test", "just a test command", lambda { |req,res| "testing" }))
|
12
|
+
broker.register_command(
|
13
|
+
RHCP::Command.new("reverse", "reversing input strings",
|
14
|
+
lambda { |req,res| req.get_param_value("input").reverse }
|
15
|
+
).add_param(RHCP::CommandParam.new("input", "the string to reverse", {
|
16
|
+
:lookup_method => lambda { [ "zaphod", "beeblebrox" ] }
|
17
|
+
}))
|
18
|
+
)
|
19
|
+
broker.register_command RHCP::Command.new("cook", "cook something nice out of some ingredients",
|
20
|
+
lambda { |req,res|
|
21
|
+
ingredients = req.get_param_value("ingredient").join(" ")
|
22
|
+
puts "cooking something with #{ingredients}"
|
23
|
+
ingredients
|
24
|
+
}
|
25
|
+
).add_param(RHCP::CommandParam.new("ingredient", "something to cook with",
|
26
|
+
{
|
27
|
+
:lookup_method => lambda { [ "mascarpone", "chocolate", "eggs", "butter", "marzipan" ] },
|
28
|
+
:allows_multiple_values => true,
|
29
|
+
:mandatory => true
|
30
|
+
}
|
31
|
+
)
|
32
|
+
)
|
33
|
+
command = RHCP::Command.new("list_stuff", "this command lists stuff",
|
34
|
+
lambda { |req,res|
|
35
|
+
[ "peace", "aquaeduct", "education" ]
|
36
|
+
}
|
37
|
+
)
|
38
|
+
command.mark_as_read_only()
|
39
|
+
command.result_hints[:display_type] = "list"
|
40
|
+
broker.register_command command
|
41
|
+
|
42
|
+
command = RHCP::Command.new("build_table", "this command returns tabular data",
|
43
|
+
lambda { |req,res|
|
44
|
+
[
|
45
|
+
{ :the_first_name => "Zaphod", :last_name => "Beeblebrox", :heads => 2, :character => "dangerous" },
|
46
|
+
{ :the_first_name => "Arthur", :last_name => "Dent", :heads => 1, :character => "harmless (mostly)" },
|
47
|
+
{ :the_first_name => "Prostetnik", :last_name => "Yoltz (?)", :heads => 1, :character => "ugly" }
|
48
|
+
]
|
49
|
+
}
|
50
|
+
)
|
51
|
+
command.mark_as_read_only()
|
52
|
+
command.result_hints[:display_type] = "table"
|
53
|
+
command.result_hints[:overview_columns] = [ "the_first_name", "last_name" ]
|
54
|
+
command.result_hints[:column_titles] = [ "First Name", "Last Name" ]
|
55
|
+
broker.register_command command
|
56
|
+
|
57
|
+
exporter = RHCP::HttpExporter.new(broker, :port => 42000)
|
58
|
+
|
59
|
+
trap("INT") {
|
60
|
+
exporter.stop
|
61
|
+
Kernel.exit 0
|
62
|
+
}
|
63
|
+
|
64
|
+
$logger.info "launching http exporter..."
|
65
|
+
exporter.start()
|
66
|
+
while (true) do
|
67
|
+
sleep 30
|
68
|
+
puts "."
|
69
|
+
end
|
70
|
+
$logger.info "exiting"
|
File without changes
|
data/lib/rhcp.rb
CHANGED
data/lib/rhcp/broker.rb
CHANGED
@@ -5,12 +5,12 @@ module RHCP
|
|
5
5
|
# all code that wants to export/publish these commands
|
6
6
|
class Broker
|
7
7
|
|
8
|
+
attr_reader :name
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
def initialize
|
10
|
+
def initialize(name = "")
|
12
11
|
# command_name => command
|
13
12
|
@known_commands = Hash.new()
|
13
|
+
@name = name
|
14
14
|
end
|
15
15
|
|
16
16
|
# returns a list of all known commands
|
@@ -12,8 +12,7 @@ module RHCP
|
|
12
12
|
# This is an implementation of a RHCP broker that retrieves it's data via
|
13
13
|
# http from a remote broker. Since it implements the same interface as RHCP::Broker,
|
14
14
|
# clients can use it exactly as if they were talking with the broker itself.
|
15
|
-
|
16
|
-
class HttpBroker
|
15
|
+
class HttpBroker < Broker
|
17
16
|
|
18
17
|
def initialize(url)
|
19
18
|
# TODO should this really be an URL? or just a host name?
|
data/lib/rhcp/http_exporter.rb
CHANGED
@@ -61,6 +61,7 @@ module RHCP
|
|
61
61
|
}
|
62
62
|
# TODO this path should probably be quite relative
|
63
63
|
@server.mount "/#{@url_prefix}/info", HTTPServlet::FileHandler, "docroot"
|
64
|
+
@server.mount "/#{@url_prefix}/info2", HTTPServlet::FileHandler, "qooxdoo_rhcp/build"
|
64
65
|
@server.mount "/#{@url_prefix}/get_commands", GetCommandsServlet, @broker
|
65
66
|
@server.mount "/#{@url_prefix}/get_lookup_values", GetLookupValuesServlet, @broker
|
66
67
|
@server.mount "/#{@url_prefix}/execute", ExecuteServlet, @broker
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Traeder
|
@@ -9,88 +9,53 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-20 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: hoe
|
27
|
-
type: :development
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.2
|
34
|
-
version:
|
35
|
-
description: The rhcp protocol allows you to register commands along with their parameter descriptions and some metadata that can then be executed by rhcp clients.
|
36
|
-
email:
|
37
|
-
- philipp@hitchhackers.net
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: philipp at hitchhackers.net
|
38
18
|
executables: []
|
39
19
|
|
40
20
|
extensions: []
|
41
21
|
|
42
|
-
extra_rdoc_files:
|
43
|
-
|
44
|
-
- Manifest.txt
|
45
|
-
- README.txt
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
46
24
|
files:
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
- docroot/builder.js
|
53
|
-
- docroot/controls.js
|
54
|
-
- docroot/dragdrop.js
|
55
|
-
- docroot/effects.js
|
56
|
-
- docroot/index.html
|
57
|
-
- docroot/prototype.js
|
58
|
-
- docroot/scriptaculous.js
|
59
|
-
- docroot/slider.js
|
60
|
-
- docroot/sound.js
|
61
|
-
- docroot/unittest.js
|
62
|
-
- lib/rhcp.rb
|
63
|
-
- lib/rhcp/broker.rb
|
25
|
+
- bin/http_test_server.rb
|
26
|
+
- bin/rhcp_test_server.sh
|
27
|
+
- lib/rhcp
|
28
|
+
- lib/rhcp/client
|
29
|
+
- lib/rhcp/client/http_broker.rb
|
64
30
|
- lib/rhcp/client/command_param_stub.rb
|
65
31
|
- lib/rhcp/client/command_stub.rb
|
66
|
-
- lib/rhcp/client/http_broker.rb
|
67
32
|
- lib/rhcp/command.rb
|
68
33
|
- lib/rhcp/command_param.rb
|
34
|
+
- lib/rhcp/response.rb
|
69
35
|
- lib/rhcp/dispatching_broker.rb
|
36
|
+
- lib/rhcp/broker.rb
|
70
37
|
- lib/rhcp/http_exporter.rb
|
71
38
|
- lib/rhcp/request.rb
|
72
|
-
- lib/rhcp/response.rb
|
73
39
|
- lib/rhcp/rhcp_exception.rb
|
74
|
-
-
|
75
|
-
- test/rhcp
|
40
|
+
- lib/rhcp.rb
|
41
|
+
- test/rhcp
|
42
|
+
- test/rhcp/client
|
76
43
|
- test/rhcp/client/command_param_stub_test.rb
|
77
44
|
- test/rhcp/client/command_stub_test.rb
|
78
45
|
- test/rhcp/command_param_test.rb
|
79
46
|
- test/rhcp/command_test.rb
|
47
|
+
- test/rhcp/response_test.rb
|
80
48
|
- test/rhcp/dispatching_broker_test.rb
|
49
|
+
- test/rhcp/broker_test.rb
|
50
|
+
- test/rhcp/http_test_server.rb
|
81
51
|
- test/rhcp/http_exporter_test.rb
|
82
52
|
- test/rhcp/http_registry_test.rb
|
83
|
-
- test/rhcp/http_test_server.rb
|
84
53
|
- test/rhcp/request_test.rb
|
85
|
-
- test/rhcp/response_test.rb
|
86
54
|
has_rdoc: true
|
87
|
-
homepage: http://
|
88
|
-
post_install_message:
|
89
|
-
|
90
|
-
|
91
|
-
rdoc_options:
|
92
|
-
- --main
|
93
|
-
- README.txt
|
55
|
+
homepage: http://rubyforge.org/projects/rhcp
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
94
59
|
require_paths:
|
95
60
|
- lib
|
96
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -111,6 +76,6 @@ rubyforge_project: rhcp
|
|
111
76
|
rubygems_version: 1.3.1
|
112
77
|
signing_key:
|
113
78
|
specification_version: 2
|
114
|
-
summary:
|
79
|
+
summary: RHCP is a protocol designed for building up a command-metadata-based communication infrastructure making it easier for application developers to export commands in applications to generic clients.
|
115
80
|
test_files: []
|
116
81
|
|
data/History.txt
DELETED
data/Manifest.txt
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
Manifest.txt
|
3
|
-
README.txt
|
4
|
-
Rakefile
|
5
|
-
build_gem.sh
|
6
|
-
docroot/builder.js
|
7
|
-
docroot/controls.js
|
8
|
-
docroot/dragdrop.js
|
9
|
-
docroot/effects.js
|
10
|
-
docroot/index.html
|
11
|
-
docroot/prototype.js
|
12
|
-
docroot/scriptaculous.js
|
13
|
-
docroot/slider.js
|
14
|
-
docroot/sound.js
|
15
|
-
docroot/unittest.js
|
16
|
-
lib/rhcp.rb
|
17
|
-
lib/rhcp/broker.rb
|
18
|
-
lib/rhcp/client/command_param_stub.rb
|
19
|
-
lib/rhcp/client/command_stub.rb
|
20
|
-
lib/rhcp/client/http_broker.rb
|
21
|
-
lib/rhcp/command.rb
|
22
|
-
lib/rhcp/command_param.rb
|
23
|
-
lib/rhcp/dispatching_broker.rb
|
24
|
-
lib/rhcp/http_exporter.rb
|
25
|
-
lib/rhcp/request.rb
|
26
|
-
lib/rhcp/response.rb
|
27
|
-
lib/rhcp/rhcp_exception.rb
|
28
|
-
rhcp_test_server.sh
|
29
|
-
test/rhcp/broker_test.rb
|
30
|
-
test/rhcp/client/command_param_stub_test.rb
|
31
|
-
test/rhcp/client/command_stub_test.rb
|
32
|
-
test/rhcp/command_param_test.rb
|
33
|
-
test/rhcp/command_test.rb
|
34
|
-
test/rhcp/dispatching_broker_test.rb
|
35
|
-
test/rhcp/http_exporter_test.rb
|
36
|
-
test/rhcp/http_registry_test.rb
|
37
|
-
test/rhcp/http_test_server.rb
|
38
|
-
test/rhcp/request_test.rb
|
39
|
-
test/rhcp/response_test.rb
|
data/README.txt
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
= RHCP
|
2
|
-
|
3
|
-
http://hitchhackers.net/projects/rhcp
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
The rhcp protocol allows you to register commands along with their parameter descriptions and some metadata that can then be executed by rhcp clients.
|
8
|
-
|
9
|
-
== FEATURES/PROBLEMS:
|
10
|
-
|
11
|
-
* FIX (list of features or problems)
|
12
|
-
|
13
|
-
== SYNOPSIS:
|
14
|
-
|
15
|
-
FIX (code sample of usage)
|
16
|
-
|
17
|
-
== REQUIREMENTS:
|
18
|
-
|
19
|
-
== INSTALL:
|
20
|
-
|
21
|
-
* FIX (sudo gem install, anything else)
|
22
|
-
|
23
|
-
== LICENSE:
|
24
|
-
|
25
|
-
(The MIT License)
|
26
|
-
|
27
|
-
Copyright (c) 2009 FIX
|
28
|
-
|
29
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
30
|
-
a copy of this software and associated documentation files (the
|
31
|
-
'Software'), to deal in the Software without restriction, including
|
32
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
-
permit persons to whom the Software is furnished to do so, subject to
|
35
|
-
the following conditions:
|
36
|
-
|
37
|
-
The above copyright notice and this permission notice shall be
|
38
|
-
included in all copies or substantial portions of the Software.
|
39
|
-
|
40
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
41
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
43
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
44
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
45
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
46
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
require 'rake/packagetask'
|
5
|
-
require 'rake/gempackagetask'
|
6
|
-
|
7
|
-
$LOAD_PATH.push('lib')
|
8
|
-
require File.join(File.dirname(__FILE__), 'lib', 'rhcp')
|
9
|
-
|
10
|
-
PKG_NAME = 'rhcp'
|
11
|
-
PKG_VERSION = RHCP::Version.to_s
|
12
|
-
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
13
|
-
|
14
|
-
# TODO hoe should be a development dependency only
|
15
|
-
|
16
|
-
desc "Default Task"
|
17
|
-
task :default => [ :test ]
|
18
|
-
|
19
|
-
###############################################
|
20
|
-
### TESTS
|
21
|
-
Rake::TestTask.new() { |t|
|
22
|
-
t.libs << "lib"
|
23
|
-
t.libs << "test"
|
24
|
-
t.libs << "test/rhcp"
|
25
|
-
t.test_files = FileList['test/rhcp/**/*_test.rb']
|
26
|
-
t.verbose = true
|
27
|
-
}
|
28
|
-
|
29
|
-
###############################################
|
30
|
-
### RDOC
|
31
|
-
Rake::RDocTask.new { |rdoc|
|
32
|
-
rdoc.rdoc_dir = 'doc'
|
33
|
-
rdoc.title = "RHCP - really helpful command protocol"
|
34
|
-
rdoc.options << '--line-numbers' << '--inline-source' <<
|
35
|
-
'--accessor' << 'cattr_accessor=object'
|
36
|
-
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
37
|
-
#rdoc.rdoc_files.include('README', 'CHANGELOG')
|
38
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
39
|
-
}
|
40
|
-
|
41
|
-
###############################################
|
42
|
-
### METRICS
|
43
|
-
task :lines do
|
44
|
-
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
|
45
|
-
|
46
|
-
for file_name in FileList["lib/**/*.rb"]
|
47
|
-
f = File.open(file_name)
|
48
|
-
|
49
|
-
while line = f.gets
|
50
|
-
lines += 1
|
51
|
-
next if line =~ /^\s*$/
|
52
|
-
next if line =~ /^\s*#/
|
53
|
-
codelines += 1
|
54
|
-
end
|
55
|
-
puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
|
56
|
-
|
57
|
-
total_lines += lines
|
58
|
-
total_codelines += codelines
|
59
|
-
|
60
|
-
lines, codelines = 0, 0
|
61
|
-
end
|
62
|
-
|
63
|
-
puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
|
64
|
-
end
|
65
|
-
|
66
|
-
task :update_manifest do
|
67
|
-
system "rake check_manifest 2>/dev/null | grep -vE 'qooxdoo|nbproject|coverage' | grep -E '^\+' | grep -vE '^$' | grep -v '(in ' | grep -vE '^\+\+\+' | cut -b 2-200 | patch"
|
68
|
-
end
|
69
|
-
|
70
|
-
# TODO add rcov
|
71
|
-
# rcov -I lib/ -x rcov.rb -x rhcp.rb test/**/*.rb
|
72
|
-
|
73
|
-
require 'rubygems'
|
74
|
-
require 'hoe'
|
75
|
-
|
76
|
-
hoe = Hoe.new('rhcp', PKG_VERSION) do |p|
|
77
|
-
# p.rubyforge_name = 'rhcp' # if different than lowercase project name
|
78
|
-
p.developer('Philipp Traeder', 'philipp@hitchhackers.net')
|
79
|
-
p.extra_deps << 'json'
|
80
|
-
p.post_install_message = "This is the initial release of rhcp - hope you'll like it.\nFeel free to send me feedback to rhcp at hitchhackers dot net."
|
81
|
-
end
|
82
|
-
|
83
|
-
|
data/build_gem.sh
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
cd pkg
|
4
|
-
|
5
|
-
echo "cleaning the build directory..."
|
6
|
-
ls -l *.gem > /dev/null && rm -v *.gem
|
7
|
-
echo ""
|
8
|
-
|
9
|
-
echo "building the new gem..."
|
10
|
-
rake gem
|
11
|
-
echo ""
|
12
|
-
|
13
|
-
echo "uninstalling the old gem if necessary..."
|
14
|
-
gem list | grep -c rhcp > /dev/null && sudo gem uninstall rhcp
|
15
|
-
echo ""
|
16
|
-
|
17
|
-
echo "installing the new one..."
|
18
|
-
sudo gem install --no-rdoc --no-ri *.gem
|
19
|
-
echo ""
|
20
|
-
|
21
|
-
cd -
|