metricky 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/metricky/base.rb +5 -1
- data/lib/metricky/helper.rb +2 -2
- data/lib/metricky/period.rb +0 -1
- data/lib/metricky/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fee18603afa8aec4d2c471600e870e6af834f5a1fd5925367edc6eabe188a70
|
4
|
+
data.tar.gz: 5faeaba4a23775b134654ccca0097a888c3e4b486ea6d09fa11d8cff4bf294d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a34d17f88e51b726fc3292d73219d4d0f47d1d271c53ab9db101b1c5fffdcb949baf9f00a897504f954a12cb4b4af26d8bb758c97a65b589c055f22e793198e8
|
7
|
+
data.tar.gz: 224db269c7b2f86d463d8c91e2403d8662bd8c16f422ff90d950324191180c801521b477686b7f0771f53bda166765a042b6d53691e189f834acef46a00f5ead
|
data/README.md
CHANGED
@@ -66,6 +66,14 @@ Then drop in Chartkick into your `application.js` (or similar):
|
|
66
66
|
|
67
67
|
~~Blatantly ripped from~~ Super-inspired by Laravel Nova's metric system.
|
68
68
|
|
69
|
+
### Sending more data into the metric
|
70
|
+
|
71
|
+
Need to pass `current_user`?
|
72
|
+
|
73
|
+
```erbruby
|
74
|
+
render_metric :users, user: current_user
|
75
|
+
```
|
76
|
+
|
69
77
|
### Value to calculate
|
70
78
|
|
71
79
|
In your metric, define columns:
|
data/lib/metricky/base.rb
CHANGED
@@ -5,8 +5,12 @@ module Metricky
|
|
5
5
|
class Base
|
6
6
|
VALID_TYPES = [:sum, :max, :min, :average, :count].freeze
|
7
7
|
attr_reader :params, :query
|
8
|
-
def initialize(params = {})
|
8
|
+
def initialize(params, options = {})
|
9
9
|
@params = params
|
10
|
+
options.each do |k,v|
|
11
|
+
self.class.attr_reader k
|
12
|
+
self.instance_variable_set("@#{k}", v)
|
13
|
+
end
|
10
14
|
@query = nil
|
11
15
|
end
|
12
16
|
|
data/lib/metricky/helper.rb
CHANGED
@@ -6,7 +6,7 @@ module Metricky
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
def render_metric(metric_name)
|
9
|
+
def render_metric(metric_name, options = {})
|
10
10
|
if metric_name.is_a?(String) || metric_name.is_a?(Symbol)
|
11
11
|
metric_name = metric_name.to_s
|
12
12
|
if metric_name.end_with?("Metric")
|
@@ -19,7 +19,7 @@ module Metricky
|
|
19
19
|
else
|
20
20
|
metric = metric_name
|
21
21
|
end
|
22
|
-
metric = metric.new(params)
|
22
|
+
metric = metric.new(params, options)
|
23
23
|
render metric, metric: metric
|
24
24
|
end
|
25
25
|
|
data/lib/metricky/period.rb
CHANGED
data/lib/metricky/version.rb
CHANGED