groupdate 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16e0f474a6785462e83ab5811c44e54bc71689ce
4
- data.tar.gz: 7b66609e83996472c4e501f1502d4b76f73f4908
3
+ metadata.gz: 0b555424def0887e8b0ab933f26c84844a6e9b8b
4
+ data.tar.gz: c16d375c965c0d289ffc8476435b47b61e09ebf2
5
5
  SHA512:
6
- metadata.gz: 260e9bf32e334238baa95e59b085418aedc824046312699d69827f6b54a736287d68a70a87bb22a62f936b5336efe0f60012c59e1d1d9babc0c9b5434702767c
7
- data.tar.gz: 5fe2dab3320cb3b0b119191440a490d967a12174290afa872d499858173c9a0c099867fff28e018369a3a8d8bc0e1afd2bc532ebcfa70c649e6dbbc4ae7a79f3
6
+ metadata.gz: 835b67dacd82ce1fde549847fcf2647cad712ef75a14841c13b42d06ce95f606c4f5db124f0795dedace821d9c0113211b6d4c011a9c29cfc717fe2cbbc4e643
7
+ data.tar.gz: 3cb677877505d1f09ad3067fbc0777f4db8d0330429710d43f38544b0782dec7ce1c98f7f9d488c947f9c8de4bb638fced6475e98514c06c6a4ad72891852a01
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 2.1
4
+ - 2.2
5
5
  - jruby
6
6
  gemfile:
7
7
  - Gemfile
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.5.0
2
+
3
+ - Added `group_by_period` method
4
+ - Added `current` option
5
+ - Raise `ArgumentError` if no block given to enumerable
6
+
1
7
  ## 2.4.0
2
8
 
3
9
  - Added localization
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in groupdate.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -15,7 +15,7 @@ Works with Rails 3.1+
15
15
 
16
16
  Supports PostgreSQL and MySQL, plus arrays and hashes
17
17
 
18
- [![Build Status](https://travis-ci.org/ankane/groupdate.png)](https://travis-ci.org/ankane/groupdate)
18
+ [![Build Status](https://travis-ci.org/ankane/groupdate.svg?branch=master)](https://travis-ci.org/ankane/groupdate)
19
19
 
20
20
  :cupid: Goes hand in hand with [Chartkick](http://ankane.github.io/chartkick/)
21
21
 
@@ -115,6 +115,12 @@ To get the most recent time periods, use:
115
115
  User.group_by_week(:created_at, last: 8).count # last 8 weeks
116
116
  ```
117
117
 
118
+ To exclude the current period, use:
119
+
120
+ ```ruby
121
+ User.group_by_week(:created_at, last: 8, current: false).count
122
+ ```
123
+
118
124
  ### Order
119
125
 
120
126
  You can order in descending order with:
@@ -129,32 +135,61 @@ or
129
135
  User.group_by_day(:created_at).order("day desc").count
130
136
  ```
131
137
 
132
- ### Pretty Keys
138
+ ### Format
133
139
 
134
140
  To get keys in a different format, use:
135
141
 
136
142
  ```ruby
137
- User.group_by_hour_of_day(:created_at, format: "%l %P").count.keys.first # 12 am
143
+ User.group_by_day(:created_at, format: "%b %-e, %Y").count
144
+ # {
145
+ # "Jan 1, 2015" => 10
146
+ # "Jan 2, 2015" => 12
147
+ # }
148
+ ```
149
+
150
+ or
151
+
152
+ ```ruby
153
+ User.group_by_hour_of_day(:created_at, format: "%-l %P").count
154
+ # {
155
+ # "12 am" => 15,
156
+ # "1 am" => 11
157
+ # ...
158
+ # }
138
159
  ```
139
160
 
140
161
  Takes a `String`, which is passed to [strftime](http://strfti.me/), or a `Proc`. You can pass a locale with the `locale` option.
141
162
 
163
+ ### Dynamic Grouping
164
+
165
+ ```ruby
166
+ User.group_by_period(:day, :created_at).count
167
+ ```
168
+
169
+ Limit groupings with the `permit` option.
170
+
171
+ ```ruby
172
+ User.group_by_period(params[:period], :created_at, permit: %w[day week]).count
173
+ ```
174
+
175
+ Raises an `ArgumentError` for unpermitted periods.
176
+
142
177
  ## Arrays and Hashes
143
178
 
144
179
  ```ruby
145
- users.group_by_day{|u| u.created_at } # or group_by_day(&:created_at)
180
+ users.group_by_day { |u| u.created_at } # or group_by_day(&:created_at)
146
181
  ```
147
182
 
148
183
  Supports the same options as above
149
184
 
150
185
  ```ruby
151
- users.group_by_day(time_zone: time_zone){|u| u.created_at }
186
+ users.group_by_day(time_zone: time_zone) { |u| u.created_at }
152
187
  ```
153
188
 
154
189
  Count
155
190
 
156
191
  ```ruby
157
- Hash[ users.group_by_day{|u| u.created_at }.map{|k, v| [k, v.size] } ]
192
+ Hash[ users.group_by_day { |u| u.created_at }.map { |k, v| [k, v.size] } ]
158
193
  ```
159
194
 
160
195
  ## Installation
data/groupdate.gemspec CHANGED
@@ -1,19 +1,19 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'groupdate/version'
4
+ require "groupdate/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "groupdate"
8
8
  spec.version = Groupdate::VERSION
9
9
  spec.authors = ["Andrew Kane"]
10
10
  spec.email = ["acekane1@gmail.com"]
11
- spec.description = %q{The simplest way to group temporal data}
12
- spec.summary = %q{The simplest way to group temporal data}
11
+ spec.description = "The simplest way to group temporal data"
12
+ spec.summary = "The simplest way to group temporal data"
13
13
  spec.homepage = "https://github.com/ankane/groupdate"
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "activerecord-jdbcmysql-adapter"
31
31
  else
32
32
  spec.add_development_dependency "pg"
33
- spec.add_development_dependency "mysql2"
33
+ spec.add_development_dependency "mysql2", "~> 0.3.20"
34
34
  end
35
35
  end
data/lib/groupdate.rb CHANGED
@@ -5,7 +5,7 @@ require "groupdate/magic"
5
5
 
6
6
  module Groupdate
7
7
  FIELDS = [:second, :minute, :hour, :day, :week, :month, :year, :day_of_week, :hour_of_day, :day_of_month, :month_of_year]
8
- METHODS = FIELDS.map{|v| :"group_by_#{v}" }
8
+ METHODS = FIELDS.map { |v| :"group_by_#{v}" }
9
9
 
10
10
  mattr_accessor :week_start, :day_start, :time_zone
11
11
  self.week_start = :sun
@@ -7,8 +7,7 @@ ActiveRecord::Base.send(:extend, Groupdate::Scopes)
7
7
 
8
8
  module ActiveRecord
9
9
  class Relation
10
-
11
- if ActiveRecord::VERSION::MAJOR == 3 and ActiveRecord::VERSION::MINOR < 2
10
+ if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 2
12
11
 
13
12
  def method_missing_with_hack(method, *args, &block)
14
13
  if Groupdate::METHODS.include?(method)
@@ -20,7 +19,6 @@ module ActiveRecord
20
19
  alias_method_chain :method_missing, :hack
21
20
 
22
21
  end
23
-
24
22
  end
25
23
  end
26
24
 
@@ -38,7 +36,6 @@ end
38
36
  # https://github.com/rails/rails/issues/7121
39
37
  module ActiveRecord
40
38
  module Calculations
41
-
42
39
  private
43
40
 
44
41
  def column_alias_for_with_hack(*keys)
@@ -49,6 +46,5 @@ module ActiveRecord
49
46
  end
50
47
  end
51
48
  alias_method_chain :column_alias_for, :hack
52
-
53
49
  end
54
50
  end
@@ -1,9 +1,21 @@
1
1
  module Enumerable
2
-
3
2
  Groupdate::FIELDS.each do |field|
4
3
  define_method :"group_by_#{field}" do |options = {}, &block|
5
- Groupdate::Magic.new(field, options).group_by(self, &block)
4
+ if block
5
+ Groupdate::Magic.new(field, options).group_by(self, &block)
6
+ else
7
+ raise ArgumentError, "no block given"
8
+ end
6
9
  end
7
10
  end
8
11
 
12
+ def group_by_period(period, options = {}, &block)
13
+ # to_sym is unsafe on user input, so convert to strings
14
+ permitted_periods = ((options[:permit] || Groupdate::FIELDS).map(&:to_sym) & Groupdate::FIELDS).map(&:to_s)
15
+ if permitted_periods.include?(period.to_s)
16
+ send("group_by_#{period}", options, &block)
17
+ else
18
+ raise ArgumentError, "Unpermitted period"
19
+ end
20
+ end
9
21
  end
@@ -8,17 +8,17 @@ module Groupdate
8
8
  @field = field
9
9
  @options = options
10
10
 
11
- if !time_zone
11
+ unless time_zone
12
12
  raise "Unrecognized time zone"
13
13
  end
14
14
 
15
- if field == :week and !week_start
15
+ if field == :week && !week_start
16
16
  raise "Unrecognized :week_start option"
17
17
  end
18
18
  end
19
19
 
20
- def group_by(enum, &block)
21
- group = enum.group_by{|v| v = yield(v); v ? round_time(v) : nil }
20
+ def group_by(enum, &_block)
21
+ group = enum.group_by { |v| v = yield(v); v ? round_time(v) : nil }
22
22
  if options[:series] == false
23
23
  group
24
24
  else
@@ -108,7 +108,7 @@ module Groupdate
108
108
 
109
109
  def perform(relation, method, *args, &block)
110
110
  # undo reverse since we do not want this to appear in the query
111
- reverse = relation.reverse_order_value
111
+ reverse = relation.send(:reverse_order_value)
112
112
  if reverse
113
113
  relation = relation.except(:reverse_order)
114
114
  end
@@ -127,15 +127,15 @@ module Groupdate
127
127
  cast_method =
128
128
  case field
129
129
  when :day_of_week, :hour_of_day, :day_of_month, :month_of_year
130
- lambda{|k| k.to_i }
130
+ lambda { |k| k.to_i }
131
131
  else
132
132
  utc = ActiveSupport::TimeZone["UTC"]
133
- lambda{|k| (k.is_a?(String) ? utc.parse(k) : k.to_time).in_time_zone(time_zone) }
133
+ lambda { |k| (k.is_a?(String) ? utc.parse(k) : k.to_time).in_time_zone(time_zone) }
134
134
  end
135
135
 
136
136
  count =
137
137
  begin
138
- Hash[ relation.send(method, *args, &block).map{|k, v| [multiple_groups ? k[0...@group_index] + [cast_method.call(k[@group_index])] + k[(@group_index + 1)..-1] : cast_method.call(k), v] } ]
138
+ Hash[relation.send(method, *args, &block).map { |k, v| [multiple_groups ? k[0...@group_index] + [cast_method.call(k[@group_index])] + k[(@group_index + 1)..-1] : cast_method.call(k), v] }]
139
139
  rescue NoMethodError
140
140
  raise "Be sure to install time zone support - https://github.com/ankane/groupdate#for-mysql"
141
141
  end
@@ -163,10 +163,11 @@ module Groupdate
163
163
  def time_range
164
164
  @time_range ||= begin
165
165
  time_range = options[:range]
166
- if !time_range and options[:last]
166
+ if !time_range && options[:last]
167
167
  step = 1.send(field) if 1.respond_to?(field)
168
168
  if step
169
169
  now = Time.now
170
+ now -= step if options[:current] == false
170
171
  time_range = round_time(now - (options[:last].to_i - 1).send(field))..now
171
172
  end
172
173
  end
@@ -196,7 +197,7 @@ module Groupdate
196
197
  # use first and last values
197
198
  sorted_keys =
198
199
  if multiple_groups
199
- count.keys.map{|k| k[@group_index] }.sort
200
+ count.keys.map { |k| k[@group_index] }.sort
200
201
  else
201
202
  count.keys.sort
202
203
  end
@@ -208,26 +209,29 @@ module Groupdate
208
209
 
209
210
  step = 1.send(field)
210
211
 
211
- while (next_step = round_time(series.last + step)) and time_range.cover?(next_step)
212
+ while (next_step = round_time(series.last + step)) && time_range.cover?(next_step)
212
213
  series << next_step
213
214
  end
214
215
 
215
- if multiple_groups
216
- keys = count.keys.map{|k| k[0...@group_index] + k[(@group_index + 1)..-1] }.uniq
217
- series = series.reverse if reverse
218
- keys.flat_map do |k|
219
- series.map{|s| k[0...@group_index] + [s] + k[@group_index..-1] }
220
- end
221
- else
222
- series
223
- end
216
+ series
224
217
  else
225
218
  []
226
219
  end
227
220
  end
228
221
 
222
+ series =
223
+ if multiple_groups
224
+ keys = count.keys.map { |k| k[0...@group_index] + k[(@group_index + 1)..-1] }.uniq
225
+ series = series.reverse if reverse
226
+ keys.flat_map do |k|
227
+ series.map { |s| k[0...@group_index] + [s] + k[@group_index..-1] }
228
+ end
229
+ else
230
+ series
231
+ end
232
+
229
233
  # reversed above if multiple groups
230
- if !multiple_groups and reverse
234
+ if !multiple_groups && reverse
231
235
  series = series.to_a.reverse
232
236
  end
233
237
 
@@ -253,7 +257,7 @@ module Groupdate
253
257
  end
254
258
  end
255
259
  else
256
- lambda{|k| k }
260
+ lambda { |k| k }
257
261
  end
258
262
 
259
263
  value = 0
@@ -302,6 +306,5 @@ module Groupdate
302
306
  def activerecord42?
303
307
  ActiveRecord::VERSION::STRING.starts_with?("4.2.")
304
308
  end
305
-
306
309
  end
307
310
  end
@@ -1,6 +1,5 @@
1
1
  module Groupdate
2
2
  module Scopes
3
-
4
3
  Groupdate::FIELDS.each do |field|
5
4
  define_method :"group_by_#{field}" do |*args|
6
5
  args = args.dup
@@ -12,5 +11,14 @@ module Groupdate
12
11
  end
13
12
  end
14
13
 
14
+ def group_by_period(period, field, options = {})
15
+ # to_sym is unsafe on user input, so convert to strings
16
+ permitted_periods = ((options[:permit] || Groupdate::FIELDS).map(&:to_sym) & Groupdate::FIELDS).map(&:to_s)
17
+ if permitted_periods.include?(period.to_s)
18
+ send("group_by_#{period}", field, options)
19
+ else
20
+ raise ArgumentError, "Unpermitted period"
21
+ end
22
+ end
15
23
  end
16
24
  end
@@ -12,7 +12,7 @@ module Groupdate
12
12
  # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/calculations.rb
13
13
  if ActiveRecord::Calculations.method_defined?(method)
14
14
  magic.perform(relation, method, *args, &block)
15
- elsif @relation.respond_to?(method)
15
+ elsif @relation.respond_to?(method, true)
16
16
  Groupdate::Series.new(magic, relation.send(method, *args, &block))
17
17
  else
18
18
  super
@@ -22,6 +22,5 @@ module Groupdate
22
22
  def respond_to?(method, include_all = false)
23
23
  ActiveRecord::Calculations.method_defined?(method) || relation.respond_to?(method) || super
24
24
  end
25
-
26
25
  end
27
26
  end
@@ -1,3 +1,3 @@
1
1
  module Groupdate
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
@@ -14,8 +14,11 @@ class TestEnumerable < Minitest::Test
14
14
  assert_equal expected, [user_a, user_b].group_by_month(&:created_at)
15
15
  end
16
16
 
17
- def call_method(method, field, options)
18
- Hash[ User.all.to_a.send(:"group_by_#{method}", options){|u| u.send(field) }.map{|k, v| [k, v.size] } ]
17
+ def test_no_block
18
+ assert_raises(ArgumentError) { [].group_by_day(:created_at) }
19
19
  end
20
20
 
21
+ def call_method(method, field, options)
22
+ Hash[User.all.to_a.group_by_period(method, options) { |u| u.send(field) }.map { |k, v| [k, v.size] }]
23
+ end
21
24
  end
data/test/mysql_test.rb CHANGED
@@ -7,5 +7,4 @@ class TestMysql < Minitest::Test
7
7
  super
8
8
  User.establish_connection :adapter => "mysql2", :database => "groupdate_test", :username => "root"
9
9
  end
10
-
11
10
  end
@@ -7,5 +7,4 @@ class TestPostgresql < Minitest::Test
7
7
  super
8
8
  User.establish_connection :adapter => "postgresql", :database => "groupdate_test"
9
9
  end
10
-
11
10
  end
data/test/test_helper.rb CHANGED
@@ -24,10 +24,8 @@ end
24
24
 
25
25
  # i18n
26
26
  I18n.enforce_available_locales = true
27
- I18n.backend.store_translations :de, {
28
- :date => {
29
- :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil)
30
- }
27
+ I18n.backend.store_translations :de, :date => {
28
+ :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil)
31
29
  }
32
30
 
33
31
  # migrations
@@ -47,7 +45,6 @@ I18n.backend.store_translations :de, {
47
45
  end
48
46
 
49
47
  module TestGroupdate
50
-
51
48
  def setup
52
49
  Groupdate.week_start = :sun
53
50
  end
@@ -55,7 +52,7 @@ module TestGroupdate
55
52
  # second
56
53
 
57
54
  def test_second_end_of_second
58
- if ActiveRecord::Base.connection.adapter_name == "Mysql2" and ActiveRecord::VERSION::STRING.starts_with?("4.2.")
55
+ if ActiveRecord::Base.connection.adapter_name == "Mysql2" && ActiveRecord::VERSION::STRING.starts_with?("4.2.")
59
56
  skip # no millisecond precision
60
57
  else
61
58
  assert_result_time :second, "2013-05-03 00:00:00 UTC", "2013-05-03 00:00:00.999"
@@ -639,6 +636,29 @@ module TestGroupdate
639
636
  assert_equal expected, User.group_by_day(:created_at).group(:score).order(:score).count
640
637
  end
641
638
 
639
+ def test_group_day_of_week
640
+ create_user "2013-05-01 00:00:00 UTC", 1
641
+ create_user "2013-05-02 00:00:00 UTC", 2
642
+ create_user "2013-05-03 00:00:00 UTC", 2
643
+ expected = {
644
+ [1, 0] => 0,
645
+ [1, 1] => 0,
646
+ [1, 2] => 0,
647
+ [1, 3] => 1,
648
+ [1, 4] => 0,
649
+ [1, 5] => 0,
650
+ [1, 6] => 0,
651
+ [2, 0] => 0,
652
+ [2, 1] => 0,
653
+ [2, 2] => 0,
654
+ [2, 3] => 0,
655
+ [2, 4] => 1,
656
+ [2, 5] => 1,
657
+ [2, 6] => 0
658
+ }
659
+ assert_equal expected, User.group(:score).group_by_day_of_week(:created_at).count
660
+ end
661
+
642
662
  def test_groupdate_multiple
643
663
  create_user "2013-05-01 00:00:00 UTC", 1
644
664
  expected = {
@@ -668,16 +688,26 @@ module TestGroupdate
668
688
  end
669
689
 
670
690
  def test_last
671
- create_user "2011-05-01 00:00:00 UTC"
672
- create_user "2013-05-01 00:00:00 UTC"
691
+ create_user "2012-05-01 00:00:00 UTC"
692
+ create_user "2014-05-01 00:00:00 UTC"
673
693
  expected = {
674
- utc.parse("2012-01-01 00:00:00 UTC") => 0,
675
- utc.parse("2013-01-01 00:00:00 UTC") => 1,
676
- utc.parse("2014-01-01 00:00:00 UTC") => 0
694
+ utc.parse("2013-01-01 00:00:00 UTC") => 0,
695
+ utc.parse("2014-01-01 00:00:00 UTC") => 1,
696
+ utc.parse("2015-01-01 00:00:00 UTC") => 0
677
697
  }
678
698
  assert_equal expected, User.group_by_year(:created_at, last: 3).count
679
699
  end
680
700
 
701
+ def test_current
702
+ create_user "2012-05-01 00:00:00 UTC"
703
+ create_user "2014-05-01 00:00:00 UTC"
704
+ expected = {
705
+ utc.parse("2013-01-01 00:00:00 UTC") => 0,
706
+ utc.parse("2014-01-01 00:00:00 UTC") => 1
707
+ }
708
+ assert_equal expected, User.group_by_year(:created_at, last: 2, current: false).count
709
+ end
710
+
681
711
  def test_format_day
682
712
  create_user "2014-03-01 00:00:00 UTC"
683
713
  assert_format :day, "March 1, 2014", "%B %-e, %Y"
@@ -742,6 +772,32 @@ module TestGroupdate
742
772
  assert_equal ({[1, "Sun"] => 1}), User.group(:score).group_by_week(:created_at, format: "%a").count
743
773
  end
744
774
 
775
+ # permit
776
+
777
+ def test_permit
778
+ assert_raises(ArgumentError, "Unpermitted period") { User.group_by_period(:day, :created_at, permit: %w[week]).count }
779
+ end
780
+
781
+ def test_permit_bad_period
782
+ assert_raises(ArgumentError, "Unpermitted period") { User.group_by_period(:bad_period, :created_at).count }
783
+ end
784
+
785
+ def test_permit_symbol_symbols
786
+ assert_equal ({}), User.group_by_period(:day, :created_at, permit: [:day]).count
787
+ end
788
+
789
+ def test_permit_string_symbols
790
+ assert_equal ({}), User.group_by_period("day", :created_at, permit: [:day]).count
791
+ end
792
+
793
+ def test_permit_symbol_strings
794
+ assert_equal ({}), User.group_by_period(:day, :created_at, permit: %w[day]).count
795
+ end
796
+
797
+ def test_permit_string_strings
798
+ assert_equal ({}), User.group_by_period("day", :created_at, permit: %w[day]).count
799
+ end
800
+
745
801
  # associations
746
802
 
747
803
  def test_associations
@@ -752,12 +808,10 @@ module TestGroupdate
752
808
  # activerecord default_timezone option
753
809
 
754
810
  def test_default_timezone_local
755
- begin
756
- User.default_timezone = :local
757
- assert_raises(RuntimeError){ User.group_by_day(:created_at).count }
758
- ensure
759
- User.default_timezone = :utc
760
- end
811
+ User.default_timezone = :local
812
+ assert_raises(RuntimeError) { User.group_by_day(:created_at).count }
813
+ ensure
814
+ User.default_timezone = :utc
761
815
  end
762
816
 
763
817
  # Brasilia Summer Time
@@ -812,7 +866,7 @@ module TestGroupdate
812
866
  end
813
867
 
814
868
  def call_method(method, field, options)
815
- User.send(:"group_by_#{method}", field, options).count
869
+ User.group_by_period(method, field, options).count
816
870
  end
817
871
 
818
872
  def create_user(created_at, score = 1)
@@ -830,5 +884,4 @@ module TestGroupdate
830
884
  def teardown
831
885
  User.delete_all
832
886
  end
833
-
834
887
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupdate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-28 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: mysql2
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.3.20
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.3.20
111
111
  description: The simplest way to group temporal data
112
112
  email:
113
113
  - acekane1@gmail.com
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  version: '0'
160
160
  requirements: []
161
161
  rubyforge_project:
162
- rubygems_version: 2.2.2
162
+ rubygems_version: 2.4.5
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: The simplest way to group temporal data
@@ -168,3 +168,4 @@ test_files:
168
168
  - test/mysql_test.rb
169
169
  - test/postgresql_test.rb
170
170
  - test/test_helper.rb
171
+ has_rdoc: