geokit-rails 2.5.1 → 2.5.2

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
  SHA256:
3
- metadata.gz: 7bc2b5e4c6de16393de8702315f0b01bc98e30038a5ecee3f54a48fe156f948f
4
- data.tar.gz: 84d6fbc137e77051518c4d20c26dd6c6c0c2c0b16345de8a8c3363765194fd85
3
+ metadata.gz: 3a39a787db2843762962e2d4fd0afe36bb117be9b951d01d65d76fd53a5dfabb
4
+ data.tar.gz: c6baa34385aad40d374ae8c1be45d99bf9e1aaaf2ddaf7c1aca731374efa7f85
5
5
  SHA512:
6
- metadata.gz: 603470542be8033cf17f8976bb1b9488727cc11b1c311039c3074318f93b9bc8dfbf2c1509f8b11a5dceb8320255f89763a27c03ad23e043ecea53da20cb3f4d
7
- data.tar.gz: f5212fc66504f5daa74b6f147132c941cb87e615d22df26525b7a4c890f53eeacf5434b347f7a0b9c6e6881c0673ca7f6e8298fca3b913ccb4312e4a5638b275
6
+ metadata.gz: e6fb8d2c395792b752865f466b09dd5671c28359917c69d700ac7e6655ad92e69a900416b647e12b1ac191aafb3a17e0c7d00ec5b685877781bafe7b8487486b
7
+ data.tar.gz: f8a7a2594dc5da7cc906ae1ce8b8f9e3741e8988f4772c6672e50d881310a3114a770753f45de8e915bd48b0bba4a65aa5d241d752eb68e4acba305160c61e20
@@ -38,7 +38,7 @@ jobs:
38
38
  strategy:
39
39
  fail-fast: false
40
40
  matrix:
41
- db: [mysql]
41
+ db: [mysql, trilogy]
42
42
  ruby: ['3.2', '4.0']
43
43
  include:
44
44
  - ruby: '3.2'
@@ -78,3 +78,48 @@ jobs:
78
78
  bundler-cache: true
79
79
 
80
80
  - run: bundle exec rake test
81
+
82
+ postgresql:
83
+ name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }} / postgresql
84
+ runs-on: ubuntu-latest
85
+
86
+ strategy:
87
+ fail-fast: false
88
+ matrix:
89
+ include:
90
+ - ruby: '3.2'
91
+ gemfile: rails7.1
92
+ - ruby: '4.0'
93
+ gemfile: rails8.1
94
+
95
+ services:
96
+ postgres:
97
+ image: postgres:18
98
+ env:
99
+ POSTGRES_USER: tests
100
+ POSTGRES_PASSWORD: tests
101
+ POSTGRES_DB: geokit_rails_tests
102
+ ports:
103
+ - 5432:5432
104
+ options: >-
105
+ --health-cmd pg_isready
106
+ --health-interval 5s
107
+ --health-timeout 5s
108
+ --health-retries 20
109
+
110
+ env:
111
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
112
+ DB: postgresql
113
+ DB_HOST: 127.0.0.1
114
+ DB_USERNAME: tests
115
+ DB_PASSWORD: tests
116
+
117
+ steps:
118
+ - uses: actions/checkout@v7
119
+
120
+ - uses: ruby/setup-ruby@v1
121
+ with:
122
+ ruby-version: ${{ matrix.ruby }}
123
+ bundler-cache: true
124
+
125
+ - run: bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
+ ## 2.5.2
2
+
3
+ * Add support for the Trilogy MySQL adapter
4
+
1
5
  ## 2.5.1
2
6
 
3
- * Run the test suite on GitHub Actions against Ruby 3.2 to 4.0, Rails 7.1 to 8.1, SQLite and MySQL
7
+ * Run the test suite on GitHub Actions against Ruby 3.2 to 4.0, Rails 7.1 to 8.1, SQLite, MySQL and PostgreSQL
4
8
  * Only look up finder adapters in `Geokit::Adapters`, so a top-level constant with the same name defined by another gem isn't mistaken for one
9
+ * Fix `in_range` returning records without coordinates on PostgreSQL
10
+ * Fix `within`, `in_range` and `by_distance` on models using `:through`, which filtered on the model's own table instead of the associated one
5
11
 
6
12
  ## 2.5.0
7
13
 
data/README.markdown CHANGED
@@ -696,7 +696,7 @@ end
696
696
 
697
697
  ## Database Compatability
698
698
 
699
- * Geokit works with MySQL, PostgreSQL, SQLite and Microsoft SQL Server. The test suite runs against SQLite and MySQL 8.4.
699
+ * Geokit works with MySQL (through the mysql2 or Trilogy adapters), PostgreSQL, SQLite and Microsoft SQL Server. The test suite runs against SQLite, MySQL 8.4 and PostgreSQL 18.
700
700
  * Geokit is known to *not* work with Postgres versions under 8.1 -- it uses the least() function.
701
701
 
702
702
 
data/geokit-rails.gemspec CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "mocha", "~> 2.0"
29
29
  spec.add_development_dependency 'coveralls_reborn'
30
30
  spec.add_development_dependency "mysql2", ">= 0.2"
31
+ spec.add_development_dependency "trilogy"
31
32
  # spec.add_development_dependency "activerecord-mysql2spatial-adapter"
32
33
  spec.add_development_dependency "pg", ">= 0.10"
33
34
  spec.add_development_dependency "sqlite3"
@@ -38,7 +38,7 @@ module Geokit
38
38
  def in_range(range, options = {})
39
39
  options[:range] = range
40
40
  #geo_scope(options)
41
- where(distance_conditions(options))
41
+ with_latlng.where(distance_conditions(options))
42
42
  end
43
43
 
44
44
  def in_bounds(bounds, options = {})
@@ -61,7 +61,9 @@ module Geokit
61
61
  end
62
62
 
63
63
  def with_latlng
64
- where(arel_table[lat_column_name].not_eq(nil).and(arel_table[lng_column_name].not_eq(nil)))
64
+ lat = Arel.sql(qualified_lat_column_name)
65
+ lng = Arel.sql(qualified_lng_column_name)
66
+ where(lat.not_eq(nil).and(lng.not_eq(nil)))
65
67
  end
66
68
 
67
69
  def closest(options = {})
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'geokit-rails/adapters/mysql'
4
+
5
+ module Geokit
6
+ module Adapters
7
+ class Trilogy < MySQL
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module GeokitRails
2
- VERSION = "2.5.1"
2
+ VERSION = "2.5.2"
3
3
  end
@@ -173,6 +173,11 @@ class ActsAsMappableTest < GeokitTestCase
173
173
  assert_equal 6, locations.count
174
174
  end
175
175
 
176
+ def test_find_range_skips_locations_without_coordinates
177
+ nowhere = locations(:g)
178
+ assert_not_includes Location.in_range(0..10, origin: @loc_a), nowhere
179
+ end
180
+
176
181
  # MockOrganization has no lat/lng columns of its own; they come from
177
182
  # mock_addresses through the join.
178
183
  def test_find_range_with_through
@@ -15,6 +15,19 @@ class AdapterResolutionTest < GeokitTestCase
15
15
  assert_instance_of Geokit::Adapters::Mysql2, adapter
16
16
  end
17
17
 
18
+ def test_trilogy_adapter
19
+ begin
20
+ # Defines the top-level ::Trilogy class, which must not be mistaken for
21
+ # the Geokit adapter of the same name.
22
+ require 'trilogy'
23
+ rescue LoadError
24
+ skip 'the trilogy gem cannot be loaded here'
25
+ end
26
+ adapter = finder_adapter_for('Trilogy')
27
+ assert_instance_of Geokit::Adapters::Trilogy, adapter
28
+ assert_kind_of Geokit::Adapters::MySQL, adapter
29
+ end
30
+
18
31
  # Database gems can define a top-level class named like an adapter, as the
19
32
  # trilogy gem does with Trilogy.
20
33
  def test_ignores_top_level_class_named_like_the_adapter
data/test/database.yml CHANGED
@@ -11,6 +11,11 @@ mysql:
11
11
  database: geokit_rails_tests
12
12
  <<: *base
13
13
 
14
+ trilogy:
15
+ adapter: trilogy
16
+ database: geokit_rails_tests
17
+ <<: *base
18
+
14
19
  mysql2spatial:
15
20
  adapter: mysql2spatial
16
21
  database: geokit_rails_tests
data/test/tasks.rake CHANGED
@@ -18,7 +18,9 @@ Rake::TestTask.new(:test) do |test|
18
18
  test.verbose = true
19
19
  end
20
20
 
21
- %w(mysql postgresql sqlserver sqlite).each do |configuration|
21
+ databases = %w[mysql trilogy postgresql sqlserver sqlite]
22
+
23
+ databases.each do |configuration|
22
24
  EnvTestTask.new("test_#{configuration}") do |t|
23
25
  t.pattern = 'test/*_test.rb'
24
26
  t.verbose = true
@@ -28,7 +30,7 @@ end
28
30
  end
29
31
 
30
32
  desc 'Test available databases.'
31
- task :test_databases => %w(test_mysql test_postgresql test_sqlserver test_sqlite)
33
+ task test_databases: databases.map { |database| "test_#{database}" }
32
34
 
33
35
  desc "Generate SimpleCov test coverage and open in your browser"
34
36
  task :coverage do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geokit-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
@@ -166,6 +166,20 @@ dependencies:
166
166
  - - ">="
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0.2'
169
+ - !ruby/object:Gem::Dependency
170
+ name: trilogy
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
169
183
  - !ruby/object:Gem::Dependency
170
184
  name: pg
171
185
  requirement: !ruby/object:Gem::Requirement
@@ -232,6 +246,7 @@ files:
232
246
  - lib/geokit-rails/adapters/postgresql.rb
233
247
  - lib/geokit-rails/adapters/sqlite.rb
234
248
  - lib/geokit-rails/adapters/sqlserver.rb
249
+ - lib/geokit-rails/adapters/trilogy.rb
235
250
  - lib/geokit-rails/distance_collection.rb
236
251
  - lib/geokit-rails/geocoder_control.rb
237
252
  - lib/geokit-rails/ip_geocode_lookup.rb