dyndoc-ruby 0.7.2 → 0.7.3
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/lib/dyndoc-convert.rb +63 -41
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfadfdc5ff9a771cb8bd843a041c96b8f1c33c0e
|
4
|
+
data.tar.gz: 1561fe45892386f94e8838b7686e853dd8629c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b19568d4e4d4ce2d1133aecea4fbac4c23031a20b9559ad97de7efc2e86cd610fa1f21bbb53140019ed5d78232e313ae28e6958d43a2b68f5d2038f7b361323
|
7
|
+
data.tar.gz: 75358580ac47c8815cb15043be4b39500de588c7e63bcf8b4be4f8a61804819616c6ae8cccb1d2dc6ec14baf1156a0923459d2be8398bf0564e5c7c44740832a
|
data/lib/dyndoc-convert.rb
CHANGED
@@ -38,7 +38,8 @@ module Dyndoc
|
|
38
38
|
return cli.content
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
## TODO: a config.yml file for the site
|
42
|
+
def Dyndoc.cli_convert_from_file(dyn_file,html_file,root={}) #ex: root={dyn: , html: }
|
42
43
|
addr="127.0.0.1"
|
43
44
|
|
44
45
|
dyn_libs,dyn_tags=nil,nil
|
@@ -54,59 +55,80 @@ module Dyndoc
|
|
54
55
|
## Dyn post
|
55
56
|
dyn_post_code=File.read(dyn_file[0...i]+"_post.dyn") if File.exist? dyn_file[0...i]+"_post.dyn"
|
56
57
|
|
58
|
+
cfg={}
|
59
|
+
|
57
60
|
if File.exist? dyn_file[0...i]+".dyn_cfg"
|
58
61
|
require 'yaml'
|
59
62
|
cfg=YAML::load_file(dyn_file[0...i]+".dyn_cfg")
|
63
|
+
end
|
60
64
|
|
61
|
-
|
65
|
+
## code to evaluate
|
66
|
+
code=File.read(dyn_file)
|
62
67
|
|
63
|
-
|
64
|
-
cfg_tmp=File.join(dyn_root,cfg["layout"])
|
65
|
-
dyn_layout=cfg_tmp if !dyn_layout and File.exist? cfg_tmp
|
66
|
-
end
|
67
|
-
if cfg["pre"]
|
68
|
-
cfg_tmp=File.join(dyn_root,cfg["pre"])
|
69
|
-
dyn_pre_code=File.read(cfg_tmp) unless dyn_pre_code and File.exist? cfg_tmp
|
70
|
-
end
|
68
|
+
page=nil
|
71
69
|
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
if code =~ /^\-{3}/
|
71
|
+
b=code.split(/^\-{3}/)
|
72
|
+
if b[0].empty?
|
73
|
+
require 'yaml'
|
74
|
+
page=YAML.load(b[1])
|
75
|
+
cfg.merge!(page)
|
76
|
+
code=b[2..-1].join("---")
|
75
77
|
end
|
78
|
+
end
|
76
79
|
|
77
|
-
|
80
|
+
# dyn_root can be overwritten by cfg
|
81
|
+
dyn_root= cfg["dyn_root"] || root[:dyn] || File.expand_path("..",dyn_file)
|
82
|
+
html_root= cfg["html_root"] || root[:html] || File.expand_path("..",dyn_file)
|
78
83
|
|
79
|
-
|
84
|
+
if cfg["layout"]
|
85
|
+
cfg_tmp=File.join(dyn_root,cfg["layout"])
|
86
|
+
dyn_layout=cfg_tmp if !dyn_layout and File.exist? cfg_tmp
|
87
|
+
end
|
88
|
+
if cfg["pre"]
|
89
|
+
cfg_tmp=File.join(dyn_root,cfg["pre"])
|
90
|
+
dyn_pre_code=File.read(cfg_tmp) unless dyn_pre_code and File.exist? cfg_tmp
|
80
91
|
end
|
81
92
|
|
82
|
-
|
93
|
+
if cfg["post"]
|
94
|
+
cfg_tmp=File.join(dyn_root,cfg["post"])
|
95
|
+
dyn_post_code=File.read(cfg_tmp) unless dyn_post_code and File.exist? cfg_tmp
|
96
|
+
end
|
83
97
|
|
98
|
+
if cfg["html_file"] #relative path from (dyn_)root
|
99
|
+
html_file=File.join(html_root,cfg["html_file"])
|
100
|
+
end
|
84
101
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
102
|
+
dyn_libs=cfg["libs"].strip if cfg["libs"]
|
103
|
+
|
104
|
+
dyn_tags="[#<]{#opt]"+cfg["tags"].strip+"[#opt}" if cfg["tags"]
|
105
|
+
|
106
|
+
if dyn_libs or dyn_pre_code
|
107
|
+
code_pre = ""
|
108
|
+
code_pre += dyn_pre_code + "\n" if dyn_pre_code
|
109
|
+
code_pre += '[#require]'+"\n"+dyn_libs if dyn_libs
|
110
|
+
code = code_pre + '[#main][#>]' + code
|
111
|
+
end
|
112
|
+
code += "\n" + dyn_post_code if dyn_post_code
|
113
|
+
## TO TEST!!!
|
114
|
+
code = dyn_tags + code if dyn_tags
|
115
|
+
code = "[#rb<]page = " + page.inspect + "[#>]" +code if page
|
116
|
+
dyndoc_start=[:dyndoc_libs,:dyndoc_layout]
|
117
|
+
|
118
|
+
cli=Dyndoc::InteractiveClient.new(code,dyn_file,addr,dyndoc_start)
|
119
|
+
|
120
|
+
if dyn_layout
|
121
|
+
cli=Dyndoc::InteractiveClient.new(File.read(dyn_layout),"",addr) #File.expand_path(dyn_layout),addr)
|
122
|
+
end
|
123
|
+
|
124
|
+
if html_file and Dir.exist? File.dirname(html_file)
|
125
|
+
File.open(html_file,"w") do |f|
|
126
|
+
f << cli.content
|
127
|
+
end
|
128
|
+
else
|
129
|
+
puts cli.content
|
130
|
+
end
|
131
|
+
end
|
110
132
|
end
|
111
133
|
|
112
134
|
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.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CQLS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: R4rb
|