geopolitical 0.0.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +1 -1
- data/README.md +24 -0
- data/Rakefile +3 -20
- data/app/assets/javascripts/geopolitical/application.js +3 -5
- data/app/assets/stylesheets/geopolitical/application.css +1 -1
- data/app/controllers/geopolitical/cities_controller.rb +4 -3
- data/app/controllers/geopolitical/geopolitical_controller.rb +12 -3
- data/app/controllers/geopolitical/hoods_controller.rb +8 -2
- data/app/controllers/geopolitical/nations_controller.rb +16 -0
- data/app/controllers/geopolitical/{provinces_controller.rb → regions_controller.rb} +4 -3
- data/app/controllers/geopolitical/zones_controller.rb +12 -0
- data/app/controllers/zones_controller.rb +17 -0
- data/app/models/address.rb +65 -0
- data/app/models/city.rb +28 -29
- data/app/models/hood.rb +9 -11
- data/app/models/nation.rb +24 -0
- data/app/models/region.rb +23 -0
- data/app/models/zone.rb +25 -0
- data/app/models/zone_member.rb +9 -0
- data/app/views/geopolitical/cities/_form.html.haml +11 -10
- data/app/views/geopolitical/cities/index.html.haml +32 -30
- data/app/views/geopolitical/cities/show.html.haml +17 -26
- data/app/views/geopolitical/geopolitical/edit.html.haml +1 -0
- data/app/views/geopolitical/geopolitical/index.html.haml +19 -22
- data/app/views/geopolitical/geopolitical/new.html.haml +1 -0
- data/app/views/geopolitical/hoods/_city.html.haml +7 -0
- data/app/views/geopolitical/hoods/_form.html.haml +27 -0
- data/app/views/geopolitical/hoods/index.html.haml +33 -0
- data/app/views/geopolitical/hoods/show.html.haml +14 -0
- data/app/views/geopolitical/nations/_form.html.haml +26 -0
- data/app/views/geopolitical/nations/_nation.html.haml +0 -0
- data/app/views/geopolitical/nations/index.html.haml +34 -0
- data/app/views/geopolitical/nations/show.html.haml +20 -0
- data/app/views/geopolitical/regions/_form.html.haml +23 -0
- data/app/views/geopolitical/regions/_region.html.haml +7 -0
- data/app/views/geopolitical/regions/index.html.haml +31 -0
- data/app/views/geopolitical/regions/show.html.haml +17 -0
- data/app/views/geopolitical/zones/_form.html.haml +23 -0
- data/app/views/geopolitical/zones/_region.html.haml +7 -0
- data/app/views/geopolitical/zones/index.html.haml +31 -0
- data/app/views/geopolitical/zones/show.html.haml +21 -0
- data/app/views/layouts/geopolitical.html.haml +20 -0
- data/config/routes.rb +5 -4
- data/lib/geopolitical/engine.rb +2 -2
- data/lib/geopolitical/helpers.rb +23 -0
- data/lib/geopolitical/version.rb +1 -1
- data/lib/geopolitical.rb +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +27 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/mongoid.yml +13 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/log/test.log +2111 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/fabricators/city_fabricator.rb +6 -0
- data/spec/fabricators/hood_fabricator.rb +6 -0
- data/spec/fabricators/nation_fabricator.rb +4 -0
- data/spec/fabricators/region_fabricator.rb +5 -0
- data/spec/models/city_spec.rb +98 -0
- data/spec/models/hood_spec.rb +16 -0
- data/spec/models/nation_spec.rb +12 -0
- data/spec/models/region_spec.rb +12 -0
- data/spec/spec_helper.rb +54 -0
- metadata +198 -42
- data/README.rdoc +0 -3
- data/app/controllers/geopolitical/countries_controller.rb +0 -10
- data/app/models/country.rb +0 -20
- data/app/models/province.rb +0 -17
- data/app/views/geopolitical/cities/edit.html.haml +0 -1
- data/app/views/geopolitical/cities/new.html.haml +0 -1
- data/app/views/geopolitical/countries/_country.html.haml +0 -11
- data/app/views/geopolitical/countries/edit.html.haml +0 -7
- data/app/views/geopolitical/countries/index.html.haml +0 -28
- data/app/views/geopolitical/countries/new.html.haml +0 -5
- data/app/views/geopolitical/countries/show.html.haml +0 -10
- data/app/views/geopolitical/provinces/_province.html.haml +0 -7
- data/app/views/geopolitical/provinces/edit.html.haml +0 -7
- data/app/views/geopolitical/provinces/index.html.haml +0 -18
- data/app/views/geopolitical/provinces/new.html.haml +0 -5
- data/app/views/geopolitical/provinces/show.html.haml +0 -13
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe City do
|
5
|
+
|
6
|
+
it "should create a city" do
|
7
|
+
lambda { City.make! }.should_not raise_error
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "instance" do
|
11
|
+
let(:city) { City.make! }
|
12
|
+
|
13
|
+
|
14
|
+
describe "Relatives" do
|
15
|
+
let(:nation) { Nation.make! }
|
16
|
+
|
17
|
+
it "should belongs to nation" do
|
18
|
+
city.nation = nation
|
19
|
+
city.save.should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should belongs to region" do
|
23
|
+
city.nation = nation
|
24
|
+
city.save.should be_true
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "geoenabled" do
|
32
|
+
before do
|
33
|
+
City.create_indexes
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should find closest one" do
|
37
|
+
pending
|
38
|
+
city = City.make!
|
39
|
+
City.closest_to(city.geom).should eql(city)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "validations" do
|
45
|
+
|
46
|
+
it "should have a slug" do
|
47
|
+
city = City.new(name: "")
|
48
|
+
|
49
|
+
|
50
|
+
city.save
|
51
|
+
city.should_not be_valid
|
52
|
+
city.should have(1).errors_on(:slug)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
# it { should have_indices :name, :geom, :area, [:region_id, :nation_id] }
|
57
|
+
|
58
|
+
|
59
|
+
# it "should accept an area" do
|
60
|
+
# @city = City.make(:area => Polygon.from_coordinates([[[0,0],[4,0],[4,4],[0,4],[0,0]],[[1,1],[3,1],[3,3],[1,3],[1,1]]]))
|
61
|
+
# @city.area.should be_instance_of(Polygon)
|
62
|
+
# end
|
63
|
+
|
64
|
+
# describe "some helpers" do
|
65
|
+
# it "should have some nice x y z" do
|
66
|
+
# @city = City.make
|
67
|
+
# @city.should respond_to(:x,:y,:z)
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
|
71
|
+
# describe "Find by proximity" do
|
72
|
+
|
73
|
+
# def pt(x,y); Point.from_x_y(x,y); end
|
74
|
+
|
75
|
+
# before(:each) do
|
76
|
+
# @perto = City.make!(:geom => pt(10,10))
|
77
|
+
# @medio = City.make!(:geom => pt(20,20))
|
78
|
+
# @longe = City.make!(:geom => pt(30,30))
|
79
|
+
# @ponto = pt(12,12)
|
80
|
+
# end
|
81
|
+
|
82
|
+
# it "should find the closest city" do
|
83
|
+
# @city = City.close_to(@ponto).first
|
84
|
+
# @city.should eql(@perto)
|
85
|
+
# end
|
86
|
+
|
87
|
+
# it "should find the closest city to make sure" do
|
88
|
+
# ponto = pt(22,22)
|
89
|
+
# @city = City.close_to(ponto).first
|
90
|
+
# @city.should eql(@medio)
|
91
|
+
# end
|
92
|
+
|
93
|
+
# it "should find the closest" do
|
94
|
+
# @poi = City.close_to(@ponto).first(2)
|
95
|
+
# @poi.should eql([@perto,@medio])
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hood do
|
4
|
+
|
5
|
+
|
6
|
+
it "should create a nation" do
|
7
|
+
lambda { Hood.make! }.should_not raise_error
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
it "should belong to city" do
|
12
|
+
Fabricate.build(:hood, :city => nil).should have(1).error_on(:city)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'faker'
|
7
|
+
require 'fabrication'
|
8
|
+
require 'fabrication/syntax/make'
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
11
|
+
# in spec/support/ and its subdirectories.
|
12
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
13
|
+
|
14
|
+
# Checks for pending migrations before tests are run.
|
15
|
+
# If you are not using ActiveRecord, you can remove this line.
|
16
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
17
|
+
|
18
|
+
Fabrication.configure do |config|
|
19
|
+
#config.fabricator_path = 'data/fabricators'
|
20
|
+
config.path_prefix = Rails.root.join("../../")
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# ## Mock Framework
|
25
|
+
#
|
26
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
27
|
+
#
|
28
|
+
# config.mock_with :mocha
|
29
|
+
# config.mock_with :flexmock
|
30
|
+
# config.mock_with :rr
|
31
|
+
config.after(:each) do
|
32
|
+
Mongoid.purge!
|
33
|
+
# $stdout = File.new( '/tmp/lastspec', 'w' )
|
34
|
+
# $stdout.sync = true
|
35
|
+
end
|
36
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
37
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
38
|
+
|
39
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
40
|
+
# examples within a transaction, remove the following line or assign false
|
41
|
+
# instead of true.
|
42
|
+
# config.use_transactional_fixtures = true
|
43
|
+
|
44
|
+
# If true, the base class of anonymous controllers will be inferred
|
45
|
+
# automatically. This will be the default behavior in future versions of
|
46
|
+
# rspec-rails.
|
47
|
+
config.infer_base_class_for_anonymous_controllers = false
|
48
|
+
|
49
|
+
# Run specs in random order to surface order dependencies. If you find an
|
50
|
+
# order dependency and want to debug it, you can fix the order by providing
|
51
|
+
# the seed, which is printed after each run.
|
52
|
+
# --seed 1234
|
53
|
+
config.order = "random"
|
54
|
+
end
|