chartkick 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -3
- data/README.md +1 -1
- data/lib/chartkick.rb +2 -26
- data/lib/chartkick/enumerable.rb +25 -0
- data/lib/chartkick/helper.rb +2 -1
- data/lib/chartkick/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5791c4748533e3fa0eaa1b2e1c6fbbffc726f8ab663f4590edfd0b9555894909
|
4
|
+
data.tar.gz: fb3e99507dcdf7934cf1bfc25052ba14f8c109af05379a45b47fda728c2eb3b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e417d6dcc2ae547cd63c7ded309329b112cfc9b6195c29c08d6192e3dbba4c630695815cc65f3d23e3b3833bdafc46bb04809b708362de8d98ee5f04568fbca3
|
7
|
+
data.tar.gz: 730f4f49ced271c3f7e15e3a3e57d5f3f81c08d5a2bd0de3792ec6e2747c433bd37b185bd38db2dfaede7aa0c5ab0ad63255d30a675379e7035182df898bf836
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
## 3.4.1 (2020-10-06)
|
2
|
+
|
3
|
+
- Relaxed validation for `width` and `height` options
|
4
|
+
|
1
5
|
## 3.4.0 (2020-08-04)
|
2
6
|
|
3
|
-
- Fixed CSS injection with `width` and `height` options
|
7
|
+
- Fixed CSS injection with `width` and `height` options - [more info](https://github.com/ankane/chartkick/issues/546)
|
4
8
|
|
5
9
|
## 3.3.2 (2020-07-23)
|
6
10
|
|
@@ -9,7 +13,7 @@
|
|
9
13
|
## 3.3.1 (2019-12-26)
|
10
14
|
|
11
15
|
- Updated Chart.js to 2.9.3
|
12
|
-
- Fixed
|
16
|
+
- Fixed deprecation warnings in Ruby 2.7
|
13
17
|
|
14
18
|
## 3.3.0 (2019-11-09)
|
15
19
|
|
@@ -27,7 +31,7 @@
|
|
27
31
|
|
28
32
|
## 3.2.0 (2019-06-04)
|
29
33
|
|
30
|
-
- Fixed XSS vulnerability -
|
34
|
+
- Fixed XSS vulnerability - [more info](https://github.com/ankane/chartkick/issues/488)
|
31
35
|
|
32
36
|
## 3.1.0 (2019-05-26)
|
33
37
|
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Create beautiful JavaScript charts with one line of Ruby. No more fighting with
|
|
4
4
|
|
5
5
|
[See it in action](https://chartkick.com)
|
6
6
|
|
7
|
-
:fire: For admin charts and dashboards, check out [Blazer](https://github.com/ankane/blazer/)
|
7
|
+
:fire: For admin charts and dashboards, check out [Blazer](https://github.com/ankane/blazer/), and for advanced visualizations, check out [Vega](https://github.com/ankane/vega)
|
8
8
|
|
9
9
|
:two_hearts: A perfect companion to [Groupdate](https://github.com/ankane/groupdate), [Hightop](https://github.com/ankane/hightop), and [ActiveMedian](https://github.com/ankane/active_median)
|
10
10
|
|
data/lib/chartkick.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# modules
|
2
|
+
require "chartkick/enumerable"
|
1
3
|
require "chartkick/helper"
|
2
4
|
require "chartkick/version"
|
3
5
|
|
@@ -18,29 +20,3 @@ module Chartkick
|
|
18
20
|
end
|
19
21
|
self.options = {}
|
20
22
|
end
|
21
|
-
|
22
|
-
# for multiple series
|
23
|
-
# use Enumerable so it can be called on arrays
|
24
|
-
module Enumerable
|
25
|
-
def chart_json
|
26
|
-
if is_a?(Hash)
|
27
|
-
if (key = keys.first) && key.is_a?(Array) && key.size == 2
|
28
|
-
group_by { |k, _v| k[0] }.map do |name, data|
|
29
|
-
{name: name, data: data.map { |k, v| [k[1], v] }}
|
30
|
-
end
|
31
|
-
else
|
32
|
-
to_a
|
33
|
-
end
|
34
|
-
elsif is_a?(Array)
|
35
|
-
map do |v|
|
36
|
-
if v.is_a?(Hash) && v[:data].is_a?(Hash)
|
37
|
-
v = v.dup
|
38
|
-
v[:data] = v[:data].to_a
|
39
|
-
end
|
40
|
-
v
|
41
|
-
end
|
42
|
-
else
|
43
|
-
self
|
44
|
-
end.to_json
|
45
|
-
end
|
46
|
-
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# for both multiple series and
|
2
|
+
# making sure hash order is preserved in JavaScript
|
3
|
+
module Enumerable
|
4
|
+
def chart_json
|
5
|
+
if is_a?(Hash)
|
6
|
+
if (key = keys.first) && key.is_a?(Array) && key.size == 2
|
7
|
+
group_by { |k, _v| k[0] }.map do |name, data|
|
8
|
+
{name: name, data: data.map { |k, v| [k[1], v] }}
|
9
|
+
end
|
10
|
+
else
|
11
|
+
to_a
|
12
|
+
end
|
13
|
+
elsif is_a?(Array)
|
14
|
+
map do |v|
|
15
|
+
if v.is_a?(Hash) && v[:data].is_a?(Hash)
|
16
|
+
v = v.dup
|
17
|
+
v[:data] = v[:data].to_a
|
18
|
+
end
|
19
|
+
v
|
20
|
+
end
|
21
|
+
else
|
22
|
+
self
|
23
|
+
end.to_json
|
24
|
+
end
|
25
|
+
end
|
data/lib/chartkick/helper.rb
CHANGED
@@ -77,7 +77,8 @@ module Chartkick
|
|
77
77
|
css_vars.each_key do |k|
|
78
78
|
# limit to alphanumeric and % for simplicity
|
79
79
|
# this prevents things like calc() but safety is the priority
|
80
|
-
|
80
|
+
# dot does not need escaped in square brackets
|
81
|
+
raise ArgumentError, "Invalid #{k}" unless css_vars[k] =~ /\A[a-zA-Z0-9%.]*\z/
|
81
82
|
# we limit above, but escape for safety as fail-safe
|
82
83
|
# to prevent XSS injection in worse-case scenario
|
83
84
|
css_vars[k] = ERB::Util.html_escape(css_vars[k])
|
data/lib/chartkick/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chartkick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email: andrew@chartkick.com
|
57
57
|
executables: []
|
58
58
|
extensions: []
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- lib/chartkick.rb
|
65
65
|
- lib/chartkick/engine.rb
|
66
|
+
- lib/chartkick/enumerable.rb
|
66
67
|
- lib/chartkick/helper.rb
|
67
68
|
- lib/chartkick/sinatra.rb
|
68
69
|
- lib/chartkick/version.rb
|
@@ -72,7 +73,7 @@ homepage: https://chartkick.com
|
|
72
73
|
licenses:
|
73
74
|
- MIT
|
74
75
|
metadata: {}
|
75
|
-
post_install_message:
|
76
|
+
post_install_message:
|
76
77
|
rdoc_options: []
|
77
78
|
require_paths:
|
78
79
|
- lib
|
@@ -87,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
89
90
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
91
|
-
signing_key:
|
91
|
+
rubygems_version: 3.0.3
|
92
|
+
signing_key:
|
92
93
|
specification_version: 4
|
93
94
|
summary: Create beautiful JavaScript charts with one line of Ruby
|
94
95
|
test_files: []
|