dialog_ruby 0.1.10 → 0.1.11

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +13 -0
  3. data/{lib/storage/redis → _dev}/redisPubSub.rb +1 -1
  4. data/background/_init.rb +43 -0
  5. data/background/batch.rb +69 -0
  6. data/background/redis.rb +34 -0
  7. data/dialog_ruby.gemspec +6 -7
  8. data/exec/conf/redis_global.conf +4 -2
  9. data/exec/dialog.sh +28 -26
  10. data/exec/git_sync/dialog__sync.service +1 -1
  11. data/exec/prereq.sh +18 -1
  12. data/exec/systemd/dialog_background.service +29 -0
  13. data/exec/systemd/dialog_redis.service +1 -1
  14. data/exec/systemd/dialog_runMode@.service +16 -6
  15. data/exec/systemd/dialog_runner@.path +8 -0
  16. data/lib/{triggers/start → begin}/_main.rb +29 -21
  17. data/lib/begin/_pre_bot.rb +58 -0
  18. data/lib/begin/background.rb +24 -0
  19. data/lib/{triggers/start → begin}/bot.rb +27 -6
  20. data/lib/{triggers/start → begin}/tdlib.rb +12 -16
  21. data/lib/configuration.rb +39 -27
  22. data/lib/dialect/canvas/element/send/Inline_query_result.rb +2 -0
  23. data/lib/dialect/canvas/element/send/background.rb +28 -0
  24. data/lib/dialect/canvas/element/send/recognize.rb +3 -2
  25. data/lib/dialect/canvas/element/send/restrict.rb +0 -1
  26. data/lib/dialect/canvas/element/send/tdlib_chat.rb +1 -1
  27. data/lib/dialect/canvas/element/send/tdlib_message.rb +1 -1
  28. data/lib/dialect/codegen/codegen.rb +9 -9
  29. data/lib/dialect/codegen/erb/functional/2.2.1.Events2ModReceive.erb +27 -4
  30. data/lib/dialect/codegen/erb/functional/4.1.AppEvent2Elements.erb +7 -2
  31. data/lib/dialect/codegen/erb/functional/5.1.Element2ModElements.erb +1 -1
  32. data/lib/dialect/codegen/erb/functional/7.ElementChains.erb +7 -6
  33. data/lib/dialog_ruby.rb +5 -2
  34. data/lib/metamess/_run.rb +1 -0
  35. data/lib/metamess/content/content_o-contact_f.rb +41 -0
  36. data/lib/metamess/content/content_o.rb +7 -6
  37. data/lib/metamess/func.rb +0 -24
  38. data/lib/metamess/naming.rb +8 -5
  39. data/lib/metamess/service/service_o-inline_f.rb +4 -3
  40. data/lib/require.rb +21 -2
  41. data/lib/statistics/func.rb +72 -0
  42. data/lib/statistics/general.rb +44 -0
  43. data/lib/statistics/redisDump.rb +49 -0
  44. data/lib/storage/redis/cached/pullpush.rb +76 -0
  45. data/lib/storage/redis/cached/pushPreproc.rb +41 -0
  46. data/lib/storage/redis/func.rb +47 -0
  47. data/lib/storage/redis/stat/push.rb +33 -0
  48. data/lib/tdlib/auth.rb +8 -7
  49. data/lib/tdlib/init.rb +5 -5
  50. data/lib/telegram/botapi.rb +2 -1
  51. data/lib/telegram/wrappers.rb +1 -2
  52. data/lib/tooling/log.rb +0 -1
  53. data/lib/tooling/strings.rb +12 -0
  54. data/lib/triggers/_func.rb +39 -0
  55. data/lib/triggers/{_meta/full.rb → console_start.rb} +8 -5
  56. data/lib/triggers/deploy.rb +104 -0
  57. data/lib/triggers/false.rb +8 -6
  58. data/lib/triggers/init.rb +23 -10
  59. data/lib/triggers/systemd_start.rb +24 -0
  60. data/lib/version.rb +1 -1
  61. metadata +83 -41
  62. data/_dev/sidekiq.rb +0 -28
  63. data/exec/systemd/_fix/dialog_bot@.path +0 -6
  64. data/exec/systemd/_fix/dialog_bot_dev@.path +0 -6
  65. data/exec/systemd/_fix/dialog_bot_dev_pre@.service +0 -16
  66. data/lib/storage/redis/rediscached.rb +0 -97
  67. data/lib/triggers/deploy/deploy.rb +0 -78
  68. data/lib/triggers/start/_pre_bot.rb +0 -43
@@ -0,0 +1,58 @@
1
+ ######## ####### ######## ####### ######## ########
2
+ ## / / / / License \ \ \ \
3
+ ## Copyleft culture, Copyright (C) is prohibited here
4
+ ## This work is licensed under a CC BY-SA 4.0
5
+ ## Creative Commons Attribution-ShareAlike 4.0 License
6
+ ## Refer to the http://creativecommons.org/licenses/by-sa/4.0/
7
+ ######## ####### ######## ####### ######## ########
8
+ ## / / / / Code Climate \ \ \ \
9
+ ## Language = ruby
10
+ ## Indent = space; 2 chars;
11
+ ######## ####### ######## ####### ######## ########
12
+
13
+ module Dialog
14
+ class << self
15
+
16
+
17
+ def redisDBStore
18
+ @redisDBStore ||= Redis.new(path: Dialog.config.db.redis_url, db: Dialog.config.db.redisDBStore)
19
+ end
20
+
21
+ def redisDBCache
22
+ @redisDBCache ||= Redis.new(path: Dialog.config.db.redis_url, db: Dialog.config.db.redisDBCache)
23
+ end
24
+
25
+ def redisDBStat
26
+ @redisDBStat ||= Redis.new(path: Dialog.config.db.redis_url, db: Dialog.config.db.redisDBStat)
27
+ end
28
+
29
+ def clear(args)
30
+ args[:x] = {metamess: {}, data: {}, labels: {}, send: {}, exec: {}}
31
+ args[:smsg] = {}
32
+ end
33
+
34
+ def directoriesMustExists
35
+ FileUtils.mkdir_p("#{Dialog.config.path.dialogData}/#{Dialog.config.run.mode}/#{Dialog.config.naming.instance}")
36
+ FileUtils.mkdir_p("#{Dialog.config.path.dialogTmpfiles}")
37
+ end
38
+
39
+ def clearApi(args)
40
+ args[:api] = {}
41
+ end
42
+
43
+
44
+ def perf(perf)
45
+ a = []
46
+ a << "mmsg: #{perf[:metamess] - perf[:init]}s"
47
+ if perf.has_key?(:preApiAction)
48
+ a << "canvas: #{perf[:preApiAction] - perf[:metamess]}s"
49
+ a << "ApiAction in canvas: #{perf[:postApiAction] - perf[:preApiAction]}s"
50
+ else
51
+ a << "canvas: #{perf[:canvas] - perf[:metamess]}s"
52
+ end
53
+ a << "statistics: #{perf[:statistics] - perf[:canvas]}s" if perf.has_key?(:statistics)
54
+ a << "full: #{perf[:fullend] - perf[:init]}s"
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,24 @@
1
+ ######## ####### ######## ####### ######## ########
2
+ ## / / / / License \ \ \ \
3
+ ## Copyleft culture, Copyright (C) is prohibited here
4
+ ## This work is licensed under a CC BY-SA 4.0
5
+ ## Creative Commons Attribution-ShareAlike 4.0 License
6
+ ## Refer to the http://creativecommons.org/licenses/by-sa/4.0/
7
+ ######## ####### ######## ####### ######## ########
8
+ ## / / / / Code Climate \ \ \ \
9
+ ## Language = ruby
10
+ ## Indent = space; 2 chars;
11
+ ######## ####### ######## ####### ######## ########
12
+
13
+ module Dialog
14
+ class << self
15
+
16
+ def start_background(args)
17
+ exec("#{Dir.home}/.gem/ruby/2.5.0/bin/sidekiq", "-r", "#{Dialog.config.path.dialog_ruby}/background/_init.rb")
18
+ # require_relative "#{Dir.home}/.gem/ruby/2.5.0/gems/sidekiq-5.2.2/lib/sidekiq/cli"
19
+
20
+ end
21
+
22
+
23
+ end
24
+ end
@@ -19,14 +19,28 @@ module Dialog
19
19
 
20
20
  ### LANG
21
21
  i18n = Dialog::Lang.initial
22
-
22
+
23
+ ###DRb
24
+ DRb.start_service
25
+
23
26
  begin
24
- Dialog::redis.call(['info', 'clients'])
27
+ Dialog::redisDBStore.call(['info', 'clients'])
28
+ Dialog::redisDBCache.call(['info', 'clients'])
29
+ Dialog::redisDBStat.call(['info', 'clients'])
25
30
  rescue
26
31
  Dialog.logger.error "No Redis connection!"
27
32
  sleep(2)
28
33
  retry
29
34
  end
35
+
36
+ ##Sidekiq
37
+ Sidekiq.configure_client do |config|
38
+ config.redis = { path: Dialog.config.db.redis_url, db: Dialog.config.db.redisDBBackground }
39
+ end
40
+
41
+ #Dirs
42
+ Dialog.directoriesMustExists
43
+
30
44
  Telegram::Bot::Client.run Dialog.config.secure.token do |bot|
31
45
  args[:bot]= bot; args[:bot].freeze
32
46
 
@@ -39,15 +53,19 @@ module Dialog
39
53
  args[:globals][:botUsername] = me["result"]["username"]
40
54
  args[:globals][:botFirstName] = me["result"]["first_name"]
41
55
  args[:globals][:botFirstNameArray] = me["result"]["first_name"].split("\s")
56
+ args[:globals][:tdlibUser] = DRbObject.new_with_uri("drbunix:./_data/tdlib/#{Dialog.config.tdlib.instance}/drb.sock")
42
57
  args[:globals].freeze
43
58
 
59
+ DRb.start_service("drbunix:./_data/bot/#{Dialog.config.naming.instance}/drb.sock", bot)
60
+ #DRb.thread.join
61
+
44
62
  #common queue
45
63
  args[:queue] = {}
46
64
  args[:queue][:threadCommon] = Concurrent::CachedThreadPool.new
47
65
 
48
66
  #Success
49
- Dialog.logger.info "Started: Bot named \"#{args[:globals][:botUsername]}\", botInstance=\"#{Dialog.config.naming.instance}\" of botInterface=\"#{Dialog.config.naming.interface}\", ID=\"#{Dialog.config.naming.id}\", loglevel=\"#{Dialog.config.log.base}\""
50
-
67
+ Dialog.logger.info "Started: Bot named \"#{args[:globals][:botUsername]}\", instance=\"#{Dialog.config.naming.instance}\", interface=\"#{Dialog.config.naming.interface}\", ID=\"#{Dialog.config.naming.id}\", loglevel=\"#{Dialog.config.log.base}\""
68
+
51
69
  begin
52
70
  bot.listen do |rmsg|
53
71
  args[:rmsg] = rmsg
@@ -80,14 +98,17 @@ module Dialog
80
98
 
81
99
  def runMessage(args)
82
100
  begin
83
- # Dialog.logger.debug "######### - REDIS STAT:\n #{Dialog::redis.call(['client', 'list'])}\n\n"
101
+ # Dialog.logger.debug "######### - REDIS STAT:\n #{Dialog::redisDBCache.call(['client', 'list'])}\n\n"
84
102
  Dialog::Metamess.firstpoint(args)
103
+ Dialog::Statistics.general(args)
104
+ args[:perf][:statistics] = Time.now
85
105
  args[:perf][:fullend] = Time.now
86
106
  Dialog.logger.info("## PERF: #{perf(args[:perf]).join(", ")}")
87
107
 
88
108
  rescue Exception => @e
89
109
  Dialog.logger.error "ERROR - #{@e.inspect}\n\n Backtrace:\n #{@e.backtrace.join("\n\t")}\n \
90
- MMSG:\n#{args[:mmsg]}\n" if @e
110
+ MMSG:\n#{args[:mmsg]}\n
111
+ RMSG:\n#{args[:rmsg].to_hash}\n" if @e
91
112
  args[:bot].api.send("sendMessage".to_sym, {chat_id: Dialog.config.monitoring.channel, disable_notification: true, text: @e}) unless Dialog.config.monitoring.channel.nil?
92
113
  raise
93
114
  end
@@ -15,28 +15,24 @@ module Dialog
15
15
 
16
16
  def start_tdlib(args)
17
17
  require 'tdlib-ruby'
18
+ require 'drb/drb'
19
+
18
20
  args[:globals] = {}
19
21
  Dir.glob(File.join("#{Dialog.config.path.dialog_rubyLib}/tdlib/**", "*.rb")).each{|f| require f}
20
- tdlibInit(args)
21
- args[:tdlib][:cli].on_ready do |client|
22
- a = client.fetch('@type' => 'getMe')
23
- args[:globals][:cliId] = a['id'].to_i
24
- end
25
- end
26
-
27
-
28
- def tdlibInit(args)
29
- inits = ['cli']
30
- args[:tdlib] = {}
31
- inits.each do |init|
32
- unless File.exists?("#{Dialog.config.path.dialogData}/tdlib/#{init}/td.binlog")
22
+ unless File.exists?("#{Dialog.config.path.dialogData}/tdlib/#{Dialog.config.naming.instance}/td.binlog")
33
23
  Dialog.logger.error "ERROR: please make init of the '#{init}' using 'ruby dialog.rb init #{init}"
34
24
  exit(false)
35
- end
36
- args[:tdlib][init.to_sym] = Dialog::TDLib.tdlibInit(init)
37
25
  end
38
- args[:tdlib].freeze
26
+ sess = Dialog::TDLib.tdlibInit
27
+ sess.on_ready do |client|
28
+ a = client.fetch('@type' => 'getMe')
29
+ args[:globals][:cliId] = a['id'].to_i
30
+ end
31
+
32
+ DRb.start_service("drbunix:./_data/tdlib/#{Dialog.config.naming.instance}/drb.sock", sess)
33
+ DRb.thread.join
39
34
  end
40
35
 
36
+
41
37
  end
42
38
  end
@@ -25,56 +25,63 @@ module Dialog
25
25
  else res = val
26
26
  end
27
27
  else res = ENV[env]; end
28
- puts err
29
28
  return res
30
29
  end
31
30
 
32
31
  err = []
33
32
  app = 'Dialog'
34
33
 
35
- setting :api do
34
+ setting :tdlib do
36
35
  setting :id, Dialog.checkEnv('ApiID', false, err)
37
36
  setting :hash_s, Dialog.checkEnv('ApiHash', false, err)
37
+ setting :instance, Dialog.checkEnv('TdlibInstance', false, err)
38
38
  end
39
39
 
40
+ _scope = Dialog.checkEnv('runScope', false, err)
41
+ _mode = Dialog.checkEnv('runMode', false, err)
42
+ _instance = Dialog.checkEnv('runInstance', false, err)
40
43
  setting :run do
41
- setting :scope, Dialog.checkEnv('runScope', false, err)
42
- setting :mode, Dialog.checkEnv('runMode', false, err)
44
+ setting :scope, _scope
45
+ setting :mode, _mode
43
46
  end
44
47
 
45
48
  setting :naming do
46
49
  setting :app, app
47
50
  end
48
51
 
49
- unless Dialog.checkEnv('runScope', false, err) == 'init'
50
- namingFull = Dialog.checkEnv('BotFullname', false, err)
52
+ _interface = Dialog.checkEnv('Interface', 'Demo')
53
+ unless _scope == 'deploy' or _mode == 'background'
51
54
  token = Dialog.checkEnv('BotToken', false, err)
52
55
 
53
56
  setting :naming do
54
57
  setting :app, app
55
- setting :full, namingFull
56
- if /__/.match? namingFull
57
- setting :interface, namingFull.split('__')[0]
58
- setting :instance, namingFull.split('__')[0]
58
+ setting :interface, _interface
59
+ unless _instance == false
60
+ setting :instance, _instance
59
61
  else
60
- err << "Error in naming!"
62
+ err << "No instance!"
61
63
  end
62
64
  setting :id, token.split(':')[0].to_i unless token == false
63
65
  end
64
66
 
65
67
  setting :dialect do
66
- setting :folder, Dialog.checkEnv('DialectFolder', false, err)
67
- setting :sqlite, Dialog.checkEnv('DialectSqlite', '/tmp/dialect.sqlite')
68
- end
69
-
70
- setting :db do
71
- setting :redis_url, "./_data/redis/redis.sock"
68
+ setting :sqlite, Dialog.checkEnv('DialectSqlite', "#{Dialog.getDialogPath}/dialect/dialect.sqlite")
69
+ setting :json, Dialog.checkEnv('DialectJSON', "#{Dialog.getDialogPath}/dialect/#{_interface}.json")
72
70
  end
73
71
 
74
72
  setting :secure do
75
73
  setting :token, token
76
74
  end
77
75
  end
76
+
77
+ setting :db do
78
+ setting :redis_url, "./_data/redis/redis.sock"
79
+ setting :redisDBBackground, 0
80
+ setting :redisDBStore, 1
81
+ setting :redisDBStat, 2
82
+ setting :redisDBCache, 3
83
+
84
+ end
78
85
 
79
86
  setting :proxy do
80
87
  setting :type, Dialog.checkEnv('BotProxyType', false, err)
@@ -89,16 +96,13 @@ module Dialog
89
96
  setting :dialog_rubyLib,"#{Dialog.getDialog_rubyPath}"
90
97
  setting :dialog, "#{Dialog.getDialogPath}"
91
98
  setting :dialogData, "#{Dialog.getDialogPath}/_data"
92
- setting :dialogRender, "#{Dialog.getDialogPath}/#{namingFull}/_render"
99
+ setting :dialogRender, "#{Dialog.getDialogPath}/_render/#{_instance}"
100
+ setting :dialogTmpfiles,"#{Dialog.getDialogPath}/_render/#{_instance}/tmpfiles"
93
101
  end
94
102
 
95
- setting :common do
96
- setting :mode, Dialog.checkEnv('runMode', false, err)
97
- end
98
-
99
103
  setting :log do
100
104
  setting :base, Dialog.checkEnv('LogLevel', 'info')
101
- setting :tdlib, Dialog.checkEnv('TdlibLoglevel', 9)
105
+ setting :tdlib, Dialog.checkEnv('LogLevel', 1)
102
106
  end
103
107
 
104
108
  setting :monitoring do
@@ -112,14 +116,22 @@ module Dialog
112
116
  setting :web_hook_url, "https://#{botInstanceHostName}/telegram/api/web_hook"
113
117
  end
114
118
 
115
- if Dialog.checkEnv('runScope', false, err) == false and Dialog.checkEnv('runMode', false, err) == false
116
- FileUtils.cp "#{Dialog.getDialog_rubyPath}/../exec/dialog.sh", "#{Dialog.getDialogPath}/" if not File.file?("#{Dialog.getDialogPath}/dialog.sh")
117
- Dialog.logger.info "dialog.sh is copied to your dialog folder, please use it for correct ENV exports!"
119
+ if _scope == false
120
+ case _mode
121
+ when false
122
+ FileUtils.cp "#{Dialog.getDialog_rubyPath}/../exec/dialog.sh", "#{Dialog.getDialogPath}/" if not File.file?("#{Dialog.getDialogPath}/dialog.sh")
123
+ Dialog.logger.info "dialog.sh is copied to your dialog folder, please use it for correct ENV exports,\nbash ./dialog.sh"
124
+ Dialog.logger.info "Deploying dialog base"
125
+ deploy = true
126
+ when 'dev'
127
+ deploy = true
128
+ end
129
+ Dialog::Triggers.trigger_deploy if deploy == true
118
130
  end
119
131
 
120
132
  unless err.empty?
121
133
  err << "EXITING!"
122
- puts err
134
+ Dialog.logger.debug "ERRORS: #{err}"
123
135
  exit(false)
124
136
  end
125
137
  end
@@ -18,12 +18,14 @@ module Dialog
18
18
  args[:smsg] ||={}
19
19
  args[:x].has_key?(:dataResp) ? results = args[:x][:dataResp] : results = makeInline_query_resultArticle(args, props, viewId)
20
20
  args[:smsg][:results] = results
21
+ return Dialog::BotApi.apiAction(args)
21
22
  end
22
23
 
23
24
  def send_DialogElementSendInline_query_resultDocument(args)
24
25
  args[:smsg] ||={}
25
26
  args[:x].has_key?(:dataResp) ? results = args[:x][:dataResp] : results = makeInline_query_resultDocument(args, props, viewId)
26
27
  args[:smsg][:results] = results
28
+ return Dialog::BotApi.apiAction(args)
27
29
  end
28
30
 
29
31
  end
@@ -0,0 +1,28 @@
1
+ ######## ####### ######## ####### ######## ########
2
+ ## / / / / License \ \ \ \
3
+ ## Copyleft culture, Copyright (C) is prohibited here
4
+ ## This work is licensed under a CC BY-SA 4.0
5
+ ## Creative Commons Attribution-ShareAlike 4.0 License
6
+ ## Refer to the http://creativecommons.org/licenses/by-sa/4.0/
7
+ ######## ####### ######## ####### ######## ########
8
+ ## / / / / Code Climate \ \ \ \
9
+ ## Language = ruby
10
+ ## Indent = space; 2 chars;
11
+ ######## ####### ######## ####### ######## ########
12
+
13
+ module Dialog
14
+ module ElementSend
15
+ class << self
16
+
17
+
18
+ def send_DialogElementSendExecBackground(args)
19
+ require "#{Dialog.config.path.dialog_ruby}/background/batch"
20
+ res = Dialog::Background::BotApi.perform_async(Dialog.config.naming.instance, args[:mmsg])
21
+ Dialog.logger.debug "Async result: '#{res}'"
22
+ end
23
+
24
+
25
+ end
26
+ end
27
+ end
28
+ #
@@ -16,7 +16,7 @@ module Dialog
16
16
 
17
17
 
18
18
  def send_DialogElementSendRecognizeCode(args)
19
- name = "#{Dialog.config.path.render}/_tmpfiles/#{Dialog::Wrappers.downloadFile(args)}"
19
+ name = "#{Dialog.config.path.dialogTmpfiles}/#{Dialog::Wrappers.downloadFile(args)}"
20
20
  attrs, stderr_str, status = Open3.capture3('/usr/bin/zbarimg', "-q", name)
21
21
 
22
22
  unless attrs == ""
@@ -29,7 +29,8 @@ module Dialog
29
29
  text = answer_DialogModSendRecognizeCommonAction_fail
30
30
  end
31
31
  args[:smsg][:text] = text
32
- args[:x][:dataRespRaw] = response
32
+ args[:x][:dataRespRaw] = response
33
+ send_DialogElementSendBot_messageSend(args)
33
34
  end
34
35
 
35
36
  def answer_DialogModSendRecognizeCommonAction_success(codeType, response)
@@ -22,7 +22,6 @@ module Dialog
22
22
  args[:smsg][:can_send_media_messages] = false
23
23
  args[:smsg][:can_send_other_messages] = false
24
24
  args[:smsg][:can_add_web_page_previews] = false
25
-
26
25
  return Dialog::BotApi.apiAction(args)
27
26
  end
28
27
 
@@ -19,7 +19,7 @@ module Dialog
19
19
  args[:smsg]['title'] = 'test'
20
20
  args[:smsg]['is_channel'] = false
21
21
  args[:smsg]['description'] = 'description'
22
- args[:tdlib][:cli].on_ready do |client|
22
+ args[:globals][:tdlibUser].on_ready do |client|
23
23
  group = client.broadcast_and_receive(args[:smsg])
24
24
  Dialog.logger.debug "#### group created - #{group}"
25
25
  end
@@ -15,7 +15,7 @@ module Dialog
15
15
  class << self
16
16
 
17
17
  def send_DialogElementSendTdlib_messageSend(args)
18
- args[:tdlib][:cli].on_ready do |client|
18
+ args[:globals][:tdlibUser].on_ready do |client|
19
19
  args[:smsg]['@type'] = 'sendMessage'
20
20
 
21
21
  if args[:smsg][:chat_id] == args[:mmsg][:fqndata][:o][:from][:id]
@@ -48,15 +48,15 @@ module Dialog
48
48
  nameSym = runProps[:name].to_sym
49
49
  data = args[:dialect][:perView][Dialog.config.naming.app.to_sym]
50
50
  if data.is_a?(Hash)
51
- data.each do |viewId, viewProps|
52
- if runProps[:erb] == 1 && data[viewId][runProps[:name]].is_a?(Hash)
53
- Dialog.logger.debug "### erb - #{runProps}"
54
- fullName = "#{runProps[:order]}_#{runProps[:name]}_#{viewId}"
55
- fullNameSym = fullName.to_sym
56
-
57
- tmpl = ERB.new(File.read("#{File.dirname(__FILE__)}/erb/#{stage}/#{runProps[:order]}.#{runProps[:name]}.erb")).result(binding)
58
- runProps.has_key?(:erb_order) ? rname = "#{runProps[:erb_order]}_#{fullName}" : rname = fullName
59
- File.open("#{Dialog.config.path.dialogRender}/code_#{type}/#{stage}__#{rname}.rb", 'w') do |f| f.write tmpl; end
51
+ data.each do |viewId, viewProps|
52
+ if runProps[:erb] == 1 && data[viewId].is_a?(Hash) and data[viewId][runProps[:name]].is_a?(Hash)
53
+ Dialog.logger.debug "### erb - #{runProps}"
54
+ fullName = "#{runProps[:order]}_#{runProps[:name]}_#{viewId}"
55
+ fullNameSym = fullName.to_sym
56
+
57
+ tmpl = ERB.new(File.read("#{File.dirname(__FILE__)}/erb/#{stage}/#{runProps[:order]}.#{runProps[:name]}.erb")).result(binding)
58
+ runProps.has_key?(:erb_order) ? rname = "#{runProps[:erb_order]}_#{fullName}" : rname = fullName
59
+ File.open("#{Dialog.config.path.dialogRender}/code_#{type}/#{stage}__#{rname}.rb", 'w') do |f| f.write tmpl; end
60
60
  end
61
61
  end
62
62
  end
@@ -30,18 +30,41 @@ module Dialog
30
30
  <% hash_tOID.each do |tOID, prop|
31
31
 
32
32
  prop[:tProp][:op] == "=~" ? valuePrefix = "/" : valuePrefix = "\""
33
- prop[:tProp][:value].to_s === prop[:tProp][:value].to_i.to_s ? value = prop[:tProp][:value] : value = "#{valuePrefix}#{prop[:tProp][:value]}#{valuePrefix}" %>
33
+ prop[:tProp][:value].to_s === prop[:tProp][:value].to_i.to_s ? value = prop[:tProp][:value] : value = "#{valuePrefix}#{prop[:tProp][:value]}#{valuePrefix}"
34
+ /[*.,.*]/.match?(value) ? valueArr = value[2..-3].split(",") : valueArr = false %>
35
+
34
36
  ## <%= prop[:tName]%>
35
37
  ## <%= prop[:fFqn]%> ->> <%= tFqn%>
36
- if args[:mmsg][:fqndata]<%= prop[:tProp][:key]%> <%= prop[:tProp][:op]%> <%= value %>
38
+ <% if valueArr.is_a?(Array)
39
+ res = ""
40
+ i = 0
41
+ valueArr.each do |v|
42
+ res = res + "args[:mmsg][:fqndata]#{prop[:tProp][:key]} #{prop[:tProp][:op]} '#{v}' "
43
+ i += 1
44
+ i < valueArr.count ? res = res + " or " : true
45
+ end %>
46
+ if <%= res %>
47
+ <% else %>
48
+ if args[:mmsg][:fqndata]<%= prop[:tProp][:key]%> <%= prop[:tProp][:op]%> <%= value %>
49
+ <% end %>
37
50
  args[:x][:labels] = {} if args[:x][:labels] == 'next'
38
51
  args[:x][:labels][:oid_<%= prop[:tOID]%>] = true
39
52
  Dialog.logger.debug "### ADD LABEL: <%= prop[:tProp][:key]%> = #{args[:mmsg][:fqndata]<%= prop[:tProp][:key]%>} <%= prop[:tProp][:op]%> %Q[#{<%= value %>}]"
40
53
  <% if args[:dialect][:perView][Dialog.config.naming.app.to_sym][viewId][:ModReceive2GetData].is_a?(Hash)
41
54
  if args[:dialect][:perView][Dialog.config.naming.app.to_sym][viewId][:ModReceive2GetData][:repack][:tOID][tOID.to_sym].is_a?(Hash)
42
55
  case args[:dialect][:perView][Dialog.config.naming.app.to_sym][viewId][:ModReceive2GetData][:repack][:tOID][tOID.to_sym][:fFqn]
43
- when "#{Dialog.config.naming.app}ArchiGetdataField" %>
44
- args[:x][:dataReq] = args[:mmsg][:fqndata]<%= prop[:tProp][:key]%>
56
+ when "#{Dialog.config.naming.app}ArchiGetdataField"
57
+ if prop[:tProp].has_key?(:vAction) and prop[:tProp].has_key?(:vFrom) and prop[:tProp].has_key?(:vTo)
58
+ case prop[:tProp][:vAction]
59
+ when 'sub' %>
60
+ args[:x][:dataReq] = args[:mmsg][:fqndata]<%= prop[:tProp][:key]%>.sub("<%= prop[:tProp][:vFrom] %>", "<%= prop[:tProp][:vTo] %>")
61
+ Dialog.logger.debug "@@@ SUB - #{args[:x][:dataReq]}"
62
+ <% when 'replace' %>
63
+ args[:x][:dataReq] = args[:mmsg][:fqndata]<%= prop[:tProp][:key]%> ## TODO
64
+ <% end %>
65
+ <% else %>
66
+ args[:x][:dataReq] = args[:mmsg][:fqndata]<%= prop[:tProp][:key]%>
67
+ <% end %>
45
68
  <% when "#{Dialog.config.naming.app}ArchiGetdataFixed" %>
46
69
  args[:x][:dataReq] = "<%= args[:dialect][:perView][Dialog.config.naming.app.to_sym][viewId][:ModReceive2GetData][:repack][:tOID][tOID.to_sym][:fProp][:data] %>"
47
70
  <% end %>