dyndoc-ruby-exec 0.1.2 → 0.2.0

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: 25ca855899830fe149198371631c1ad6799ef6ba
4
- data.tar.gz: 95706e8408ab156182d91746f27c78e76c45ff34
3
+ metadata.gz: 3e595ec0591bedf58982901cf0301a6f4fee71be
4
+ data.tar.gz: 3bf4118abc7965fd1f598803cc386524a0f9f806
5
5
  SHA512:
6
- metadata.gz: 6e4631cec87f6d8d75fa1cd9997b326d02f09ae484e557ef23dad683398b8566d633bf4d8621ceb8f152101222d1e17e785e891d2a6a78c06f7ccc0b916db6e9
7
- data.tar.gz: 88a016c2b62cca4f69865e31789d8585be91de3b42f0dedab2c0846a9738fb2d624026a8919e807496ab04ae1aaa25da9e71cdf8632b8dcb15133c2209d039e5
6
+ metadata.gz: 838bc2ec316476d7af324d66cc4303316ada49037596048ec4fa0417209ef5af7605041ecd85bb49eb283c265d41a24bc537a99335cc22b34e6cf2a0cfc0a79f
7
+ data.tar.gz: c82b94759686b33528315e61aaa7d2855aa83f6b885e70ee3f31da501be6d7cfa91c7a5d3db06e9ad3f3cde37c786efe6adb05b26a875756526853295eb6ca68
@@ -54,8 +54,7 @@ module Dyndoc
54
54
  end
55
55
  end
56
56
 
57
- def Converter.pandoc(input,opt='')
58
- output = ''
57
+ def Converter.pandoc_available?
59
58
  unless SOFTWARE[:pandoc]
60
59
  if File.exist? File.join(ENV["HOME"],".cabal","bin","pandoc")
61
60
  SOFTWARE[:pandoc]=File.join(ENV["HOME"],".cabal","bin","pandoc")
@@ -66,7 +65,12 @@ module Dyndoc
66
65
  #SOFTWARE[:pandoc]=cmd.strip.split(" ")[2] unless cmd.empty?
67
66
  end
68
67
  end
69
- if SOFTWARE[:pandoc]
68
+ SOFTWARE[:pandoc]
69
+ end
70
+
71
+ def Converter.pandoc(input,opt='')
72
+ output = ''
73
+ if Converter.pandoc_available?
70
74
  ##DEBUG: p [:pandoc_soft, SOFTWARE[:pandoc]+" #{opt}"]
71
75
  if input
72
76
  ##DEBUG: p [:pandoc_iput,input]
@@ -120,6 +124,41 @@ module Dyndoc
120
124
  Asciidoctor.convert(code,:attributes => {"icons" => "font"})
121
125
  end
122
126
 
127
+ def Converter.redcarpet_engine
128
+ unless @@markdown
129
+ require 'redcarpet'
130
+ @@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
131
+ end
132
+ @@markdown
133
+ end
134
+
135
+ def Converter.redcarpet(code)
136
+ Dyndoc::Converter.redcarpet_engine ? @@markdown.render(code) : ""
137
+ end
138
+
139
+
140
+ def Converter.markdown_engine=(engine)
141
+ @@markdown_engine=engine unless Dyndoc::Converter.markdown_engine == engine
142
+
143
+ end
144
+
145
+ def Converter.markdown_engine
146
+ (@@markdown_engine ||= :pandoc)
147
+ end
148
+
149
+ def Converter.markdown(code)
150
+ if Dyndoc::Converter.markdown_engine == :pandoc
151
+ if Dyndoc::Converter.pandoc_available?
152
+ Dyndoc::Converter.pandoc(code)
153
+ else
154
+ Converter.markdown_engine=:redcarpet
155
+ end
156
+ end
157
+ Converter.redcarpet(code) if Dyndoc::Converter.markdown_engine == :redcarpet
158
+ ## default output if no available engine found
159
+ ""
160
+ end
161
+
123
162
  def Converter.convert(input,format,outputFormat,to_protect=nil)
124
163
  ##
125
164
  format=format.to_s unless format.is_a? String
@@ -127,14 +166,14 @@ module Dyndoc
127
166
  outputFormat=outputFormat.to_s unless outputFormat.is_a? String
128
167
  res=""
129
168
  input.split("__PROTECTED__FORMAT__").each_with_index do |code,i|
130
- ## Dyndoc.warn "code",[i,code,format,outputFormat]
169
+ ##Dyndoc.warn "code",[i,code,format,outputFormat]
131
170
  if i%2==0
132
171
  res << case format+outputFormat
133
172
  when "adoc>html"
134
173
  Dyndoc::Converter.asciidoctor(code)
135
174
  when "md>html"
136
175
  ##PandocRuby.new(code, :from => :markdown, :to => :html).convert
137
- Dyndoc::Converter.pandoc(code)
176
+ Dyndoc::Converter.markdown(code)
138
177
  when "md>tex"
139
178
  #puts "latex documentclass";p Dyndoc::Utils.dyndoc_globvar("_DOCUMENTCLASS_")
140
179
  if Dyndoc::Utils.dyndoc_globvar("_DOCUMENTCLASS_")=="beamer"
@@ -173,7 +212,7 @@ module Dyndoc
173
212
  else
174
213
  res << code
175
214
  end
176
- #puts "res";p res
215
+ #Dyndoc.warn "res",res
177
216
  end
178
217
  return (to_protect ? "__PROTECTED__FORMAT__"+res+"__PROTECTED__FORMAT__": res)
179
218
  end
@@ -2,10 +2,18 @@ module Dyndoc
2
2
 
3
3
  SOFTWARE={}
4
4
 
5
+ def self.mingw32_software?
6
+ RUBY_PLATFORM=~/mingw32/
7
+ end
8
+
9
+ def self.scoop_install?
10
+ self.mingw32_software? and !(`where scoop`.strip.empty?)
11
+ end
12
+
5
13
  def self.software_init(force=false)
6
14
 
7
15
  unless SOFTWARE[:R]
8
- if RUBY_PLATFORM=~/mingw32/
16
+ if self.mingw32_software?
9
17
  cmd=Dir[File.join(ENV["HomeDrive"],"Program Files","R","**","R.exe")]
10
18
  SOFTWARE[:R]=cmd[0] unless cmd.empty?
11
19
  else
@@ -15,7 +23,7 @@ module Dyndoc
15
23
  end
16
24
 
17
25
  unless SOFTWARE[:Rscript]
18
- if RUBY_PLATFORM=~/mingw32/
26
+ if self.mingw32_software?
19
27
  cmd=Dir[File.join(ENV["HomeDrive"],"Program Files","R","**","Rscript.exe")]
20
28
  SOFTWARE[:Rscript]=cmd[0] unless cmd.empty?
21
29
  else
@@ -58,6 +66,19 @@ module Dyndoc
58
66
  SOFTWARE[:ttm]=cmd.strip.split(" ")[2] unless cmd.empty?
59
67
  end
60
68
 
69
+ unless SOFTWARE[:bash]
70
+ if self.scoop_install?
71
+ bash_path=File.expand_path('../../bin/bash.exe',`scoop which git`)
72
+ if File.exist? bash_path
73
+ bash_path
74
+ else # Needs to be in the PATH
75
+ "bash"
76
+ end
77
+ else
78
+ "/bin/bash"
79
+ end
80
+ end
81
+
61
82
  end
62
83
 
63
84
  def self.software
@@ -71,12 +92,20 @@ module Dyndoc
71
92
  def self.pdflatex
72
93
  # this has to be initialized each time you need pdflatex since TEXINPUTS could change!
73
94
  if ENV['TEXINPUTS']
74
- "env TEXINPUTS=#{ENV['TEXINPUTS']}" + (RUBY_PLATFORM=~/mingw32/ ? "; " : " ") + SOFTWARE[:pdflatex]
95
+ "env TEXINPUTS=#{ENV['TEXINPUTS']}" + (self.mingw32_software? ? "; " : " ") + SOFTWARE[:pdflatex]
75
96
  else
76
97
  SOFTWARE[:pdflatex]
77
98
  end
78
99
  end
79
100
 
101
+ def self.bash(bash_path=nil)
102
+ if bash_path # Needs to be in the PATH
103
+ return bash_path
104
+ else
105
+ SOFTWARE[:bash]
106
+ end
107
+ end
108
+
80
109
  def self.R
81
110
  SOFTWARE[:R]
82
111
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dyndoc-ruby-exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.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-02-25 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Converters and software for dyndoc.
@@ -41,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - none
43
43
  rubyforge_project:
44
- rubygems_version: 2.0.14
44
+ rubygems_version: 2.0.14.1
45
45
  signing_key:
46
46
  specification_version: 4
47
47
  summary: Converters and software for dyndoc