statosio 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-06-02
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at andreasbanholzer@me.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in statosio.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rubocop", "~> 1.7"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 a6b8
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,182 @@
1
+ <img src="https://github.com/a6b8/statosio.rb/blob/main/assets/statosio.rb.png?raw=true" width="300">
2
+
3
+ ## Usage
4
+ Statosio.rb is based on [statosio.js](https://github.com/a6b8/statosio.js) and helps to generate simple charts, in a fast and reliable way.
5
+
6
+ Statosio generate charts in a ```.svg``` format. Works with [prawn-svg](https://github.com/mogest/prawn-svg) to generate ```.pdf``` documents. All Charts Data can be searched no information get lost.
7
+
8
+ ✔️ build simple diagrams fast and reliable, with one function!<br>
9
+ ✔️ pure javascript, no additonal css.<br>
10
+ ✔️ highly customizable with 40+ style and data options.<br>
11
+
12
+
13
+ **Video Introduction:**
14
+ [https://www.youtube.com/watch?v=i6od9O8jz1E](https://www.youtube.com/watch?v=i6od9O8jz1E)
15
+
16
+ **Documentation:**
17
+ [https://d3.statosio.com](https://d3.statosio.com/)
18
+
19
+
20
+ ## Chart Types
21
+ ### Bar
22
+ ![# d3.statosio](https://d3.statosio.com/assets/images/example-bar-400.jpg)<br>
23
+ [Create simple bar chart](https://d3.statosio.com/tutorials/simple-bar-chart.html)
24
+ ### Point
25
+ ![# d3.statosio](https://d3.statosio.com/assets/images/example-point-400.jpg)<br>
26
+ [Create a simple point chart](https://d3.statosio.com/tutorials/simple-point-chart.html)
27
+ ### Stacked
28
+ ![# d3.statosio](https://d3.statosio.com/assets/images/example-stacked-bar-400.jpg)<br>
29
+ [Create simple stacked bar chart](https://d3.statosio.com/tutorials/simple-stacked-bar-chart.html)
30
+
31
+ ## Features
32
+ ### Select
33
+ ![# d3.statosio](https://d3.statosio.com/assets/images/example-select-400.jpg)<br>
34
+ [Select and change position of columns](https://d3.statosio.com/tutorials/select-data.html)
35
+ ### Sort Data
36
+ ![# d3.statosio](https://d3.statosio.com/assets/images/example-sort-400.jpg)<br>
37
+ [Sort dataset by values](https://d3.statosio.com/tutorials/sort-data.html)
38
+ ### Change Style
39
+ ![# d3.statosio](https://d3.statosio.com/assets/images/example-customize-400.jpg)<br>
40
+ [Change style to dark-mode](https://d3.statosio.com/tutorials/change-style.html)
41
+
42
+
43
+ ## Quickstart
44
+
45
+ ```ruby
46
+ gem install 'statosio'
47
+ gem install 'open-uri'
48
+ gem install 'json'
49
+ ```
50
+
51
+ ```ruby
52
+ require 'statosio'
53
+ require 'open-uri'
54
+ require 'json'
55
+
56
+ # Initialize Statosio
57
+ statosio = Statosio::Generate.new
58
+
59
+ # Load Sample Dataset
60
+ url = 'https://d3.statosio.com/data/performance.json'
61
+ content = URI.open( url ).read
62
+ dataset = JSON.parse( content )
63
+
64
+ # Generate chart as .svg
65
+ chart = statosio.svg(
66
+ dataset: dataset,
67
+ x: 'name',
68
+ y: 'mobile',
69
+ options: {}
70
+ )
71
+
72
+ puts chart
73
+ # -> <svg>[]....</svg>
74
+ ```
75
+
76
+
77
+ ## ```Statosio``` with ```prawn```
78
+ ```ruby
79
+ gem install 'statosio'
80
+ gem install 'prawn'
81
+ gem install 'prawn-svg'
82
+ ```
83
+
84
+ ```ruby
85
+ require 'open-uri'
86
+ require 'statosio'
87
+
88
+ require 'prawn'
89
+ require 'prawn-svg'
90
+
91
+ # Initialize Statosio
92
+ statosio = Statosio::Generate.new
93
+
94
+ # Load Sample Dataset
95
+ url = 'https://d3.statosio.com/data/performance.json'
96
+ content = URI.open( url ).read
97
+ dataset = JSON.parse( content )
98
+
99
+ # Generate Statosio
100
+ chart = statosio.svg(
101
+ dataset: dataset,
102
+ x: 'name',
103
+ y: 'mobile',
104
+ options: {}
105
+ )
106
+
107
+ # Generate .pdf
108
+ Prawn::Document.generate( "statosio.pdf" ) do | pdf |
109
+ pdf.svg( chart, width: 500, )
110
+ end
111
+ ```
112
+
113
+ ## Parameters
114
+
115
+ | | **Value** | **Type** | **Required** |
116
+ |------:|:------|:------| :------|
117
+ | **dataset** | ```[{},{}...]``` | Array of Hash | yes |
118
+ | **x** | ```"name"``` | String | yes |
119
+ | **y** | ```"mobile"```, ```[ "mobile",... ]``` | String or Array of Strings | yes |
120
+ | **options** | ```{}``` | Hash | yes |
121
+ | **silent** | ```true``` or ```false```| Boolean | no |
122
+
123
+ <br>
124
+
125
+ ## Options
126
+
127
+
128
+ | | **Option** | **Default** | **Examples** | **Description** |
129
+ |:--|:--|:--|:--|:--|
130
+ | A.1. | [showTitle](https://d3.statosio.com/options/show__title.html) | false | [A](https://d3.statosio.com/options/show__title.html#example-a), [B](https://d3.statosio.com/options/show__title.html#example-b) | Show or hide title on the front of the diagram. |
131
+ | A.2. | [showLegend](https://d3.statosio.com/options/show__legend.html) | false | [A](https://d3.statosio.com/options/show__legend.html#example-a), [B](https://d3.statosio.com/options/show__legend.html#example-b), [C](https://d3.statosio.com/options/show__legend.html#example-c) | Show or hide legend. Recommended for stacked diagrams. |
132
+ | A.3. | [showAverage](https://d3.statosio.com/options/show__average.html) | true | [A](https://d3.statosio.com/options/show__average.html#example-a), [B](https://d3.statosio.com/options/show__average.html#example-b), [C](https://d3.statosio.com/options/show__average.html#example-c) | Calculate and show average line |
133
+ | A.4. | [showRangeYLog](https://d3.statosio.com/options/show__range_y_log.html) | false | [A](https://d3.statosio.com/options/show__range_y_log.html#example-a), [B](https://d3.statosio.com/options/show__range_y_log.html#example-b) | Calculate and show range y in a log scale. |
134
+ | A.5. | [showDataAsCircle](https://d3.statosio.com/options/show__data_as_circle.html) | false | [A](https://d3.statosio.com/options/show__data_as_circle.html#example-a), [B](https://d3.statosio.com/options/show__data_as_circle.html#example-b), [C](https://d3.statosio.com/options/show__data_as_circle.html#example-c) | Show data as circles instead of rectangles. Only for not stacked diagram available. |
135
+ | B.1. | [viewTitle](https://d3.statosio.com/options/view__title.html) | "Statosio Demo" | [A](https://d3.statosio.com/options/view__title.html#example-a) | Set title content. |
136
+ | B.2. | [viewDomId](https://d3.statosio.com/options/view__dom_id.html) | "d3_statosio" | [A](https://d3.statosio.com/options/view__dom_id.html#example-a) | Set id from the <div> Element which holds the d3 content inside. |
137
+ | B.3. | [viewMarginTop](https://d3.statosio.com/options/view__margin__top.html) | 20 | [A](https://d3.statosio.com/options/view__margin__top.html#example-a), [B](https://d3.statosio.com/options/view__margin__top.html#example-b) | Set margin top |
138
+ | B.4. | [viewMarginRight](https://d3.statosio.com/options/view__margin__right.html) | 40 | [A](https://d3.statosio.com/options/view__margin__right.html#example-a), [B](https://d3.statosio.com/options/view__margin__right.html#example-b) | Set margin right |
139
+ | B.5. | [viewMarginBottom](https://d3.statosio.com/options/view__margin__bottom.html) | 100 | [A](https://d3.statosio.com/options/view__margin__bottom.html#example-a), [B](https://d3.statosio.com/options/view__margin__bottom.html#example-b) | Set margin bottom |
140
+ | B.6. | [viewMarginLeft](https://d3.statosio.com/options/view__margin__left.html) | 60 | [A](https://d3.statosio.com/options/view__margin__left.html#example-a), [B](https://d3.statosio.com/options/view__margin__left.html#example-b) | Set margin left |
141
+ | B.7. | [viewWidthOuter](https://d3.statosio.com/options/view__width__outer.html) | 600 | [A](https://d3.statosio.com/options/view__width__outer.html#example-a), [B](https://d3.statosio.com/options/view__width__outer.html#example-b) | Set width of the "canvas" including margin, titles etc. |
142
+ | B.8. | [viewHeightOuter](https://d3.statosio.com/options/view__height__outer.html) | 300 | [A](https://d3.statosio.com/options/view__height__outer.html#example-a), [B](https://d3.statosio.com/options/view__height__outer.html#example-b) | Set height of the "canvas" including margin. |
143
+ | B.9. | [viewTranslateMultiplicator](https://d3.statosio.com/options/view__translate__multiplicator.html) | 1.5 | [A](https://d3.statosio.com/options/view__translate__multiplicator.html#example-a), [B](https://d3.statosio.com/options/view__translate__multiplicator.html#example-b) | Between title, legend and diagram are spaces. These spaces gets calculated through this multiplicator. |
144
+ | C.1. | [dataXKey](https://d3.statosio.com/options/data__x__key.html) | "" | | Expect a "key" name from the dataset to arrange the x range. |
145
+ | C.2. | [dataXSelectors](https://d3.statosio.com/options/data__x__selectors.html) | [] | [A](https://d3.statosio.com/options/data__x__selectors.html#example-a), [B](https://d3.statosio.com/options/data__x__selectors.html#example-b) | Expect one or more names which are included in the x range. |
146
+ | C.3. | [dataXTextLength](https://d3.statosio.com/options/data__x__text__length.html) | 25 | [A](https://d3.statosio.com/options/data__x__text__length.html#example-a), [B](https://d3.statosio.com/options/data__x__text__length.html#example-b) | This value counts the length of the x range names an cut of the rest. |
147
+ | C.4. | [dataXTextPlaceholder](https://d3.statosio.com/options/data__x__text__placeholder.html) | "..." | [A](https://d3.statosio.com/options/data__x__text__placeholder.html#example-a), [B](https://d3.statosio.com/options/data__x__text__placeholder.html#example-b) | Set an suffix behind a string. As a signal to the viewer, that the text was cut of. |
148
+ | C.5. | [dataYKeys](https://d3.statosio.com/options/data__y__keys.html) | [] | | Expect "keys" from the dataset to arrange the y range. If you use one key the internal state is "bar". if you use multiple the internal is "stacked" |
149
+ | C.6. | [dataYTicks](https://d3.statosio.com/options/data__y__ticks.html) | 5 | [A](https://d3.statosio.com/options/data__y__ticks.html#example-a), [B](https://d3.statosio.com/options/data__y__ticks.html#example-b) | Ticks in d3 land means "steps". Here you can set the steps from the grid and y range. |
150
+ | C.7. | [dataSortCurrent](https://d3.statosio.com/options/data__sort__current.html) | "none" | [A](https://d3.statosio.com/options/data__sort__current.html#example-a), [B](https://d3.statosio.com/options/data__sort__current.html#example-b) | Set the general route for sorting. You can choose between "none", "values", "names". |
151
+ | C.8. | [dataSortByValues](https://d3.statosio.com/options/data__sort__by__values.html) | "decending" | [A](https://d3.statosio.com/options/data__sort__by__values.html#example-a), [B](https://d3.statosio.com/options/data__sort__by__values.html#example-b), [C](https://d3.statosio.com/options/data__sort__by__values.html#example-c) | Here you can set type of sorting. You can choose between "ascending" and "decending" |
152
+ | C.9. | [dataSortByNames](https://d3.statosio.com/options/data__sort__by__names.html) | "ascending" | [A](https://d3.statosio.com/options/data__sort__by__names.html#example-a), [B](https://d3.statosio.com/options/data__sort__by__names.html#example-b) | Here you can set type of sorting. You can choose between "ascending" and "decending" |
153
+ | C.10. | [dataSortSelection](https://d3.statosio.com/options/data__sort__selection.html) | "none" | [A](https://d3.statosio.com/options/data__sort__selection.html#example-a), [B](https://d3.statosio.com/options/data__sort__selection.html#example-b), [C](https://d3.statosio.com/options/data__sort__selection.html#example-c) | Change position of your selection. You can choose between "start", "end" and "none" |
154
+ | C.11. | [dataLegendTextSeparater](https://d3.statosio.com/options/data__legend__text__separater.html) | "_" | [A](https://d3.statosio.com/options/data__legend__text__separater.html#example-a) | This tweak split your keys with the separater and capitalize every word and insert a space in between. |
155
+ | D.1. | [styleColorAverage](https://d3.statosio.com/options/style__color__average.html) | "#000000" | [A](https://d3.statosio.com/options/style__color__average.html#example-a), [B](https://d3.statosio.com/options/style__color__average.html#example-b) | Set color of the average line. |
156
+ | D.2. | [styleColorCanvasBackground](https://d3.statosio.com/options/style__color__canvas_background.html) | "white" | [A](https://d3.statosio.com/options/style__color__canvas_background.html#example-a), [B](https://d3.statosio.com/options/style__color__canvas_background.html#example-b) | Set background color. |
157
+ | D.3. | [styleColorFont](https://d3.statosio.com/options/style__color__font.html) | "#000000" | [A](https://d3.statosio.com/options/style__color__font.html#example-a), [B](https://d3.statosio.com/options/style__color__font.html#example-b) | Set default font color. Excluding non-selection content. |
158
+ | D.4. | [styleColorLegends](https://d3.statosio.com/options/style__color__legends.html) | ["#5186EC", "#D95040", "#F2BD42"] | [A](https://d3.statosio.com/options/style__color__legends.html#example-a), [B](https://d3.statosio.com/options/style__color__legends.html#example-b) | Set legend color palettes. Expect an array of "hex" values or "html" color-names. |
159
+ | D.5. | [styleColorGridline](https://d3.statosio.com/options/style__color__gridline.html) | "#E5E5E5" | [A](https://d3.statosio.com/options/style__color__gridline.html#example-a), [B](https://d3.statosio.com/options/style__color__gridline.html#example-b) | Set the gridline color. Use "hex" value or "html" color-names. |
160
+ | D.6. | [styleColorSelectorsChart](https://d3.statosio.com/options/style__color__selectors__chart.html) | ["#EE752F", "#5186EC"] | [A](https://d3.statosio.com/options/style__color__selectors__chart.html#example-a), [B](https://d3.statosio.com/options/style__color__selectors__chart.html#example-b) | Colorize the chart of the selection. Use "hex" values or "html" color-names. |
161
+ | D.7. | [styleColorSelectorsText](https://d3.statosio.com/options/style__color__selectors__text.html) | ["#000000", "#000000"] | [A](https://d3.statosio.com/options/style__color__selectors__text.html#example-a), [B](https://d3.statosio.com/options/style__color__selectors__text.html#example-b) | Colorize the font of the selection. Use "hex" values or "html" color-names. |
162
+ | D.8. | [styleFontSizeText](https://d3.statosio.com/options/style__font__size__text.html) | 10 | [A](https://d3.statosio.com/options/style__font__size__text.html#example-a), [B](https://d3.statosio.com/options/style__font__size__text.html#example-b) | Set default font size, including selection. |
163
+ | D.9. | [styleFontSizeTitle](https://d3.statosio.com/options/style__font__size__title.html) | 18 | [A](https://d3.statosio.com/options/style__font__size__title.html#example-a), [B](https://d3.statosio.com/options/style__font__size__title.html#example-b) | Set font size of title |
164
+ | D.10. | [styleFontFamily](https://d3.statosio.com/options/style__font__family.html) | "arial" | [A](https://d3.statosio.com/options/style__font__family.html#example-a), [B](https://d3.statosio.com/options/style__font__family.html#example-b) | Set default font family |
165
+ | D.11. | [styleFontFormatSelectors](https://d3.statosio.com/options/style__font__format__selectors.html) | ["bold", "normal"] | [A](https://d3.statosio.com/options/style__font__format__selectors.html#example-a), [B](https://d3.statosio.com/options/style__font__format__selectors.html#example-b) | Set format of content use "Html" Syntax ("bold", "underline", "normal" etc.). |
166
+ | D.12. | [styleStrokeAverage](https://d3.statosio.com/options/style__stroke__average.html) | 2 | [A](https://d3.statosio.com/options/style__stroke__average.html#example-a), [B](https://d3.statosio.com/options/style__stroke__average.html#example-b) | Set stroke weight of average line. |
167
+ | D.13. | [styleStrokeGridline](https://d3.statosio.com/options/style__stroke__gridline.html) | 2 | [A](https://d3.statosio.com/options/style__stroke__gridline.html#example-a), [B](https://d3.statosio.com/options/style__stroke__gridline.html#example-b) | Set stroke weight of gridline. |
168
+ | D.14. | [styleLegendRectSizeFull](https://d3.statosio.com/options/style__legend__rect_size__full.html) | 16 | [A](https://d3.statosio.com/options/style__legend__rect_size__full.html#example-a), [B](https://d3.statosio.com/options/style__legend__rect_size__full.html#example-b) | Set rectangle size of legend item. |
169
+ | D.15. | [styleOtherCircleChartRadius](https://d3.statosio.com/options/style__other__circle_chart_radius.html) | 4 | [A](https://d3.statosio.com/options/style__other__circle_chart_radius.html#example-a), [B](https://d3.statosio.com/options/style__other__circle_chart_radius.html#example-b) | Set radius of circle. |
170
+ | D.16. | [styleOtherRangeXTextRotation](https://d3.statosio.com/options/style__other__range_x_text_rotation.html) | -45 | [A](https://d3.statosio.com/options/style__other__range_x_text_rotation.html#example-a), [B](https://d3.statosio.com/options/style__other__range_x_text_rotation.html#example-b) | Set text rotation of the x axis. |
171
+
172
+ ## Contributing
173
+
174
+ Bug reports and pull requests are welcome on GitHub at https://github.com/a6b8/statosio.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/a6b8/statosio/blob/master/CODE_OF_CONDUCT.md).
175
+
176
+ ## License
177
+
178
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
179
+
180
+ ## Code of Conduct
181
+
182
+ Everyone interacting in the Statosio project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/a6b8/statosio/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
@@ -0,0 +1,1459 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "44709dec",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Functions"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "60793629",
14
+ "metadata": {},
15
+ "source": [
16
+ "## obj_prepare_path"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": 1,
22
+ "id": "3bbf3ab7",
23
+ "metadata": {},
24
+ "outputs": [
25
+ {
26
+ "data": {
27
+ "text/plain": [
28
+ ":obj_prepare_path"
29
+ ]
30
+ },
31
+ "execution_count": 1,
32
+ "metadata": {},
33
+ "output_type": "execute_result"
34
+ }
35
+ ],
36
+ "source": [
37
+ "def obj_prepare_path( obj, salt, status )\n",
38
+ " def helper_parse_path( str )\n",
39
+ " if str[ str.length - 1, 1 ] != '/'\n",
40
+ " str = str + '/'\n",
41
+ " end\n",
42
+ " return str\n",
43
+ " end\n",
44
+ "\n",
45
+ " def draw_obj_line_edge( l, offset )\n",
46
+ " str = ''\n",
47
+ " for i in 1..( ( l - 1 ) * offset )\n",
48
+ " str += ' '\n",
49
+ " end\n",
50
+ " if l > 1\n",
51
+ " str += \"┗\"\n",
52
+ " str += \"━\"\n",
53
+ " str += \" \"\n",
54
+ " else\n",
55
+ " str += ' '\n",
56
+ " end\n",
57
+ " return str\n",
58
+ " end\n",
59
+ " \n",
60
+ " def draw_obj_path_local( str, l, offset )\n",
61
+ " result = ''\n",
62
+ " for i in 0..( ( l - 1 ) * offset )\n",
63
+ " result += ' '\n",
64
+ " end\n",
65
+ " result += ''\n",
66
+ " result += str\n",
67
+ " return result\n",
68
+ " end\n",
69
+ "\n",
70
+ " def helper_obj_path( name, salt, k, f=nil )\n",
71
+ " str = ''\n",
72
+ " str += draw_obj_line_edge( name[ 1, name.length ].to_i, 4 )\n",
73
+ " str += 'hash[:path]'\n",
74
+ " if k.length == 0\n",
75
+ "\n",
76
+ " else\n",
77
+ " for i in 0..k.length-1\n",
78
+ " str += '[:children]'\n",
79
+ " str += '[:'\n",
80
+ " str += k[ i ].to_s\n",
81
+ " str += ']' \n",
82
+ " end\n",
83
+ " end\n",
84
+ "\n",
85
+ " if !f.nil?\n",
86
+ " str += '[:files][:'\n",
87
+ " str += f.to_s\n",
88
+ " str += '][:full]' \n",
89
+ " else\n",
90
+ " str += '[:full]'\n",
91
+ " end\n",
92
+ " return str\n",
93
+ " end\n",
94
+ " \n",
95
+ " def helper_insert_salt( salt, str )\n",
96
+ " if salt[ 0, 1 ] == ''\n",
97
+ " \n",
98
+ " else\n",
99
+ " if salt[ 0, 1 ] == '-'\n",
100
+ " else\n",
101
+ " salt = '-' + salt \n",
102
+ " end\n",
103
+ " end\n",
104
+ "\n",
105
+ " str = str.gsub( \"{{SALT}}\", salt )\n",
106
+ " return str\n",
107
+ " end\n",
108
+ "\n",
109
+ " def helper_parse_path( str )\n",
110
+ " if str[ str.length - 1, 1 ] != '/'\n",
111
+ " str = str + '/'\n",
112
+ " end\n",
113
+ " return str\n",
114
+ " end\n",
115
+ "\n",
116
+ " def draw_obj_line_edge( l, offset )\n",
117
+ " str = ''\n",
118
+ " for i in 1..( ( l - 1 ) * offset )\n",
119
+ " str += ' '\n",
120
+ " end\n",
121
+ " if l > 1\n",
122
+ " str += \"┗\"\n",
123
+ " str += \"━\"\n",
124
+ " str += \" \"\n",
125
+ " else\n",
126
+ " str += ' '\n",
127
+ " end\n",
128
+ " return str\n",
129
+ " end\n",
130
+ " \n",
131
+ " def draw_obj_path_local( str, l, offset )\n",
132
+ " result = ''\n",
133
+ " for i in 0..( ( l - 1 ) * offset )\n",
134
+ " result += ' '\n",
135
+ " end\n",
136
+ " result = result[ 1, result.length ]\n",
137
+ " \n",
138
+ " if str.index('.') != nil\n",
139
+ " result += 'File: '\n",
140
+ " else\n",
141
+ " result += 'Folder: '\n",
142
+ " end\n",
143
+ " result += str\n",
144
+ " return result\n",
145
+ " end\n",
146
+ "\n",
147
+ " def helper_obj_path( name, salt, k, f=nil )\n",
148
+ " str = ''\n",
149
+ " str += draw_obj_line_edge( name[ 1, name.length ].to_i, 4 )\n",
150
+ " str += ''\n",
151
+ " str += 'hash[:path]'\n",
152
+ " if k.length == 0\n",
153
+ "\n",
154
+ " else\n",
155
+ " for i in 0..k.length-1\n",
156
+ " str += '[:children]'\n",
157
+ " str += '[:'\n",
158
+ " str += k[ i ].to_s\n",
159
+ " str += ']' \n",
160
+ " end\n",
161
+ " end\n",
162
+ "\n",
163
+ " if !f.nil?\n",
164
+ " str += '[:files][:'\n",
165
+ " str += f.to_s\n",
166
+ " str += '][:full]' \n",
167
+ " else\n",
168
+ " str += '[:full]'\n",
169
+ " end\n",
170
+ " return str\n",
171
+ " end\n",
172
+ " \n",
173
+ " def helper_insert_salt( salt, str )\n",
174
+ " if salt[ 0, 1 ] == ''\n",
175
+ " \n",
176
+ " else\n",
177
+ " if salt[ 0, 1 ] == '-'\n",
178
+ " else\n",
179
+ " salt = '-' + salt \n",
180
+ " end\n",
181
+ " end\n",
182
+ "\n",
183
+ " str = str.gsub( \"{{SALT}}\", salt )\n",
184
+ " return str\n",
185
+ " end\n",
186
+ "\n",
187
+ " mode = {\n",
188
+ " :general => nil,\n",
189
+ " :hash => nil,\n",
190
+ " :path => nil\n",
191
+ " }\n",
192
+ " \n",
193
+ " case status\n",
194
+ " when 0\n",
195
+ " mode[:general] = false\n",
196
+ " mode[:hash] = false\n",
197
+ " mode[:path] = false\n",
198
+ " when 1\n",
199
+ " mode[:general] = true\n",
200
+ " mode[:hash] = true\n",
201
+ " mode[:path] = false\n",
202
+ " when 2\n",
203
+ " mode[:general] = true\n",
204
+ " mode[:hash] = false\n",
205
+ " mode[:path] = true\n",
206
+ " when 3\n",
207
+ " mode[:general] = true\n",
208
+ " mode[:hash] = true\n",
209
+ " mode[:path] = true\n",
210
+ " end\n",
211
+ " \n",
212
+ " \n",
213
+ " mode[:general] ? puts( 'TREE OVERVIEW' ) : ''\n",
214
+ " \n",
215
+ " obj[:full] = ''\n",
216
+ " obj[:full] += obj[:root]\n",
217
+ " obj[:full] += helper_parse_path( helper_insert_salt( salt, obj[:name] ) )\n",
218
+ " \n",
219
+ " mode[:hash] ? puts( helper_obj_path( 'l1', salt, [ ] ) ) : ''\n",
220
+ " mode[:path] ? puts( draw_obj_path_local( obj[:full], 2, 4 ) ) : ''\n",
221
+ "\n",
222
+ " obj[:children].keys.each { | l2 | \n",
223
+ " obj[:children][ l2 ][:full] = ''\n",
224
+ " obj[:children][ l2 ][:full] += obj[:full]\n",
225
+ " obj[:children][ l2 ][:full] += helper_parse_path( helper_insert_salt( salt, obj[:children][ l2 ][:name] ) )\n",
226
+ " mode[:hash] ? puts( helper_obj_path( 'l2', salt, [ l2 ] ) ) : ''\n",
227
+ " mode[:path] ? puts( draw_obj_path_local( obj[:children][ l2 ][:full], 3, 4 ) ) : ''\n",
228
+ " FileUtils.mkdir_p obj[:children][ l2 ][:full]\n",
229
+ "\n",
230
+ " if !obj[:children][ l2 ][:files].nil?\n",
231
+ " obj[:children][ l2 ][:files].keys.each { | f1 | \n",
232
+ " obj[:children][ l2 ][:files][ f1 ][:full] = '' \n",
233
+ " obj[:children][ l2 ][:files][ f1 ][:full] += obj[:children][ l2 ][:full] \n",
234
+ " obj[:children][ l2 ][:files][ f1 ][:full] += helper_insert_salt( salt, obj[:children][ l2 ][:files][ f1 ][:name] )\n",
235
+ " mode[:hash] ? puts( helper_obj_path( 'l2', salt, [ l2 ], f1 ) ) : ''\n",
236
+ " mode[:path] ? puts( draw_obj_path_local( obj[:children][ l2 ][:files][ f1 ][:full], 3, 4 ) ) : ''\n",
237
+ " }\n",
238
+ " end\n",
239
+ "\n",
240
+ " if !obj[:children][ l2 ][:children].nil?\n",
241
+ " obj[:children][ l2 ][:children].keys.each { | l3 | \n",
242
+ " obj[:children][ l2 ][:children][ l3 ][:full] = ''\n",
243
+ " obj[:children][ l2 ][:children][ l3 ][:full] += obj[:children][ l2 ][:full]\n",
244
+ " obj[:children][ l2 ][:children][ l3 ][:full] += helper_parse_path( helper_insert_salt( salt, obj[:children][ l2 ][:children][ l3 ][:name] ) )\n",
245
+ "\n",
246
+ " FileUtils.mkdir_p obj[:children][ l2 ][:children][ l3 ][:full]\n",
247
+ " mode[:hash] ? puts( helper_obj_path( 'l3', salt, [ l2, l3 ] ) ) : ''\n",
248
+ " mode[:path] ? puts( draw_obj_path_local( obj[:children][ l2 ][:children][ l3 ][:full], 4, 4 ) ) : ''\n",
249
+ "\n",
250
+ " if !obj[:children][ l2 ][:children][ l3 ][:files].nil?\n",
251
+ " obj[:children][ l2 ][:children][ l3 ][:files].keys.each { | f2 | \n",
252
+ " obj[:children][ l2 ][:children][ l3 ][:files][ f2 ][:full] = ''\n",
253
+ " obj[:children][ l2 ][:children][ l3 ][:files][ f2 ][:full] += obj[:children][ l2 ][:children][ l3 ][:full]\n",
254
+ " obj[:children][ l2 ][:children][ l3 ][:files][ f2 ][:full] += helper_insert_salt( salt, obj[:children][ l2 ][:children][ l3 ][:files][ f2 ][:name] )\n",
255
+ " mode[:hash] ? puts( helper_obj_path( 'l3', salt, [ l2, l3 ], f2 ) ) : ''\n",
256
+ " mode[:path] ? puts( draw_obj_path_local( obj[:children][ l2 ][:children][ l3 ][:files][ f2 ][:full], 4, 4 ) ) : ''\n",
257
+ " }\n",
258
+ " end\n",
259
+ " }\n",
260
+ " end\n",
261
+ " }\n",
262
+ " return obj\n",
263
+ "end"
264
+ ]
265
+ },
266
+ {
267
+ "cell_type": "markdown",
268
+ "id": "cfe05ab8",
269
+ "metadata": {},
270
+ "source": [
271
+ "## boilerplate_create"
272
+ ]
273
+ },
274
+ {
275
+ "cell_type": "code",
276
+ "execution_count": 2,
277
+ "id": "fc56b50e",
278
+ "metadata": {},
279
+ "outputs": [
280
+ {
281
+ "data": {
282
+ "text/plain": [
283
+ ":boilerplate_create"
284
+ ]
285
+ },
286
+ "execution_count": 2,
287
+ "metadata": {},
288
+ "output_type": "execute_result"
289
+ }
290
+ ],
291
+ "source": [
292
+ "def boilerplate_create( obj )\n",
293
+ " files = {\n",
294
+ " d3: nil,\n",
295
+ " statosio: nil,\n",
296
+ " html: nil,\n",
297
+ " ruby: nil\n",
298
+ " }\n",
299
+ "\n",
300
+ " files\n",
301
+ " .keys.each do | key |\n",
302
+ " p = ''\n",
303
+ " p += obj[:path][:children][:jupyter][:children][:templates][:full]\n",
304
+ " p += key.to_s\n",
305
+ " \n",
306
+ " k = ''\n",
307
+ " if key == :html or key == :ruby\n",
308
+ " k = '.txt'\n",
309
+ " else\n",
310
+ " k = '.js'\n",
311
+ " end\n",
312
+ "\n",
313
+ " p += k\n",
314
+ " files[ key ] = File.read( p )\n",
315
+ " end\n",
316
+ " \n",
317
+ " \n",
318
+ " item = {}\n",
319
+ " keys = [ :d3, :statosio ]\n",
320
+ " keys.each { | key | item[ key ] = { sub: '<--' + key.to_s + '-->', value: nil } }\n",
321
+ " \n",
322
+ " values = [ :d3, :statosio ]\n",
323
+ " values.each { | key | item[ key ][:value] = files[ key ] }\n",
324
+ " \n",
325
+ " html = files[:html].clone\n",
326
+ " item.keys.each { | key | html.gsub!( item[ key ][:sub], item[ key ][:value] ) }\n",
327
+ " \n",
328
+ " ruby = File.read( obj[:path][:children][:jupyter][:children][:templates][:files][:ruby][:full] )\n",
329
+ " ruby.gsub!( \"<<--boilerplate-->>\", html )\n",
330
+ " \n",
331
+ " path = obj[:path][:children][:lib][:files][:boilerplate][:full]\n",
332
+ " File.open( path, \"w\" ) { | f | f.write( ruby ) }\n",
333
+ " \n",
334
+ " return true\n",
335
+ "end"
336
+ ]
337
+ },
338
+ {
339
+ "cell_type": "markdown",
340
+ "id": "56944408",
341
+ "metadata": {},
342
+ "source": [
343
+ "## example_values"
344
+ ]
345
+ },
346
+ {
347
+ "cell_type": "code",
348
+ "execution_count": 3,
349
+ "id": "c59f5550",
350
+ "metadata": {},
351
+ "outputs": [
352
+ {
353
+ "data": {
354
+ "text/plain": [
355
+ ":example_values"
356
+ ]
357
+ },
358
+ "execution_count": 3,
359
+ "metadata": {},
360
+ "output_type": "execute_result"
361
+ }
362
+ ],
363
+ "source": [
364
+ "def example_values( obj )\n",
365
+ " path = obj[:path][:children][:jupyter][:children][:templates][:files][:dataset][:full]\n",
366
+ " values = { dataset: nil }\n",
367
+ "\n",
368
+ " tmp = JSON.parse( File.read( path ) ).with_indifferent_access\n",
369
+ " values[:dataset] = tmp[:data]\n",
370
+ " values[:x] = 'name'\n",
371
+ " values[:y] = 'mobile'\n",
372
+ " values[:options] = {}\n",
373
+ " return values\n",
374
+ "end"
375
+ ]
376
+ },
377
+ {
378
+ "cell_type": "markdown",
379
+ "id": "bf68bdeb",
380
+ "metadata": {},
381
+ "source": [
382
+ "## boilerplate_test"
383
+ ]
384
+ },
385
+ {
386
+ "cell_type": "code",
387
+ "execution_count": 4,
388
+ "id": "7b218452",
389
+ "metadata": {},
390
+ "outputs": [
391
+ {
392
+ "data": {
393
+ "text/plain": [
394
+ ":boilerplate_test"
395
+ ]
396
+ },
397
+ "execution_count": 4,
398
+ "metadata": {},
399
+ "output_type": "execute_result"
400
+ }
401
+ ],
402
+ "source": [
403
+ "def boilerplate_test( obj, values )\n",
404
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
405
+ " require module_path\n",
406
+ " a = Boilerplate.new\n",
407
+ " a.set_markers_value( values )\n",
408
+ " a.set_boilerplate\n",
409
+ " html = a.get_boilerplate\n",
410
+ " path = obj[:path][:children][:jupyter][:children][:test][:files][:test][:full]\n",
411
+ " File.open( path, \"w\" ) { | f | f.write( html ) } \n",
412
+ " return html\n",
413
+ "end"
414
+ ]
415
+ },
416
+ {
417
+ "cell_type": "markdown",
418
+ "id": "18581fe7",
419
+ "metadata": {},
420
+ "source": [
421
+ "## module_test_svg"
422
+ ]
423
+ },
424
+ {
425
+ "cell_type": "code",
426
+ "execution_count": 5,
427
+ "id": "721107c8",
428
+ "metadata": {},
429
+ "outputs": [
430
+ {
431
+ "data": {
432
+ "text/plain": [
433
+ ":module_test_html"
434
+ ]
435
+ },
436
+ "execution_count": 5,
437
+ "metadata": {},
438
+ "output_type": "execute_result"
439
+ }
440
+ ],
441
+ "source": [
442
+ "def module_test_html( obj, values )\n",
443
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
444
+ " require module_path\n",
445
+ " a = Statosio::Generate.new\n",
446
+ " html = a.render_prepare( values )\n",
447
+ " path = obj[:path][:children][:jupyter][:children][:test][:files][:gem][:full]\n",
448
+ " File.open( path, \"w\" ) { | f | f.write( html ) } \n",
449
+ " return true\n",
450
+ "end"
451
+ ]
452
+ },
453
+ {
454
+ "cell_type": "markdown",
455
+ "id": "0fdc9aa4",
456
+ "metadata": {},
457
+ "source": [
458
+ "## module_test_svg"
459
+ ]
460
+ },
461
+ {
462
+ "cell_type": "code",
463
+ "execution_count": 6,
464
+ "id": "733cbfb3",
465
+ "metadata": {},
466
+ "outputs": [
467
+ {
468
+ "data": {
469
+ "text/plain": [
470
+ ":module_test_svg"
471
+ ]
472
+ },
473
+ "execution_count": 6,
474
+ "metadata": {},
475
+ "output_type": "execute_result"
476
+ }
477
+ ],
478
+ "source": [
479
+ "def module_test_svg( obj, values )\n",
480
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
481
+ " require module_path\n",
482
+ " a = Statosio::Generate.new\n",
483
+ " svg = a.render_svg( values )\n",
484
+ " return svg\n",
485
+ "end"
486
+ ]
487
+ },
488
+ {
489
+ "cell_type": "markdown",
490
+ "id": "7a7a3b4a",
491
+ "metadata": {},
492
+ "source": [
493
+ "## module_test_generate"
494
+ ]
495
+ },
496
+ {
497
+ "cell_type": "code",
498
+ "execution_count": 7,
499
+ "id": "caa69d91",
500
+ "metadata": {},
501
+ "outputs": [
502
+ {
503
+ "data": {
504
+ "text/plain": [
505
+ ":module_test_generate"
506
+ ]
507
+ },
508
+ "execution_count": 7,
509
+ "metadata": {},
510
+ "output_type": "execute_result"
511
+ }
512
+ ],
513
+ "source": [
514
+ "def module_test_generate( obj )\n",
515
+ " path = obj[:path][:children][:jupyter][:children][:templates][:files][:dataset][:full]\n",
516
+ " data = JSON.parse( File.read( path ) ).with_indifferent_access\n",
517
+ " \n",
518
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
519
+ " require module_path\n",
520
+ " a = Statosio::Generate.new\n",
521
+ " svg = a.svg( dataset: data[:data], x: 'name', y: 'mobile', options: {}, silent: false)\n",
522
+ " return svg\n",
523
+ "end"
524
+ ]
525
+ },
526
+ {
527
+ "cell_type": "markdown",
528
+ "id": "3cb56f16",
529
+ "metadata": {},
530
+ "source": [
531
+ "## module_test_svg_w_prawn"
532
+ ]
533
+ },
534
+ {
535
+ "cell_type": "code",
536
+ "execution_count": 8,
537
+ "id": "30d068e3",
538
+ "metadata": {},
539
+ "outputs": [
540
+ {
541
+ "data": {
542
+ "text/plain": [
543
+ ":module_test_svg_w_prawn"
544
+ ]
545
+ },
546
+ "execution_count": 8,
547
+ "metadata": {},
548
+ "output_type": "execute_result"
549
+ }
550
+ ],
551
+ "source": [
552
+ "def module_test_svg_w_prawn( obj, values )\n",
553
+ " require 'prawn'\n",
554
+ " require 'prawn-svg'\n",
555
+ " \n",
556
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
557
+ " require module_path\n",
558
+ " \n",
559
+ " path = obj[:path][:children][:jupyter][:children][:test][:files][:svg][:full]\n",
560
+ " Prawn::Document.generate( path ) do | doc |\n",
561
+ " svg_path = module_test_svg( obj, values )\n",
562
+ " doc.svg svg_path\n",
563
+ " end\n",
564
+ "end"
565
+ ]
566
+ },
567
+ {
568
+ "cell_type": "markdown",
569
+ "id": "504de5c4",
570
+ "metadata": {},
571
+ "source": [
572
+ "## module_test_generate_w_prawn"
573
+ ]
574
+ },
575
+ {
576
+ "cell_type": "code",
577
+ "execution_count": 9,
578
+ "id": "e7922063",
579
+ "metadata": {},
580
+ "outputs": [
581
+ {
582
+ "data": {
583
+ "text/plain": [
584
+ ":module_test_generate_w_prawn"
585
+ ]
586
+ },
587
+ "execution_count": 9,
588
+ "metadata": {},
589
+ "output_type": "execute_result"
590
+ }
591
+ ],
592
+ "source": [
593
+ "def module_test_generate_w_prawn( obj )\n",
594
+ " require 'prawn'\n",
595
+ " require 'prawn-svg'\n",
596
+ " \n",
597
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
598
+ " require module_path\n",
599
+ " \n",
600
+ " path = obj[:path][:children][:jupyter][:children][:test][:files][:generate][:full]\n",
601
+ " Prawn::Document.generate( path ) do | doc |\n",
602
+ " svg_path = module_test_generate( obj )\n",
603
+ " doc.svg svg_path\n",
604
+ " end\n",
605
+ "end"
606
+ ]
607
+ },
608
+ {
609
+ "cell_type": "markdown",
610
+ "id": "d0829ef3",
611
+ "metadata": {},
612
+ "source": [
613
+ "## values_validation"
614
+ ]
615
+ },
616
+ {
617
+ "cell_type": "code",
618
+ "execution_count": 10,
619
+ "id": "1b616b98",
620
+ "metadata": {},
621
+ "outputs": [
622
+ {
623
+ "data": {
624
+ "text/plain": [
625
+ ":values_validation"
626
+ ]
627
+ },
628
+ "execution_count": 10,
629
+ "metadata": {},
630
+ "output_type": "execute_result"
631
+ }
632
+ ],
633
+ "source": [
634
+ "def values_validation( dataset: nil, x: nil, y: nil, options: nil, allow_list: nil, silent: false ) \n",
635
+ " def check_dataset( dataset, messages, errors )\n",
636
+ " if !dataset.nil?\n",
637
+ " if dataset.class.to_s == 'Array'\n",
638
+ " if dataset[ 0 ].class.to_s == 'Hash' or dataset[ 0 ].class.to_s == 'ActiveSupport::HashWithIndifferentAccess'\n",
639
+ " if dataset[ 0 ].keys.length > 1\n",
640
+ " search = dataset[ 0 ].keys\n",
641
+ " keys = dataset\n",
642
+ " .map { | a | a.keys }\n",
643
+ " .flatten\n",
644
+ " .to_set\n",
645
+ " .to_a\n",
646
+ " if keys.eql? search\n",
647
+ " else\n",
648
+ " errors.push( messages[:dataset][ 4 ])\n",
649
+ " end\n",
650
+ " else\n",
651
+ " errors.push( messages[:dataset][ 3 ])\n",
652
+ " end\n",
653
+ " else\n",
654
+ " errors.push( messages[:dataset][ 2 ] )\n",
655
+ " end\n",
656
+ " else\n",
657
+ " errors.push( messages[:dataset][ 1 ] )\n",
658
+ " end\n",
659
+ " else\n",
660
+ " errors.push( messages[:dataset][ 0 ] )\n",
661
+ " end\n",
662
+ " return errors\n",
663
+ " end\n",
664
+ "\n",
665
+ "\n",
666
+ " def check_x( x, messages, errors )\n",
667
+ " if !x.nil?\n",
668
+ " if x.class.to_s == \"String\"\n",
669
+ " else\n",
670
+ " errors.push( messages[:x][ 1 ] )\n",
671
+ " end\n",
672
+ " else\n",
673
+ " errors.push( messages[:x][ 0 ] )\n",
674
+ " end\n",
675
+ " return errors\n",
676
+ " end\n",
677
+ "\n",
678
+ "\n",
679
+ " def check_y( y, messages, errors )\n",
680
+ " if !y.nil?\n",
681
+ " if y.class.to_s == 'String' or y.class.to_s == 'Array'\n",
682
+ " else\n",
683
+ " errors.push( messages[:y][ 1 ] )\n",
684
+ " end\n",
685
+ " else\n",
686
+ " errors.push( messages[:y][ 0 ] )\n",
687
+ " end\n",
688
+ " return errors\n",
689
+ " end \n",
690
+ "\n",
691
+ "\n",
692
+ " def check_options( options, messages, allow_list, errors )\n",
693
+ " def str_difference( a, b )\n",
694
+ " a = a.to_s.downcase.split( '_' ).join( '' )\n",
695
+ " b = b.to_s.downcase.split( '_' ).join( '' )\n",
696
+ " longer = [ a.size, b.size ].max\n",
697
+ " same = a\n",
698
+ " .each_char\n",
699
+ " .zip( b.each_char )\n",
700
+ " .select { | a, b | a == b }\n",
701
+ " .size\n",
702
+ " ( longer - same ) / a.size.to_f\n",
703
+ " end\n",
704
+ "\n",
705
+ "\n",
706
+ " if !options.nil?\n",
707
+ " if options.class.to_s == 'Hash'\n",
708
+ " options.keys.each do | key |\n",
709
+ " if allow_list.include?( key.to_s )\n",
710
+ " else\n",
711
+ " tmp = messages[:options][ 2 ][ 0 ]\n",
712
+ " tmp = tmp.gsub( '<--key-->', key.to_s)\n",
713
+ "\n",
714
+ " nearest = allow_list\n",
715
+ " .map { | word | { score: str_difference( key, word ), word: word } }\n",
716
+ " .min_by { | item | item[:score] }\n",
717
+ " tmp = tmp.gsub( '<--similar-->', nearest[:word] )\n",
718
+ " errors.push( [ tmp, messages[:options][ 2 ][ 1 ] ] )\n",
719
+ " end\n",
720
+ " end\n",
721
+ " else\n",
722
+ " errors.push( messages[:options][ 1 ] )\n",
723
+ " end\n",
724
+ " else\n",
725
+ " errors.push( messages[:options][ 0 ] )\n",
726
+ " end\n",
727
+ "\n",
728
+ " return errors\n",
729
+ " end\n",
730
+ "\n",
731
+ "\n",
732
+ " def check_silent( silent, messages, errors )\n",
733
+ " value = silent.class.to_s\n",
734
+ " if value == 'FalseClass' or value == 'TrueClass'\n",
735
+ " else\n",
736
+ " errors.push( messages[:silent][ 0 ] )\n",
737
+ " end\n",
738
+ " return errors\n",
739
+ " end\n",
740
+ "\n",
741
+ "\n",
742
+ " messages = {\n",
743
+ " dataset: [\n",
744
+ " [ \"dataset:\\t is empty. Expect: \\\"Array\\\" [{},{}]\", :d0 ],\n",
745
+ " [ \"dataset:\\t is not class \\\"Array\\\"\", :d1 ],\n",
746
+ " [ \"dataset:\\t is not class \\\"Hash\\\"\", :d2 ],\n",
747
+ " [ \"dataset:\\t \\\"Hash\\\" has less then 2 keys\", :d3 ],\n",
748
+ " [ \"dataset:\\t have diffrent keys\", :d4 ]\n",
749
+ " ],\n",
750
+ " x: [\n",
751
+ " [ \"x:\\t\\t is empty. Expect: \\\"String\\\"\", :x0 ],\n",
752
+ " [ \"x:\\t\\t is not Class \\\"String\\\"\", :x1 ]\n",
753
+ " ],\n",
754
+ " y: [\n",
755
+ " [ \"y:\\t\\t is empty. Expect: \\\"String\\\"\", :y0 ],\n",
756
+ " [ \"y:\\t\\t is not Class \\\"String\\\"\", :y1 ]\n",
757
+ " ],\n",
758
+ " options: [\n",
759
+ " [ \"options:\\t is empty. Expect: \\\"Hash\\\"\", :o0 ],\n",
760
+ " [ \"options:\\t is not Class \\\"Hash\\\"\", :o1 ],\n",
761
+ " [ \"options:\\t key: \\\"<--key-->\\\" is not a valid parameter, did you mean: \\\"<--similar-->\\\"? For more Information visit: https://docs.statosio.com/options/<--similar-->\", :o2 ]\n",
762
+ " ],\n",
763
+ " silent: [\n",
764
+ " [ \"silent:\\t is not Class \\\"Hash\\\"\", :s0 ]\n",
765
+ " ]\n",
766
+ " }\n",
767
+ "\n",
768
+ " errors = []\n",
769
+ " errors = check_dataset( dataset, messages, errors )\n",
770
+ " errors = check_y( y, messages, errors )\n",
771
+ " errors = check_x( x, messages, errors )\n",
772
+ " errors = check_options( options, messages, allow_list, errors )\n",
773
+ " errors = check_silent( silent, messages, errors )\n",
774
+ "\n",
775
+ " if silent == false\n",
776
+ " if errors.length != 0\n",
777
+ " puts errors.length.to_s + ' Errors found: '\n",
778
+ " errors.each { | error | puts( ' - ' + error[ 0 ] ) }\n",
779
+ " end\n",
780
+ " end\n",
781
+ "\n",
782
+ " return errors\n",
783
+ "end"
784
+ ]
785
+ },
786
+ {
787
+ "cell_type": "markdown",
788
+ "id": "0e06be6e",
789
+ "metadata": {},
790
+ "source": [
791
+ "## values_validation_test"
792
+ ]
793
+ },
794
+ {
795
+ "cell_type": "code",
796
+ "execution_count": 11,
797
+ "id": "31131f9c",
798
+ "metadata": {},
799
+ "outputs": [
800
+ {
801
+ "data": {
802
+ "text/plain": [
803
+ ":values_validation_test"
804
+ ]
805
+ },
806
+ "execution_count": 11,
807
+ "metadata": {},
808
+ "output_type": "execute_result"
809
+ }
810
+ ],
811
+ "source": [
812
+ "def values_validation_test( obj, mode, debug )\n",
813
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
814
+ " require module_path\n",
815
+ " a = Statosio::Generate.new\n",
816
+ " options_allow_list = a.get_options_allow_list\n",
817
+ " \n",
818
+ " validations = {\n",
819
+ " dataset: [\n",
820
+ " [ nil, :d0 ],\n",
821
+ " [ '', :d1 ],\n",
822
+ " [ 23, :d1 ],\n",
823
+ " [ {}, :d1 ],\n",
824
+ " [ [], :d2 ],\n",
825
+ " [ [ {} ], :d3 ],\n",
826
+ " [ [ { a: '23' } ], :d3 ],\n",
827
+ " [ [ { a: '23', b: '23' } ], :ok ],\n",
828
+ " [ [ { a: 23, b: 23 }, { a: 23, b: 23, c: 232 } ], :d4 ],\n",
829
+ " [ [ { a: 23, b: 23, c: 2323 }, { a: 23, b: 23, c: 232 } ], :ok ]\n",
830
+ " ],\n",
831
+ " x: [\n",
832
+ " [ nil, :x0 ],\n",
833
+ " [ '', :ok ],\n",
834
+ " [ 1, :x1 ],\n",
835
+ " [ [], :x1 ],\n",
836
+ " [ {}, :x1 ],\n",
837
+ " ],\n",
838
+ " y: [\n",
839
+ " [ nil, :y0 ],\n",
840
+ " [ 2, :y1 ],\n",
841
+ " [ '', :ok ],\n",
842
+ " [ [], :ok ],\n",
843
+ " [ {}, :y1 ]\n",
844
+ " ],\n",
845
+ " options: [\n",
846
+ " [ nil, :o0 ],\n",
847
+ " [ '', :o1 ],\n",
848
+ " [ 2, :o1 ],\n",
849
+ " [ [], :o1 ],\n",
850
+ " [ {}, :ok ],\n",
851
+ " [ { 'showLegend': 'dede' }, :ok ],\n",
852
+ " [ { show_legend: 'dede' }, :o2 ],\n",
853
+ " [ { show__legend: 'dede', 'showTitle': false, 'show__Title': false }, :o2 ],\n",
854
+ " ],\n",
855
+ " silent: [\n",
856
+ " [ nil, :s0 ],\n",
857
+ " [ '', :s0 ],\n",
858
+ " [ 2, :s0 ],\n",
859
+ " [ {}, :s0 ],\n",
860
+ " [ [], :s0 ],\n",
861
+ " [ true, :ok ]\n",
862
+ " ]\n",
863
+ " }\n",
864
+ "\n",
865
+ " results = []\n",
866
+ "\n",
867
+ " index = 0\n",
868
+ " validations.keys.each do | type |\n",
869
+ " if mode == 'detail' or mode == 'user'\n",
870
+ " puts type.to_s + ':'\n",
871
+ " end\n",
872
+ " validations[ type ].each do | test |\n",
873
+ " case type\n",
874
+ " when :dataset\n",
875
+ " codes = values_validation( dataset: test[ 0 ], x: nil, y: nil, options: nil, allow_list: options_allow_list, silent: debug )\n",
876
+ " when :x\n",
877
+ " codes = values_validation( dataset: nil, x: test[ 0 ], y: '', options: nil, allow_list: options_allow_list, silent: debug )\n",
878
+ " when :y\n",
879
+ " codes = values_validation( dataset: nil, x: nil, y: test[ 0 ], options: nil, allow_list: options_allow_list, silent: debug )\n",
880
+ " when :options\n",
881
+ " codes = values_validation( dataset: [ { a: 1, b: 2 } ], x: '', y: [ '' ], options: test[ 0 ], allow_list: options_allow_list, silent: debug )\n",
882
+ " when :silent\n",
883
+ " codes = values_validation( dataset: nil, x: nil, y: nil, options: nil, allow_list: options_allow_list, silent: test[ 0 ] )\n",
884
+ " end\n",
885
+ "\n",
886
+ " short = type.to_s[ 0, 1 ]\n",
887
+ " find = codes.select do | a | \n",
888
+ " a[ 1 ].to_s[ 0, 1 ] == short ? true : false \n",
889
+ " end\n",
890
+ "\n",
891
+ " if find.length == 0 and test[ 1 ] == :ok\n",
892
+ " result = true\n",
893
+ " else\n",
894
+ " result = find[0].include?( test[ 1 ] )\n",
895
+ " end\n",
896
+ " results.push( result )\n",
897
+ " case mode\n",
898
+ " when 'detail'\n",
899
+ " index.to_s.length == 1 ? m = ' ' : m = ''\n",
900
+ " print ' [' + index.to_s + '] ' + m\n",
901
+ " if find.length == 0 \n",
902
+ " print \"Code: \" + find.to_s + \"\\t\"\n",
903
+ " else\n",
904
+ " print \"Code: \" + find[ 0 ][ 1 ].to_s + \"\\t\"\n",
905
+ " end\n",
906
+ " \n",
907
+ " print \"Expect: \" + test[ 1 ].to_s + \"\\t\"\n",
908
+ " print \"Result: \" + result.to_s\n",
909
+ " puts\n",
910
+ " index = index + 1\n",
911
+ " when 'user'\n",
912
+ " index.to_s.length == 1 ? m = ' ' : m = ''\n",
913
+ " print ' [' + index.to_s + '] ' + m\n",
914
+ " # print codes[ 0 ]\n",
915
+ " puts\n",
916
+ " index = index + 1\n",
917
+ " when 'result'\n",
918
+ " end\n",
919
+ " end\n",
920
+ " if mode == 'detail' or mode == 'user'\n",
921
+ " puts\n",
922
+ " end\n",
923
+ " end\n",
924
+ " \n",
925
+ " if mode == 'result'\n",
926
+ " all = results.to_set.to_a == [true]\n",
927
+ " print 'All tests were passed successfully: '\n",
928
+ " print all.to_s\n",
929
+ " end\n",
930
+ " \n",
931
+ " return true\n",
932
+ "end"
933
+ ]
934
+ },
935
+ {
936
+ "cell_type": "markdown",
937
+ "id": "68aef192",
938
+ "metadata": {},
939
+ "source": [
940
+ "## example_svg"
941
+ ]
942
+ },
943
+ {
944
+ "cell_type": "code",
945
+ "execution_count": 29,
946
+ "id": "e0f2a3fe",
947
+ "metadata": {},
948
+ "outputs": [
949
+ {
950
+ "data": {
951
+ "text/plain": [
952
+ ":example_svg"
953
+ ]
954
+ },
955
+ "execution_count": 29,
956
+ "metadata": {},
957
+ "output_type": "execute_result"
958
+ }
959
+ ],
960
+ "source": [
961
+ "def example_svg( obj )\n",
962
+ " require 'open-uri'\n",
963
+ "\n",
964
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
965
+ " require module_path\n",
966
+ "\n",
967
+ " url = obj[:example][:dataset]\n",
968
+ " content = URI.open( url ).read\n",
969
+ " dataset = JSON.parse( content )\n",
970
+ "\n",
971
+ " statosio = Statosio::Generate.new\n",
972
+ " svg = statosio.svg(\n",
973
+ " dataset: dataset,\n",
974
+ " x: 'name',\n",
975
+ " y: 'mobile',\n",
976
+ " options: {}\n",
977
+ " )\n",
978
+ "\n",
979
+ " \n",
980
+ " path = obj[:path][:children][:jupyter][:children][:example][:files][:one][:full]\n",
981
+ " File.open( path, \"w\" ) { | f | f.write( svg ) }\n",
982
+ " \n",
983
+ " puts svg[ 0, 20 ] + ' ... '\n",
984
+ "end"
985
+ ]
986
+ },
987
+ {
988
+ "cell_type": "markdown",
989
+ "id": "3518dc05",
990
+ "metadata": {},
991
+ "source": [
992
+ "## example_prawn"
993
+ ]
994
+ },
995
+ {
996
+ "cell_type": "code",
997
+ "execution_count": 35,
998
+ "id": "63831d01",
999
+ "metadata": {},
1000
+ "outputs": [
1001
+ {
1002
+ "data": {
1003
+ "text/plain": [
1004
+ ":example_prawn"
1005
+ ]
1006
+ },
1007
+ "execution_count": 35,
1008
+ "metadata": {},
1009
+ "output_type": "execute_result"
1010
+ }
1011
+ ],
1012
+ "source": [
1013
+ "def example_prawn( obj )\n",
1014
+ " require 'open-uri'\n",
1015
+ "\n",
1016
+ " module_path = obj[:path][:children][:lib][:files][:statosio][:full]\n",
1017
+ " require module_path\n",
1018
+ "\n",
1019
+ " require 'prawn'\n",
1020
+ " require 'prawn-svg'\n",
1021
+ "\n",
1022
+ " # Initialize Statosio\n",
1023
+ " statosio = Statosio::Generate.new\n",
1024
+ "\n",
1025
+ " # Load Sample Dataset\n",
1026
+ " url = obj[:example][:dataset]\n",
1027
+ " content = URI.open( url ).read\n",
1028
+ " dataset = JSON.parse( content )\n",
1029
+ "\n",
1030
+ " # Generate Statosio\n",
1031
+ " chart = statosio.svg(\n",
1032
+ " dataset: dataset,\n",
1033
+ " x: \"name\",\n",
1034
+ " y: 'mobile',\n",
1035
+ " options: {\n",
1036
+ " styleColorSelectorsChart: [\"#E2B08E\", \"#CC8074\"],\n",
1037
+ " styleColorCanvasBackground: \"none\",\n",
1038
+ " styleColorGridline: \"#2F3138\",\n",
1039
+ " styleStrokeGridline: 1,\n",
1040
+ " styleColorFont: \"#BABABA\",\n",
1041
+ " styleColorSelectorsText: [\"#E2B08E\", \"#BABABA\"],\n",
1042
+ " showAverage: false\n",
1043
+ " }\n",
1044
+ " )\n",
1045
+ " \n",
1046
+ " # Generate .pdf\n",
1047
+ " path = obj[:path][:children][:jupyter][:children][:example][:files][:two][:full]\n",
1048
+ " Prawn::Document.generate( path ) do | pdf |\n",
1049
+ " pdf.svg( chart, width: 500, )\n",
1050
+ " end\n",
1051
+ " return true\n",
1052
+ "end"
1053
+ ]
1054
+ },
1055
+ {
1056
+ "cell_type": "markdown",
1057
+ "id": "89066688",
1058
+ "metadata": {},
1059
+ "source": [
1060
+ "# Execute"
1061
+ ]
1062
+ },
1063
+ {
1064
+ "cell_type": "code",
1065
+ "execution_count": 12,
1066
+ "id": "7c36bb85",
1067
+ "metadata": {},
1068
+ "outputs": [
1069
+ {
1070
+ "data": {
1071
+ "text/plain": [
1072
+ "true"
1073
+ ]
1074
+ },
1075
+ "execution_count": 12,
1076
+ "metadata": {},
1077
+ "output_type": "execute_result"
1078
+ }
1079
+ ],
1080
+ "source": [
1081
+ "require 'json'\n",
1082
+ "require 'active_support/core_ext/hash'\n",
1083
+ "require 'puppeteer'\n",
1084
+ "require 'prawn'\n",
1085
+ "require 'prawn-svg'"
1086
+ ]
1087
+ },
1088
+ {
1089
+ "cell_type": "code",
1090
+ "execution_count": 26,
1091
+ "id": "9012064d",
1092
+ "metadata": {
1093
+ "scrolled": true
1094
+ },
1095
+ "outputs": [
1096
+ {
1097
+ "name": "stdout",
1098
+ "output_type": "stream",
1099
+ "text": [
1100
+ "TREE OVERVIEW\n",
1101
+ " hash[:path][:full]\n",
1102
+ " ┗━ hash[:path][:children][:jupyter][:full]\n",
1103
+ " ┗━ hash[:path][:children][:jupyter][:children][:templates][:full]\n",
1104
+ " ┗━ hash[:path][:children][:jupyter][:children][:templates][:files][:dataset][:full]\n",
1105
+ " ┗━ hash[:path][:children][:jupyter][:children][:templates][:files][:html][:full]\n",
1106
+ " ┗━ hash[:path][:children][:jupyter][:children][:templates][:files][:ruby][:full]\n",
1107
+ " ┗━ hash[:path][:children][:jupyter][:children][:test][:full]\n",
1108
+ " ┗━ hash[:path][:children][:jupyter][:children][:test][:files][:test][:full]\n",
1109
+ " ┗━ hash[:path][:children][:jupyter][:children][:test][:files][:gem][:full]\n",
1110
+ " ┗━ hash[:path][:children][:jupyter][:children][:test][:files][:svg][:full]\n",
1111
+ " ┗━ hash[:path][:children][:jupyter][:children][:test][:files][:generate][:full]\n",
1112
+ " ┗━ hash[:path][:children][:jupyter][:children][:example][:full]\n",
1113
+ " ┗━ hash[:path][:children][:jupyter][:children][:example][:files][:one][:full]\n",
1114
+ " ┗━ hash[:path][:children][:jupyter][:children][:example][:files][:two][:full]\n",
1115
+ " ┗━ hash[:path][:children][:lib][:full]\n",
1116
+ " ┗━ hash[:path][:children][:lib][:files][:statosio][:full]\n",
1117
+ " ┗━ hash[:path][:children][:lib][:files][:boilerplate][:full]\n",
1118
+ "\n"
1119
+ ]
1120
+ }
1121
+ ],
1122
+ "source": [
1123
+ "hash = {\n",
1124
+ " path: {\n",
1125
+ " root: '.',\n",
1126
+ " name: '/',\n",
1127
+ " children: {\n",
1128
+ " jupyter: {\n",
1129
+ " name: 'jupyter',\n",
1130
+ " children: {\n",
1131
+ " templates: {\n",
1132
+ " name: '0-templates',\n",
1133
+ " files: {\n",
1134
+ " dataset: {\n",
1135
+ " name: 'dataset.json',\n",
1136
+ " },\n",
1137
+ " html: {\n",
1138
+ " name: 'test.html',\n",
1139
+ " },\n",
1140
+ " ruby: {\n",
1141
+ " name: 'ruby.txt',\n",
1142
+ " }\n",
1143
+ " }\n",
1144
+ " },\n",
1145
+ " test: {\n",
1146
+ " name: '1-test',\n",
1147
+ " files: {\n",
1148
+ " test: {\n",
1149
+ " name: 'boilerplate-test.html',\n",
1150
+ " },\n",
1151
+ " gem: {\n",
1152
+ " name: 'module-test-html.html',\n",
1153
+ " },\n",
1154
+ " svg: {\n",
1155
+ " name: 'module-test-generate-svg.pdf',\n",
1156
+ " },\n",
1157
+ " generate: {\n",
1158
+ " name: 'module-test-generate.pdf'\n",
1159
+ " }\n",
1160
+ " }\n",
1161
+ " },\n",
1162
+ " example: {\n",
1163
+ " name: '2-examples',\n",
1164
+ " files: {\n",
1165
+ " one: {\n",
1166
+ " name: '0-example1.svg'\n",
1167
+ " },\n",
1168
+ " two: {\n",
1169
+ " name: '1-example2.pdf'\n",
1170
+ " }\n",
1171
+ " }\n",
1172
+ " }\n",
1173
+ " }\n",
1174
+ " },\n",
1175
+ " lib: {\n",
1176
+ " name: 'lib',\n",
1177
+ " files: {\n",
1178
+ " statosio: {\n",
1179
+ " name: 'statosio.rb'\n",
1180
+ " },\n",
1181
+ " boilerplate: {\n",
1182
+ " name: 'boilerplate.rb'\n",
1183
+ " }\n",
1184
+ " }\n",
1185
+ " }\n",
1186
+ " }\n",
1187
+ " },\n",
1188
+ " example: {\n",
1189
+ " dataset: 'https://d3.statosio.com/data/performance.json'\n",
1190
+ " }\n",
1191
+ "}\n",
1192
+ "\n",
1193
+ "\n",
1194
+ "hash[:path] = obj_prepare_path( hash[:path], '', 1 )\n",
1195
+ "puts"
1196
+ ]
1197
+ },
1198
+ {
1199
+ "cell_type": "markdown",
1200
+ "id": "55fc8828",
1201
+ "metadata": {},
1202
+ "source": [
1203
+ "## Boilerplate Create"
1204
+ ]
1205
+ },
1206
+ {
1207
+ "cell_type": "code",
1208
+ "execution_count": 14,
1209
+ "id": "929e1383",
1210
+ "metadata": {},
1211
+ "outputs": [
1212
+ {
1213
+ "data": {
1214
+ "text/plain": [
1215
+ "true"
1216
+ ]
1217
+ },
1218
+ "execution_count": 14,
1219
+ "metadata": {},
1220
+ "output_type": "execute_result"
1221
+ }
1222
+ ],
1223
+ "source": [
1224
+ "boilerplate_create( hash )"
1225
+ ]
1226
+ },
1227
+ {
1228
+ "cell_type": "markdown",
1229
+ "id": "b48e85b7",
1230
+ "metadata": {},
1231
+ "source": [
1232
+ "## Boilerplate Test"
1233
+ ]
1234
+ },
1235
+ {
1236
+ "cell_type": "code",
1237
+ "execution_count": 15,
1238
+ "id": "48f709e6",
1239
+ "metadata": {},
1240
+ "outputs": [
1241
+ {
1242
+ "name": "stdout",
1243
+ "output_type": "stream",
1244
+ "text": [
1245
+ "\n"
1246
+ ]
1247
+ }
1248
+ ],
1249
+ "source": [
1250
+ "values = example_values( hash )\n",
1251
+ "html = boilerplate_test( hash, values )\n",
1252
+ "puts"
1253
+ ]
1254
+ },
1255
+ {
1256
+ "cell_type": "markdown",
1257
+ "id": "bd468eef",
1258
+ "metadata": {},
1259
+ "source": [
1260
+ "## Module Test generate_html"
1261
+ ]
1262
+ },
1263
+ {
1264
+ "cell_type": "code",
1265
+ "execution_count": 16,
1266
+ "id": "0b0f1c19",
1267
+ "metadata": {},
1268
+ "outputs": [
1269
+ {
1270
+ "data": {
1271
+ "text/plain": [
1272
+ "true"
1273
+ ]
1274
+ },
1275
+ "execution_count": 16,
1276
+ "metadata": {},
1277
+ "output_type": "execute_result"
1278
+ }
1279
+ ],
1280
+ "source": [
1281
+ "values = example_values( hash )\n",
1282
+ "html_path = module_test_html( hash, values )"
1283
+ ]
1284
+ },
1285
+ {
1286
+ "cell_type": "markdown",
1287
+ "id": "d5fcc8a2",
1288
+ "metadata": {},
1289
+ "source": [
1290
+ "## Module Test generate_svg"
1291
+ ]
1292
+ },
1293
+ {
1294
+ "cell_type": "code",
1295
+ "execution_count": 23,
1296
+ "id": "e45bc5e3",
1297
+ "metadata": {},
1298
+ "outputs": [
1299
+ {
1300
+ "name": "stdout",
1301
+ "output_type": "stream",
1302
+ "text": [
1303
+ "\n"
1304
+ ]
1305
+ }
1306
+ ],
1307
+ "source": [
1308
+ "values = example_values( hash )\n",
1309
+ "svg_path = module_test_svg( hash, values )\n",
1310
+ "puts"
1311
+ ]
1312
+ },
1313
+ {
1314
+ "cell_type": "markdown",
1315
+ "id": "e115e0e5",
1316
+ "metadata": {},
1317
+ "source": [
1318
+ "## Module Test generate_svg w/ prawn"
1319
+ ]
1320
+ },
1321
+ {
1322
+ "cell_type": "code",
1323
+ "execution_count": 18,
1324
+ "id": "721a3394",
1325
+ "metadata": {},
1326
+ "outputs": [],
1327
+ "source": [
1328
+ "values = example_values( hash )\n",
1329
+ "module_test_svg_w_prawn( hash, values )"
1330
+ ]
1331
+ },
1332
+ {
1333
+ "cell_type": "markdown",
1334
+ "id": "e987f1a6",
1335
+ "metadata": {},
1336
+ "source": [
1337
+ "## Module Test Validation"
1338
+ ]
1339
+ },
1340
+ {
1341
+ "cell_type": "code",
1342
+ "execution_count": 19,
1343
+ "id": "cc8084cf",
1344
+ "metadata": {},
1345
+ "outputs": [
1346
+ {
1347
+ "name": "stdout",
1348
+ "output_type": "stream",
1349
+ "text": [
1350
+ "All tests were passed successfully: true"
1351
+ ]
1352
+ },
1353
+ {
1354
+ "data": {
1355
+ "text/plain": [
1356
+ "true"
1357
+ ]
1358
+ },
1359
+ "execution_count": 19,
1360
+ "metadata": {},
1361
+ "output_type": "execute_result"
1362
+ }
1363
+ ],
1364
+ "source": [
1365
+ "index = 1\n",
1366
+ "modes = [ 'detail', 'result' ]\n",
1367
+ "values_validation_test( hash, modes[ index ], true )"
1368
+ ]
1369
+ },
1370
+ {
1371
+ "cell_type": "markdown",
1372
+ "id": "313464d3",
1373
+ "metadata": {},
1374
+ "source": [
1375
+ "## Module Test generate w/ prawn"
1376
+ ]
1377
+ },
1378
+ {
1379
+ "cell_type": "code",
1380
+ "execution_count": 20,
1381
+ "id": "11158e15",
1382
+ "metadata": {},
1383
+ "outputs": [],
1384
+ "source": [
1385
+ "module_test_generate_w_prawn( hash )"
1386
+ ]
1387
+ },
1388
+ {
1389
+ "cell_type": "markdown",
1390
+ "id": "b92e937b",
1391
+ "metadata": {},
1392
+ "source": [
1393
+ "## Example SVG"
1394
+ ]
1395
+ },
1396
+ {
1397
+ "cell_type": "code",
1398
+ "execution_count": 30,
1399
+ "id": "7f9b13d7",
1400
+ "metadata": {},
1401
+ "outputs": [
1402
+ {
1403
+ "name": "stdout",
1404
+ "output_type": "stream",
1405
+ "text": [
1406
+ "<svg width=\"600\" hei ... \n"
1407
+ ]
1408
+ }
1409
+ ],
1410
+ "source": [
1411
+ "example_svg( hash )"
1412
+ ]
1413
+ },
1414
+ {
1415
+ "cell_type": "markdown",
1416
+ "id": "b5d86afd",
1417
+ "metadata": {},
1418
+ "source": [
1419
+ "## Example Prawn"
1420
+ ]
1421
+ },
1422
+ {
1423
+ "cell_type": "code",
1424
+ "execution_count": 36,
1425
+ "id": "96a4d0ab",
1426
+ "metadata": {},
1427
+ "outputs": [
1428
+ {
1429
+ "data": {
1430
+ "text/plain": [
1431
+ "true"
1432
+ ]
1433
+ },
1434
+ "execution_count": 36,
1435
+ "metadata": {},
1436
+ "output_type": "execute_result"
1437
+ }
1438
+ ],
1439
+ "source": [
1440
+ "example_prawn( hash )"
1441
+ ]
1442
+ }
1443
+ ],
1444
+ "metadata": {
1445
+ "kernelspec": {
1446
+ "display_name": "Ruby 3.0.0",
1447
+ "language": "ruby",
1448
+ "name": "ruby"
1449
+ },
1450
+ "language_info": {
1451
+ "file_extension": ".rb",
1452
+ "mimetype": "application/x-ruby",
1453
+ "name": "ruby",
1454
+ "version": "3.0.0"
1455
+ }
1456
+ },
1457
+ "nbformat": 4,
1458
+ "nbformat_minor": 5
1459
+ }