rhcp 0.2.19 → 0.2.20
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/lib/rhcp.rb +1 -1
- data/lib/rhcp/client/http_broker.rb +6 -8
- data/lib/rhcp/command.rb +3 -1
- data/lib/rhcp/command_param.rb +4 -4
- data/lib/rhcp/request.rb +17 -0
- metadata +26 -26
data/lib/rhcp.rb
CHANGED
@@ -14,7 +14,7 @@ module RHCP
|
|
14
14
|
# clients can use it exactly as if they were talking to the broker itself.
|
15
15
|
class HttpBroker < Broker
|
16
16
|
|
17
|
-
def initialize(url)
|
17
|
+
def initialize(url, user = nil, password = nil)
|
18
18
|
# TODO should this really be an URL? or just a host name?
|
19
19
|
@url = url
|
20
20
|
@logger = RHCP::ModuleHelper.instance.logger
|
@@ -32,13 +32,11 @@ module RHCP
|
|
32
32
|
# @op.log_to_jabber_detail("message" => "HTTP_START #{uri} : #{req}")
|
33
33
|
# response = http.request(req)
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
http.get("/rhcp/")
|
41
|
-
}
|
35
|
+
http = Net::HTTP.new(@url.host, @url.port)
|
36
|
+
request = Net::HTTP::Get.new('/rhcp/')
|
37
|
+
request.basic_auth user, password if user and password
|
38
|
+
res = http.request request
|
39
|
+
|
42
40
|
if (res.code == "200")
|
43
41
|
@logger.info "connected to '#{@url}' successfully."
|
44
42
|
else
|
data/lib/rhcp/command.rb
CHANGED
@@ -178,7 +178,9 @@ module RHCP
|
|
178
178
|
end
|
179
179
|
rescue Exception => ex
|
180
180
|
if (/undefined\sparameter/.match(ex.message))
|
181
|
-
raise RHCP::RhcpException.new(ex.message) unless @accepts_extra_params or @ignores_extra_params
|
181
|
+
raise RHCP::RhcpException.new(ex.message) unless @accepts_extra_params or @ignores_extra_params
|
182
|
+
else
|
183
|
+
raise ex
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
data/lib/rhcp/command_param.rb
CHANGED
@@ -26,7 +26,7 @@ module RHCP
|
|
26
26
|
# the key to a context value that is used for filling this parameter
|
27
27
|
attr_reader :autofill_context_key
|
28
28
|
|
29
|
-
|
29
|
+
attr_accessor :allows_extra_values
|
30
30
|
|
31
31
|
attr_accessor :default_value
|
32
32
|
|
@@ -99,8 +99,7 @@ module RHCP
|
|
99
99
|
# check against lookup values
|
100
100
|
if @has_lookup_values
|
101
101
|
possible_value.each do |value|
|
102
|
-
if
|
103
|
-
! @allows_extra_values
|
102
|
+
if (not get_lookup_values(request).include?(value)) and (not @allows_extra_values)
|
104
103
|
raise RHCP::RhcpException.new("invalid value '#{value}' for parameter '#{@name}'")
|
105
104
|
end
|
106
105
|
end
|
@@ -119,7 +118,8 @@ module RHCP
|
|
119
118
|
'has_lookup_values' => @has_lookup_values,
|
120
119
|
'is_default_param' => @is_default_param,
|
121
120
|
'mandatory' => @mandatory,
|
122
|
-
'autofill_context_key' => @autofill_context_key
|
121
|
+
'autofill_context_key' => @autofill_context_key,
|
122
|
+
'allows_extra_values' => @allows_extra_values
|
123
123
|
}.to_json(*args)
|
124
124
|
end
|
125
125
|
|
data/lib/rhcp/request.rb
CHANGED
@@ -44,6 +44,15 @@ module RHCP
|
|
44
44
|
param_values[param.name] = param.default_value
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
# autobox if necessary
|
49
|
+
# if param.allows_multiple_values
|
50
|
+
# k = param.name
|
51
|
+
# v = param_values[k]
|
52
|
+
# unless v.instance_of? Array
|
53
|
+
# param_values[k] = [ v ]
|
54
|
+
# end
|
55
|
+
# end
|
47
56
|
end
|
48
57
|
|
49
58
|
# autobox the parameters if necessary
|
@@ -74,6 +83,14 @@ module RHCP
|
|
74
83
|
@param_values[param_name][0]
|
75
84
|
end
|
76
85
|
end
|
86
|
+
|
87
|
+
def values
|
88
|
+
result = {}
|
89
|
+
@param_values.keys.each do |k|
|
90
|
+
result[k] = get_param_value(k)
|
91
|
+
end
|
92
|
+
result
|
93
|
+
end
|
77
94
|
|
78
95
|
def has_param_value(param_name)
|
79
96
|
@param_values.has_key?(param_name)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 20
|
10
|
+
version: 0.2.20
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Philipp T.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-02-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
description: 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.
|
37
|
-
email: philipp
|
37
|
+
email: philipp at virtualop dot org
|
38
38
|
executables:
|
39
39
|
- rhcp_test_server
|
40
40
|
extensions: []
|
@@ -43,38 +43,38 @@ extra_rdoc_files: []
|
|
43
43
|
|
44
44
|
files:
|
45
45
|
- bin/rhcp_test_server
|
46
|
-
- lib/rhcp
|
47
|
-
- lib/rhcp/
|
48
|
-
- lib/rhcp/
|
46
|
+
- lib/rhcp.rb
|
47
|
+
- lib/rhcp/http_exporter.rb
|
48
|
+
- lib/rhcp/request.rb
|
49
49
|
- lib/rhcp/rhcp_exception.rb
|
50
|
+
- lib/rhcp/logging_broker.rb
|
51
|
+
- lib/rhcp/dispatching_broker.rb
|
52
|
+
- lib/rhcp/command.rb
|
53
|
+
- lib/rhcp/response.rb
|
54
|
+
- lib/rhcp/client/http_broker.rb
|
50
55
|
- lib/rhcp/client/context_aware_broker.rb
|
51
|
-
- lib/rhcp/client/command_param_stub.rb
|
52
56
|
- lib/rhcp/client/command_stub.rb
|
53
|
-
- lib/rhcp/client/
|
54
|
-
- lib/rhcp/command.rb
|
55
|
-
- lib/rhcp/context.rb
|
56
|
-
- lib/rhcp/request.rb
|
57
|
-
- lib/rhcp/http_exporter.rb
|
58
|
-
- lib/rhcp/dispatching_broker.rb
|
57
|
+
- lib/rhcp/client/command_param_stub.rb
|
59
58
|
- lib/rhcp/broker.rb
|
60
|
-
- lib/rhcp.rb
|
59
|
+
- lib/rhcp/command_param.rb
|
60
|
+
- lib/rhcp/context.rb
|
61
|
+
- test/rhcp/http_broker_test.rb
|
62
|
+
- test/rhcp/request_test.rb
|
63
|
+
- test/rhcp/broker_test.rb
|
64
|
+
- test/rhcp/tests_for_writable_brokers.rb
|
61
65
|
- test/rhcp/context_test.rb
|
62
|
-
- test/rhcp/
|
66
|
+
- test/rhcp/http_test_server.rb
|
67
|
+
- test/rhcp/dispatching_broker_test.rb
|
68
|
+
- test/rhcp/command_param_test.rb
|
69
|
+
- test/rhcp/command_test.rb
|
63
70
|
- test/rhcp/tests_for_brokers.rb
|
64
71
|
- test/rhcp/logging_broker_test.rb
|
65
|
-
- test/rhcp/command_test.rb
|
66
72
|
- test/rhcp/response_test.rb
|
67
73
|
- test/rhcp/context_aware_broker_test.rb
|
68
74
|
- test/rhcp/test_base.rb
|
69
|
-
- test/rhcp/broker_test.rb
|
70
|
-
- test/rhcp/tests_for_writable_brokers.rb
|
71
|
-
- test/rhcp/client/command_param_stub_test.rb
|
72
75
|
- test/rhcp/client/command_stub_test.rb
|
73
|
-
- test/rhcp/
|
74
|
-
- test/rhcp/
|
75
|
-
- test/rhcp/command_param_test.rb
|
76
|
-
- test/rhcp/request_test.rb
|
77
|
-
- test/rhcp/http_broker_test.rb
|
76
|
+
- test/rhcp/client/command_param_stub_test.rb
|
77
|
+
- test/rhcp/http_exporter_test.rb
|
78
78
|
homepage: http://rubyforge.org/projects/rhcp
|
79
79
|
licenses: []
|
80
80
|
|