geopolitical 1.0.2 → 1.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 +4 -4
- data/Gemfile +0 -1
- data/Guardfile +2 -2
- data/app/controllers/geopolitical/nations_controller.rb +0 -1
- data/app/models/city.rb +3 -3
- data/app/models/concerns/geopolitocracy.rb +26 -21
- data/app/models/hood.rb +5 -0
- data/app/models/nation.rb +2 -2
- data/app/models/region.rb +1 -1
- data/lib/geopolitical/version.rb +1 -1
- data/spec/dummy/bin/rails +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/log/test.log +7200 -0
- data/spec/fabricators/hood_fabricator.rb +1 -1
- data/spec/fabricators/nation_fabricator.rb +1 -1
- data/spec/models/city_spec.rb +8 -2
- data/spec/models/hood_spec.rb +20 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5f18cc9f1bcf0dc111ab2545a439e13982cb6b
|
4
|
+
data.tar.gz: 1b9139b45fb6091fa6b0f50435507829d94dc5d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a40d4e8c3284d3de08d7997311807e2ae7dd8f53aebf491701a0e9944c96a4240a8d33fe1b8251b69941f2eb39816d99ff283c76edeec5b24454a6bf74e242d
|
7
|
+
data.tar.gz: e9cb615e832174edf67b2949f55b768af7eba05c1d05275037dd757312fa2c7bd3197b31865f747b3775225e7971571a531fc0e6870bfae4a79eac68e9effe98
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -13,8 +13,8 @@ guard :rspec, cmd: 'bundle exec rspec' do
|
|
13
13
|
watch(/^spec\/spec_helper\.rb$/) { 'spec' }
|
14
14
|
watch(/^app\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
|
15
15
|
watch(/^lib\/(.+)\.rb$/) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
16
|
-
watch(%r{^app/models/concerns/(.+)\.rb$})
|
17
|
-
watch(%r{^app/controllers/(.+)_(controller)\.rb$})
|
16
|
+
watch(%r{^app/models/concerns/(.+)\.rb$}) { |_m| 'spec/models/*._spec.rb' }
|
17
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
|
18
18
|
[
|
19
19
|
"spec/routing/#{m[1]}_routing_spec.rb",
|
20
20
|
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
|
data/app/models/city.rb
CHANGED
@@ -6,8 +6,8 @@ class City
|
|
6
6
|
include Mongoid::Geospatial
|
7
7
|
include Geopolitocracy
|
8
8
|
|
9
|
-
field :area, type: Integer
|
10
|
-
field :geom, type: Point,
|
9
|
+
field :area, type: Integer # m2 square area
|
10
|
+
field :geom, type: Point, spatial: true
|
11
11
|
# field :capital, type: String
|
12
12
|
|
13
13
|
spatial_scope :geom
|
@@ -43,7 +43,7 @@ class City
|
|
43
43
|
return unless City.where(slug: slug).first
|
44
44
|
self.slug += "-#{region.abbr}"
|
45
45
|
return unless City.where(slug: slug).first
|
46
|
-
|
46
|
+
raise "Two cities with the same name in #{region}: '#{slug}'"
|
47
47
|
end
|
48
48
|
|
49
49
|
def phone
|
@@ -5,15 +5,15 @@ module Geopolitocracy
|
|
5
5
|
included do
|
6
6
|
# field :gid, type: Integer # geonames id
|
7
7
|
|
8
|
-
field :name,
|
9
|
-
field :abbr,
|
10
|
-
field :nick,
|
8
|
+
field :name, type: String, localize: true
|
9
|
+
field :abbr, type: String
|
10
|
+
field :nick, type: String
|
11
11
|
|
12
|
-
field :souls,
|
12
|
+
field :souls, type: Fixnum # Population
|
13
13
|
|
14
|
-
field :ascii,
|
15
|
-
field :code,
|
16
|
-
field :slug,
|
14
|
+
field :ascii, type: String
|
15
|
+
field :code, type: String
|
16
|
+
field :slug, type: String # , default: -> { name }
|
17
17
|
|
18
18
|
field :postal, type: String # , default: -> { name }
|
19
19
|
field :phone, type: String # , default: -> { name }
|
@@ -32,24 +32,29 @@ module Geopolitocracy
|
|
32
32
|
|
33
33
|
scope :ordered, -> { order_by(name: 1) }
|
34
34
|
|
35
|
+
def ensure_slug
|
36
|
+
self.slug ||= name
|
37
|
+
end
|
38
|
+
|
39
|
+
def name=(txt)
|
40
|
+
txt = txt.titleize unless txt =~ /[A-Z][a-z]/
|
41
|
+
super txt
|
42
|
+
end
|
43
|
+
|
44
|
+
def slug=(txt)
|
45
|
+
return unless txt
|
46
|
+
self[:slug] = ActiveSupport::Inflector
|
47
|
+
.transliterate(txt).delete('.').gsub(/\W/, '-').downcase
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
name || slug
|
52
|
+
end
|
53
|
+
|
35
54
|
def self.search(txt, lazy = false)
|
36
55
|
key = ActiveSupport::Inflector.transliterate(txt).gsub(/\W/, '-')
|
37
56
|
char = lazy ? nil : '$'
|
38
57
|
where(slug: /^#{key}#{char}/i)
|
39
58
|
end
|
40
59
|
end
|
41
|
-
|
42
|
-
def ensure_slug
|
43
|
-
self.slug ||= name
|
44
|
-
end
|
45
|
-
|
46
|
-
def slug=(txt)
|
47
|
-
return unless txt
|
48
|
-
self[:slug] = ActiveSupport::Inflector.transliterate(txt)
|
49
|
-
.gsub(/\W/, '-').downcase
|
50
|
-
end
|
51
|
-
|
52
|
-
def to_s
|
53
|
-
name || slug
|
54
|
-
end
|
55
60
|
end
|
data/app/models/hood.rb
CHANGED
data/app/models/nation.rb
CHANGED
@@ -14,8 +14,8 @@ class Nation
|
|
14
14
|
field :lang, type: String # Official/main language
|
15
15
|
field :langs, type: Array # All official languages
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
alias currency cash
|
18
|
+
alias iso_3166_3 code3
|
19
19
|
|
20
20
|
validates :abbr, uniqueness: true, presence: true
|
21
21
|
|
data/app/models/region.rb
CHANGED
data/lib/geopolitical/version.rb
CHANGED
data/spec/dummy/bin/rails
CHANGED
@@ -13,7 +13,7 @@ Dummy::Application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.serve_static_files
|
16
|
+
config.serve_static_files = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
data/spec/dummy/config.ru
CHANGED