dyndoc-ruby-core 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d61c9814fbee12e7690e969be05be1508045df8a
4
- data.tar.gz: 894618eac5de35bb862ae6156ade8203da680907
3
+ metadata.gz: 19c3a0bb1d282d76f63c957e6700a3fd46156475
4
+ data.tar.gz: 051d7200700504fd0ee87a228fb1a7f09cc8b5cd
5
5
  SHA512:
6
- metadata.gz: 754c502ef583d5da3e567ba0b64824e4cd3fff6a3b84ecca326ed562405495755df4ea2482d1001993d0e66cf7cd6415c469bbd9879ff2fe35520207c23900d3
7
- data.tar.gz: 6783f7f70b01b0ed79ac6e1e65fca16fb92ba0ac6f2cc08fdc6e135f891e77e42be7085b8f94a438c786af1757996a981d588095b96046f0f36a849d4b436c0f
6
+ metadata.gz: ea70a95998f2df4846135b2e2471332384e19fda6cfb88bfda5904b9e053dcde65173ce73eb277a556d2fe5cae89d19e9ebf761e07da271af73f38ea2e119f80
7
+ data.tar.gz: 78eadace07933caa6fe65fecef6c1b8f2130c3a3ec838cbf012e9622d782cf8e4ddcf61d180750ba2bb996727a7b8d48d57b3261aaf0cf825ee03a2bd9f23863
@@ -47,13 +47,19 @@ require 'dyndoc/common/uv'
47
47
  syntax=File.join(Uv.syntax_path,syntax+".syntax")
48
48
  #end
49
49
  uv_code = (#{=file}.empty? ? nil : File.read(#{=file}))
50
- uv_code=((!(#{=code}.empty?) or #{=key}.empty?) ? #{=code} : CqlsDoc::Utils.dyndoc_raw_text(#{=key})).strip unless uv_code
50
+ uv_code=((!(#{=code}.empty?) or #{=key}.empty?) ? #{=code} : Dyndoc::Utils.dyndoc_raw_text(#{=key})).strip unless uv_code
51
+ uv_code = Dyndoc::Utils.unprotect_dyn_block_for_atom(uv_code) if Dyndoc::Ruby::TemplateManager.interactive
51
52
  #Dyndoc.warn "CODE",uv_code,#{lines}
52
53
  #Uv.parse(uv_code, "xhtml", syntax , #{lines}, render,true)
53
54
  #OLD: uv_res=CqlsDoc::AS_IS+Uv.parse(uv_code, "xhtml", #{=syntax}.downcase, true, #{=render})+CqlsDoc::AS_IS
54
55
  #Dyndoc.warn "titi"
56
+ warn_level = $VERBOSE
57
+ $VERBOSE = nil
55
58
  uv_res=Uv.parse(uv_code, "xhtml", syntax , #{lines}, render,false)
56
- uv_res = CqlsDoc::AS_IS+uv_res+CqlsDoc::AS_IS unless CqlsDoc::V3::TemplateManager.interactive
59
+ $VERBOSE = warn_level
60
+ ## TODO: trouble with interactive????
61
+ uv_res = Dyndoc::Utils.protect_dyn_block_for_atom(uv_res) if Dyndoc::Ruby::TemplateManager.interactive
62
+ uv_res = Dyndoc::AS_IS+uv_res+Dyndoc::AS_IS unless Dyndoc::Ruby::TemplateManager.interactive
57
63
  #Dyndoc.warn "titi"
58
64
  #Dyndoc.warn "uv_res:", uv_res
59
65
  [#>][:{uv_res}<\n>]
@@ -62,7 +68,7 @@ uv_res = CqlsDoc::AS_IS+uv_res+CqlsDoc::AS_IS unless CqlsDoc::V3::TemplateManage
62
68
  [#def}
63
69
 
64
70
  {#def]rverbUV[#,]code[][#,]render[amy][#,]lines[false]
65
- [#?]CqlsDoc::V3::TemplateManager.interactive
71
+ [#?]Dyndoc::Ruby::TemplateManager.interactive
66
72
  [#>]{#rverb]#{code}[#mode]raw[#rverb}
67
73
  [#?]else
68
74
  [#>]{#uv]{#rverb]#{code}[#mode]raw[#rverb}
@@ -88,11 +94,11 @@ function update_#{.ObjectName}_Switcher(choice) {
88
94
  var choices="#{.choices}".split(",");
89
95
  for(i in choices) {
90
96
  //alert("lang="+langs[l]);
91
- if(choices[i]==choice) {
97
+ if(choices[i]==choice) {
92
98
  $("[choice="+choices[i]+"]").show();
93
99
  } else {
94
100
  $("[choice="+choices[i]+"]").hide();
95
- }
101
+ }
96
102
  }
97
103
  };
98
104
  </script>
@@ -112,7 +118,7 @@ function update_#{.ObjectName}_Switcher(choice) {
112
118
  lang=#{=.lang}.split(",")
113
119
  lang2=lang.reverse
114
120
  [0,1].each {|i| #
115
- {#>]<div lang=":{lang[i]}"><img alt=":{lang2[i]}" src="#{document.rsrcSrvUrl?}/images/common/:{lang2[i]}.gif" langSwitcher=":{lang2[i]}"/></div>[#>}
121
+ {#>]<div lang=":{lang[i]}"><img alt=":{lang2[i]}" src="#{document.rsrcSrvUrl?}/images/common/:{lang2[i]}.gif" langSwitcher=":{lang2[i]}"/></div>[#>}
116
122
  }
117
123
  [#meth}
118
124
 
@@ -126,11 +132,11 @@ function updateLanguage(lang) {
126
132
  var langs="#{.lang}".split(",");
127
133
  for(l in langs) {
128
134
  //alert("lang="+langs[l]);
129
- if(langs[l]==lang) {
135
+ if(langs[l]==lang) {
130
136
  $("[lang="+langs[l]+"]").show();
131
137
  } else {
132
138
  $("[lang="+langs[l]+"]").hide();
133
- }
139
+ }
134
140
  }
135
141
  $.cookie("langSwitcher",lang)
136
142
  };
@@ -157,12 +163,12 @@ $(document).ready(function() {
157
163
  [#def}
158
164
 
159
165
  {#new]JQuerySwitchable[#of]JsLoader[#code]
160
- function showSwitched(type,key) {
166
+ function showSwitched(type,key) {
161
167
  $('.switchable[id="'+type+'"][switch="'+key+'"]').show();
162
168
  $('.switchable[id="'+type+'"][switch!="'+key+'"]').hide();
163
169
  };
164
170
 
165
- function activateSwitchedLink(type,key) {
171
+ function activateSwitchedLink(type,key) {
166
172
  $('a[id="'+type+'"][switch="'+key+'"]').toggleClass("active",true);
167
173
  $('a[id="'+type+'"][switch!="'+key+'"]').toggleClass("active",false);
168
174
 
@@ -201,7 +207,7 @@ function selectSwitchedPage(type,key) {
201
207
  end
202
208
  end
203
209
  [#rb<]Dyndoc.warn "AAAA: mainMenu" "mainMenu",#{=mainMenu};Dyndoc.warn "ZZZZZ: mainPages",#{=mainPages}
204
- [#=]::document.mainMenu[<div id="mainMenu">
210
+ [#=]::document.mainMenu[<div id="mainMenu">
205
211
  <span class="lastMenuItem"></span><\n>#{mainMenu}<\n></div>]
206
212
  [#=]::document.mainPages[<div id="mainPages"><\n>#{mainPages}<\n></div>]
207
213
  [#}
@@ -215,7 +221,7 @@ end
215
221
  [#blck]:post
216
222
  [#=]subMenu[]
217
223
  [#=]subPages[]
218
- [#rb<]subMenu=@vars[blckName[-1]][:subMenu]
224
+ [#rb<]subMenu=@vars[blckName[-1]][:subMenu]
219
225
  Dyndoc.warn "blckName[-1]", @vars[blckName[-1]]
220
226
  subMenu.each_with_index do |menu,i| #
221
227
  {#<][#+]subMenu[<li class="here"><a id="subPage" switch=":{menu[:link]}" {#if]!menu[:subpage][#>]href=":{menu[:link]}"[#}{#if]i==@vars[blckName[-1]][:active][#>] class="select"[#if} {#if]menu[:subpage][#>]onclick='selectSwitchedPage("subPage",":{menu[:link]}");'[#}>:{menu[:title]}</a></li> <\n>][#<}
@@ -283,4 +289,4 @@ $(document).ready(function() {
283
289
  [#?]#{0?en}[#=]en[#{fr}][#?]end
284
290
  [#>]
285
291
  [<a id="mainPage" switch="#{link}" onclick='selectSwitchedPage("mainPage","#{link}");'>{#fr]#{fr}[#en]#{en}[#}</a>]
286
- [#}
292
+ [#}
@@ -593,7 +593,8 @@ p [vars,b2]
593
593
  if @fmtContainer[1] and @fmtContainer[1]==@fmtContainer[0] #no need to convert!
594
594
  tex << val
595
595
  else #convert
596
- ## Dyndoc.warn "txtl formats",[@fmtContainer[0],@fmtOutput,@fmtContainer[1]]
596
+ ##Dyndoc.warn "txtl formats",[@fmtContainer[0],@fmtOutput,@fmtContainer[1]]
597
+ ##Dyndoc.warn :val, val
597
598
  tex << Dyndoc::Converter.convert(val,@fmtContainer[0],@fmtOutput,@fmtContainer[1]) #last parameter: true means to protect
598
599
  end
599
600
  @curFmtContainer=@fmtContainer[0] unless @curFmtContainer
@@ -958,11 +959,12 @@ p [vars,b2]
958
959
  Utils.escape_delim!(code)
959
960
  #puts "do_eval2: code";p code
960
961
  mode=[]
961
- while code=~/^(test|pre|last|raw)\|.*/
962
+ while code=~/^(atom|test|pre|last|raw)\|.*/
962
963
  code = code[($1.length+1)..-1]
963
964
  mode << $1.to_sym
964
965
  end
965
966
  code=Dyndoc::Utils.dyndoc_raw_text(code) if mode.include? :test
967
+ code=Dyndoc::Utils.unprotect_dyn_block_for_atom(code) if mode.include? :atom
966
968
  #puts "do_eval:mode";p mode;p code
967
969
  #PUT THE FOLLOWING IN THE DOCUMENTATION:
968
970
  #puts "WARNING: {#dyn] accept :last and :raw in this order!" unless (mode - [:last,:raw]).empty?
@@ -61,12 +61,12 @@ module Dyndoc
61
61
  def Utils.escape!(str,chars_set)
62
62
  chars_set.each{|chars| str.gsub!(/#{Regexp.escape(chars[0])}/,chars[1]) }
63
63
  end
64
-
64
+
65
65
  def Utils.escape_delim!(str,mode=:last)
66
66
  chars_set=(mode==:first ? CHARS_SET_FIRST : CHARS_SET_LAST )
67
67
  chars_set.each{|chars| str.gsub!(/#{Regexp.escape(chars[0])}/,chars[1]) }
68
68
  return str
69
- end
69
+ end
70
70
 
71
71
  def Utils.end_line(key,code)
72
72
  while key[-1,1]=="\\"
@@ -97,7 +97,7 @@ module Dyndoc
97
97
  #puts "unprotect blocktext";p str
98
98
  str.gsub(seq,"")
99
99
  end
100
-
100
+
101
101
  def Utils.format_blocktext(str)
102
102
  str.gsub(/\n[ \t\r\f]*\|/,"\n").gsub(/\|\n/,"").gsub("<\\n>","\n").gsub("<\\t>","\t")
103
103
  end
@@ -218,11 +218,11 @@ module Dyndoc
218
218
  #puts "parse_raw_text:key added";p key
219
219
  code << key if type==">"
220
220
  if tmplMngr
221
- ## puts inside global envir!
221
+ ## puts inside global envir!
222
222
  envir=tmplMngr.filterGlobal.envir
223
223
  envir[lang+"."+name+".name"]=key
224
224
  envir[lang+"."+name+".code"]=@@raw_text[-1]
225
- ## "content" would be the name of the result after evaluation and saved in <dyn_basename_file>.dyn_out/raw_code.dyn
225
+ ## "content" would be the name of the result after evaluation and saved in <dyn_basename_file>.dyn_out/raw_code.dyn
226
226
  end
227
227
  @@raw_var_ls << lang+"."+name #
228
228
  txt2.shift #last close tag!
@@ -235,14 +235,14 @@ module Dyndoc
235
235
  ##OLD: @@raw_key_index=@@raw_key.map{|key| key=~/\_\_(.*)\|(.*)/ ? $1 : nil}.compact
236
236
  ##puts "code";p code
237
237
  txt.replace(code)
238
-
238
+
239
239
  end
240
240
 
241
241
  def Utils.dyndoc_raw_var_ls
242
242
  @@raw_var_ls
243
243
  end
244
244
 
245
- def Utils.dyndoc_raw_var_eval(var,tmplMngr=nil) #var differs from key since it is saved in filter!
245
+ def Utils.dyndoc_raw_var_eval(var,tmplMngr=nil) #var differs from key since it is saved in filter!
246
246
  return "" unless tmplMngr
247
247
  #p var
248
248
  return ((@@raw_var_ls.include? var) ? tmplMngr.parse(tmplMngr.filterGlobal.envir[var+".code"]) : "" )
@@ -331,7 +331,7 @@ module Dyndoc
331
331
  def Utils.saved_content_get(var,tmplMngr=nil,force=nil)
332
332
  return unless tmplMngr
333
333
  if force
334
- return (Utils.saved_content_to_be_recreated(tmplMngr).include? var) ? nil : tmplMngr.filterGlobal.envir[var]
334
+ return (Utils.saved_content_to_be_recreated(tmplMngr).include? var) ? nil : tmplMngr.filterGlobal.envir[var]
335
335
  else
336
336
  return tmplMngr.filterGlobal.envir[var]
337
337
  end
@@ -339,7 +339,11 @@ module Dyndoc
339
339
 
340
340
  ## Added for atom
341
341
  def Utils.protect_dyn_block_for_atom(txt)
342
- txt.gsub("#","__DIESE_ATOM__") # => since dyndoc command uses "#" this is very easy way to protect evaluation
342
+ txt.gsub("#","<_DIESE_ATOM_>").gsub("@","<_AROBAS_ATOM_>").gsub(":","<_SEMICOLON_ATOM_>").gsub("|","<_BAR_ATOM_>").gsub("$>","<_RVAR_ATOM_>") # => since dyndoc command uses "#" this is very easy way to protect evaluation
343
+ end
344
+
345
+ def Utils.unprotect_dyn_block_for_atom(txt)
346
+ txt.gsub("<_DIESE_ATOM_>","#").gsub("<_AROBAS_ATOM_>","@").gsub("<_SEMICOLON_ATOM_>",":").gsub("<_BAR_ATOM_>","|").gsub("<_RVAR_ATOM_>","$>") # => since dyndoc command uses "#" this is very easy way to protect evaluation
343
347
  end
344
348
 
345
349
  def Utils.parse_dyn_block_for_interactive!(txt)
@@ -353,13 +357,13 @@ module Dyndoc
353
357
  if txt2[0]=="{#dyn>]" and txt2[1..-1].include? "[#dyn>}"
354
358
  start,tmp,stop=txt2.shift(3)
355
359
  ## protect the dyndoc code to delay the evaluation after unprotection (in javascript)
356
- code << Utils.protect_dyn_block_for_atom(tmp.inspect)
360
+ code << Utils.protect_dyn_block_for_atom(tmp) ##BIZARRE! .inspect)
357
361
  else
358
362
  code << txt2.shift
359
363
  end
360
364
  end
361
365
  code << txt2.join("") #the remaining code
362
- #Dyndoc.warn "atom",code
366
+ #Dyndoc.warn "atom",code
363
367
  txt.replace(code)
364
368
  end
365
369
 
@@ -1,20 +1,20 @@
1
1
  #cmd="a=1\n(a)\nfor i in 1:3\nprintln(i)\nend"
2
2
 
3
3
  # # Unused! See capture_julia
4
- # function capture_cmd(cmd::String)
5
- # add,cmd0=true,String[]
6
- # res=Any[] #Dict{String,Any}()
4
+ # function capture_cmd(cmd::AbstractString)
5
+ # add,cmd0=true,AbstractString[]
6
+ # res=Any[] #Dict{AbstractString,Any}()
7
7
  # for l=split(cmd,"\n")
8
8
  # #println("l => ",l)
9
- # push!(cmd0,l)
9
+ # push!(cmd0,l)
10
10
  # pcmd0=Base.parse_input_line(join(cmd0,"\n"))
11
11
  # #print(join(cmd0,"\n")*":");println(pcmd0)
12
12
  # add = typeof(pcmd0)==Expr && pcmd0.head == :continue
13
- # if !add
13
+ # if !add
14
14
  # #print("ici:")
15
15
  # #println(Base.eval(pcmd0))
16
- # push!(res,(join(cmd0,"\n"),eval(pcmd0)))
17
- # cmd0=String[]
16
+ # push!(res,(join(cmd0,"\n"),eval(pcmd0)))
17
+ # cmd0=AbstractString[]
18
18
  # end
19
19
  # #println(res)
20
20
  # end
@@ -37,7 +37,7 @@ end
37
37
 
38
38
  function get_stdout_iobuffer()
39
39
  #seek(DyndocSandbox.OUTPUT_STREAM, 0)
40
- #jl4rb_out =
40
+ #jl4rb_out =
41
41
  takebuf_string(DyndocSandbox.OUTPUT_STREAM)
42
42
  #truncate(DyndocSandbox.OUTPUT_STREAM, 0)
43
43
  #jl4rb_out
@@ -53,14 +53,14 @@ end
53
53
 
54
54
  # export weave
55
55
  # module DyndocSandbox
56
- # # Copied from Gadfly.jl/src/weave.jl
56
+ # # Copied from Gadfly.jl/src/weave.jl
57
57
  # # Replace OUTPUT_STREAM references so we can capture output.
58
58
  # OUTPUT_STREAM = IOString()
59
59
  # print(x) = Base.print(OUTPUT_STREAM, x)
60
60
  # println(x) = Base.println(OUTPUT_STREAM, x)
61
61
 
62
62
  # function eval(expr)
63
- # result = try
63
+ # result = try
64
64
  # Base.eval(DyndocSandbox, expr)
65
65
  # seek(DyndocSandbox.OUTPUT_STREAM, 0)
66
66
  # output = takebuf_string(DyndocSandbox.OUTPUT_STREAM)
@@ -78,21 +78,21 @@ end
78
78
  # end
79
79
  # end
80
80
 
81
- function capture_julia(cmd::String)
82
- add,cmd0=true,String[]
83
- res=Any[] #Dict{String,Any}()
81
+ function capture_julia(cmd::AbstractString)
82
+ add,cmd0=true,AbstractString[]
83
+ res=Any[] #Dict{AbstractString,Any}()
84
84
  #println(cmd)
85
85
  for l=split(cmd,"\n")
86
86
  #println("l => ",l)
87
- push!(cmd0,l)
87
+ push!(cmd0,l)
88
88
  pcmd0=Base.parse_input_line(join(cmd0,"\n"))
89
89
  #print(join(cmd0,"\n")*":");println(pcmd0)
90
90
  add = typeof(pcmd0)==Expr && pcmd0.head == :incomplete
91
- if !add
91
+ if !add
92
92
  #print("ici:")
93
93
  #println(Base.eval(pcmd0))
94
- result,error = "",""
95
- try
94
+ result,error = "",""
95
+ try
96
96
  result=eval(DyndocSandbox, pcmd0)
97
97
  catch e
98
98
  #io = IOBuffer()
@@ -101,10 +101,10 @@ function capture_julia(cmd::String)
101
101
  error = "Error: $(string(e))"
102
102
  #close(io)
103
103
  end
104
- push!(res,(join(cmd0,"\n"),string(result),get_stdout_iobuffer(),error,get_stderr_iobuffer()))
105
- cmd0=String[]
104
+ push!(res,(join(cmd0,"\n"),string(result),get_stdout_iobuffer(),error,get_stderr_iobuffer()))
105
+ cmd0=AbstractString[]
106
106
  end
107
107
  #println(res)
108
108
  end
109
109
  res
110
- end
110
+ end
@@ -2,27 +2,30 @@
2
2
 
3
3
  module Ruby
4
4
 
5
- librb=dlopen("libruby")
5
+ if "JULIA_RUBYLIB_PATH" in keys(ENV)
6
+ push!(Libdl.DL_LOAD_PATH, ENV["JULIA_RUBYLIB_PATH"])
7
+ end
8
+ librb=Libdl.dlopen("libruby")
6
9
 
7
10
  export start,stop,run,alive
8
11
 
9
12
  global ruby_alive=false
10
13
 
11
14
  function start()
12
- ccall(dlsym(librb,:ruby_init),Void,())
13
- ccall(dlsym(librb,:ruby_init_loadpath),Void,())
15
+ ccall(Libdl.dlsym(librb,:ruby_init),Void,())
16
+ ccall(Libdl.dlsym(librb,:ruby_init_loadpath),Void,())
14
17
  ruby_alive=true
15
18
  end
16
19
 
17
20
  function stop()
18
- ccall(dlsym(librb,:ruby_finalize),Void,())
21
+ ccall(Libdl.dlsym(librb,:ruby_finalize),Void,())
19
22
  ruby_alive=false
20
23
  end
21
24
 
22
- function run(code::String)
25
+ function run(code::AbstractString)
23
26
  state=1 #not modified then
24
27
  ##println(code)
25
- res=ccall(dlsym(librb,:rb_eval_string_protect),Ptr{Uint64},(Ptr{Uint8},Ptr{Uint32}),bytestring(code),&state)
28
+ res=ccall(Libdl.dlsym(librb,:rb_eval_string_protect),Ptr{UInt64},(Ptr{UInt8},Ptr{UInt32}),bytestring(code),&state)
26
29
  return nothing
27
30
  end
28
31
 
@@ -34,4 +37,4 @@ module Ruby
34
37
  ruby_alive
35
38
  end
36
39
 
37
- end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyndoc-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.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-06-16 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: configliere