galaaz 0.4.2 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +25 -0
  3. data/Rakefile +8 -0
  4. data/bin/gknit +9 -5
  5. data/bin/gstudio +4 -2
  6. data/bin/gstudio.rb +32 -2
  7. data/blogs/dev/dev.html +219 -34
  8. data/blogs/dev/dev.md +26 -26
  9. data/blogs/dev/dev_files/figure-html/bubble-1.png +0 -0
  10. data/blogs/dev/dev_files/figure-html/diverging_bar.png +0 -0
  11. data/blogs/dplyr/dplyr.rb +63 -0
  12. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +38 -26
  13. data/blogs/galaaz_ggplot/galaaz_ggplot.aux +16 -17
  14. data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
  15. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +65 -31
  16. data/blogs/oh_my/not_so.rb +2342 -0
  17. data/blogs/oh_my/oh_my.Rmd +493 -0
  18. data/blogs/oh_my/oh_my.html +680 -0
  19. data/blogs/oh_my/oh_my.md +597 -0
  20. data/blogs/oh_my/old.Rmd +2100 -0
  21. data/blogs/ruby_plot/figures/facets_with_decorations.png +0 -0
  22. data/blogs/ruby_plot/figures/facets_with_jitter.png +0 -0
  23. data/blogs/ruby_plot/figures/final_box_plot.png +0 -0
  24. data/blogs/ruby_plot/figures/final_violin_plot.png +0 -0
  25. data/blogs/ruby_plot/figures/violin_with_jitter.png +0 -0
  26. data/blogs/ruby_plot/ruby_plot.Rmd +147 -122
  27. data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +662 -0
  28. data/blogs/ruby_plot/ruby_plot.html +49 -54
  29. data/blogs/ruby_plot/ruby_plot.md +147 -122
  30. data/blogs/ruby_plot/ruby_plot.pdf +0 -0
  31. data/blogs/ruby_plot/ruby_plot.tex +776 -157
  32. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +57 -0
  33. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +106 -0
  34. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +110 -0
  35. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +174 -0
  36. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +236 -0
  37. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  38. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +296 -0
  39. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +236 -0
  40. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +218 -0
  41. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +128 -0
  42. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +150 -0
  43. data/examples/islr/ch2.spec.rb +21 -18
  44. data/examples/islr/ch3_boston.rb +14 -5
  45. data/examples/islr/ch3_multiple_regression.rb +2 -3
  46. data/examples/islr/ch6.spec.rb +1 -1
  47. data/examples/islr/x_y_rnorm.jpg +0 -0
  48. data/lib/R_interface/r.rb +14 -10
  49. data/lib/R_interface/r_libs.R +9 -0
  50. data/lib/R_interface/r_methods.rb +77 -6
  51. data/lib/R_interface/{expression.rb → r_module_s.rb} +13 -14
  52. data/lib/R_interface/rbinary_operators.rb +58 -71
  53. data/lib/R_interface/rdata_frame.rb +2 -1
  54. data/lib/R_interface/rdevices.R +4 -0
  55. data/lib/R_interface/rdevices.rb +1 -1
  56. data/lib/R_interface/renvironment.rb +34 -1
  57. data/lib/R_interface/rexpression.rb +108 -2
  58. data/lib/R_interface/rindexed_object.rb +3 -1
  59. data/lib/R_interface/rlanguage.rb +18 -2
  60. data/lib/R_interface/rmatrix.rb +14 -0
  61. data/lib/R_interface/rmd_indexed_object.rb +5 -1
  62. data/lib/R_interface/robject.rb +61 -23
  63. data/lib/R_interface/rsupport.rb +111 -53
  64. data/lib/R_interface/rsymbol.rb +6 -5
  65. data/lib/R_interface/ruby_extensions.rb +130 -4
  66. data/lib/R_interface/runary_operators.rb +35 -3
  67. data/lib/R_interface/rvector.rb +1 -0
  68. data/lib/galaaz.rb +0 -2
  69. data/lib/gknit/knitr_engine.rb +58 -4
  70. data/lib/gknit/ruby_engine.rb +5 -6
  71. data/lib/util/exec_ruby.rb +55 -9
  72. data/specs/all.rb +13 -3
  73. data/specs/figures/dose_len.png +0 -0
  74. data/specs/r_dataframe.spec.rb +49 -26
  75. data/specs/r_environment.spec.rb +140 -0
  76. data/specs/r_eval.spec.rb +0 -15
  77. data/specs/r_formula.spec.rb +232 -0
  78. data/specs/r_function.spec.rb +7 -8
  79. data/specs/r_list.spec.rb +4 -0
  80. data/specs/r_list_apply.spec.rb +11 -11
  81. data/specs/r_matrix.spec.rb +3 -3
  82. data/specs/{r_plots.spec.rb~ → r_nse.spec.rb} +29 -6
  83. data/specs/r_vector_creation.spec.rb +6 -0
  84. data/specs/r_vector_object.spec.rb +2 -2
  85. data/specs/r_vector_operators.spec.rb +3 -3
  86. data/specs/r_vector_subsetting.spec.rb +4 -4
  87. data/specs/ruby_expression.spec.rb +324 -0
  88. data/specs/tmp.rb +12 -524
  89. data/sty/galaaz.sty +71 -0
  90. data/version.rb +1 -1
  91. metadata +31 -41
  92. data/bin/gknit2~ +0 -6
  93. data/bin/ogk~ +0 -4
  94. data/bin/prepareR.rb~ +0 -1
  95. data/blogs/dev/dev.Rmd~ +0 -104
  96. data/blogs/galaaz_ggplot/galaaz_ggplot.dvi +0 -0
  97. data/blogs/galaaz_ggplot/midwest_external_png~ +0 -1
  98. data/blogs/gknit/gknit.Rmd~ +0 -184
  99. data/blogs/gknit/gknit.Rnd~ +0 -17
  100. data/blogs/gknit/model.rb~ +0 -46
  101. data/blogs/ruby_plot/ruby_plot.Rmd~ +0 -215
  102. data/examples/islr/Figure.jpg +0 -0
  103. data/examples/misc/moneyball.rb~ +0 -16
  104. data/examples/misc/subsetting.rb~ +0 -372
  105. data/lib/R/eng_ruby.R~ +0 -63
  106. data/lib/R_interface/capture_plot.rb~ +0 -23
  107. data/lib/R_interface/r.rb~ +0 -121
  108. data/lib/R_interface/rdevices.rb~ +0 -27
  109. data/lib/gknit.rb~ +0 -26
  110. data/lib/gknit/knitr_engine.rb~ +0 -102
  111. data/lib/gknit/ruby_engine.rb~ +0 -72
  112. data/lib/util/inline_file.rb~ +0 -23
  113. data/r_requires/knitr.rb~ +0 -4
  114. data/specs/r_language.spec.rb +0 -157
@@ -1,63 +0,0 @@
1
- # define the ruby engine for processing Ruby chunks in
2
- # rmarkdown
3
- eng_ruby = function(options) {
4
- block_code = paste(options$code, collapse = "\\n");
5
- code = paste0("GalaazUtil.exec_ruby(",
6
- shQuote(block_code),
7
- ")
8
- ");
9
-
10
- # png(paste0("gknit_files/figure-html/", options$label, ".png"));
11
-
12
- keep = options$fig.keep
13
- keep.idx = NULL
14
- if (is.numeric(keep)) {
15
- keep.idx = keep
16
- keep = "index"
17
- }
18
-
19
- tmp.fig = tempfile(); on.exit(unlink(tmp.fig), add = TRUE)
20
-
21
- # open a device to record plots
22
- if (chunk_device(options$fig.width[1L], options$fig.height[1L], keep != "none",
23
- options$dev, options$dev.args, options$dpi, options, tmp.fig)) {
24
- # preserve par() settings from the last code chunk
25
- if (keep.pars <- opts_knit$get("global.par"))
26
- par2(opts_knit$get("global.pars"))
27
- showtext(options$fig.showtext) # showtext support
28
- dv = dev.cur()
29
- on.exit({
30
- if (keep.pars) opts_knit$set(global.pars = par(no.readonly = TRUE))
31
- dev.off(dv)
32
- }, add = TRUE)
33
- }
34
-
35
- # guess plot file type if it is NULL
36
- if (keep != "none" && is.null(options$fig.ext))
37
- options$fig.ext = dev2ext(options$dev)
38
-
39
- # out = eval.polyglot("ruby", code);
40
- res = eval.polyglot("ruby", code);
41
-
42
- # rearrange locations of figures
43
- figs = find_recordedplot(res)
44
- if (length(figs) && any(figs)) {
45
- if (keep == 'none') {
46
- res = res[!figs] # remove all
47
- } else {
48
- if (options$fig.show == 'hold') res = c(res[!figs], res[figs]) # move to the end
49
- figs = find_recordedplot(res)
50
- if (length(figs) && sum(figs) > 1) {
51
- if (keep %in% c('first', 'last')) {
52
- res = res[-(if (keep == 'last') head else tail)(which(figs), -1L)]
53
- } else {
54
- # keep only selected
55
- if (keep == 'index') res = res[which(figs)[keep.idx]]
56
- # merge low-level plotting changes
57
- if (keep == 'high') res = merge_low_plot(res, figs)
58
- }
59
- }
60
- }
61
- }
62
- engine_output(options, block_code, res)
63
- }
@@ -1,23 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ##########################################################################################
4
- # @author Rodrigo Botafogo
5
- #
6
- # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
- # and distribute this software and its documentation, without fee and without a signed
8
- # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
- # paragraph and the following two paragraphs appear in all copies, modifications, and
10
- # distributions.
11
- #
12
- # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
- # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
- # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
- # POSSIBILITY OF SUCH DAMAGE.
16
- #
17
- # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
- # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
- # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
- # OR MODIFICATIONS.
22
- ##########################################################################################
23
-
@@ -1,121 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ##########################################################################################
4
- # @author Rodrigo Botafogo
5
- #
6
- # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
- # and distribute this software and its documentation, without fee and without a signed
8
- # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
- # paragraph and the following two paragraphs appear in all copies, modifications, and
10
- # distributions.
11
- #
12
- # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
- # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
- # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
- # POSSIBILITY OF SUCH DAMAGE.
16
- #
17
- # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
- # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
- # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
- # OR MODIFICATIONS.
22
- ##########################################################################################
23
-
24
- require_relative 'robject'
25
- require_relative 'rsupport'
26
-
27
- module R
28
-
29
- RCONSTANTS = ["LETTERS", "letters", "month.abb", "month.name", "pi"]
30
-
31
- #----------------------------------------------------------------------------------------
32
- #
33
- #----------------------------------------------------------------------------------------
34
-
35
- def self.method_missing(symbol, *args, &block)
36
-
37
- if (block_given?)
38
- val = R::Support.process_missing(symbol, false, *args)
39
- return R::Support.new_scope(symbol, val, *args, &block)
40
- end
41
-
42
- R::Support.process_missing(symbol, false, *args)
43
-
44
- end
45
-
46
- #----------------------------------------------------------------------------------------
47
- #
48
- #----------------------------------------------------------------------------------------
49
-
50
- def self.internal_eval(symbol, *args)
51
- R::Support.process_missing(symbol, true, *args)
52
- end
53
-
54
- #----------------------------------------------------------------------------------------
55
- # Checks to see if the given libs are installed in R and if not, install them
56
- # @param libs [Array] Array of strings with the names of the libraries to check and
57
- # install
58
- #----------------------------------------------------------------------------------------
59
-
60
- def self.install_rlibs(*libs)
61
-
62
- packages = R.c(libs)
63
-
64
- new_packages = packages[!(packages._ :in, R.installed__packages[:all, "Package"])]
65
- if(new_packages.size > 0)
66
- puts "The following packages are missing and will be installed:\n #{new_packages}"
67
- R.install__packages(new_packages)
68
- end
69
-
70
- end
71
-
72
- #----------------------------------------------------------------------------------------
73
- #
74
- #----------------------------------------------------------------------------------------
75
-
76
- def self.install_and_loads(*libs)
77
- R.install_rlibs(*libs)
78
- libs.each { |lib| R.require lib }
79
- end
80
-
81
- end
82
-
83
- # define methods for accessing indexed object: Vector, Lists
84
- require_relative 'rindexed_object'
85
- # define methods for accessing multi dimensional indexed objects: Matrix, DataFrames
86
- require_relative 'rmd_indexed_object'
87
- # Binary operators: '+', '-', etc
88
- require_relative 'rbinary_operators'
89
- # Unary operators: '!', '@-', etc
90
- require_relative 'runary_operators'
91
- # Definition of R Vector
92
- require_relative 'rvector'
93
- # Definition of R Lists
94
- require_relative 'rlist'
95
- # Definition of R Matrix
96
- require_relative 'rmatrix'
97
- # Definition of R DataFrame
98
- require_relative 'rdata_frame'
99
- # Definition of R Closure (functions)
100
- require_relative 'rclosure'
101
- # Definition of R Expression
102
- require_relative 'rexpression'
103
- # Definition of R Environment
104
- require_relative 'renvironment'
105
- # Definition of R Language
106
- require_relative 'rlanguage'
107
- # Definition of R Symbol
108
- require_relative 'rsymbol'
109
- # Access to package symbols
110
- require_relative 'rpkg'
111
-
112
- # Defines the E module for creating R expressions
113
- require_relative 'expression'
114
- # Ruby class extensions. Extends Symbol to allow the creation of
115
- # expressions using Symbol: (:x > 10)
116
- require_relative 'ruby_extensions'
117
- # Class to allow R calling back into Ruby
118
- require_relative 'ruby_callback'
119
-
120
- # Util to execute Ruby code in a string redirecting stdout
121
- require_relative 'util/exec_ruby'
@@ -1,27 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ##########################################################################################
4
- # @author Rodrigo Botafogo
5
- #
6
- # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
- # and distribute this software and its documentation, without fee and without a signed
8
- # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
- # paragraph and the following two paragraphs appear in all copies, modifications, and
10
- # distributions.
11
- #
12
- # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
- # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
- # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
- # POSSIBILITY OF SUCH DAMAGE.
16
- #
17
- # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
- # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
- # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
- # OR MODIFICATIONS.
22
- ##########################################################################################
23
-
24
- dir = File.dirname(File.expand_path('.', __FILE__))
25
- src = "#{dir}/capture_plot.R"
26
-
27
- R.source(src)
@@ -1,26 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ##########################################################################################
4
- # @author Rodrigo Botafogo
5
- #
6
- # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
- # and distribute this software and its documentation, without fee and without a signed
8
- # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
- # paragraph and the following two paragraphs appear in all copies, modifications, and
10
- # distributions.
11
- #
12
- # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
- # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
- # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
- # POSSIBILITY OF SUCH DAMAGE.
16
- #
17
- # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
- # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
- # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
- # OR MODIFICATIONS.
22
- ##########################################################################################
23
-
24
- require 'galaaz'
25
-
26
- puts "gknit loaded"
@@ -1,102 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ##########################################################################################
4
- # @author Rodrigo Botafogo
5
- #
6
- # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
- # and distribute this software and its documentation, without fee and without a signed
8
- # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
- # paragraph and the following two paragraphs appear in all copies, modifications, and
10
- # distributions.
11
- #
12
- # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
- # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
- # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
- # POSSIBILITY OF SUCH DAMAGE.
16
- #
17
- # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
- # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
- # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
- # OR MODIFICATIONS.
22
- ##########################################################################################
23
-
24
- R.install_and_loads('knitr', 'rmarkdown')
25
-
26
- # dir = File.dirname(File.expand_path('.', __FILE__))
27
- # src = "#{dir}/R/eng_ruby.R"
28
-
29
- class KnitrEngine
30
-
31
- attr_reader :keep
32
-
33
- #--------------------------------------------------------------------------------------
34
- # opens a device for plot recording. Method chunk_device in knitr is not exported,
35
- # so it cannot yet be accessed by Galaaz. Need to develop a local function that calls
36
- # the non-exported function.
37
- #--------------------------------------------------------------------------------------
38
-
39
- R::Support.eval(<<-R)
40
- _ck_dv = function(width, height, record = TRUE, dev, dev.args, dpi, options,
41
- tmp = tempfile()) {
42
- knitr:::chunk_device(width, height, record, dev, dev.args, dpi, options, tmp)
43
- }
44
- R
45
-
46
- #--------------------------------------------------------------------------------------
47
- # The showtext package, is able to support more font formats and more graphics
48
- # devices, and avoids using external software such as Ghostscript. showtext makes it
49
- # even easier to use various types of fonts (TrueType, OpenType, Type 1, web fonts,
50
- # etc.) in R graphs.
51
- #--------------------------------------------------------------------------------------
52
-
53
- R::Support.eval(<<-R)
54
- showtext = function() {
55
- print("showtext beginning")
56
- showtext::showtext_begin()
57
- }
58
- R
59
-
60
- #--------------------------------------------------------------------------------------
61
- # Process the fig.keep chunk option
62
- # @bug this does not what it should
63
- #--------------------------------------------------------------------------------------
64
-
65
- def self.fig_keep(keep)
66
- puts "checking fig_keep options"
67
-
68
- @keep = keep
69
- puts @keep
70
-
71
- @keep.idx = nil
72
-
73
- if (@keep.is__numeric << 0)
74
- puts "keep is numeric"
75
-
76
- @keep.idx = keep
77
- @keep = "index"
78
- end
79
-
80
- puts @keep
81
-
82
- end
83
-
84
- #--------------------------------------------------------------------------------------
85
- # Process the chunk options
86
- #--------------------------------------------------------------------------------------
87
-
88
- def self.process_options(options)
89
- fig_keep(options.fig__keep)
90
- end
91
-
92
- #--------------------------------------------------------------------------------------
93
- # Adds the new knitr engine to the list of engines
94
- # @param spec [Hash] hash with only one pair containing the machine key and the engine
95
- # function
96
- #--------------------------------------------------------------------------------------
97
-
98
- def add(spec)
99
- (~:knit_engines).set.call(spec)
100
- end
101
-
102
- end
@@ -1,72 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ##########################################################################################
4
- # @author Rodrigo Botafogo
5
- #
6
- # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
- # and distribute this software and its documentation, without fee and without a signed
8
- # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
- # paragraph and the following two paragraphs appear in all copies, modifications, and
10
- # distributions.
11
- #
12
- # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
- # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
- # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
- # POSSIBILITY OF SUCH DAMAGE.
16
- #
17
- # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
- # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
- # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
- # OR MODIFICATIONS.
22
- ##########################################################################################
23
-
24
- # Ruby engine for processing Ruby chunks
25
- eng_ruby = Proc.new do |options|
26
-
27
- begin
28
- # read the chunk code
29
- code = R.paste(options.code, collapse: "\n") << 0
30
-
31
- # process the chunk options
32
- KnitrEngine.process_options(options)
33
-
34
- # opens a device for the current chunk for plot recording. Knitr provides
35
- # method chunck_device for that, but it is a non-exported method. Galaaz
36
- # does not yet provide a way to accessing non-exported methods, so, the ck_dv
37
- # local method was developed that just calls chunk_device.
38
- if (R._ck_dv(options.fig__width[1], options.fig__height[1], options.dev,
39
- options.dev__args, options.dpi, options, record: true) << 0)
40
-
41
- puts "===================================="
42
- puts "fig.showtext is element?"
43
- puts R.is__element('fig.showtext', options)
44
- puts options['fig.showtext']
45
- puts "===================================="
46
-
47
- if (R.is__element('fig.showtext', options) << 0)
48
- puts "==============================="
49
- puts options.fig__showtext
50
- puts options.fig__showtext << 0
51
- end
52
-
53
- R.showtext if (R.is__element('fig.showtext', options) << 0) &&
54
- (options.fig__showtext << 0) == true
55
- dv = R.dev__cur
56
- end
57
-
58
- # executes the code
59
- res = GalaazUtil.exec_ruby(code)
60
-
61
- # formats and outputs the code and results
62
- R.engine_output(options, options.code, res)
63
-
64
- ensure
65
- R.dev__off(dv)
66
- end
67
-
68
- end
69
-
70
- ruby_engine = KnitrEngine.new
71
- ruby_engine.add(ruby: eng_ruby)
72
-
@@ -1,23 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- ##########################################################################################
4
- # @author Rodrigo Botafogo
5
- #
6
- # Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
7
- # and distribute this software and its documentation, without fee and without a signed
8
- # licensing agreement, is hereby granted, provided that the above copyright notice, this
9
- # paragraph and the following two paragraphs appear in all copies, modifications, and
10
- # distributions.
11
- #
12
- # IN NO EVENT SHALL RODRIGO BOTAFOGO BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
13
- # INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF
14
- # THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RODRIGO BOTAFOGO HAS BEEN ADVISED OF THE
15
- # POSSIBILITY OF SUCH DAMAGE.
16
- #
17
- # RODRIGO BOTAFOGO SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
19
- # SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS".
20
- # RODRIGO BOTAFOGO HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
21
- # OR MODIFICATIONS.
22
- ##########################################################################################
23
-