dyndoc-ruby 0.7.7 → 0.8.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/lib/dyndoc-convert.rb +34 -18
- 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: 6dfa98b7f4b1e4e0f2e24a0e1a14f0c606652c70
|
4
|
+
data.tar.gz: db99310de0352bed9ede3996f38507afae4e9b06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61d509f0b744936f553afafcd46c57d6c6f61fdabdae4859d81c3ecf1af8328e4dd4ee77abf182a67aa349c722f3293b68180a857ad966d057e40d0b2c43a1dc
|
7
|
+
data.tar.gz: 2959605938ad254875a139fb6d4d697e4e5b5040efa73ca55902d2d495b01d6a2f4c48f677951e5cf20a3fbb91494402d852ad8f99b83f4211a41eaab7c761c5
|
data/lib/dyndoc-convert.rb
CHANGED
@@ -40,25 +40,25 @@ module Dyndoc
|
|
40
40
|
end
|
41
41
|
|
42
42
|
## TODO: a config.yml file for the site
|
43
|
-
def Dyndoc.cli_convert_from_file(dyn_file,html_file,
|
43
|
+
def Dyndoc.cli_convert_from_file(dyn_file,html_file,opts={}) #ex: opts={dyn_root: , html_root:, user: , doc_tag: }
|
44
44
|
addr="127.0.0.1"
|
45
45
|
|
46
|
-
return unless
|
46
|
+
return unless opts[:dyn_root]
|
47
47
|
|
48
48
|
dyn_libs,dyn_tags=nil,nil
|
49
49
|
|
50
|
-
## requirement: dyn_file is provided relatively to the
|
50
|
+
## requirement: dyn_file is provided relatively to the opts[:dyn_root] (for security reason too)
|
51
51
|
|
52
52
|
dyn_path=dyn_file.split(File::Separator)
|
53
53
|
|
54
|
-
dyn_file=File.join(
|
54
|
+
dyn_file=File.join(opts[:dyn_root],dyn_file) unless dyn_file[0]=="/"
|
55
55
|
|
56
56
|
if i=(dyn_file =~ /\_?(?:html)?\.dyn$/)
|
57
57
|
|
58
58
|
cfg={}
|
59
59
|
## find the previous config.yml in the tree folder
|
60
60
|
## TODO: read all previous config.yml and merge them from root to current
|
61
|
-
cfg_yml_files=dyn_path.inject([""]) {|res,e| res + [(res[-1,1]+[e]).flatten]}.map{|pa| File.join(
|
61
|
+
cfg_yml_files=dyn_path.inject([""]) {|res,e| res + [(res[-1,1]+[e]).flatten]}.map{|pa| File.join(opts[:dyn_root],pa,"config.yml")}.reverse
|
62
62
|
cfg_yml_file=cfg_yml_files.select{|c| File.exists? c}[0]
|
63
63
|
cfg=YAML::load_file(cfg_yml_file) if cfg_yml_file
|
64
64
|
|
@@ -83,22 +83,22 @@ module Dyndoc
|
|
83
83
|
page=nil
|
84
84
|
|
85
85
|
if code =~ /^\-{3}/
|
86
|
-
b=code.split(
|
87
|
-
if b[0].empty?
|
86
|
+
b=code.split(/^(\-{3,})/,-1)
|
87
|
+
if b[0].empty? and b.length>4
|
88
88
|
require 'yaml'
|
89
|
-
page=YAML.load(b[
|
89
|
+
page=YAML.load(b[2])
|
90
90
|
cfg.merge!(page)
|
91
|
-
code=b[
|
91
|
+
code=b[4..-1].join("")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
# dyn_root can be overwritten by cfg
|
96
|
-
dyn_root= cfg["dyn_root"] ||
|
97
|
-
html_root= cfg["html_root"] ||
|
96
|
+
dyn_root= cfg["dyn_root"] || opts[:dyn_root] || File.expand_path("..",dyn_file)
|
97
|
+
html_root= cfg["html_root"] || opts[:html_root] || File.expand_path("..",dyn_file)
|
98
98
|
|
99
99
|
if cfg["layout"]
|
100
100
|
if cfg["layout"][0] == "%" #user mode
|
101
|
-
cfg_tmp=File.join(
|
101
|
+
cfg_tmp=File.join(opts[:dyn_root],'users',opts[:user],cfg["layout"][1..-1])
|
102
102
|
else
|
103
103
|
cfg_tmp=File.join(dyn_root,cfg["layout"][0] == "/" ? cfg["layout"][1..-1] : ["layout",cfg["layout"]])
|
104
104
|
end
|
@@ -106,7 +106,7 @@ module Dyndoc
|
|
106
106
|
end
|
107
107
|
if cfg["pre"]
|
108
108
|
if cfg["pre"][0] == "%" #user mode
|
109
|
-
cfg_tmp=File.join(
|
109
|
+
cfg_tmp=File.join(opts[:dyn_root],'users',opts[:user],cfg["pre"][1..-1])
|
110
110
|
else
|
111
111
|
#cfg_tmp=File.join(dyn_root,cfg["pre"])
|
112
112
|
cfg_tmp=File.join(dyn_root,cfg["pre"][0] == "/" ? cfg["pre"][1..-1] : ["preload",cfg["pre"]])
|
@@ -116,7 +116,7 @@ module Dyndoc
|
|
116
116
|
|
117
117
|
if cfg["post"]
|
118
118
|
if cfg["post"][0] == "%" #user mode
|
119
|
-
cfg_tmp=File.join(
|
119
|
+
cfg_tmp=File.join(opts[:dyn_root],'users',opts[:user],cfg["post"][1..-1])
|
120
120
|
else
|
121
121
|
#cfg_tmp=File.join(dyn_root,cfg["post"])
|
122
122
|
cfg_tmp=File.join(dyn_root,cfg["post"][0] == "/" ? cfg["post"][1..-1] : ["postload",cfg["post"]])
|
@@ -124,8 +124,6 @@ module Dyndoc
|
|
124
124
|
dyn_post_code=File.read(cfg_tmp) unless dyn_post_code and File.exist? cfg_tmp
|
125
125
|
end
|
126
126
|
|
127
|
-
|
128
|
-
|
129
127
|
## deal with html_file
|
130
128
|
html_file=File.join(html_root,cfg["html_file"] || html_file)
|
131
129
|
unless File.exist? html_file
|
@@ -136,7 +134,14 @@ module Dyndoc
|
|
136
134
|
|
137
135
|
dyn_libs=cfg["libs"].strip if cfg["libs"]
|
138
136
|
|
139
|
-
|
137
|
+
## mode multi-documents
|
138
|
+
docs_tags=[]
|
139
|
+
docs_tags << opts[:doc_tag] if opts[:doc_tag]
|
140
|
+
## complete docs_tags with cfg["tags"]
|
141
|
+
docs_tags += (cfg["tags"]||"").split(",").map{|e| e.strip}
|
142
|
+
dyn_tags="[#<]{#opt]"+docs_tags.join(",")+"[#opt}[#>]" unless docs_tags.empty?
|
143
|
+
|
144
|
+
Dyndoc.warn :dyn_tags,[docs_tags,dyn_tags]
|
140
145
|
|
141
146
|
if dyn_libs or dyn_pre_code
|
142
147
|
code_pre = ""
|
@@ -149,7 +154,18 @@ module Dyndoc
|
|
149
154
|
code = "[#rb<]require 'ostruct';cfg = OpenStruct.new(" + cfg.inspect + ")[#>]" +code
|
150
155
|
code = "[#rb<]page = " + page.inspect + "[#>]" +code if page
|
151
156
|
code = dyn_tags + code if dyn_tags
|
152
|
-
|
157
|
+
|
158
|
+
## add path for user
|
159
|
+
code_path = "[#path]"+File.join(opts[:dyn_root],'users',opts[:user],"dynlib")
|
160
|
+
code_path << "\n" << File.join(opts[:dyn_root],'users',opts[:user])
|
161
|
+
code_path << "\n" << opts[:dyn_root] << "\n"
|
162
|
+
code_path << "[#main][#<]\n"
|
163
|
+
code = code_path + code
|
164
|
+
|
165
|
+
###
|
166
|
+
Dyndoc.warn :code,code
|
167
|
+
|
168
|
+
dyndoc_start=[:dyndoc_libs,:dyndoc_layout]
|
153
169
|
|
154
170
|
cli=Dyndoc::InteractiveClient.new(code,dyn_file,addr,dyndoc_start)
|
155
171
|
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CQLS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: R4rb
|