groupdate 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +14 -5
- data/lib/groupdate.rb +1 -0
- data/lib/groupdate/scopes.rb +1 -1
- data/lib/groupdate/version.rb +1 -1
- data/test/test_helper.rb +12 -0
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b79c5fbce92b20167a5d590b155aa54a5f9a7719
|
4
|
+
data.tar.gz: 8fc3b7483fbb78e6dd28b1aa993eb6f7554aea49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23fb19dd4593f11e762e9728c9e637831aa00e64a466e8a3def9ccc0e51817c14150f387c27461d457cb27a6c310c76975f0383b4c24bc635d5fe06d04963554
|
7
|
+
data.tar.gz: d53817d4a0825181dafd79532107184aaab0ae473f3e697b26e6a44baa00674be21532b7757e8f119cc03aa26c1ae49bc6710eb180614133eb2b0e6e913cae2a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -190,6 +190,14 @@ gem "activerecord-jdbcpostgresql-adapter", :github => "jruby/activerecord-jdbc-a
|
|
190
190
|
gem "activerecord-jdbcmysql-adapter", :github => "jruby/activerecord-jdbc-adapter"
|
191
191
|
```
|
192
192
|
|
193
|
+
## Reference
|
194
|
+
|
195
|
+
The default time zone is `Time.zone`. To change this, use:
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
Groupdate.time_zone = "Pacific Time (US & Canada)"
|
199
|
+
```
|
200
|
+
|
193
201
|
## Complete list
|
194
202
|
|
195
203
|
group_by_?
|
@@ -245,8 +253,9 @@ Groupdate follows [Semantic Versioning](http://semver.org/)
|
|
245
253
|
|
246
254
|
## Contributing
|
247
255
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
256
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
257
|
+
|
258
|
+
- [Report bugs](https://github.com/ankane/groupdate/issues)
|
259
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/groupdate/pulls)
|
260
|
+
- Write, clarify, or fix documentation
|
261
|
+
- Suggest or add new features
|
data/lib/groupdate.rb
CHANGED
data/lib/groupdate/scopes.rb
CHANGED
@@ -11,7 +11,7 @@ module Groupdate
|
|
11
11
|
args = args.dup
|
12
12
|
options = args[-1].is_a?(Hash) ? args.pop : {}
|
13
13
|
column = connection.quote_table_name(args[0])
|
14
|
-
time_zone = args[1] || Time.zone || "Etc/UTC"
|
14
|
+
time_zone = args[1] || Groupdate.time_zone || Time.zone || "Etc/UTC"
|
15
15
|
if time_zone.is_a?(ActiveSupport::TimeZone) or time_zone = ActiveSupport::TimeZone[time_zone]
|
16
16
|
time_zone = time_zone.tzinfo.name
|
17
17
|
else
|
data/lib/groupdate/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -320,6 +320,17 @@ module TestGroupdate
|
|
320
320
|
assert_equal 0, User.group_by_hour_of_day(:created_at, Time.zone, true).count[0]
|
321
321
|
end
|
322
322
|
|
323
|
+
def test_zeroes_range_true
|
324
|
+
create_user "2013-05-01 00:00:00 UTC"
|
325
|
+
create_user "2013-05-03 00:00:00 UTC"
|
326
|
+
expected = {
|
327
|
+
Time.parse("2013-05-01 00:00:00 UTC") => 1,
|
328
|
+
Time.parse("2013-05-02 00:00:00 UTC") => 0,
|
329
|
+
Time.parse("2013-05-03 00:00:00 UTC") => 1
|
330
|
+
}
|
331
|
+
assert_equal expected, User.group_by_day(:created_at, Time.zone, true).count
|
332
|
+
end
|
333
|
+
|
323
334
|
# week_start
|
324
335
|
|
325
336
|
def test_week_start
|
@@ -365,6 +376,7 @@ module TestGroupdate
|
|
365
376
|
create_user time_str
|
366
377
|
expected = expected.is_a?(Time) ? time_key(expected) : number_key(expected)
|
367
378
|
assert_equal ordered_hash({expected => 1}), User.send(:"group_by_#{method}", :created_at, time_zone ? "Pacific Time (US & Canada)" : nil, options).order(method.to_s).count
|
379
|
+
assert_equal 1, User.send(:"group_by_#{method}", :created_at, time_zone ? "Pacific Time (US & Canada)" : nil, true, options).count[expected]
|
368
380
|
end
|
369
381
|
|
370
382
|
def assert_zeros(method, created_at, keys, range_start, range_end, time_zone = nil, options = {})
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupdate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: pg
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mysql2
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: The simplest way to group temporal data
|
@@ -101,8 +101,8 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- .gitignore
|
105
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
106
|
- CHANGELOG.md
|
107
107
|
- Gemfile
|
108
108
|
- LICENSE.txt
|
@@ -127,17 +127,17 @@ require_paths:
|
|
127
127
|
- lib
|
128
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- -
|
135
|
+
- - ">="
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.2.0
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: The simplest way to group temporal data
|