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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aca7ed94e70ba77cb94f64a51398c1c7a8b3a888
4
- data.tar.gz: f8601b3f0fc5c9ee1a0886ecd717b02901c215ef
3
+ metadata.gz: b79c5fbce92b20167a5d590b155aa54a5f9a7719
4
+ data.tar.gz: 8fc3b7483fbb78e6dd28b1aa993eb6f7554aea49
5
5
  SHA512:
6
- metadata.gz: 285ff44107dc4028bf1369203abcf466443a0faf90d36060cdfc688511c87ca33b88a242cd37c6b9ad45f0c5f9702b381ef3a3fed00ce6d5b3e6b5b98934887e
7
- data.tar.gz: 2a068e99ecdfe6c6feaf1dd1a6134440dcaf17b284fa85488abe57adabc27c2bfd4228c1a5307efe1cca4a0820c8d39c2cc43fd92f895cff6c6637d32fb278e8
6
+ metadata.gz: 23fb19dd4593f11e762e9728c9e637831aa00e64a466e8a3def9ccc0e51817c14150f387c27461d457cb27a6c310c76975f0383b4c24bc635d5fe06d04963554
7
+ data.tar.gz: d53817d4a0825181dafd79532107184aaab0ae473f3e697b26e6a44baa00674be21532b7757e8f119cc03aa26c1ae49bc6710eb180614133eb2b0e6e913cae2a
@@ -1,3 +1,7 @@
1
+ # 1.0.5
2
+
3
+ - Added global time_zone option
4
+
1
5
  # 1.0.4
2
6
 
3
7
  - Added global week_start option
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
- 1. Fork it
249
- 2. Create your feature branch (`git checkout -b my-new-feature`)
250
- 3. Commit your changes (`git commit -am 'Add some feature'`)
251
- 4. Push to the branch (`git push origin my-new-feature`)
252
- 5. Create new Pull Request
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
@@ -24,5 +24,6 @@ end
24
24
 
25
25
  module Groupdate
26
26
  mattr_accessor :week_start
27
+ mattr_accessor :time_zone
27
28
  self.week_start = :sun
28
29
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Groupdate
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -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
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: 2013-07-20 00:00:00.000000000 Z
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.0.0
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