rich-iannone / DiagrammeR
Showing 1 of 1 files from the diff.

@@ -76,16 +76,14 @@
Loading
76 76
77 77
    # Extract the spec into several pieces: first being the body,
78 78
    # subsequent pieces belonging the replacement references
79 -
80 79
    spec_body <- unlist(strsplit(x = spec, "\\n\\s*\\[1\\]:"))[1]
81 80
82 -
    spec_references <- paste0("[1]:",
83 -
                              unlist(strsplit(x = spec, "\\n\\s*\\[1\\]:"))[2])
81 +
    spec_references <-
82 +
      paste0("[1]:", unlist(strsplit(x = spec, "\\n\\s*\\[1\\]:"))[2])
84 83
85 84
    # Split the references into a vector of R statements
86 85
    split_references <-
87 -
      gsub("\\[[0-9]+\\]:[ ]?", "",
88 -
           unlist(strsplit(x = spec_references, "\\n")))
86 +
      gsub("\\[[0-9]+\\]:[ ]?", "", unlist(strsplit(x = spec_references, "\\n")))
89 87
90 88
    # Evaluate the expressions and save into a list object
91 89
    for (i in 1:length(split_references)) {
@@ -94,18 +92,18 @@
Loading
94 92
        eval_expressions <- list()
95 93
      }
96 94
97 -
      eval_expressions <- c(eval_expressions,
98 -
                            list(eval(parse(text = split_references[i]))))
95 +
      eval_expressions <-
96 +
        c(
97 +
          eval_expressions,
98 +
          list(eval(parse(text = split_references[i])))
99 +
        )
99 100
    }
100 101
101 -
    # Make replacements to the spec body for each replacement that has
102 -
    # no hyphen
102 +
    # Make replacements to the spec body for each replacement that has no hyphen
103 103
    for (i in 1:length(split_references)) {
104 -
105 104
      while (grepl(paste0("@@", i, "([^-0-9])"), spec_body)) {
106 -
107 -
        spec_body <- gsub(paste0("@@", i),
108 -
                          eval_expressions[[i]][1], spec_body)
105 +
        spec_body <-
106 +
          gsub(paste0("@@", i, "(?=[^-0-9])"), eval_expressions[[i]][1], spec_body, perl = TRUE)
109 107
      }
110 108
    }
111 109
@@ -113,22 +111,31 @@
Loading
113 111
    # following and return the value from that index
114 112
    for (i in 1:length(split_references)) {
115 113
      while (grepl(paste0("@@", i, "-", "[0-9]+"), spec_body)) {
114 +
116 115
        the_index <-
117 -
          as.numeric(gsub("^([0-9]+)(.*)", "\\1",
118 -
                          strsplit(spec_body,
119 -
                                   paste0("@@", i, "-"))[[1]][2]))
116 +
          gsub(
117 +
            "^([0-9]+)(.*)", "\\1",
118 +
            strsplit(spec_body, paste0("@@", i, "-"))[[1]][2]
119 +
          ) %>%
120 +
          as.numeric()
120 121
121 122
        if (the_index > length(eval_expressions[[i]])) {
123 +
122 124
          spec_body <-
123 -
            gsub(paste0("@@", i, "-", the_index, "([^0-9])"),
124 -
                 paste0(eval_expressions[[i]][length(eval_expressions[[i]])],
125 -
                        "\\1"),
126 -
                 spec_body)
125 +
            gsub(
126 +
              paste0("@@", i, "-", the_index, "([^0-9])"),
127 +
              paste0(eval_expressions[[i]][length(eval_expressions[[i]])], "\\1"),
128 +
              spec_body
129 +
            )
130 +
127 131
        } else {
132 +
128 133
          spec_body <-
129 -
            gsub(paste0("@@", i, "-", the_index, "([^0-9])"),
130 -
                 paste0(eval_expressions[[i]][the_index], "\\1"),
131 -
                 spec_body)
134 +
            gsub(
135 +
              paste0("@@", i, "-", the_index, "([^0-9])"),
136 +
              paste0(eval_expressions[[i]][the_index], "\\1"),
137 +
              spec_body
138 +
            )
132 139
        }
133 140
      }
134 141
    }
Files Coverage
R 80.97%
Project Totals (241 files) 80.97%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading