app-mgr 0.2.6 → 0.4.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 +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/app-mgr.rb +86 -82
  4. data.tar.gz.sig +0 -0
  5. metadata +54 -28
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ca85f8abea6e44df322504a0a23e380f7b77e519
4
- data.tar.gz: f9e41aa1cc6712c7e70b81c5abcb5ee7517ead7c
2
+ SHA256:
3
+ metadata.gz: 3230c5bba90440fdeef08992f6f099f6d5fd452c05d907e9fbd42ab346f1355e
4
+ data.tar.gz: 01a8d05fcc809791b44492403ced88a59a22e4538fcf5d55c6d3c4d344505dab
5
5
  SHA512:
6
- metadata.gz: 44f9864a6ee9dec5b93f2e03bf237cf8c50b4b73a28282287c245e1d1bd52895550a072db13974fa771e0582c3abfe2a5923001f7c6ca6fbc2f5a69de1ccbb1c
7
- data.tar.gz: 0f6fd3c56ea64dbf366affc57bb3fe3b8e258b79baf62ec6f273c2290b84a5cef07d554175d8dbe0be527332ab9a1fc630f568678199ed715ae1ffa476e49f7c
6
+ metadata.gz: f8baeb4e49782dfe2764bdf124e04db1b7559276e73c41b0df73a6b1ed1e0ff9a3afc9e03156341193fe934bdd228713718feffd0771176025cc453ff304d23c
7
+ data.tar.gz: 1b5c292f4f4a7b688c96c2abdccb3c6c15c5e26cb06211f889825a91aaf516b1778b223bf3a32be876abbe74dfb48bf2efa44f0f43b773ffadc7a2daa805eca4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/app-mgr.rb CHANGED
@@ -1,122 +1,126 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  # file: app-mgr.rb
4
+
5
+ require 'rscript'
6
+
7
+ class Runner
8
+ def run(s)
9
+ eval(s)
10
+ end
11
+ end
12
+
13
+
4
14
  class AppMgr
5
- def initialize()
15
+
16
+ def initialize(rsf: nil, type: 'app', debug: false)
17
+
18
+ @rsf, @type, @debug = rsf, type, debug
19
+ @rscript = RScript.new(type: type, cache: nil, debug: debug)
6
20
  @app = {}
7
- @content_type = 'text/xml'
8
- super()
9
- end
10
21
 
11
- def load(opt={})
12
- o = {name: '', object: nil, config: {}, public: {}}.merge!(opt)
22
+ load_all(rsf)
13
23
 
14
- key, name = o.shift
15
- @app[name] = o
16
- "'%s' loaded" % name
17
24
  end
18
25
 
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)
26
+ def [](name)
27
+
28
+ app = @app[name.to_sym]
29
+
30
+ return app[:running] if app and app[:running]
25
31
 
26
- return "'%s' running ..." % app_name
27
- else
28
- return "app %s not available" % app_name
29
- end
30
32
  end
31
-
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
33
+
34
+ def available()
35
+ @app.keys
39
36
  end
40
-
41
- def execute(app_name, method, params='')
42
- @app[app_name][:running].method('call_' + method.gsub(/-/,'_').to_sym).call(params)
37
+
38
+ def restart(name)
39
+ load_app(name)
40
+ run(name)
41
+ name.to_s + ' restarted'
43
42
  end
44
43
 
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
44
+ def run(name)
45
+
46
+ app = @app[name.to_sym]
47
+
48
+ #app[:running] = eval(app[:code])
49
+ app[:running] = Runner.new.run(app[:code])
50
+
51
51
  end
52
52
 
53
53
  def running()
54
54
  @app.select {|k,v| v[:running]}.keys
55
55
  end
56
56
 
57
- def running?(app_name)
58
- @app[app_name][:running]
59
- end
60
-
61
- def available()
62
- @app.select {|k,v| v[:available] == true}.keys
57
+ def running?(name)
58
+ @app[name.to_sym][:running] ? true : false
63
59
  end
64
60
 
65
- def unload(app_name)
66
61
 
67
- handler_name = @app[app_name][:running].name
68
-
69
- if handler_name then
70
- Object.send(:remove_const, handler_name)
71
- @app.delete app_name
72
- return "app %s unloaded" % app_name
62
+ def stop(name)
63
+
64
+ app = @app[name.to_sym]
65
+
66
+ if app.delete(:running) then
67
+ return "app %s stopped" % name
73
68
  else
74
- return "couldn't find app %s" % app_name
69
+ return "couldn't find app %s" % name
75
70
  end
71
+
76
72
  end
77
73
 
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(', ')
74
+ def unload(name)
75
+
76
+ app = @app[name.to_sym]
77
+
78
+ if class_name then
79
+
80
+ @app.delete name.to_sym
81
+ return "app %s unloaded" % name
82
+
82
83
  else
83
- return "app %s not running" % app_name
84
+ return "couldn't find app %s" % name
84
85
  end
86
+
85
87
  end
86
88
 
87
-
88
- def run_projectx(project_name, method_name, qparams=[])
89
+ private
89
90
 
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
- def projectx_handler(xml_project)
96
- out = ''
97
- doc = Document.new(xml_project)
98
- project_name = doc.root.attribute('name').to_s
91
+ def load_all(rsf_package)
99
92
 
100
- if self.running? project_name then
93
+ @rscript.jobs(rsf_package).each do |app_name|
101
94
 
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
95
+ puts 'app_name: ' + app_name.inspect if @debug
105
96
 
106
- method_out, @content_type = self.execute(project_name, methodx, params)
107
- method_out
108
- end
97
+ @app[app_name] = {}
98
+ codeblock, _, attr = @rscript.read(["//#{@type}:" + app_name.to_s, @rsf])
99
+
100
+ next if attr[:disabled] == 'true'
101
+
102
+ puts 'codeblock: ' + codeblock.inspect if @debug
103
+ @app[app_name][:code] = codeblock
104
+ app = @app[app_name]
105
+
106
+ puts 'app: ' + app.inspect
107
+ next unless app
108
+
109
+ app[:running] = Runner.new.run(app[:code])
109
110
 
110
- out = out.first if out.length == 1
111
- else
112
- out = "that project doesn't exist"
113
111
  end
114
-
115
- @content_type ||= 'text/xml'
116
-
117
- [out, @content_type]
112
+
113
+ def load_app(name)
114
+
115
+ codeblock, _, attr = @rscript.read(["//#{@type}:" + name.to_s, @rsf])
116
+
117
+ return if attr[:disabled] == 'true'
118
+
119
+ puts 'codeblock: ' + codeblock.inspect if @debug
120
+ @app[name][:code] = codeblock
121
+ return @app[name]
122
+ end
123
+
118
124
  end
119
125
 
120
-
121
126
  end
122
-
data.tar.gz.sig CHANGED
Binary file
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.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,29 +10,55 @@ 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/ffYxPQiB1SW9fCGCsLPoxPNuDb0/RHzAjWHvAi/5S536
19
- 2gXMd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IgEmh0N8BD6IjYggzq2T8iE
33
+ Z1siRlr4sgUZd8mLi0o2nG+zqq/9DkV3S7rygERkGccM+tAsakwl0wKIyHJYibNM
34
+ F0SeCKO+Jsn433fz0woyhqdSpuOEEL88twKvwzHS1gzV2RRIy/db8PRsrjsaNhy3
35
+ 8W1C1GMiIJ0XiC7HJfZ9gdjiGK6QbbiqPhA0yRtNjQJWU1id4Nn7ZkaMvjc56Zto
36
+ wgl6kIb23YwRPlLR4VAcERqL
31
37
  -----END CERTIFICATE-----
32
- date: 2013-07-27 00:00:00.000000000 Z
33
- dependencies: []
38
+ date: 2022-04-24 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rscript
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.9'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.9.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.9'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.9.0
34
60
  description:
35
- email: james@r0bertson.co.uk
61
+ email: digital.robertson@gmail.com
36
62
  executables: []
37
63
  extensions: []
38
64
  extra_rdoc_files: []
@@ -48,18 +74,18 @@ require_paths:
48
74
  - lib
49
75
  required_ruby_version: !ruby/object:Gem::Requirement
50
76
  requirements:
51
- - - '>='
77
+ - - ">="
52
78
  - !ruby/object:Gem::Version
53
- version: '0'
79
+ version: 2.1.2
54
80
  required_rubygems_version: !ruby/object:Gem::Requirement
55
81
  requirements:
56
- - - '>='
82
+ - - ">="
57
83
  - !ruby/object:Gem::Version
58
84
  version: '0'
59
85
  requirements: []
60
- rubyforge_project:
61
- rubygems_version: 2.0.0.rc.2
86
+ rubygems_version: 3.2.22
62
87
  signing_key:
63
88
  specification_version: 4
64
- summary: app-mgr
89
+ summary: Runs 1 or more headless apps from a kind of XML file for use in a back-end
90
+ server
65
91
  test_files: []
metadata.gz.sig CHANGED
Binary file