app-mgr 0.3.1 → 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 +56 -41
  4. data.tar.gz.sig +0 -0
  5. metadata +32 -28
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 19554bb1a7aad5dc3f001f6dfa583ce7d324138f
4
- data.tar.gz: e65dcd8093b4ebabffe02c71b93683ae6c2d8fe2
2
+ SHA256:
3
+ metadata.gz: 3230c5bba90440fdeef08992f6f099f6d5fd452c05d907e9fbd42ab346f1355e
4
+ data.tar.gz: 01a8d05fcc809791b44492403ced88a59a22e4538fcf5d55c6d3c4d344505dab
5
5
  SHA512:
6
- metadata.gz: f867b4649393116e46b3c9a3b97bbb4b5868a07823b9cd5d13e87ac24bf39c40b60c5d4d54c7c730c63e3d17667cb0a283a5730d53c1bccce1b6d718421834bb
7
- data.tar.gz: bec5af08ac8301c5e0f4cee5f46dbd1be023aefec1c67676d686e1faeeb2fcffbd56eeb48f6a2ac5549e6600bb49fbf6c8408786a97049d6477abda3101e1656
6
+ metadata.gz: f8baeb4e49782dfe2764bdf124e04db1b7559276e73c41b0df73a6b1ed1e0ff9a3afc9e03156341193fe934bdd228713718feffd0771176025cc453ff304d23c
7
+ data.tar.gz: 1b5c292f4f4a7b688c96c2abdccb3c6c15c5e26cb06211f889825a91aaf516b1778b223bf3a32be876abbe74dfb48bf2efa44f0f43b773ffadc7a2daa805eca4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/app-mgr.rb CHANGED
@@ -4,41 +4,49 @@
4
4
 
5
5
  require 'rscript'
6
6
 
7
+ class Runner
8
+ def run(s)
9
+ eval(s)
10
+ end
11
+ end
12
+
7
13
 
8
14
  class AppMgr
9
15
 
10
- attr_reader :app
16
+ def initialize(rsf: nil, type: 'app', debug: false)
11
17
 
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)
18
+ @rsf, @type, @debug = rsf, type, debug
19
+ @rscript = RScript.new(type: type, cache: nil, debug: debug)
16
20
  @app = {}
17
21
 
18
22
  load_all(rsf)
19
-
23
+
24
+ end
25
+
26
+ def [](name)
27
+
28
+ app = @app[name.to_sym]
29
+
30
+ return app[:running] if app and app[:running]
31
+
20
32
  end
21
33
 
22
34
  def available()
23
35
  @app.keys
24
36
  end
25
-
26
- def call(app_name)
27
-
28
- run(app_name) unless running? app_name
29
- @app[app_name.to_sym][:running].call
30
-
31
- end
32
37
 
33
- def execute(name, method, params='')
34
- @app[name.to_sym][:running].method(method.to_sym).call(params)
38
+ def restart(name)
39
+ load_app(name)
40
+ run(name)
41
+ name.to_s + ' restarted'
35
42
  end
36
43
 
37
44
  def run(name)
38
45
 
39
46
  app = @app[name.to_sym]
40
- class_name = app[:code][/(?<=class )\w+/]
41
- app[:running] = eval(class_name + '.new')
47
+
48
+ #app[:running] = eval(app[:code])
49
+ app[:running] = Runner.new.run(app[:code])
42
50
 
43
51
  end
44
52
 
@@ -48,20 +56,9 @@ class AppMgr
48
56
 
49
57
  def running?(name)
50
58
  @app[name.to_sym][:running] ? true : false
51
- end
52
-
53
- def connect(name)
54
-
55
- app = @app[name.to_sym]
56
-
57
- if app and app[:running] then
58
- yield(app[:running])
59
- else
60
- return "app %s not running" % name
61
- end
62
-
63
59
  end
64
60
 
61
+
65
62
  def stop(name)
66
63
 
67
64
  app = @app[name.to_sym]
@@ -71,21 +68,22 @@ class AppMgr
71
68
  else
72
69
  return "couldn't find app %s" % name
73
70
  end
74
-
71
+
75
72
  end
76
73
 
77
74
  def unload(name)
78
75
 
79
- class_name = @app[name.to_sym][:running].class.name
80
-
76
+ app = @app[name.to_sym]
77
+
81
78
  if class_name then
82
- Object.send(:remove_const, class_name)
79
+
83
80
  @app.delete name.to_sym
84
81
  return "app %s unloaded" % name
82
+
85
83
  else
86
84
  return "couldn't find app %s" % name
87
85
  end
88
-
86
+
89
87
  end
90
88
 
91
89
  private
@@ -95,15 +93,32 @@ class AppMgr
95
93
  @rscript.jobs(rsf_package).each do |app_name|
96
94
 
97
95
  puts 'app_name: ' + app_name.inspect if @debug
98
- app = @app[app_name] = {}
99
96
 
100
- codeblock = @rscript.read(['//app:' + app_name.to_s, @rsf]).first
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])
110
+
111
+ end
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
+
101
119
  puts 'codeblock: ' + codeblock.inspect if @debug
102
- app[:code] = codeblock
103
-
104
- reg, rsc = @reg, @rsc
105
- eval codeblock
106
-
120
+ @app[name][:code] = codeblock
121
+ return @app[name]
107
122
  end
108
123
 
109
124
  end
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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,27 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwNzMwMjIxMjU1Whc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YmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEAsfATj4aER/l+5WpvQRcLkEHBSrlcRvgDkK7geiP5
29
+ lzDVU06ndUwBszXoiGbO1oqvSPQYlGY9B5ITqsUY/pEcvSXw6sJ0IrUrGgze25Ha
30
+ sMc5EKYXjTD01FTGyzbsEeijUKT3AMKREOv+htuPxtorHjvZFqG/XQVKITb0SjF9
31
+ Eu8CSq9tXwpS/H7g2NPR3BWOgpRtaBmqtmN6u5Xpx53YX7EfUIOCAEdjbLH83ewU
32
+ o1qWubtMwnFvZzEd7AhASE6zMevhN/x6Y+e8D6YDzIgEmh0N8BD6IjYggzq2T8iE
33
+ Z1siRlr4sgUZd8mLi0o2nG+zqq/9DkV3S7rygERkGccM+tAsakwl0wKIyHJYibNM
34
+ F0SeCKO+Jsn433fz0woyhqdSpuOEEL88twKvwzHS1gzV2RRIy/db8PRsrjsaNhy3
35
+ 8W1C1GMiIJ0XiC7HJfZ9gdjiGK6QbbiqPhA0yRtNjQJWU1id4Nn7ZkaMvjc56Zto
36
+ wgl6kIb23YwRPlLR4VAcERqL
32
37
  -----END CERTIFICATE-----
33
- date: 2018-07-31 00:00:00.000000000 Z
38
+ date: 2022-04-24 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: rscript
@@ -38,22 +43,22 @@ dependencies:
38
43
  requirements:
39
44
  - - "~>"
40
45
  - !ruby/object:Gem::Version
41
- version: '0.5'
46
+ version: '0.9'
42
47
  - - ">="
43
48
  - !ruby/object:Gem::Version
44
- version: 0.5.2
49
+ version: 0.9.0
45
50
  type: :runtime
46
51
  prerelease: false
47
52
  version_requirements: !ruby/object:Gem::Requirement
48
53
  requirements:
49
54
  - - "~>"
50
55
  - !ruby/object:Gem::Version
51
- version: '0.5'
56
+ version: '0.9'
52
57
  - - ">="
53
58
  - !ruby/object:Gem::Version
54
- version: 0.5.2
59
+ version: 0.9.0
55
60
  description:
56
- email: james@jamesrobertson.eu
61
+ email: digital.robertson@gmail.com
57
62
  executables: []
58
63
  extensions: []
59
64
  extra_rdoc_files: []
@@ -78,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
83
  - !ruby/object:Gem::Version
79
84
  version: '0'
80
85
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.6.13
86
+ rubygems_version: 3.2.22
83
87
  signing_key:
84
88
  specification_version: 4
85
89
  summary: Runs 1 or more headless apps from a kind of XML file for use in a back-end
metadata.gz.sig CHANGED
Binary file