geopolitical 0.0.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +24 -0
  4. data/Rakefile +3 -20
  5. data/app/assets/javascripts/geopolitical/application.js +3 -5
  6. data/app/assets/stylesheets/geopolitical/application.css +1 -1
  7. data/app/controllers/geopolitical/cities_controller.rb +4 -3
  8. data/app/controllers/geopolitical/geopolitical_controller.rb +12 -3
  9. data/app/controllers/geopolitical/hoods_controller.rb +8 -2
  10. data/app/controllers/geopolitical/nations_controller.rb +16 -0
  11. data/app/controllers/geopolitical/{provinces_controller.rb → regions_controller.rb} +4 -3
  12. data/app/controllers/geopolitical/zones_controller.rb +12 -0
  13. data/app/controllers/zones_controller.rb +17 -0
  14. data/app/models/address.rb +65 -0
  15. data/app/models/city.rb +28 -29
  16. data/app/models/hood.rb +9 -11
  17. data/app/models/nation.rb +24 -0
  18. data/app/models/region.rb +23 -0
  19. data/app/models/zone.rb +25 -0
  20. data/app/models/zone_member.rb +9 -0
  21. data/app/views/geopolitical/cities/_form.html.haml +11 -10
  22. data/app/views/geopolitical/cities/index.html.haml +32 -30
  23. data/app/views/geopolitical/cities/show.html.haml +17 -26
  24. data/app/views/geopolitical/geopolitical/edit.html.haml +1 -0
  25. data/app/views/geopolitical/geopolitical/index.html.haml +19 -22
  26. data/app/views/geopolitical/geopolitical/new.html.haml +1 -0
  27. data/app/views/geopolitical/hoods/_city.html.haml +7 -0
  28. data/app/views/geopolitical/hoods/_form.html.haml +27 -0
  29. data/app/views/geopolitical/hoods/index.html.haml +33 -0
  30. data/app/views/geopolitical/hoods/show.html.haml +14 -0
  31. data/app/views/geopolitical/nations/_form.html.haml +26 -0
  32. data/app/views/geopolitical/nations/_nation.html.haml +0 -0
  33. data/app/views/geopolitical/nations/index.html.haml +34 -0
  34. data/app/views/geopolitical/nations/show.html.haml +20 -0
  35. data/app/views/geopolitical/regions/_form.html.haml +23 -0
  36. data/app/views/geopolitical/regions/_region.html.haml +7 -0
  37. data/app/views/geopolitical/regions/index.html.haml +31 -0
  38. data/app/views/geopolitical/regions/show.html.haml +17 -0
  39. data/app/views/geopolitical/zones/_form.html.haml +23 -0
  40. data/app/views/geopolitical/zones/_region.html.haml +7 -0
  41. data/app/views/geopolitical/zones/index.html.haml +31 -0
  42. data/app/views/geopolitical/zones/show.html.haml +21 -0
  43. data/app/views/layouts/geopolitical.html.haml +20 -0
  44. data/config/routes.rb +5 -4
  45. data/lib/geopolitical/engine.rb +2 -2
  46. data/lib/geopolitical/helpers.rb +23 -0
  47. data/lib/geopolitical/version.rb +1 -1
  48. data/lib/geopolitical.rb +4 -0
  49. data/spec/dummy/README.rdoc +28 -0
  50. data/spec/dummy/Rakefile +6 -0
  51. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  52. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  53. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  54. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  55. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  56. data/spec/dummy/bin/bundle +3 -0
  57. data/spec/dummy/bin/rails +4 -0
  58. data/spec/dummy/bin/rake +4 -0
  59. data/spec/dummy/config/application.rb +27 -0
  60. data/spec/dummy/config/boot.rb +5 -0
  61. data/spec/dummy/config/environment.rb +5 -0
  62. data/spec/dummy/config/environments/development.rb +29 -0
  63. data/spec/dummy/config/environments/production.rb +80 -0
  64. data/spec/dummy/config/environments/test.rb +36 -0
  65. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  66. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  67. data/spec/dummy/config/initializers/inflections.rb +16 -0
  68. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  69. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  70. data/spec/dummy/config/initializers/session_store.rb +3 -0
  71. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  72. data/spec/dummy/config/locales/en.yml +23 -0
  73. data/spec/dummy/config/mongoid.yml +13 -0
  74. data/spec/dummy/config/routes.rb +4 -0
  75. data/spec/dummy/config.ru +4 -0
  76. data/spec/dummy/log/test.log +2111 -0
  77. data/spec/dummy/public/404.html +58 -0
  78. data/spec/dummy/public/422.html +58 -0
  79. data/spec/dummy/public/500.html +57 -0
  80. data/spec/dummy/public/favicon.ico +0 -0
  81. data/spec/fabricators/city_fabricator.rb +6 -0
  82. data/spec/fabricators/hood_fabricator.rb +6 -0
  83. data/spec/fabricators/nation_fabricator.rb +4 -0
  84. data/spec/fabricators/region_fabricator.rb +5 -0
  85. data/spec/models/city_spec.rb +98 -0
  86. data/spec/models/hood_spec.rb +16 -0
  87. data/spec/models/nation_spec.rb +12 -0
  88. data/spec/models/region_spec.rb +12 -0
  89. data/spec/spec_helper.rb +54 -0
  90. metadata +198 -42
  91. data/README.rdoc +0 -3
  92. data/app/controllers/geopolitical/countries_controller.rb +0 -10
  93. data/app/models/country.rb +0 -20
  94. data/app/models/province.rb +0 -17
  95. data/app/views/geopolitical/cities/edit.html.haml +0 -1
  96. data/app/views/geopolitical/cities/new.html.haml +0 -1
  97. data/app/views/geopolitical/countries/_country.html.haml +0 -11
  98. data/app/views/geopolitical/countries/edit.html.haml +0 -7
  99. data/app/views/geopolitical/countries/index.html.haml +0 -28
  100. data/app/views/geopolitical/countries/new.html.haml +0 -5
  101. data/app/views/geopolitical/countries/show.html.haml +0 -10
  102. data/app/views/geopolitical/provinces/_province.html.haml +0 -7
  103. data/app/views/geopolitical/provinces/edit.html.haml +0 -7
  104. data/app/views/geopolitical/provinces/index.html.haml +0 -18
  105. data/app/views/geopolitical/provinces/new.html.haml +0 -5
  106. 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,6 @@
1
+ Fabricator :city do
2
+ nation
3
+ name { sequence(:name) { |i| "#{Faker::Address.city}#{i}" }}
4
+ geom { [rand(30) - 50, rand(40) - 30] }
5
+ #code { object.name[0..2].upcase }
6
+ end
@@ -0,0 +1,6 @@
1
+ Fabricator :hood do
2
+ city
3
+ name { sequence(:name) { |i| "#{Faker::Address.city}#{i}" }}
4
+ geom { [rand(30) - 50, rand(40) - 30] }
5
+ #code { object.name[0..2].upcase }
6
+ end
@@ -0,0 +1,4 @@
1
+ Fabricator :nation do
2
+ name { sequence { |i| Faker::Address.country }}
3
+ abbr { |c| c[:name].first.upcase + ('A'..'Z').to_a[rand(23)] }
4
+ end
@@ -0,0 +1,5 @@
1
+ Fabricator :region do
2
+ name { Faker::Address.city }
3
+ abbr { |p| p[:name][0..2].upcase }
4
+ nation
5
+ end
@@ -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
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Nation do
4
+
5
+
6
+ it "should create a nation" do
7
+ lambda { Nation.make! }.should_not raise_error
8
+ end
9
+
10
+
11
+
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe Region do
4
+
5
+
6
+ it "should create a region" do
7
+ lambda { Region.make! }.should_not raise_error
8
+ end
9
+
10
+
11
+
12
+ end
@@ -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