by_star 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/mysql.yml +92 -0
  3. data/.github/workflows/postgresql.yml +99 -0
  4. data/.gitignore +1 -0
  5. data/.travis.yml +67 -36
  6. data/CHANGELOG.md +15 -0
  7. data/README.md +172 -133
  8. data/UPGRADING +1 -3
  9. data/by_star.gemspec +2 -2
  10. data/lib/by_star/base.rb +16 -15
  11. data/lib/by_star/between.rb +81 -52
  12. data/lib/by_star/directional.rb +2 -4
  13. data/lib/by_star/kernel/date.rb +0 -9
  14. data/lib/by_star/kernel/in_time_zone.rb +20 -0
  15. data/lib/by_star/normalization.rb +52 -23
  16. data/lib/by_star/orm/active_record/by_star.rb +20 -6
  17. data/lib/by_star/orm/mongoid/by_star.rb +20 -6
  18. data/lib/by_star/version.rb +1 -1
  19. data/lib/by_star.rb +1 -0
  20. data/spec/database.yml +1 -1
  21. data/spec/fixtures/active_record/models.rb +2 -2
  22. data/spec/fixtures/mongoid/models.rb +1 -1
  23. data/spec/fixtures/shared/seeds.rb +10 -0
  24. data/spec/gemfiles/Gemfile.rails +5 -0
  25. data/spec/gemfiles/Gemfile.rails32 +7 -0
  26. data/spec/gemfiles/Gemfile.rails40 +1 -1
  27. data/spec/gemfiles/Gemfile.rails41 +1 -1
  28. data/spec/gemfiles/Gemfile.rails42 +2 -2
  29. data/spec/gemfiles/Gemfile.rails50 +1 -4
  30. data/spec/gemfiles/Gemfile.rails51 +1 -4
  31. data/spec/gemfiles/Gemfile.rails52 +7 -0
  32. data/spec/gemfiles/Gemfile.rails60 +7 -0
  33. data/spec/gemfiles/Gemfile.rails61 +7 -0
  34. data/spec/integration/active_record/active_record_spec.rb +6 -3
  35. data/spec/integration/mongoid/mongoid_spec.rb +3 -1
  36. data/spec/integration/shared/at_time.rb +53 -0
  37. data/spec/integration/shared/between_dates.rb +99 -0
  38. data/spec/integration/shared/between_times.rb +27 -10
  39. data/spec/integration/shared/by_day.rb +24 -0
  40. data/spec/integration/shared/by_direction.rb +11 -57
  41. data/spec/integration/shared/index_scope_parameter.rb +111 -0
  42. data/spec/spec_helper.rb +4 -0
  43. data/spec/unit/kernel_date_spec.rb +6 -6
  44. data/spec/unit/normalization_spec.rb +128 -49
  45. metadata +33 -21
  46. data/spec/gemfiles/Gemfile.master +0 -6
  47. data/spec/integration/shared/scope_parameter.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b215af1453a6bb5552109578699e5bc4e5e18aa4df583461b3eb9544dfba72e7
4
- data.tar.gz: 43918eb7759cd1539fe52f3c9d33f087029e302dc25d28842b73485cc446ec67
3
+ metadata.gz: ae1bb4b3e4e148196c9a1164b3b0b70022fd84843eb4d5adc0cb9dfd41b0ff5a
4
+ data.tar.gz: ec16b5bb712e19cae620110b979774fe472c430d5485565bd62d8bb30595858a
5
5
  SHA512:
6
- metadata.gz: f15335c52f3dea9f54dfbf054d8b1e532535cc7cd1c9616bd7b5bf1d1a4274fb0df3d4c2619025ab1f6db975b46a93a74f77458e3533fa3867c0aaaa39a48b6a
7
- data.tar.gz: eba9a69f7a83a0b8c65e4c1bee16451f6f4beeec1eb65d836e8b22841bfa70e02b4136b8f495577b91e023ed5f709221547ea9cc067d816a66c28e3f6ded0e27
6
+ metadata.gz: 4749e66ea10dddf1c32c87d0e598b6f852708dcc195dec7f96f3cf83580ff6d50ffcc0f2b286d1cd5b0332d7579634dc23c48aac0b4a97d7e8935d0c89300dc3
7
+ data.tar.gz: 2efd2cab53a2844e1a1ad28fc01557ca3c5e84ddb1e5b0e719f00130c41348c137c121b793cf73ca6d5c7cc88f5d714c075de00785e34afffc6175199f25aafe
@@ -0,0 +1,92 @@
1
+ name: MySQL tests
2
+
3
+ on:
4
+ # Trigger the workflow on push or pull request,
5
+ # but only for the master branch
6
+ push:
7
+ branches:
8
+ - master
9
+ pull_request:
10
+ branches:
11
+ - master
12
+
13
+ jobs:
14
+ mysql:
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby_version: [3.0, 2.7, 2.6, 2.5, jruby]
19
+ gemfile:
20
+ [
21
+ spec/gemfiles/Gemfile.rails50,
22
+ spec/gemfiles/Gemfile.rails51,
23
+ spec/gemfiles/Gemfile.rails52,
24
+ spec/gemfiles/Gemfile.rails60,
25
+ spec/gemfiles/Gemfile.rails61,
26
+ spec/gemfiles/Gemfile.rails,
27
+ ]
28
+ exclude:
29
+ # Ruby 3.x is not supported by Rails 5.2.x
30
+ - ruby_version: 3.0
31
+ gemfile: spec/gemfiles/Gemfile.rails52
32
+ # Ruby 3.x is not supported by Rails 5.1.x
33
+ - ruby_version: 3.0
34
+ gemfile: spec/gemfiles/Gemfile.rails51
35
+ # Ruby 3.x is not supported by Rails 5.0.x
36
+ - ruby_version: 3.0
37
+ gemfile: spec/gemfiles/Gemfile.rails50
38
+
39
+ - ruby_version: 2.6
40
+ gemfile: spec/gemfiles/Gemfile.rails32
41
+
42
+ # Ruby 2.6.x is not supported by Rails main
43
+ - ruby_version: 2.6
44
+ gemfile: spec/gemfiles/Gemfile.rails
45
+
46
+ # Ruby 2.5.x is not supported by Rails main
47
+ - ruby_version: 2.5
48
+ gemfile: spec/gemfiles/Gemfile.rails
49
+
50
+ # Ruby 2.4.x is not supported by Rails main
51
+ - ruby_version: 2.4
52
+ gemfile: spec/gemfiles/Gemfile.rails
53
+ # Ruby 2.4.x is not supported by Rails 6.1.x
54
+ - ruby_version: 2.4
55
+ gemfile: spec/gemfiles/Gemfile.rails61
56
+ # Ruby 2.4.x is not supported by Rails 6.0.x
57
+ - ruby_version: 2.4
58
+ gemfile: spec/gemfiles/Gemfile.rails60
59
+ # Ruby 2.3.x is not supported by Rails 6.1.x
60
+ - ruby_version: 2.3
61
+ gemfile: spec/gemfiles/Gemfile.rails61
62
+ # Ruby 2.3.x is not supported by Rails main
63
+ - ruby_version: 2.3
64
+ gemfile: spec/gemfiles/Gemfile.rails
65
+ # Ruby 2.3.x is not supported by Rails 6.0.x
66
+ - ruby_version: 2.3
67
+ gemfile: spec/gemfiles/Gemfile.rails60
68
+ # JRuby is not supported by Rails main
69
+ - ruby_version: jruby
70
+ gemfile: spec/gemfiles/Gemfile.rails
71
+
72
+ runs-on: ubuntu-latest
73
+
74
+ steps:
75
+ - uses: actions/checkout@v2
76
+
77
+ - name: Set up Ruby
78
+ uses: ruby/setup-ruby@master
79
+ with:
80
+ ruby-version: ${{ matrix.ruby_version }}
81
+
82
+ - name: Start MySQL
83
+ - run: sudo /etc/init.d/mysql start
84
+
85
+ - name: Build and test with Rake
86
+ env:
87
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
88
+ DB: "postgres"
89
+ run: |
90
+ gem install bundler
91
+ bundle install --jobs 4 --retry 3
92
+ bundle exec rake
@@ -0,0 +1,99 @@
1
+ name: PostgreSQL tests
2
+
3
+ on:
4
+ # Trigger the workflow on push or pull request,
5
+ # but only for the master branch
6
+ push:
7
+ branches:
8
+ - master
9
+ pull_request:
10
+ branches:
11
+ - master
12
+
13
+ jobs:
14
+ postgresql:
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby_version: [3.0, 2.7, 2.6, 2.5, jruby]
19
+ gemfile:
20
+ [
21
+ spec/gemfiles/Gemfile.rails50,
22
+ spec/gemfiles/Gemfile.rails51,
23
+ spec/gemfiles/Gemfile.rails52,
24
+ spec/gemfiles/Gemfile.rails60,
25
+ spec/gemfiles/Gemfile.rails61,
26
+ spec/gemfiles/Gemfile.rails,
27
+ ]
28
+ exclude:
29
+ # Ruby 3.x is not supported by Rails 5.2.x
30
+ - ruby_version: 3.0
31
+ gemfile: spec/gemfiles/Gemfile.rails52
32
+ # Ruby 3.x is not supported by Rails 5.1.x
33
+ - ruby_version: 3.0
34
+ gemfile: spec/gemfiles/Gemfile.rails51
35
+ # Ruby 3.x is not supported by Rails 5.0.x
36
+ - ruby_version: 3.0
37
+ gemfile: spec/gemfiles/Gemfile.rails50
38
+
39
+ - ruby_version: 2.6
40
+ gemfile: spec/gemfiles/Gemfile.rails32
41
+
42
+ # Ruby 2.6.x is not supported by Rails main
43
+ - ruby_version: 2.6
44
+ gemfile: spec/gemfiles/Gemfile.rails
45
+
46
+ # Ruby 2.5.x is not supported by Rails main
47
+ - ruby_version: 2.5
48
+ gemfile: spec/gemfiles/Gemfile.rails
49
+
50
+ # Ruby 2.4.x is not supported by Rails main
51
+ - ruby_version: 2.4
52
+ gemfile: spec/gemfiles/Gemfile.rails
53
+ # Ruby 2.4.x is not supported by Rails 6.1.x
54
+ - ruby_version: 2.4
55
+ gemfile: spec/gemfiles/Gemfile.rails61
56
+ # Ruby 2.4.x is not supported by Rails 6.0.x
57
+ - ruby_version: 2.4
58
+ gemfile: spec/gemfiles/Gemfile.rails60
59
+ # Ruby 2.3.x is not supported by Rails 6.1.x
60
+ - ruby_version: 2.3
61
+ gemfile: spec/gemfiles/Gemfile.rails61
62
+ # Ruby 2.3.x is not supported by Rails main
63
+ - ruby_version: 2.3
64
+ gemfile: spec/gemfiles/Gemfile.rails
65
+ # Ruby 2.3.x is not supported by Rails 6.0.x
66
+ - ruby_version: 2.3
67
+ gemfile: spec/gemfiles/Gemfile.rails60
68
+ # JRuby is not supported by Rails main
69
+ - ruby_version: jruby
70
+ gemfile: spec/gemfiles/Gemfile.rails
71
+
72
+ runs-on: ubuntu-latest
73
+
74
+ steps:
75
+ - uses: actions/checkout@v2
76
+
77
+ - name: Set up Ruby
78
+ uses: ruby/setup-ruby@master
79
+ with:
80
+ ruby-version: ${{ matrix.ruby_version }}
81
+
82
+ - uses: harmon758/postgresql-action@v1
83
+ with:
84
+ postgresql version: '11'
85
+
86
+ - name: Start PostgreSQL
87
+ run: |
88
+ sudo service postgresql start
89
+ sudo -u postgres createuser --superuser "$USER"
90
+ createdb by_star_test
91
+
92
+ - name: Build and test with Rake
93
+ env:
94
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
95
+ DB: "postgres"
96
+ run: |
97
+ gem install bundler
98
+ bundle install --jobs 4 --retry 3
99
+ bundle exec rake
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .idea
1
2
  tmp
2
3
  spec/fixtures/database.yml
3
4
  pkg
data/.travis.yml CHANGED
@@ -1,6 +1,4 @@
1
- before_install:
2
- - gem update --system
3
- - gem update bundler
1
+ services: mongodb
4
2
 
5
3
  before_script:
6
4
  - "mysql -e 'create database by_star_test;'"
@@ -13,49 +11,82 @@ env:
13
11
  - DB=mongodb
14
12
 
15
13
  gemfile:
14
+ - spec/gemfiles/Gemfile.rails32
16
15
  - spec/gemfiles/Gemfile.rails40
17
16
  - spec/gemfiles/Gemfile.rails41
18
17
  - spec/gemfiles/Gemfile.rails42
19
18
  - spec/gemfiles/Gemfile.rails50
20
19
  - spec/gemfiles/Gemfile.rails51
20
+ - spec/gemfiles/Gemfile.rails52
21
21
  - spec/gemfiles/Gemfile.master
22
22
 
23
- notifications:
24
- email:
25
- - radarlistener@gmail.com
26
-
27
- branches:
28
- only:
29
- - master
30
-
31
23
  rvm:
32
24
  - 2.0.0
33
- - 2.1.9
34
- - 2.2.5
35
- - 2.3.1
36
- - 2.4.2
37
- - 2.5.0
25
+ - 2.1.10
26
+ - 2.2.10
27
+ - 2.3.8
28
+ - 2.4.6
29
+ - 2.5.5
30
+ - 2.6.3
38
31
 
39
32
  matrix:
40
- exclude:
41
- - rvm: 2.0.0
42
- gemfile: "spec/gemfiles/Gemfile.rails50"
43
- - rvm: 2.0.0
44
- gemfile: "spec/gemfiles/Gemfile.rails51"
45
- - rvm: 2.1.9
46
- gemfile: "spec/gemfiles/Gemfile.rails50"
47
- - rvm: 2.1.9
48
- gemfile: "spec/gemfiles/Gemfile.rails51"
49
- - rvm: 2.4.2
50
- gemfile: "spec/gemfiles/Gemfile.rails40"
51
- - rvm: 2.5.0
52
- gemfile: "spec/gemfiles/Gemfile.rails40"
53
- - rvm: 2.4.2
54
- gemfile: "spec/gemfiles/Gemfile.rails41"
55
- - rvm: 2.5.0
56
- gemfile: "spec/gemfiles/Gemfile.rails41"
57
- allow_failures:
58
- - gemfile: spec/gemfiles/Gemfile.master
33
+ fast_finish: true
59
34
 
35
+ exclude:
36
+ - gemfile: 'spec/gemfiles/Gemfile.rails32'
37
+ rvm: 2.2.10
38
+ - gemfile: 'spec/gemfiles/Gemfile.rails32'
39
+ rvm: 2.3.8
40
+ - gemfile: 'spec/gemfiles/Gemfile.rails32'
41
+ rvm: 2.4.6
42
+ - gemfile: 'spec/gemfiles/Gemfile.rails32'
43
+ rvm: 2.5.5
44
+ - gemfile: 'spec/gemfiles/Gemfile.rails32'
45
+ rvm: 2.6.3
46
+ - gemfile: 'spec/gemfiles/Gemfile.rails40'
47
+ rvm: 2.4.6
48
+ - gemfile: 'spec/gemfiles/Gemfile.rails40'
49
+ rvm: 2.5.5
50
+ - gemfile: 'spec/gemfiles/Gemfile.rails40'
51
+ rvm: 2.6.3
52
+ - gemfile: 'spec/gemfiles/Gemfile.rails41'
53
+ rvm: 2.4.6
54
+ - gemfile: 'spec/gemfiles/Gemfile.rails41'
55
+ rvm: 2.5.5
56
+ - gemfile: 'spec/gemfiles/Gemfile.rails41'
57
+ rvm: 2.6.3
58
+ - gemfile: 'spec/gemfiles/Gemfile.rails50'
59
+ rvm: 2.0.0
60
+ - gemfile: 'spec/gemfiles/Gemfile.rails50'
61
+ rvm: 2.1.10
62
+ - gemfile: 'spec/gemfiles/Gemfile.rails50'
63
+ rvm: 2.6.3
64
+ - gemfile: 'spec/gemfiles/Gemfile.rails51'
65
+ rvm: 2.0.0
66
+ - gemfile: 'spec/gemfiles/Gemfile.rails51'
67
+ rvm: 2.1.10
68
+ - gemfile: 'spec/gemfiles/Gemfile.rails51'
69
+ rvm: 2.6.3
70
+ - gemfile: 'spec/gemfiles/Gemfile.rails52'
71
+ rvm: 2.0.0
72
+ - gemfile: 'spec/gemfiles/Gemfile.rails52'
73
+ rvm: 2.1.10
60
74
 
61
- services: mongodb
75
+ allow_failures:
76
+ - gemfile: 'spec/gemfiles/Gemfile.master'
77
+ - gemfile: 'spec/gemfiles/Gemfile.rails32'
78
+ env: 'DB=sqlite'
79
+ - gemfile: 'spec/gemfiles/Gemfile.rails32'
80
+ env: 'DB=mysql'
81
+ - gemfile: 'spec/gemfiles/Gemfile.rails40'
82
+ env: 'DB=sqlite'
83
+ - gemfile: 'spec/gemfiles/Gemfile.rails40'
84
+ env: 'DB=mysql'
85
+ - gemfile: 'spec/gemfiles/Gemfile.rails41'
86
+ env: 'DB=sqlite'
87
+ - gemfile: 'spec/gemfiles/Gemfile.rails41'
88
+ env: 'DB=mysql'
89
+ - gemfile: 'spec/gemfiles/Gemfile.rails42'
90
+ env: 'DB=sqlite'
91
+ - gemfile: 'spec/gemfiles/Gemfile.rails50'
92
+ env: 'DB=sqlite'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v4.0.0 - Unreleased
4
+
5
+ * BREAKING CHANGE - `#between` method has been removed (was deprecated in 2.2.0)
6
+ * BREAKING CHANGE - `:order` arg for `#between_times` has been removed.
7
+ * BREAKING CHANGE - Drop support for option `:year` used as a standalone. Use `by_year` instead.
8
+ * BREAKING CHANGE - `#between_times` now queries on records until end of day on `end_time`, if it is a date.
9
+ * `#between_times` now accepts one-sided arguments, e.g. `Time, nil` or `nil, Time`.
10
+ * `#between_times` now accepts `Range` or `Array` as an argument, while continuing to support existing `Time, Time` interface.
11
+ * Add `#at_time` method for point-in-time query.
12
+ * Timespan "strict" query now sets double-sided constraints on both fields to ensure database indexes are used properly.
13
+ * Add optional `:index_scope` option for timespan "non-strict" queries to improve database performance.
14
+ * Fixes `offset` option to set hour, min, and sec of day for queries on dates for better DST support.
15
+ * More consistent application of `Time.zone`.
16
+ * Re-add test coverage for Rails 3.2. This will be removed when we upgrade to Ruby 2.2+ as minimum version.
17
+
3
18
  ## v3.0.0
4
19
 
5
20
  * Upgrade Travis for broader coverage of Ruby, ActiveRecord, and Mongoid versions - @johnnyshields