magic_addresses 0.0.21 → 0.0.22

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: d1740954bb74162aa5db6ff41b37392286598125
4
- data.tar.gz: 61ce0db068c139e5c551581354fc11b2b375d4c8
3
+ metadata.gz: f14808f092d806e953d577241679aa14d82b7ff6
4
+ data.tar.gz: 9265f6532a359f6f5b496b7c8fbd8dc7ec9194f9
5
5
  SHA512:
6
- metadata.gz: c9bf3d8f3f0b10c82b826cc612bf7f292f0f6b96079de6d4bb1e1d927df4de14607b70107c2994f822b359a164715942eafadbcb002bd3faca3ae44f0ea2c83a
7
- data.tar.gz: 845d619cf206b152ce5e656116588cd3e3fdd2f66b46bb55f828ba89a08ad7b9214365cb453870ae22c492370d796e3af9cffd9f3187671ce93ab6046d779ae2
6
+ metadata.gz: 23f0dc9da740e003b22f7b724c012ef3d668f232b96b71621960fb50a2fd92298ef911e22f66c520f0ddfcbf5a7e1adf48fb230e2fa83472b0bf46ec7f66efa0
7
+ data.tar.gz: 5ecf767c8ef3bb1bf201f1b5e9b4147cb332369ef95edd5839f6bd0be4eb0c2dc93e3344c762e6068fe1abd95e7c54b5c9327d3e1b30f1e80f07e4cf3cbdad5e
@@ -77,7 +77,7 @@ module MagicAddresses
77
77
  module OneInstanceMethods
78
78
 
79
79
  # => http://stackoverflow.com/a/6989403/1470996
80
- def build_address(params)
80
+ def build_address(params = {})
81
81
  self.address = MagicAddresses::Address.new(params)
82
82
  end
83
83
 
@@ -11,7 +11,14 @@ class AddEarthdistance < ActiveRecord::Migration
11
11
  enable_extension "earthdistance"
12
12
  end
13
13
 
14
- unless index_exists?(:mgca_addresses, [:latitude,:longitude], name: "mgca_addresses_earthdistance_ix")
14
+ ## ActiveRecord indexes .. doesnt include earthdistance, because its build directly in postgres!
15
+ # => address_indexes = ActiveRecord::Base.connection.indexes(:mgca_addresses).map{ |x| x.name }
16
+ # => index_exists?(:mgca_addresses, :earthdistance, name: "mgca_addresses_earthdistance_ix")
17
+
18
+ ## Postgres-Indexes .. thanks to: http://www.alberton.info/postgresql_meta_info.html#p13
19
+ address_indexes = execute( "SELECT c.relname AS index_name FROM pg_class AS a JOIN pg_index AS b ON (a.oid = b.indrelid) JOIN pg_class AS c ON (c.oid = b.indexrelid) WHERE a.relname = 'mgca_addresses';").map{ |that| that["index_name"] }
20
+
21
+ unless address_indexes.include?("mgca_addresses_earthdistance_ix")
15
22
  add_earthdistance_index :mgca_addresses, lat: 'latitude', lng: 'longitude'
16
23
  end
17
24
 
@@ -26,7 +33,13 @@ class AddEarthdistance < ActiveRecord::Migration
26
33
  disable_extension "cube"
27
34
  end
28
35
 
29
- remove_index :mgca_addresses, [:latitude,:longitude], name: "mgca_addresses_earthdistance_ix"
36
+ ## Postgres-Indexes
37
+ address_indexes = execute( "SELECT c.relname AS index_name FROM pg_class AS a JOIN pg_index AS b ON (a.oid = b.indrelid) JOIN pg_class AS c ON (c.oid = b.indexrelid) WHERE a.relname = 'mgca_addresses';").map{ |that| that["index_name"] }
38
+
39
+ if address_indexes.include?("mgca_addresses_earthdistance_ix")
40
+ remove_earthdistance_index :mgca_addresses
41
+ end
42
+
30
43
 
31
44
  end
32
45
  end
@@ -1,3 +1,3 @@
1
1
  module MagicAddresses
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.22"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_addresses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Torsten Wetzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-19 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -723,7 +723,6 @@ files:
723
723
  - spec/dummy/tmp/cache/assets/development/sprockets/fbeae887906c8a9e094b9de8fc7d52fe
724
724
  - spec/dummy/tmp/cache/assets/development/sprockets/fe322514affb78a8dc2e29095b28d577
725
725
  - spec/dummy/tmp/cache/assets/development/sprockets/fe51c58ea609c72d7706c18fd127b049
726
- - spec/dummy/tmp/pids/server.pid
727
726
  - spec/models/company_spec.rb
728
727
  - spec/models/magic_addresses/address_spec.rb
729
728
  - spec/models/magic_addresses/association_spec.rb
@@ -1668,7 +1667,6 @@ test_files:
1668
1667
  - spec/dummy/tmp/cache/assets/development/sprockets/fbeae887906c8a9e094b9de8fc7d52fe
1669
1668
  - spec/dummy/tmp/cache/assets/development/sprockets/fe322514affb78a8dc2e29095b28d577
1670
1669
  - spec/dummy/tmp/cache/assets/development/sprockets/fe51c58ea609c72d7706c18fd127b049
1671
- - spec/dummy/tmp/pids/server.pid
1672
1670
  - spec/models/company_spec.rb
1673
1671
  - spec/models/magic_addresses/address_spec.rb
1674
1672
  - spec/models/magic_addresses/association_spec.rb
@@ -1 +0,0 @@
1
- 84678