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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 658a25239c266d3ecdb01b9a7e189fe872e527b93f2eebf4d18a1ced0c6f44b7
4
- data.tar.gz: a568dcedbed1b33cd18f5a8fac81acb997557962475f7930399c0d805a0b6ab3
3
+ metadata.gz: 8fee18603afa8aec4d2c471600e870e6af834f5a1fd5925367edc6eabe188a70
4
+ data.tar.gz: 5faeaba4a23775b134654ccca0097a888c3e4b486ea6d09fa11d8cff4bf294d3
5
5
  SHA512:
6
- metadata.gz: a07937c18a85e031d0dbe2abcda2d9c3234327cccac545841f159f147e9ed542cbec0c6ad31bc7a68d5e5f6e5fb287a0b3187ce5368f268e85ffb3c2010fde17
7
- data.tar.gz: de9ed1c8abd005edb7dba4a86596feaa833a28093b42f9c108803bbc9700cd218f62f6b5315b245669ab99f23d18fb3b901828bbfdfa1430993de936abb4330f
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
 
@@ -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
 
@@ -27,6 +27,5 @@ module Metricky
27
27
  raise NameError, "period must be one of #{Groupdate::PERIODS}. It is #{period}."
28
28
  end
29
29
  deprecate_and_alias_method :valid_period?, :valid_trend?
30
-
31
30
  end
32
31
  end
@@ -1,3 +1,3 @@
1
1
  module Metricky
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metricky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Brody