dyndoc-ruby 0.6.2 → 0.6.6
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/bin/dyn-cli +6 -86
- data/lib/dyndoc-convert.rb +41 -0
- data/lib/dyndoc/cli/interactive-client.rb +81 -0
- data/lib/dyndoc/srv/interactive-server.rb +6 -1
- data/lib/dyndoc/srv/tilt.rb +88 -0
- data/share/etc/dyn-cli/dyn_layout +1 -0
- data/share/etc/dyn-cli/layout/default.dyn +17 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c1bc9ee21c0b73f6ec34b2d9557d231d4f5c6a7
|
4
|
+
data.tar.gz: 34f971a6891594b7947d6bea3244b00c3cae9c7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f744eb4bf0c12dd54f721ece3a10484c58c4cd331fe95be72cd7b405035a670ce5f94298c302b18cb879484faa76207947604c969ec605d6fedc28e8b8c3328
|
7
|
+
data.tar.gz: 765d193d39d43b2df85ccd3f9920f8d5602d9defc32b4edfbecc80bb39e00c672a7a887d2bc2c15bde10cdd13e8a6f9dcd353ad1430473ef0222d68cd4ca3cf5
|
data/bin/dyn-cli
CHANGED
@@ -1,86 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
module Dyndoc
|
6
|
-
|
7
|
-
class Client
|
8
|
-
|
9
|
-
attr_reader :content
|
10
|
-
|
11
|
-
@@end_token="__[[END_TOKEN]]__"
|
12
|
-
|
13
|
-
## reinit is an array
|
14
|
-
def initialize(cmd,tmpl_filename,addr="127.0.0.1",reinit=[],port=7777)
|
15
|
-
|
16
|
-
@addr,@port,@cmd,@tmpl_filename=addr,port,cmd,tmpl_filename
|
17
|
-
##p [:tmpl_filename,@tmpl_filename,@cmd]
|
18
|
-
## The layout needs to be reintailized for new dyndoc file but not for the layout (of course)!
|
19
|
-
dyndoc_cmd="dyndoc"
|
20
|
-
dyndoc_cmd += "_with_tag_tmpl" if reinit.include? :dyndoc_tag_tmpl
|
21
|
-
dyndoc_cmd += "_with_libs_reinit" if reinit.include? :dyndoc_libs
|
22
|
-
dyndoc_cmd += "_with_layout_reinit" if reinit.include? :dyndoc_layout
|
23
|
-
|
24
|
-
#p [:addr,@addr]
|
25
|
-
Socket.tcp(@addr, @port) {|sock|
|
26
|
-
msg='__send_cmd__[['+dyndoc_cmd+'|'+@tmpl_filename+']]__' + @cmd + @@end_token
|
27
|
-
#p msg
|
28
|
-
sock.print msg
|
29
|
-
#sleep 1
|
30
|
-
sock.close_write
|
31
|
-
@result=sock.read
|
32
|
-
}
|
33
|
-
|
34
|
-
data=@result.split(@@end_token,-1)
|
35
|
-
last=data.pop
|
36
|
-
resCmd=decode_cmd(data.join(""))
|
37
|
-
##p [:resCmd,resCmd]
|
38
|
-
if resCmd and resCmd[:cmd] != "windows_platform"
|
39
|
-
@content=resCmd[:content]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def decode_cmd(res)
|
44
|
-
if res =~ /^__send_cmd__\[\[([a-zA-Z0-9_]*)\]\]__([\s\S]*)/m
|
45
|
-
return {cmd: $1, content: $2}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# def listen
|
50
|
-
# ##@response = Thread.new do
|
51
|
-
# result=""
|
52
|
-
# @content=nil
|
53
|
-
# msg=""
|
54
|
-
# loop {
|
55
|
-
# msg=@server.recv(1024)
|
56
|
-
# ##p msg
|
57
|
-
# if msg
|
58
|
-
# msg.chomp!
|
59
|
-
# ##puts "#{msg}"
|
60
|
-
# data=msg.split(@@end_token,-1)
|
61
|
-
# ##p data
|
62
|
-
# last=data.pop
|
63
|
-
# result += data.join("")
|
64
|
-
# #p "last:<<"+last+">>"
|
65
|
-
# if last == ""
|
66
|
-
# #console.log("<<"+result+">>")
|
67
|
-
# resCmd = decode_cmd(result)
|
68
|
-
# ##p resCmd
|
69
|
-
# if resCmd[:cmd] != "windows_platform"
|
70
|
-
# #console.log("data: "+resCmd["content"])
|
71
|
-
# @content=resCmd[:content]
|
72
|
-
# @server.close
|
73
|
-
# break
|
74
|
-
# end
|
75
|
-
# else
|
76
|
-
# result += last if last
|
77
|
-
# end
|
78
|
-
# end
|
79
|
-
# }
|
80
|
-
# #end
|
81
|
-
# end
|
82
|
-
end
|
83
|
-
end
|
3
|
+
require 'dyndoc/cli/interactive-client.rb'
|
84
4
|
|
85
5
|
# USAGE:
|
86
6
|
# dyndoc-ruby-client.rb|dyn-cli test.dyn[@127.0.0.1] [output_filename.html]
|
@@ -186,11 +106,11 @@ if dyn_file
|
|
186
106
|
code=File.read(dyn_file)
|
187
107
|
if dyn_libs or dyn_pre_code
|
188
108
|
code_pre = ""
|
189
|
-
code_pre += dyn_pre_code +
|
190
|
-
code_pre += '[#require]\n
|
109
|
+
code_pre += dyn_pre_code + "\n" if dyn_pre_code
|
110
|
+
code_pre += '[#require]'+"\n"+dyn_libs if dyn_libs
|
191
111
|
code = code_pre + '[#main][#>]' + code
|
192
112
|
end
|
193
|
-
code +=
|
113
|
+
code += "\n" + dyn_post_code if dyn_post_code
|
194
114
|
code = dyn_tag_tmpl+code if dyn_tag_tmpl
|
195
115
|
dyndoc_start=[:dyndoc_libs,:dyndoc_layout]
|
196
116
|
## tag tmpl attempt to communicate to the server
|
@@ -199,10 +119,10 @@ if dyn_file
|
|
199
119
|
## but also to dyndoc-server-simple.rb
|
200
120
|
end
|
201
121
|
|
202
|
-
cli=Dyndoc::
|
122
|
+
cli=Dyndoc::InteractiveClient.new(code,File.expand_path(dyn_file),addr,dyndoc_start)
|
203
123
|
|
204
124
|
if dyn_layout
|
205
|
-
cli=Dyndoc::
|
125
|
+
cli=Dyndoc::InteractiveClient.new(File.read(dyn_layout),"",addr) #File.expand_path(dyn_layout),addr)
|
206
126
|
end
|
207
127
|
|
208
128
|
if dyn_output and Dir.exist? File.dirname(dyn_output)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "dyndoc-core"
|
2
|
+
require 'dyndoc/cli/interactive-client.rb'
|
3
|
+
|
4
|
+
|
5
|
+
module Dyndoc
|
6
|
+
|
7
|
+
@@dyndoc_tmpl_mngr=nil
|
8
|
+
|
9
|
+
## does notwork when called twice!!!! (ex: jekyll-dyndoc in mode dyndoc)
|
10
|
+
def Dyndoc.convert(input,config={})
|
11
|
+
unless @@dyndoc_tmpl_mngr
|
12
|
+
Dyndoc.cfg_dyn['dyndoc_session']=:interactive
|
13
|
+
@@dyndoc_tmpl_mngr = Dyndoc::Ruby::TemplateManager.new({})
|
14
|
+
##is it really well-suited for interactive mode???
|
15
|
+
@@dyndoc_tmpl_mngr.init_doc({:format_output=> "html"})
|
16
|
+
@@dyndoc_tmpl_mngr.require_dyndoc_libs("DyndocWebTools")
|
17
|
+
puts "InteractiveServer (re)initialized!\n"
|
18
|
+
@@dyndoc_tmpl_mngr.as_default_tmpl_mngr! #=> Dyndoc.tmpl_mngr activated!
|
19
|
+
end
|
20
|
+
Dyndoc.warn :input, input
|
21
|
+
output=@@dyndoc_tmpl_mngr.parse(input)
|
22
|
+
##
|
23
|
+
Dyndoc.warn :output, output
|
24
|
+
@@dyndoc_tmpl_mngr.filterGlobal.envir["body.content"]=output
|
25
|
+
if config['tmpl_filename']
|
26
|
+
@@dyndoc_tmpl_mngr.filterGlobal.envir["_FILENAME_CURRENT_"]=config['tmpl_filename'].dup
|
27
|
+
@@dyndoc_tmpl_mngr.filterGlobal.envir["_FILENAME_"]=config['tmpl_filename'].dup #register name of template!!!
|
28
|
+
@@dyndoc_tmpl_mngr.filterGlobal.envir["_FILENAME_ORIG_"]=config['tmpl_filename'].dup #register name of template!!!
|
29
|
+
@@dyndoc_tmpl_mngr.filterGlobal.envir["_PWD_"]=File.dirname(config['tmpl_filename'])
|
30
|
+
end
|
31
|
+
return output
|
32
|
+
end
|
33
|
+
|
34
|
+
def Dyndoc.cli_convert(input,config={})
|
35
|
+
addr="127.0.0.1"
|
36
|
+
dyndoc_start=[:dyndoc_libs]
|
37
|
+
cli=Dyndoc::InteractiveClient.new(input,"",addr,dyndoc_start)
|
38
|
+
return cli.content
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "socket"
|
2
|
+
|
3
|
+
module Dyndoc
|
4
|
+
|
5
|
+
class InteractiveClient
|
6
|
+
|
7
|
+
attr_reader :content
|
8
|
+
|
9
|
+
@@end_token="__[[END_TOKEN]]__"
|
10
|
+
|
11
|
+
## reinit is an array
|
12
|
+
def initialize(cmd,tmpl_filename,addr="127.0.0.1",reinit=[],port=7777)
|
13
|
+
|
14
|
+
@addr,@port,@cmd,@tmpl_filename=addr,port,cmd,tmpl_filename
|
15
|
+
##p [:tmpl_filename,@tmpl_filename,@cmd]
|
16
|
+
## The layout needs to be reintailized for new dyndoc file but not for the layout (of course)!
|
17
|
+
dyndoc_cmd="dyndoc"
|
18
|
+
dyndoc_cmd += "_with_tag_tmpl" if reinit.include? :dyndoc_tag_tmpl
|
19
|
+
dyndoc_cmd += "_with_libs_reinit" if reinit.include? :dyndoc_libs
|
20
|
+
dyndoc_cmd += "_with_layout_reinit" if reinit.include? :dyndoc_layout
|
21
|
+
|
22
|
+
#p [:addr,@addr]
|
23
|
+
Socket.tcp(@addr, @port) {|sock|
|
24
|
+
msg='__send_cmd__[['+dyndoc_cmd+'|'+@tmpl_filename+']]__' + @cmd + @@end_token
|
25
|
+
#p msg
|
26
|
+
sock.print msg
|
27
|
+
#sleep 1
|
28
|
+
sock.close_write
|
29
|
+
@result=sock.read
|
30
|
+
}
|
31
|
+
|
32
|
+
data=@result.split(@@end_token,-1)
|
33
|
+
last=data.pop
|
34
|
+
resCmd=decode_cmd(data.join(""))
|
35
|
+
##p [:resCmd,resCmd]
|
36
|
+
if resCmd and resCmd[:cmd] != "windows_platform"
|
37
|
+
@content=resCmd[:content]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def decode_cmd(res)
|
42
|
+
if res =~ /^__send_cmd__\[\[([a-zA-Z0-9_]*)\]\]__([\s\S]*)/m
|
43
|
+
return {cmd: $1, content: $2}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# def listen
|
48
|
+
# ##@response = Thread.new do
|
49
|
+
# result=""
|
50
|
+
# @content=nil
|
51
|
+
# msg=""
|
52
|
+
# loop {
|
53
|
+
# msg=@server.recv(1024)
|
54
|
+
# ##p msg
|
55
|
+
# if msg
|
56
|
+
# msg.chomp!
|
57
|
+
# ##puts "#{msg}"
|
58
|
+
# data=msg.split(@@end_token,-1)
|
59
|
+
# ##p data
|
60
|
+
# last=data.pop
|
61
|
+
# result += data.join("")
|
62
|
+
# #p "last:<<"+last+">>"
|
63
|
+
# if last == ""
|
64
|
+
# #console.log("<<"+result+">>")
|
65
|
+
# resCmd = decode_cmd(result)
|
66
|
+
# ##p resCmd
|
67
|
+
# if resCmd[:cmd] != "windows_platform"
|
68
|
+
# #console.log("data: "+resCmd["content"])
|
69
|
+
# @content=resCmd[:content]
|
70
|
+
# @server.close
|
71
|
+
# break
|
72
|
+
# end
|
73
|
+
# else
|
74
|
+
# result += last if last
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
# }
|
78
|
+
# #end
|
79
|
+
# end
|
80
|
+
end
|
81
|
+
end
|
@@ -55,7 +55,12 @@ module Dyndoc
|
|
55
55
|
loop {
|
56
56
|
socket = @server.accept
|
57
57
|
|
58
|
-
|
58
|
+
## Rmk: I can't remember the whole story but I started with recv and then need read (but did not notice that the atom-plugin did not work anymore). gets() seems to be the solution.
|
59
|
+
## read and gets are blocking and recv is not
|
60
|
+
b=socket.gets("__[[END_TOKEN]]__")
|
61
|
+
#b=socket.read
|
62
|
+
#b=socket.recv(100000)
|
63
|
+
|
59
64
|
##p [:b,b]
|
60
65
|
data=b.to_s.strip
|
61
66
|
##p [:data,data]
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'tilt' #this allows the use of any other template
|
2
|
+
require 'tilt/template' #for creating the dyndoc one
|
3
|
+
require 'redcloth'
|
4
|
+
|
5
|
+
## This version relies on dyn-srv!
|
6
|
+
|
7
|
+
|
8
|
+
module Tilt
|
9
|
+
|
10
|
+
class DynCliTemplate < Template
|
11
|
+
|
12
|
+
attr_reader :content
|
13
|
+
|
14
|
+
@@end_token="__[[END_TOKEN]]__"
|
15
|
+
|
16
|
+
def DynCliTemplate.init(libs=nil)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
## reinit is an array
|
21
|
+
def send_dyndoc(code)
|
22
|
+
|
23
|
+
addr,port="127.0.0.1",7777
|
24
|
+
|
25
|
+
|
26
|
+
#p [:addr,@addr]
|
27
|
+
Socket.tcp(addr, port) {|sock|
|
28
|
+
msg='__send_cmd__[['+@dyndoc_cmd+']]__' + code + @@end_token
|
29
|
+
#p msg
|
30
|
+
sock.print msg
|
31
|
+
#sleep 1
|
32
|
+
sock.close_write
|
33
|
+
@result=sock.read
|
34
|
+
}
|
35
|
+
|
36
|
+
data=@result.split(@@end_token,-1)
|
37
|
+
last=data.pop
|
38
|
+
resCmd=decode_cmd(data.join(""))
|
39
|
+
##p [:resCmd,resCmd]
|
40
|
+
if resCmd and resCmd[:cmd] != "windows_platform"
|
41
|
+
@content=resCmd[:content]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def decode_cmd(res)
|
46
|
+
if res =~ /^__send_cmd__\[\[([a-zA-Z0-9_]*)\]\]__([\s\S]*)/m
|
47
|
+
return {cmd: $1, content: $2}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.engine_initialized?
|
52
|
+
defined? ::DynDoc
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize_engine
|
56
|
+
DynCliTemplate.init
|
57
|
+
end
|
58
|
+
|
59
|
+
def prepare; end
|
60
|
+
|
61
|
+
|
62
|
+
def prepare_output
|
63
|
+
send_dyndoc(data)
|
64
|
+
return @content
|
65
|
+
end
|
66
|
+
|
67
|
+
def evaluate(scope, locals, &block)
|
68
|
+
if locals.keys.include? :reinit and locals[:reinit]
|
69
|
+
## The layout needs to be reintailized for new dyndoc file but not for the layout (of course)!
|
70
|
+
@dyndoc_cmd="dyndoc"
|
71
|
+
@dyndoc_cmd += "_with_tag_tmpl" if locals[:reinit].include? :dyndoc_tag_tmpl
|
72
|
+
@dyndoc_cmd += "_with_libs_reinit" if locals[:reinit].include? :dyndoc_libs
|
73
|
+
@dyndoc_cmd += "_with_layout_reinit" if locals[:reinit].include? :dyndoc_layout
|
74
|
+
locals.delete :reinit
|
75
|
+
end
|
76
|
+
|
77
|
+
@output=prepare_output
|
78
|
+
#puts @output
|
79
|
+
#@output
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
Tilt.register Tilt::DynCliTemplate, '_html.dyn'
|
88
|
+
#puts "dyn registered in tilt!"
|
@@ -0,0 +1 @@
|
|
1
|
+
default
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
6
|
+
[#=]::layout.title?[Dyndoc Project]
|
7
|
+
[#>]
|
8
|
+
<title>#{layout.title}</title>
|
9
|
+
{#LayoutHeader#}
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
#{body.content}
|
14
|
+
|
15
|
+
{#LayoutPostJS#}
|
16
|
+
</body>
|
17
|
+
</html>
|
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.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CQLS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: R4rb
|
@@ -100,7 +100,10 @@ files:
|
|
100
100
|
- bin/dyn-forever
|
101
101
|
- bin/dyn-init
|
102
102
|
- bin/dyn-srv
|
103
|
+
- lib/dyndoc-convert.rb
|
104
|
+
- lib/dyndoc/cli/interactive-client.rb
|
103
105
|
- lib/dyndoc/srv/interactive-server.rb
|
106
|
+
- lib/dyndoc/srv/tilt.rb
|
104
107
|
- share/demo/first.dyn
|
105
108
|
- share/demo/firstAsciidoc.dyn
|
106
109
|
- share/demo/second.dyn
|
@@ -111,6 +114,8 @@ files:
|
|
111
114
|
- share/demo/testBeamer_lib.dyn
|
112
115
|
- share/demo/test_atom.dyn
|
113
116
|
- share/etc/alias
|
117
|
+
- share/etc/dyn-cli/dyn_layout
|
118
|
+
- share/etc/dyn-cli/layout/default.dyn
|
114
119
|
- share/etc/dyndoc_library_path
|
115
120
|
- share/etc/helpers
|
116
121
|
- share/etc/uv/render/README
|