fxruby-enhancement 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.semver +2 -2
- data/Gemfile.lock +1 -1
- data/README.org +250 -27
- data/examples/data_target.rb +60 -0
- data/examples/dialog_box.rb +54 -0
- data/examples/hello.rb +1 -4
- data/fxruby-enhancement.gemspec +5 -3
- data/lib/fxruby-enhancement/api-mapper.rb +688 -688
- data/lib/fxruby-enhancement/api-mapper.rb.erb +3 -3
- data/lib/fxruby-enhancement/enhancement.rb +1 -0
- data/lib/fxruby-enhancement/ostruct-monkey.rb +33 -3
- metadata +4 -2
@@ -50,8 +50,8 @@ module Fox
|
|
50
50
|
module Enhancement
|
51
51
|
module Mapper
|
52
52
|
<% for @class, @details in @api %>
|
53
|
-
def <%= @class.snake %> name = nil, ii: <%= (Fox::Enhancement::INITFORCE.member? @class) ? Fox::Enhancement::INITFORCE[@class] : 0 %>, pos: Enhancement.stack.last, &block
|
54
|
-
Enhancement.stack << (@os = os = OpenStruct.new(klass: <%= @class %>, op: [], ii: ii, fx: nil, kinder: [], inst: nil, instance_result: nil))
|
53
|
+
def <%= @class.snake %> name = nil, ii: <%= (Fox::Enhancement::INITFORCE.member? @class) ? Fox::Enhancement::INITFORCE[@class] : 0 %>, pos: Enhancement.stack.last, reuse: nil, &block
|
54
|
+
Enhancement.stack << (@os = os = OpenStruct.new(klass: <%= @class %>, op: [], ii: ii, fx: nil, kinder: [], inst: nil, instance_result: nil, reusable: reuse))
|
55
55
|
Enhancement.components[name] = os unless name.nil?
|
56
56
|
unless pos.nil?
|
57
57
|
pos.kinder << os
|
@@ -73,7 +73,7 @@ module Fox
|
|
73
73
|
<% @i+=1; end unless @details[:initialize].nil? %>
|
74
74
|
self.instance_eval &block
|
75
75
|
<% unless Fox::Enhancement::SPECIAL.member? @class %>
|
76
|
-
os.fx = ->(){ <%= @class %>.new(*([pos.inst] + os.op[os.ii].to_h.values[1..-1])) }
|
76
|
+
os.fx = ->(){ <%= @class %>.new(*([pos.inst] + os.op[os.ii].to_h.values[1..-1].map{|v| (v.is_a?(OpenStruct)? v.inst : v)} )) }
|
77
77
|
<% else %>
|
78
78
|
os.fx = ->(){ <%= @class %>.new(*(os.op[os.ii].to_h.values)) }
|
79
79
|
<% end %>
|
@@ -1,18 +1,24 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
class OpenStruct
|
3
3
|
extend Forwardable
|
4
|
-
def_delegator :inst, :create,
|
4
|
+
def_delegator :inst, :create, :activate
|
5
|
+
def_delegator :inst, :destroy, :deactivate
|
5
6
|
def_delegator :inst, :run, :run_application
|
6
7
|
|
7
8
|
# This assumes this OpenStruct instance represents the base,
|
8
9
|
# and additionaly will take an optional object to use as the
|
9
10
|
# actual base to allow for composures.
|
10
11
|
#
|
12
|
+
# For the reuseable part of the tree, those are not created
|
13
|
+
# right away.
|
14
|
+
#
|
11
15
|
# Returns the os base
|
12
16
|
def create_fox_components use_as_base = nil
|
13
17
|
if use_as_base.nil?
|
14
18
|
self.inst = fx.() if self.inst.nil?
|
15
|
-
self.kinder.each{ |os|
|
19
|
+
self.kinder.each{ |os|
|
20
|
+
os.create_fox_components unless os.reusable?
|
21
|
+
}
|
16
22
|
else
|
17
23
|
OpenStruct.new(klass: use_as_base.class,
|
18
24
|
kinder: [self],
|
@@ -21,9 +27,21 @@ class OpenStruct
|
|
21
27
|
self
|
22
28
|
end
|
23
29
|
|
30
|
+
def reusable?
|
31
|
+
self.reusable
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy_fox_components all: false
|
35
|
+
self.deactivate unless self.inst.nil?
|
36
|
+
self.kinder.each{ |os|
|
37
|
+
os.destroy_fox_components if all or not os.reusable?
|
38
|
+
}
|
39
|
+
self.inst = nil
|
40
|
+
end
|
41
|
+
|
24
42
|
def instance_final_activate
|
25
43
|
self.instance_result = self.instance_block.(self.inst) unless self.instance_block.nil?
|
26
|
-
self.kinder.each{ |os| os.instance_final_activate }
|
44
|
+
self.kinder.each{ |os| os.instance_final_activate unless os.reusable? }
|
27
45
|
self
|
28
46
|
end
|
29
47
|
|
@@ -35,4 +53,16 @@ class OpenStruct
|
|
35
53
|
Enhancement.activate_ingress_handlers self if ingress
|
36
54
|
run_application
|
37
55
|
end
|
56
|
+
|
57
|
+
# start the reusable components
|
58
|
+
def starten
|
59
|
+
create_fox_components
|
60
|
+
instance_final_activate
|
61
|
+
activate
|
62
|
+
end
|
63
|
+
|
64
|
+
# stop and deallocate the resusable components
|
65
|
+
def stoppen
|
66
|
+
destroy_fox_components
|
67
|
+
end
|
38
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fxruby-enhancement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Mitchell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semver2
|
@@ -282,6 +282,8 @@ files:
|
|
282
282
|
- build/scrape-rdoc.rb
|
283
283
|
- examples/.ruby-version
|
284
284
|
- examples/bounce.rb
|
285
|
+
- examples/data_target.rb
|
286
|
+
- examples/dialog_box.rb
|
285
287
|
- examples/hello.rb
|
286
288
|
- fxruby-enhancement.gemspec
|
287
289
|
- lib/fxruby-enhancement.rb
|