magic_addresses 0.0.40 → 0.0.41

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,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8735fd4ae4de78e2439288776253de6119c03987
4
- data.tar.gz: 0ff658497d0649f3304daedc45be6a5f8813bf56
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmU1Yjc5ZGJiNWUzYjlkMWFlZmFmN2RhYTYyYTJkNGIyYWRiZjEyZQ==
5
+ data.tar.gz: !binary |-
6
+ MGUxODAxNDFkMGRhNzczY2M2ZGU5MjljZGNjYzk2YzQ3MjRlYjQzYw==
5
7
  SHA512:
6
- metadata.gz: 05db027c18081cc99d48070336e6e4d128d0d74b9b9dd994b1969c2a8933b88251e77a7ef48430d5fbe626af341561f0eb8f3c040429bd18ad288aeebae12fd3
7
- data.tar.gz: 5286851a43b31cb85798f64d1630b349bf58ec10ec2f1dab23add2938ec5b3856a532b09cd5747b9a240d512de0376e8ed05d6ef8504cd2d3da3ae0ffa1fb225
8
+ metadata.gz: !binary |-
9
+ NGZjNTQ1ZjQxZWE0MzE4OGYxZmFlMGFkYWQ1NGY3NGNlZjVjOTljNDk0Mjdk
10
+ ODA1OTg0YTUwMGI4MTkwOGM3MjBjNzBkZDVlN2M2N2E3OTQxYzRjMDA3Mjlk
11
+ MDhkZDlhNmMyMzQxODExMGM2ZDZhZGU1NjhlYzFlNzkwZWE3ZjM=
12
+ data.tar.gz: !binary |-
13
+ OTU1OGFkYTQxMDM1M2M4N2NkOWVkZDFhZTY4ODU5ZmZkOGU3NzhjY2M1NzQ3
14
+ YjlhMWRkMTQwMTUyODFiZTQyMzg0N2IwZjVkYzkwMzFkY2U5Yjk4N2ZjZjhl
15
+ NzI4OTUxMDRlZWRjNTQyMGQ3YWUzMzA2MWYyZjNiMjY0MjViZmM=
@@ -106,11 +106,11 @@ class MagicAddresses::Address < ActiveRecord::Base
106
106
 
107
107
  # =====> I N S T A N C E - M E T H O D S <================================================= #
108
108
 
109
- def presentation( type = "inline" )
109
+ def presentation( style = "full", type = "inline" )
110
110
  adr = []
111
111
  adr << "#{street} #{number}".strip if street.present?
112
112
  adr << "#{postalcode} #{city}" if zipcode.present? || city.present?
113
- adr << country if country.present?
113
+ adr << country if country.present? if style == "full"
114
114
  if adr.count == 0
115
115
  I18n.t("addresses.no_address_given")
116
116
  else
@@ -203,7 +203,7 @@ private
203
203
  # translate other languages
204
204
 
205
205
  if MagicAddresses.configuration.job_backend == :sidekiq
206
- MagicAddresses::AddressWorker.perform_async( self.id )
206
+ ::MagicAddresses::AddressWorker.perform_async( self.id )
207
207
  else
208
208
  complete_translated_attributes()
209
209
  end
@@ -2,8 +2,8 @@
2
2
  class MagicAddresses::AddressWorker
3
3
  include Sidekiq::Worker
4
4
 
5
- def perform( address_id = nil )
6
- if address_id && address = ::MagicAddresses::Address.find( address_id )
5
+ def perform( address_id = nil, counter = 1 )
6
+ if address_id && address = ::MagicAddresses::Address.find( address_id.to_i )
7
7
 
8
8
  if address.fetch_address.present?
9
9
  puts "###"
@@ -12,6 +12,17 @@ class MagicAddresses::AddressWorker
12
12
  address.trigger_complete_translated_attributes
13
13
  end
14
14
 
15
+ else
16
+
17
+ counter = counter.to_i
18
+ puts "###"
19
+ puts "### AddressWorker => NO Address with ID: #{id} ...try ##{counter}"
20
+ puts "###"
21
+ if counter <= 3
22
+ counter += 1
23
+ ::MagicAddresses::AddressWorker.perform_in( 1.minute, id, counter )
24
+ end
25
+
15
26
  end
16
27
  end
17
28
 
@@ -1,4 +1,12 @@
1
1
  class AddEarthdistance < ActiveRecord::Migration
2
+ def get_indexes_for_table( table = 'mgca_addresses' )
3
+ ## ActiveRecord indexes .. doesnt include earthdistance, because its build directly in postgres!
4
+ # => ActiveRecord::Base.connection.indexes(:mgca_addresses).map{ |x| x.name }
5
+ # => index_exists?(:mgca_addresses, :earthdistance, name: "mgca_addresses_earthdistance_ix")
6
+ ## Postgres-Indexes .. thanks to: http://www.alberton.info/postgresql_meta_info.html#p13
7
+ 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 = '#{table}';").map{ |that| that["index_name"] }
8
+ end
9
+
2
10
  def self.up
3
11
 
4
12
  # comented out to avoid PG::InsufficientPrivilege-ERROR
@@ -11,17 +19,31 @@ class AddEarthdistance < ActiveRecord::Migration
11
19
  enable_extension "earthdistance"
12
20
  end
13
21
 
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")
22
+ unless get_indexes_for_table('mgca_addresses').include?("mgca_addresses_earthdistance_ix")
22
23
  add_earthdistance_index :mgca_addresses, lat: 'latitude', lng: 'longitude'
23
24
  end
24
25
 
26
+
27
+ ## Want to add indexes to other models?
28
+ ## -- Model needs this mehtod
29
+ ## acts_as_geolocated lat: 'latitude', lng: 'longitude')
30
+ ##
31
+ ## i.e.: Job-model:
32
+ ##
33
+ # => add_column :jobs, :latitude, :float
34
+ # => add_column :jobs, :longitude, :float
35
+ # => Job.all.each do |that|
36
+ # => if that.address && that.address.latitude && that.address.longitude
37
+ # => that.latitude = that.address.latitude
38
+ # => that.longitude = that.address.longitude
39
+ # => that.save(:validate => false)
40
+ # => end
41
+ # => end
42
+ # => unless get_indexes_for_table('jobs').include?("jobs_earthdistance_ix")
43
+ # => add_earthdistance_index :jobs, lat: 'latitude', lng: 'longitude'
44
+ # => end
45
+
46
+
25
47
  end
26
48
 
27
49
  def self.down
@@ -33,13 +55,18 @@ class AddEarthdistance < ActiveRecord::Migration
33
55
  disable_extension "cube"
34
56
  end
35
57
 
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
58
 
39
- if address_indexes.include?("mgca_addresses_earthdistance_ix")
59
+ if get_indexes_for_table('mgca_addresses').include?("mgca_addresses_earthdistance_ix")
40
60
  remove_earthdistance_index :mgca_addresses
41
61
  end
42
62
 
63
+ ## remove from Job
64
+ # => if get_indexes_for_table('jobs').include?("jobs_earthdistance_ix")
65
+ # => remove_earthdistance_index :jobs
66
+ # => end
67
+ # => remove_column :jobs, :latitude, :float
68
+ # => remove_column :jobs, :longitude, :float
69
+
43
70
 
44
71
  end
45
72
  end
@@ -1,3 +1,3 @@
1
1
  module MagicAddresses
2
- VERSION = "0.0.40"
2
+ VERSION = "0.0.41"
3
3
  end
@@ -4,22 +4,33 @@
4
4
  # Ensure the SQLite 3 gem is defined in your Gemfile
5
5
  # gem 'sqlite3'
6
6
  #
7
+ # default: &default
8
+ # adapter: sqlite3
9
+ # pool: 5
10
+ # timeout: 5000
11
+
7
12
  default: &default
8
- adapter: sqlite3
13
+ adapter: postgresql
14
+ encoding: unicode
9
15
  pool: 5
10
- timeout: 5000
16
+ host: localhost
17
+ username: austin
18
+ password:
11
19
 
12
20
  development:
13
21
  <<: *default
14
- database: db/development.sqlite3
22
+ # database: db/development.sqlite3
23
+ database: mgca_addresses_development
15
24
 
16
25
  # Warning: The database defined as "test" will be erased and
17
26
  # re-generated from your development database when you run "rake".
18
27
  # Do not set this db to the same as development or production.
19
28
  test:
20
29
  <<: *default
21
- database: db/test.sqlite3
30
+ # database: db/test.sqlite3
31
+ database: mgca_addresses_test
22
32
 
23
33
  production:
24
34
  <<: *default
25
- database: db/production.sqlite3
35
+ # database: db/production.sqlite3
36
+ database: mgca_addresses_production
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_addresses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.40
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Torsten Wetzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-06 00:00:00.000000000 Z
11
+ date: 2016-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.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: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: globalize
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 5.0.1
34
34
  type: :runtime
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: 5.0.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: geocoder
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.2'
48
48
  type: :runtime
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: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activerecord-postgres-earthdistance
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.3'
62
62
  type: :runtime
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.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: railties
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '4.0'
76
76
  type: :runtime
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: '4.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
- version: '3.2'
89
+ version: '3.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
- version: '3.2'
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - ! '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.3'
111
111
  description: Easy sortable and translated addresses uses google-api with nominatim
@@ -1101,17 +1101,17 @@ require_paths:
1101
1101
  - lib
1102
1102
  required_ruby_version: !ruby/object:Gem::Requirement
1103
1103
  requirements:
1104
- - - ">="
1104
+ - - ! '>='
1105
1105
  - !ruby/object:Gem::Version
1106
1106
  version: '0'
1107
1107
  required_rubygems_version: !ruby/object:Gem::Requirement
1108
1108
  requirements:
1109
- - - ">="
1109
+ - - ! '>='
1110
1110
  - !ruby/object:Gem::Version
1111
1111
  version: '0'
1112
1112
  requirements: []
1113
1113
  rubyforge_project:
1114
- rubygems_version: 2.5.0
1114
+ rubygems_version: 2.4.8
1115
1115
  signing_key:
1116
1116
  specification_version: 4
1117
1117
  summary: A really nice address plugin we offten use.