dyndoc-ruby 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb254e9ad92b5568c919766480b545b9a6e19054
4
- data.tar.gz: 12d3d9a40d28a5ab9e4195a8b578697fd6dc4be4
3
+ metadata.gz: 0ac774f36b64410fb7fbf8b82443f7e1ad954c9a
4
+ data.tar.gz: e7f918d02181d52d714d9b0029947b06efec8c30
5
5
  SHA512:
6
- metadata.gz: 189698d34c271c9e3e3e74cf3cbaf191362faca8b8e7b79dd6903bca7b616323ceb6dfa77d39a31142b0bcbadebbe8792231859547bce22b597aabc35c3165c7
7
- data.tar.gz: edb7b9b614e731a5a9de5de318ca0b075705f23fb1d9e16dd6565f145b4af18d491779fd13fa5fbe088c0c713a11b34e442c4c367cb217a55087f2b40b228741
6
+ metadata.gz: 5f912f420bea616f0ef7bd05efa013fca1f7169eadf3868f682c062d74ec19edf0fd0388ea210122e2c241106091fdf49ad459a3c89b9310085bfd0fcc7e2baa
7
+ data.tar.gz: 8456636dbb36ea49602152590377e6c2507c526397f66d6416215167d336c3a8745a7815f453e5fd7a572b1fce2a9f8bd7305578a180feae84d27535a7f2f4a2
data/bin/dyn-forever ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'forever'
4
+ require "dyndoc/srv/interactive-server"
5
+
6
+ Forever.run do
7
+ on_error do |e|
8
+
9
+ puts "%s\n %s\n" % [e.message, e.backtrace.join("\n ")]
10
+
11
+ end
12
+ before :all do
13
+ Dyndoc::InteractiveServer.new.run
14
+ end
15
+
16
+ end
data/bin/dyn-srv CHANGED
@@ -1,101 +1,5 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require 'socket' # Get sockets from stdlib
4
- require "dyndoc-core"
5
-
6
-
7
- module Dyndoc
8
-
9
- class InteractiveServer
10
-
11
- def initialize
12
- @tmpl_mngr=nil
13
- @tmpl_filename=nil
14
- init_dyndoc
15
- init_server
16
- end
17
-
18
- def init_dyndoc
19
- unless @tmpl_mngr
20
- Dyndoc.cfg_dyn['dyndoc_session']=:interactive
21
- @tmpl_mngr = Dyndoc::Ruby::TemplateManager.new({})
22
- ##is it really well-suited for interactive mode???
23
- end
24
- reinit_dyndoc
25
- end
26
-
27
- def reinit_dyndoc
28
- if @tmpl_mngr
29
- @tmpl_mngr.init_doc({:format_output=> "html"})
30
- @tmpl_mngr.require_dyndoc_libs("DyndocWebTools")
31
- puts "InteractiveServer (re)initialized!\n"
32
- @tmpl_mngr.as_default_tmpl_mngr! #=> Dyndoc.tmpl_mngr activated!
33
- end
34
- end
35
-
36
-
37
- def process_dyndoc(content)
38
- ##p [:process_dyndoc_content,content]
39
- @content=@tmpl_mngr.parse(content)
40
- ##Dyndoc.warn :content, @content
41
- @tmpl_mngr.filterGlobal.envir["body.content"]=@content
42
- if @tmpl_filename
43
- @tmpl_mngr.filterGlobal.envir["_FILENAME_CURRENT_"]=@tmpl_filename.dup
44
- @tmpl_mngr.filterGlobal.envir["_FILENAME_"]=@tmpl_filename.dup #register name of template!!!
45
- @tmpl_mngr.filterGlobal.envir["_FILENAME_ORIG_"]=@tmpl_filename.dup #register name of template!!!
46
- @tmpl_mngr.filterGlobal.envir["_PWD_"]=File.dirname(@tmpl_filename)
47
- end
48
- return @content
49
- end
50
-
51
- def init_server
52
- @server = TCPServer.new('0.0.0.0',7777)
53
- end
54
-
55
- def run
56
- trap("SIGINT") { @server.close;exit! }
57
- loop {
58
- socket = @server.accept
59
-
60
- b=socket.recv(100000)
61
- ##p [:b,b]
62
- data=b.to_s.strip
63
- ##p [:data,data]
64
- if data =~ /^__send_cmd__\[\[([a-z,_]*)\|?([^\]]*)?\]\]__(.*)__\[\[END_TOKEN\]\]__$/m
65
- cmd,@tmpl_filename,content = $1,$2,$3
66
- ##p [:cmd,cmd,:content,content,:filename,@tmpl_filename]
67
- #p [:tmpl_mngr,@tmpl_filename]
68
- unless @tmpl_filename.empty?
69
- Question.session_dir(File.dirname(@tmpl_filename))
70
- end
71
- if content.strip == "__EXIT__"
72
- socket.close
73
- @server.close
74
- break
75
- end
76
-
77
- if cmd =~ /(.*)_with_layout_reinit$/
78
- LayoutMngr.reinit
79
- cmd=$1
80
- end
81
-
82
- if cmd =~ /(.*)_with_libs_reinit$/
83
- reinit_dyndoc
84
- cmd=$1
85
- end
86
-
87
- if cmd == "dyndoc"
88
- res = process_dyndoc(content)
89
- ##p [:dyndoc_server,content,res]
90
- socket.write "__send_cmd__[[dyndoc]]__"+res+"__[[END_TOKEN]]__"
91
- end
92
- end
93
- socket.close
94
- }
95
- end
96
-
97
- end
98
-
99
- end
3
+ require "dyndoc/srv/interactive-server"
100
4
 
101
5
  Dyndoc::InteractiveServer.new.run
@@ -0,0 +1,97 @@
1
+ require 'socket' # Get sockets from stdlib
2
+ require "dyndoc-core"
3
+
4
+
5
+ module Dyndoc
6
+
7
+ class InteractiveServer
8
+
9
+ def initialize
10
+ @tmpl_mngr=nil
11
+ @tmpl_filename=nil
12
+ init_dyndoc
13
+ init_server
14
+ end
15
+
16
+ def init_dyndoc
17
+ unless @tmpl_mngr
18
+ Dyndoc.cfg_dyn['dyndoc_session']=:interactive
19
+ @tmpl_mngr = Dyndoc::Ruby::TemplateManager.new({})
20
+ ##is it really well-suited for interactive mode???
21
+ end
22
+ reinit_dyndoc
23
+ end
24
+
25
+ def reinit_dyndoc
26
+ if @tmpl_mngr
27
+ @tmpl_mngr.init_doc({:format_output=> "html"})
28
+ @tmpl_mngr.require_dyndoc_libs("DyndocWebTools")
29
+ puts "InteractiveServer (re)initialized!\n"
30
+ @tmpl_mngr.as_default_tmpl_mngr! #=> Dyndoc.tmpl_mngr activated!
31
+ end
32
+ end
33
+
34
+
35
+ def process_dyndoc(content)
36
+ ##p [:process_dyndoc_content,content]
37
+ @content=@tmpl_mngr.parse(content)
38
+ ##Dyndoc.warn :content, @content
39
+ @tmpl_mngr.filterGlobal.envir["body.content"]=@content
40
+ if @tmpl_filename
41
+ @tmpl_mngr.filterGlobal.envir["_FILENAME_CURRENT_"]=@tmpl_filename.dup
42
+ @tmpl_mngr.filterGlobal.envir["_FILENAME_"]=@tmpl_filename.dup #register name of template!!!
43
+ @tmpl_mngr.filterGlobal.envir["_FILENAME_ORIG_"]=@tmpl_filename.dup #register name of template!!!
44
+ @tmpl_mngr.filterGlobal.envir["_PWD_"]=File.dirname(@tmpl_filename)
45
+ end
46
+ return @content
47
+ end
48
+
49
+ def init_server
50
+ @server = TCPServer.new('0.0.0.0',7777)
51
+ end
52
+
53
+ def run
54
+ trap("SIGINT") { @server.close;exit! }
55
+ loop {
56
+ socket = @server.accept
57
+
58
+ b=socket.recv(100000)
59
+ ##p [:b,b]
60
+ data=b.to_s.strip
61
+ ##p [:data,data]
62
+ if data =~ /^__send_cmd__\[\[([a-z,_]*)\|?([^\]]*)?\]\]__(.*)__\[\[END_TOKEN\]\]__$/m
63
+ cmd,@tmpl_filename,content = $1,$2,$3
64
+ ##p [:cmd,cmd,:content,content,:filename,@tmpl_filename]
65
+ #p [:tmpl_mngr,@tmpl_filename]
66
+ unless @tmpl_filename.empty?
67
+ Question.session_dir(File.dirname(@tmpl_filename))
68
+ end
69
+ if content.strip == "__EXIT__"
70
+ socket.close
71
+ @server.close
72
+ break
73
+ end
74
+
75
+ if cmd =~ /(.*)_with_layout_reinit$/
76
+ LayoutMngr.reinit
77
+ cmd=$1
78
+ end
79
+
80
+ if cmd =~ /(.*)_with_libs_reinit$/
81
+ reinit_dyndoc
82
+ cmd=$1
83
+ end
84
+
85
+ if cmd == "dyndoc"
86
+ res = process_dyndoc(content)
87
+ ##p [:dyndoc_server,content,res]
88
+ socket.write "__send_cmd__[[dyndoc]]__"+res+"__[[END_TOKEN]]__"
89
+ end
90
+ end
91
+ socket.close
92
+ }
93
+ end
94
+
95
+ end
96
+
97
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyndoc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - CQLS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-27 00:00:00.000000000 Z
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: R4rb
@@ -97,6 +97,7 @@ executables:
97
97
  - dyn
98
98
  - dyn-cli
99
99
  - dyn-srv
100
+ - dyn-forever
100
101
  - dpm
101
102
  - dyn-init
102
103
  extensions: []
@@ -105,8 +106,10 @@ files:
105
106
  - bin/dpm
106
107
  - bin/dyn
107
108
  - bin/dyn-cli
109
+ - bin/dyn-forever
108
110
  - bin/dyn-init
109
111
  - bin/dyn-srv
112
+ - lib/dyndoc/srv/interactive-server.rb
110
113
  - share/demo/first.dyn
111
114
  - share/demo/second.dyn
112
115
  - share/demo/simple.dyn