app-mgr 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +3 -1
  3. data.tar.gz.sig +0 -0
  4. data/lib/app-mgr.rb +67 -81
  5. metadata +49 -27
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca85f8abea6e44df322504a0a23e380f7b77e519
4
- data.tar.gz: f9e41aa1cc6712c7e70b81c5abcb5ee7517ead7c
3
+ metadata.gz: d1b7f9478ff5a8baa6ca8fe533dd7d0ed1c2ff31
4
+ data.tar.gz: 82c38a2ae61cf314e15f8475d38c4bc7f984d2ee
5
5
  SHA512:
6
- metadata.gz: 44f9864a6ee9dec5b93f2e03bf237cf8c50b4b73a28282287c245e1d1bd52895550a072db13974fa771e0582c3abfe2a5923001f7c6ca6fbc2f5a69de1ccbb1c
7
- data.tar.gz: 0f6fd3c56ea64dbf366affc57bb3fe3b8e258b79baf62ec6f273c2290b84a5cef07d554175d8dbe0be527332ab9a1fc630f568678199ed715ae1ffa476e49f7c
6
+ metadata.gz: f680a411fe83caf47a19127138c43cf4b2db29c1973d03f0afe517e8783da6cabbae9dfc3ebf35d018867a2969ba0bf81985b7d1b07fd0270e8db75c00bfd7c4
7
+ data.tar.gz: 562307f3909b8517b739183f97f8f9e5a0d70e00bef588f6983be93e976b06870e2e519f57274695d3c5aa354a0c1b4f187d6dd39f836ba95d723ba944cc9956
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
1
- |�����!$@ �ι�9��k�~��@&�%����r���y��8����ɥ�'..x��l=��þ;�fݸ3X���
1
+ g5�0a���ɸn��4Swx� �v�zpb�C�?Ϥ��c��䢑8>��� �'yТ��G곈ٌ|or5@%N�? |�~\H �2���"���PA��V���!�� �]��z-f:+�&�4P�?U���@ )>�O̯n]
2
+ f��֭��-t�
3
+ ��R����5~��
data.tar.gz.sig CHANGED
Binary file
data/lib/app-mgr.rb CHANGED
@@ -1,122 +1,108 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  # file: app-mgr.rb
4
+
5
+ require 'rscript'
6
+
7
+
4
8
  class AppMgr
5
- def initialize()
6
- @app = {}
7
- @content_type = 'text/xml'
8
- super()
9
- end
10
9
 
11
- def load(opt={})
12
- o = {name: '', object: nil, config: {}, public: {}}.merge!(opt)
10
+ attr_reader :app
13
11
 
14
- key, name = o.shift
15
- @app[name] = o
16
- "'%s' loaded" % name
17
- end
12
+ def initialize(rsf: nil, reg: nil, rsc: nil, debug: true)
13
+
14
+ @rsf, @reg, @rsc, @debug = rsf, reg, rsc, debug
15
+ @rscript = RScript.new(type: 'app', debug: debug)
16
+ @app = {}
18
17
 
19
- def run(app_name)
20
- app = @app[app_name]
21
- if app then
22
- options = {public: app[:public]}
23
- options[:config] = app[:config] unless app[:config].empty?
24
- app[:running] = app[:object].new(options, self)
18
+ load_all(rsf)
19
+
20
+ end
25
21
 
26
- return "'%s' running ..." % app_name
27
- else
28
- return "app %s not available" % app_name
29
- end
22
+ def available()
23
+ @app.select {|k,v| v[:available] == true}.keys
30
24
  end
31
25
 
32
- def connect(app_name)
33
- app = @app[app_name]
34
- if app and app[:running] then
35
- yield(app[:public])
36
- else
37
- return "app %s not running" % app_name
38
- end
26
+ def call(app_name)
27
+ @app[app_name.to_sym][:running].call
39
28
  end
40
-
41
- def execute(app_name, method, params='')
42
- @app[app_name][:running].method('call_' + method.gsub(/-/,'_').to_sym).call(params)
29
+
30
+ def execute(name, method, params='')
31
+ @app[name.to_sym][:running].method(method.to_sym).call(params)
43
32
  end
44
33
 
45
- def stop(app_name)
46
- if @app[app_name].delete(:running) then
47
- return "app %s stopped" % app_name
48
- else
49
- return "couldn't find app %s" % app_name
50
- end
34
+ def run(name)
35
+
36
+ app = @app[name.to_sym]
37
+ class_name = app[:code][/(?<=class )\w+/]
38
+ app[:running] = eval(class_name + '.new')
39
+
51
40
  end
52
41
 
53
42
  def running()
54
43
  @app.select {|k,v| v[:running]}.keys
55
44
  end
56
45
 
57
- def running?(app_name)
58
- @app[app_name][:running]
46
+ def running?(name)
47
+ @app[name.to_sym][:running] ? true : false
59
48
  end
60
-
61
- def available()
62
- @app.select {|k,v| v[:available] == true}.keys
63
- end
64
49
 
65
- def unload(app_name)
50
+ def connect(name)
66
51
 
67
- handler_name = @app[app_name][:running].name
52
+ app = @app[name.to_sym]
68
53
 
69
- if handler_name then
70
- Object.send(:remove_const, handler_name)
71
- @app.delete app_name
72
- return "app %s unloaded" % app_name
54
+ if app and app[:running] then
55
+ yield(app[:running])
73
56
  else
74
- return "couldn't find app %s" % app_name
57
+ return "app %s not running" % name
75
58
  end
59
+
76
60
  end
77
61
 
78
- def show_public_methods(app_name)
79
- app = @app[app_name]
80
- if app and app[:running] then
81
- return app[:running].public_methods.map(&:to_s).grep(/call_/).map {|x| x.gsub(/call_/,'').gsub(/_/,'-')}.sort.join(', ')
62
+ def stop(name)
63
+
64
+ app = @app[name.to_sym]
65
+
66
+ if app.delete(:running) then
67
+ return "app %s stopped" % name
82
68
  else
83
- return "app %s not running" % app_name
69
+ return "couldn't find app %s" % name
84
70
  end
71
+
85
72
  end
86
73
 
87
-
88
- def run_projectx(project_name, method_name, qparams=[])
74
+ def unload(name)
89
75
 
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
76
+ class_name = @app[name.to_sym][:running].class.name
94
77
 
95
- def projectx_handler(xml_project)
96
- out = ''
97
- doc = Document.new(xml_project)
98
- project_name = doc.root.attribute('name').to_s
78
+ if class_name then
79
+ Object.send(:remove_const, class_name)
80
+ @app.delete name.to_sym
81
+ return "app %s unloaded" % name
82
+ else
83
+ return "couldn't find app %s" % name
84
+ end
85
+
86
+ end
99
87
 
100
- if self.running? project_name then
88
+ private
101
89
 
102
- out = XPath.match(doc.root, 'methods/method').map do |node_method|
103
- methodx = node_method.attributes.get_attribute('name').to_s
104
- params = node_method.elements['params'].to_s
90
+ def load_all(rsf_package)
105
91
 
106
- method_out, @content_type = self.execute(project_name, methodx, params)
107
- method_out
108
- end
92
+ @rscript.jobs(rsf_package).each do |app_name|
109
93
 
110
- out = out.first if out.length == 1
111
- else
112
- out = "that project doesn't exist"
94
+ puts 'app_name: ' + app_name.inspect if @debug
95
+ app = @app[app_name] = {}
96
+
97
+ codeblock = @rscript.read(['//app:' + app_name.to_s, @rsf]).first
98
+ puts 'codeblock: ' + codeblock.inspect if @debug
99
+ app[:code] = codeblock
100
+
101
+ reg, rsc = @reg, @rsc
102
+ eval codeblock
103
+
113
104
  end
114
-
115
- @content_type ||= 'text/xml'
116
-
117
- [out, @content_type]
105
+
118
106
  end
119
107
 
120
-
121
108
  end
122
-
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.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,29 +10,50 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTEzMDIwNjIwNTMyOFoXDTE0MDIwNjIwNTMyOFowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAMM35ArfzPXVCoU/ffYxPQiB1SW9fC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oIBAQDQEOnA
17
+ GJ3ksMw8AjH3o2qGvN/2pUUV9w9BPemOxJD0A1cN9Bxiqldhq2rOasa5R7NWYJVb
18
+ XqNRzoX+ZM+o34N94Rs084bmt4UY3AIB8Qwh7b6hrPOcIMmXxvUKlTGPQmbT3xTf
19
+ 0U3stPA6bSjvVoe6S1SaAufvofhPf6RK3Ha85B9rnJ6SwhXMBfefT9+46G9rg4e8
20
+ Dl5hStoXpzMvZbjRl8k+chSYIkrZRUgY2DPB4uYIGhou7pdvXz8OG44eG2emHAoP
21
+ Hq7gKRjfLEJU7Lcvuy7TW1DHQawd9fJLETF4OCe3tfmrz+paKgIGdRsBZlhcVYFi
22
+ H+CwReKpsten5B0nAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
+ HQYDVR0OBBYEFMPdyMUkpkMm4orIvKu+1K0RBEHBMCYGA1UdEQQfMB2BG2dlbW1h
24
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
25
+ ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBAFMKmUscAAsNitItdGmM
26
+ fER7OWnQRkNGgQQh4c0vHz4K634HXaX8Mnq76reEkbKzyeHmwFww1EV8XpkCLLjN
27
+ k7TP/AD9LJzUtXa2M3rMuLBPu98TZZvDBP/NBFXUvW6HzH77n4D2EfO+Zn/pwnb/
28
+ H47c680aCpzYPb+7x4atUtx3UGahHg6GXT5T6x+5RzCe9iNDqnC5RW6Hj9FKybsc
29
+ CiRE+GvZQcTC3EhUyHYe9A9tXqIzzaqRh3s9YdltXryzuocM/dwlT8zu4BzYKHTe
30
+ jZi4xFnZ2LNxhD09t1Ag0wOhNh+yHsyECmyU5Zu7FKG0ZNnX0zc5IAupPGBsMKXf
31
+ at4=
31
32
  -----END CERTIFICATE-----
32
- date: 2013-07-27 00:00:00.000000000 Z
33
- dependencies: []
33
+ date: 2018-07-30 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: rscript
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.3'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.3.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '0.3'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.0
34
55
  description:
35
- email: james@r0bertson.co.uk
56
+ email: james@jamesrobertson.eu
36
57
  executables: []
37
58
  extensions: []
38
59
  extra_rdoc_files: []
@@ -48,18 +69,19 @@ require_paths:
48
69
  - lib
49
70
  required_ruby_version: !ruby/object:Gem::Requirement
50
71
  requirements:
51
- - - '>='
72
+ - - ">="
52
73
  - !ruby/object:Gem::Version
53
- version: '0'
74
+ version: 2.1.2
54
75
  required_rubygems_version: !ruby/object:Gem::Requirement
55
76
  requirements:
56
- - - '>='
77
+ - - ">="
57
78
  - !ruby/object:Gem::Version
58
79
  version: '0'
59
80
  requirements: []
60
81
  rubyforge_project:
61
- rubygems_version: 2.0.0.rc.2
82
+ rubygems_version: 2.6.13
62
83
  signing_key:
63
84
  specification_version: 4
64
- summary: app-mgr
85
+ summary: Runs 1 or more headless apps from a kind of XML file for use in a back-end
86
+ server
65
87
  test_files: []
metadata.gz.sig CHANGED
Binary file