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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dyndoc-convert.rb +34 -18
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c735f02d2467683edb8b01726297f83ec532a335
4
- data.tar.gz: 2d91e69c41b210872b082a7471dfed2f7de77b5a
3
+ metadata.gz: 6dfa98b7f4b1e4e0f2e24a0e1a14f0c606652c70
4
+ data.tar.gz: db99310de0352bed9ede3996f38507afae4e9b06
5
5
  SHA512:
6
- metadata.gz: ca1178d1207decf26e2ce351f05c54f9a34f05915c92d9b3c685598c8c1b66b3cadaa18f1254ce3aa33b1204ae4a90023afebb4d75e3c8581ec1e686a6de631f
7
- data.tar.gz: daa9d46c3a45f878a1d2e6495abb8dae57482f90dd5e26921bbf8f9c886b3c853160cd8bda26d0af4749371d824cfd310f4fff1915a7afd3a7829e2c459a278d
6
+ metadata.gz: 61d509f0b744936f553afafcd46c57d6c6f61fdabdae4859d81c3ecf1af8328e4dd4ee77abf182a67aa349c722f3293b68180a857ad966d057e40d0b2c43a1dc
7
+ data.tar.gz: 2959605938ad254875a139fb6d4d697e4e5b5040efa73ca55902d2d495b01d6a2f4c48f677951e5cf20a3fbb91494402d852ad8f99b83f4211a41eaab7c761c5
@@ -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,root={}) #ex: root={dyn: , html: }
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 root[:dyn]
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 root[:dyn] (for security reason too)
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(root[:dyn],dyn_file) unless dyn_file[0]=="/"
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(root[:dyn],pa,"config.yml")}.reverse
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(/^\-{3}/)
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[1])
89
+ page=YAML.load(b[2])
90
90
  cfg.merge!(page)
91
- code=b[2..-1].join("---")
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"] || root[:dyn] || File.expand_path("..",dyn_file)
97
- html_root= cfg["html_root"] || root[:html] || File.expand_path("..",dyn_file)
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(root[:dyn],'users',root[:user],cfg["layout"][1..-1])
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(root[:dyn],'users',root[:user],cfg["pre"][1..-1])
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(root[:dyn],'users',root[:user],cfg["post"][1..-1])
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
- dyn_tags="[#<]{#opt]"+cfg["tags"].strip+"[#opt}[#>]" if cfg["tags"]
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
- dyndoc_start=[:dyndoc_libs,:dyndoc_layout]
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.7.7
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-27 00:00:00.000000000 Z
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: R4rb