spqr 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,4 +1,10 @@
1
- version 0.1.1
1
+ * Enhancements to SPQR/Rhubarb interoperability. (Rhubarb row_ids are
2
+ now used for half of the QMF object ID).
3
+
4
+ * Enhancements to app skeleton class: now allows specifying username,
5
+ password, hostname, and port in the constructor to SPQR::App.
6
+
7
+ version 0.1.1 (85c87b1239f730374d47e2d8baf795c8c69050f4)
2
8
 
3
9
  * Other minor Rhubarb fixes.
4
10
 
data/TODO CHANGED
@@ -6,6 +6,7 @@ To do, overall:
6
6
  To do for spqr:
7
7
 
8
8
  ! Event support
9
+ * Support for map-, array-, and list-valued parameters and properties (QMF on Ruby itself does not support these at the moment)
9
10
  * Broader query support (partially done)
10
11
  * Documentation
11
12
  * Test suite (partially done)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -130,6 +130,8 @@ module PersistingClassMixins
130
130
  return self.new(tup) if tup
131
131
  nil
132
132
  end
133
+
134
+ alias find_by_id find
133
135
 
134
136
  def find_by(arg_hash)
135
137
  arg_hash = arg_hash.dup
@@ -418,7 +420,7 @@ module Persisting
418
420
  other.class_eval do
419
421
  attr_reader :row_id
420
422
  attr_reader :created
421
- attr_reader :updated
423
+ attr_reader :updated
422
424
  end
423
425
  end
424
426
 
data/lib/spqr/app.rb CHANGED
@@ -21,7 +21,7 @@ module SPQR
21
21
  class ClassMeta < Struct.new(:object_class, :schema_class) ; end
22
22
 
23
23
  def initialize(options=nil)
24
- defaults = {:logfile=>STDERR, :loglevel=>Logger::WARN, :notifier=>nil}
24
+ defaults = {:logfile=>STDERR, :loglevel=>Logger::WARN, :notifier=>nil, :server=>"localhost", :port=>5672}
25
25
 
26
26
  # convenient shorthands for log levels
27
27
  loglevels = {:debug => Logger::DEBUG, :info => Logger::INFO, :warn => Logger::WARN, :error => Logger::ERROR, :fatal => Logger::FATAL}
@@ -45,7 +45,16 @@ module SPQR
45
45
  @classes_by_id = {}
46
46
  @pipe = options[:notifier]
47
47
  @app_name = (options[:appname] or "SPQR application")
48
-
48
+ @qmf_host = options[:server]
49
+ @qmf_port = options[:port]
50
+ @qmf_sendUserId = if options.has_key?(:send_user_id)
51
+ options[:send_user_id]
52
+ else
53
+ (options.has_key?(:user) or options.has_key?(:password))
54
+ end
55
+
56
+ @qmf_user = options[:user]
57
+ @qmf_password = options[:password]
49
58
  end
50
59
 
51
60
  def register(*ks)
@@ -82,18 +91,20 @@ module SPQR
82
91
  raise RuntimeError.new("#{managed_object.class} does not have #{name} exposed as a manageable method; has #{managed_object.class.spqr_meta.mmethods.inspect}") unless managed_method
83
92
 
84
93
  # Extract actual parameters from the Qmf::Arguments structure into a proper ruby list
85
-
86
- # XXX: consider adding appropriate impl method to Manageable
87
- # to avoid this little dance
94
+ @log.debug("actual params are: #{args.instance_variable_get(:@by_hash).inspect}") rescue nil
88
95
  actuals_in = managed_method.formals_in.inject([]) {|acc,nm| acc << args[nm]}
89
- actuals_in = actuals_in[0] if actuals_in.size == 1
96
+ actual_count = actuals_in.size
90
97
 
91
98
  @log.debug("managed_object.respond_to? #{managed_method.name.to_sym} ==> #{managed_object.respond_to? managed_method.name.to_sym}")
92
99
  @log.debug("managed_object.class.spqr_meta.mmethods.include? #{name.to_sym} ==> #{managed_object.class.spqr_meta.mmethods.include? name.to_sym}")
93
100
  @log.debug("formals: #{managed_method.formals_in.inspect}")
94
101
  @log.debug("actuals: #{actuals_in.inspect}")
95
102
 
96
- actuals_out = actuals_in.size > 0 ? managed_object.send(name.to_sym, actuals_in) : managed_object.send(name.to_sym)
103
+ actuals_out = case actual_count
104
+ when 0 then managed_object.send(name.to_sym)
105
+ when 1 then managed_object.send(name.to_sym, actuals_in[0])
106
+ else managed_object.send(name.to_sym, *actuals_in)
107
+ end
97
108
 
98
109
  raise RuntimeError.new("#{managed_object.class} did not return the appropriate number of return values; got '#{actuals_out.inspect}', but expected #{managed_method.types_out.inspect}") unless result_valid(actuals_out, managed_method)
99
110
 
@@ -157,7 +168,12 @@ module SPQR
157
168
  @log.debug("starting SPQR::App.main...")
158
169
 
159
170
  settings = Qmf::ConnectionSettings.new
160
- settings.host = 'localhost'
171
+ settings.host = @qmf_host
172
+ settings.port = @qmf_port
173
+ settings.sendUserId = @qmf_sendUserId
174
+
175
+ settings.username = @qmf_user if @qmf_sendUserId
176
+ settings.password = @qmf_password if @qmf_sendUserId
161
177
 
162
178
  @connection = Qmf::Connection.new(settings)
163
179
  @log.debug(" +-- @connection created: #{@connection}")
@@ -201,7 +217,9 @@ module SPQR
201
217
 
202
218
  def find_object(ctx, c_id, obj_id)
203
219
  # XXX: context is currently ignored
220
+ @log.debug("in find_object; class ID is #{c_id}, object ID is #{obj_id}...")
204
221
  klass = @classes_by_id[c_id]
222
+ @log.debug("found class #{klass.inspect}")
205
223
  klass.find_by_id(obj_id) if klass
206
224
  end
207
225
 
@@ -207,6 +207,8 @@ module SPQR
207
207
  result = 0
208
208
  if self.respond_to? :spqr_object_id
209
209
  result = spqr_object_id
210
+ elsif self.respond_to? :row_id
211
+ result = row_id
210
212
  else
211
213
  result = object_id
212
214
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spqr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Benton
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-16 00:00:00 -06:00
12
+ date: 2009-12-21 00:00:00 -06:00
13
13
  default_executable: spqr-gen.rb
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency