app-mgr 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/app-mgr.rb +40 -2
  2. metadata +2 -2
@@ -2,9 +2,10 @@
2
2
 
3
3
  # file: app-mgr.rb
4
4
  class AppMgr
5
- def initialize()
6
- super()
5
+ def initialize(content_type)
7
6
  @app = {}
7
+ @content_type = content_type
8
+ super()
8
9
  end
9
10
 
10
11
  def load(opt={})
@@ -82,5 +83,42 @@ class AppMgr
82
83
  return "app %s not running" % app_name
83
84
  end
84
85
  end
86
+
87
+
88
+ def run_projectx(project_name, method_name, qparams=[])
89
+
90
+ params = "<params>%s</params>" % qparams.map{|k,v| "<param var='%s'>%s</param>" % [k,v]}.join
91
+ xml_project = project = "<project name='%s'><methods><method name='%s'>%s</method></methods></project>" % [project_name, method_name, params]
92
+ projectx_handler(xml_project)
93
+ end
94
+
95
+ private
96
+
97
+ def projectx_handler(xml_project)
98
+ out = ''
99
+ doc = Document.new(xml_project)
100
+ project_name = doc.root.attribute('name').to_s
101
+
102
+ if self.running? project_name then
103
+
104
+ out = XPath.match(doc.root, 'methods/method').map do |node_method|
105
+ method = node_method.attributes.get_attribute('name').to_s
106
+ params = node_method.elements['params'].to_s
107
+
108
+ method_out, @content_type = @@app.execute(project_name, method, params)
109
+ method_out
110
+ end
111
+
112
+ out = out.first if out.length == 1
113
+ else
114
+ out = "that project doesn't exist"
115
+ end
116
+ @content_type ||= 'text/xml'
117
+
118
+ out
119
+ end
120
+
121
+
122
+
85
123
  end
86
124
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app-mgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-08-08 00:00:00 +01:00
12
+ date: 2010-08-12 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15