sequel-location 0.0.2 → 0.0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae7c66becf0ac1b721bc227bea9263fd285765db
4
+ data.tar.gz: 061638ef41c82fd14084d8297c1ebf735d9ccbe5
5
+ SHA512:
6
+ metadata.gz: f34391d6c2bd10d3f5d1438c6e861839efe53bcf16a9c55e3600fca3b840aadcc79a7d05e36e7c2edf4db2be633bef8c44815d5923cbf879d8143663e9590378
7
+ data.tar.gz: 3c8f56b5335001a87c4306c5942522000ba766502b0d611d603c8742c957df6d1cdf88ec6b6a2fcc902d36af9d51522ca2206fc3c49750aef45da310f459d478
@@ -1,30 +1,28 @@
1
1
  module Sequel
2
2
  module Postgres
3
- class PgLocation
4
- module DatabaseMethods
5
- def add_extension(name)
6
- quoted_name = quote_identifier(name) if name
7
- run("CREATE EXTENSION IF NOT EXISTS #{quoted_name}")
8
- end
3
+ module PgLocation
4
+ def add_extension(name)
5
+ quoted_name = quote_identifier(name) if name
6
+ run("CREATE EXTENSION IF NOT EXISTS #{quoted_name}")
7
+ end
9
8
 
10
- def drop_extension(name)
11
- quoted_name = quote_identifier(name) if name
12
- run("DROP EXTENSION IF EXISTS #{quoted_name}")
13
- end
9
+ def drop_extension(name)
10
+ quoted_name = quote_identifier(name) if name
11
+ run("DROP EXTENSION IF EXISTS #{quoted_name}")
12
+ end
14
13
 
15
- def add_location_trigger(table, op={})
16
- self.run("CREATE FUNCTION update_#{table.to_s}_ll_point() RETURNS TRIGGER AS 'BEGIN NEW.#{op[:earth_point] || "ll_point"}=ll_to_earth(NEW.#{op[:latitude] || "latitude"}, NEW.#{op[:longitude] || "longitude"}); return NEW; END;' LANGUAGE plpgsql;")
17
- self.run("CREATE TRIGGER trigger_#{table.to_s}_ll_point BEFORE INSERT OR UPDATE ON #{table.to_s} FOR ROW EXECUTE PROCEDURE update_#{table.to_s}_ll_point();")
18
- end
14
+ def add_location_trigger(table, op={})
15
+ self.run("CREATE FUNCTION update_#{table.to_s}_ll_point() RETURNS TRIGGER AS 'BEGIN NEW.#{op[:earth_point] || "ll_point"}=ll_to_earth(NEW.#{op[:latitude] || "latitude"}, NEW.#{op[:longitude] || "longitude"}); return NEW; END;' LANGUAGE plpgsql;")
16
+ self.run("CREATE TRIGGER trigger_#{table.to_s}_ll_point BEFORE INSERT OR UPDATE ON #{table.to_s} FOR ROW EXECUTE PROCEDURE update_#{table.to_s}_ll_point();")
17
+ end
19
18
 
20
- def drop_location_trigger(table)
21
- self.run("DROP TRIGGER trigger_#{table.to_s}_ll_point ON #{table.to_s};")
22
- self.run("DROP FUNCTION update_#{table.to_s}_ll_point();")
23
- end
19
+ def drop_location_trigger(table)
20
+ self.run("DROP TRIGGER trigger_#{table.to_s}_ll_point ON #{table.to_s};")
21
+ self.run("DROP FUNCTION update_#{table.to_s}_ll_point();")
24
22
  end
25
23
  end
26
24
  end
27
- Database.register_extension(:pg_location, Postgres::PgLocation::DatabaseMethods)
25
+ Database.register_extension(:pg_location, Postgres::PgLocation)
28
26
  end
29
27
 
30
28
 
@@ -15,6 +15,8 @@ module Sequel
15
15
  super
16
16
  subclass.instance_variable_set(:@location_cache_field, instance_variable_get(:@location_cache_field))
17
17
  end
18
+
19
+ Plugins.def_dataset_methods(self, :nearest)
18
20
  end
19
21
 
20
22
  module DatasetMethods
@@ -24,8 +26,8 @@ module Sequel
24
26
  lat = lat.to_f
25
27
  lng = lng.to_f
26
28
  where("earth_box(ll_to_earth(?,?),?) @> #{location_cache_field}", lat, lng, radius_in_km).where("earth_distance(ll_to_earth(?, ?), #{location_cache_field}) < ?", lat, lng, radius_in_km).select_append{
27
- (Sequel.function(:earth_distance, Sequel.function(:ll_to_earth,lat,lng), location_cache_field)).as(distance)
28
- }.order(:distance)
29
+ (Sequel.function(:earth_distance, Sequel.function(:ll_to_earth,lat,lng), location_cache_field).as('distance'))
30
+ }.order('distance')
29
31
  end
30
32
  end
31
33
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-location
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nick Gartmann
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-25 00:00:00.000000000 Z
11
+ date: 2014-02-03 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Add support for geolocation search to sequel models
15
14
  email: nick.gartmann@gmail.com
@@ -21,26 +20,25 @@ files:
21
20
  - lib/sequel/plugins/pg_location.rb
22
21
  homepage: https://github.com/nickgartmann/sequel-location
23
22
  licenses: []
23
+ metadata: {}
24
24
  post_install_message:
25
25
  rdoc_options: []
26
26
  require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
- none: false
30
29
  requirements:
31
- - - ! '>='
30
+ - - '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  required_rubygems_version: !ruby/object:Gem::Requirement
35
- none: false
36
34
  requirements:
37
- - - ! '>='
35
+ - - '>='
38
36
  - !ruby/object:Gem::Version
39
37
  version: '0'
40
38
  requirements: []
41
39
  rubyforge_project:
42
- rubygems_version: 1.8.24
40
+ rubygems_version: 2.2.1
43
41
  signing_key:
44
- specification_version: 3
42
+ specification_version: 4
45
43
  summary: sequel-location
46
44
  test_files: []