go_geography 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b8c29193934b8609dbca73a15d83d6c47e044c0
4
+ data.tar.gz: 7582aa198196ecdbf868200285e3e8d2c49ae9e1
5
+ SHA512:
6
+ metadata.gz: 7298a28aa9c8faa90c65e1148c5057e10bd07a8f2ca0520751424e49f29c166fe0e98e73eabaec62259e0cd0b2b70edd47a6ebf354cd6d4a79f3c9b4740ceee3
7
+ data.tar.gz: d7eecd6bbdbcfd99a9b5edba0d93c950e404dadcb03b44f8680ef42423ab7875c223aa015decf242e3c74b4cd0535e4caaa2b1c64d94c821cb731edf50905a3d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 João Carlos Ottobboni
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # GoGeography
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'go_geography'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install go_geography
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'GoGeography'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task default: :test
File without changes
@@ -0,0 +1,64 @@
1
+ module Geography
2
+ class CitiesController < ApplicationController
3
+ before_action :set_city, only: [:show, :edit, :update, :destroy]
4
+ before_action :authenticate_user!
5
+ add_breadcrumb 'Cidades', :cities_path
6
+ add_breadcrumb 'Criar nova cidade', '', :only => [:new, :create]
7
+ add_breadcrumb 'Editar nova cidade', '', :only => [:edit, :update]
8
+ # GET /cities
9
+ def index
10
+ @cities = City.all.page(params[:page])
11
+ end
12
+
13
+ # GET /cities/1
14
+ def show
15
+ add_breadcrumb @city.name, ''
16
+ end
17
+
18
+ # GET /cities/new
19
+ def new
20
+ @city = City.new
21
+ end
22
+
23
+ # GET /cities/1/edit
24
+ def edit
25
+ end
26
+
27
+ # POST /cities
28
+ def create
29
+ @city = City.new(city_params)
30
+
31
+ if @city.save
32
+ redirect_to @city, notice: 'City was successfully created.'
33
+ else
34
+ render :new
35
+ end
36
+ end
37
+
38
+ # PATCH/PUT /cities/1
39
+ def update
40
+ if @city.update(city_params)
41
+ redirect_to @city, notice: 'City was successfully updated.'
42
+ else
43
+ render :edit
44
+ end
45
+ end
46
+
47
+ # DELETE /cities/1
48
+ def destroy
49
+ @city.destroy
50
+ redirect_to cities_url, notice: 'City was successfully destroyed.'
51
+ end
52
+
53
+ private
54
+ # Use callbacks to share common setup or constraints between actions.
55
+ def set_city
56
+ @city = City.find(params[:id])
57
+ end
58
+
59
+ # Only allow a trusted parameter "white list" through.
60
+ def city_params
61
+ params.require(:city).permit(:name, :cdg_ibge, :state_id, :population_2010, :demographic_density, :gentle, :area)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,61 @@
1
+ module Geography
2
+ class StatesController < ApplicationController
3
+ before_action :set_state, only: [:show, :edit, :update, :destroy]
4
+ before_action :authenticate_user!
5
+
6
+ # GET /states
7
+ def index
8
+ @states = State.all
9
+ end
10
+
11
+ # GET /states/1
12
+ def show
13
+ end
14
+
15
+ # GET /states/new
16
+ def new
17
+ @state = State.new
18
+ end
19
+
20
+ # GET /states/1/edit
21
+ def edit
22
+ end
23
+
24
+ # POST /states
25
+ def create
26
+ @state = State.new(state_params)
27
+
28
+ if @state.save
29
+ redirect_to @state, notice: 'State was successfully created.'
30
+ else
31
+ render :new
32
+ end
33
+ end
34
+
35
+ # PATCH/PUT /states/1
36
+ def update
37
+ if @state.update(state_params)
38
+ redirect_to @state, notice: 'State was successfully updated.'
39
+ else
40
+ render :edit
41
+ end
42
+ end
43
+
44
+ # DELETE /states/1
45
+ def destroy
46
+ @state.destroy
47
+ redirect_to states_url, notice: 'State was successfully destroyed.'
48
+ end
49
+
50
+ private
51
+ # Use callbacks to share common setup or constraints between actions.
52
+ def set_state
53
+ @state = State.find(params[:id])
54
+ end
55
+
56
+ # Only allow a trusted parameter "white list" through.
57
+ def state_params
58
+ params.require(:state).permit(:name, :initials)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,6 @@
1
+ module Geography
2
+ def self.table_name_prefix
3
+ 'geography_'
4
+ end
5
+ end
6
+
@@ -0,0 +1,20 @@
1
+ module Geography
2
+ class City < ApplicationRecord
3
+ # extends ...................................................................
4
+ # includes ..................................................................
5
+ # security (i.e. attr_accessible) ...........................................
6
+ # relationships .............................................................
7
+ belongs_to :state
8
+ # validations ...............................................................
9
+ # callbacks .................................................................
10
+ # scopes ....................................................................
11
+ # additional config .........................................................
12
+ # class methods .............................................................
13
+ def state_name
14
+ self.state.name if self.state
15
+ end
16
+ # public instance methods ...................................................
17
+ # protected instance methods ................................................
18
+ # private instance methods ..................................................
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module Geography
2
+ class State < ApplicationRecord
3
+ # extends ...................................................................
4
+ # includes ..................................................................
5
+ # security (i.e. attr_accessible) ...........................................
6
+ # relationships .............................................................
7
+ has_many :cities
8
+ # validations ...............................................................
9
+ # callbacks .................................................................
10
+ # scopes ....................................................................
11
+ # additional config .........................................................
12
+ # class methods .............................................................
13
+ # public instance methods ...................................................
14
+ # protected instance methods ................................................
15
+ # private instance methods ..................................................
16
+ end
17
+ end
@@ -0,0 +1,24 @@
1
+ <% collection.each do |resource| %>
2
+ <tr>
3
+ <td><%= resource.name %></td>
4
+ <td><%= resource.cdg_ibge %></td>
5
+ <td><%= resource.state_id %></td>
6
+ <td><%= resource.population_2010 %></td>
7
+ <td><%= resource.demographic_density %></td>
8
+ <td><%= resource.gentle %></td>
9
+ <td><%= resource.area %></td>
10
+
11
+ <td class="text-center">
12
+ <%= link_to resource, data: {toggle: 'tooltip', original_title: I18n.t('views.misc.actions.show')}, title: '', class: "btn btn-xs btn-default" do %>
13
+ <i class="fa fa-list"></i>
14
+ <% end %>
15
+ <%= link_to edit_city_path(resource), data: {toggle: 'tooltip', original_title: I18n.t('views.misc.actions.edit')}, title: '', class: "btn btn-xs btn-default" do %>
16
+ <i class="fa fa-pencil"></i>
17
+ <% end %>
18
+
19
+ <%= link_to resource, method: :delete, data: { confirm: I18n.t('views.misc.actions.confirm') }, title: '', class: "btn btn-xs btn-default" do %>
20
+ <i class="fa fa-times"></i>
21
+ <% end %>
22
+ </td>
23
+ </tr>
24
+ <% end %>
@@ -0,0 +1,52 @@
1
+ <%= form_for(city) do |f| %>
2
+ <% if city.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(city.errors.count, "error") %> prohibited this city from being saved:</h2>
5
+
6
+ <ul>
7
+ <% city.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= f.label :cdg_ibge %>
21
+ <%= f.number_field :cdg_ibge %>
22
+ </div>
23
+
24
+ <div class="field">
25
+ <%= f.label :state_id %>
26
+ <%= f.number_field :state_id %>
27
+ </div>
28
+
29
+ <div class="field">
30
+ <%= f.label :population_2010 %>
31
+ <%= f.number_field :population_2010 %>
32
+ </div>
33
+
34
+ <div class="field">
35
+ <%= f.label :demographic_density %>
36
+ <%= f.text_field :demographic_density %>
37
+ </div>
38
+
39
+ <div class="field">
40
+ <%= f.label :gentle %>
41
+ <%= f.text_field :gentle %>
42
+ </div>
43
+
44
+ <div class="field">
45
+ <%= f.label :area %>
46
+ <%= f.text_field :area %>
47
+ </div>
48
+
49
+ <div class="actions">
50
+ <%= f.submit %>
51
+ </div>
52
+ <% end %>
@@ -0,0 +1,9 @@
1
+
2
+ <%= provide :page_title, I18n.t('cities.edit.header', resource: @city.try(:id) ) %>
3
+
4
+ <%= render 'form', city: @city %>
5
+
6
+ <br>
7
+ <%= link_to I18n.t('views.misc.actions.show'), @city ,class: 'btn btn-sm btn-square btn-default'%> |
8
+ <%= link_to I18n.t('views.misc.actions.back'), cities_path, class: 'btn btn-sm btn-square btn-default' %>
9
+
@@ -0,0 +1,28 @@
1
+ <p id="notice"><%= notice %></p>
2
+ <h1><%= I18n.t('activerecord.models.city.other') %></h1>
3
+
4
+
5
+ <table class="table-hover">
6
+ <thead>
7
+ <tr>
8
+ <th><%= I18n.t 'activerecord.attributes.city.name' %></th>
9
+ <th><%= I18n.t 'activerecord.attributes.city.cdg_ibge' %></th>
10
+ <th><%= I18n.t 'activerecord.attributes.city.state' %></th>
11
+ <th><%= I18n.t 'activerecord.attributes.city.population_2010' %></th>
12
+ <th><%= I18n.t 'activerecord.attributes.city.demographic_density' %></th>
13
+ <th><%= I18n.t 'activerecord.attributes.city.gentle' %></th>
14
+ <th><%= I18n.t 'activerecord.attributes.city.area' %></th>
15
+ <th colspan="3"></th>
16
+ </tr>
17
+ </thead>
18
+
19
+ <tbody>
20
+ <%= render 'collection', collection: @cities %>
21
+ </tbody>
22
+ </table>
23
+
24
+ <br>
25
+
26
+ <%= paginate @cities %>
27
+
28
+ <%= page_entries_info @cities %>
@@ -0,0 +1,6 @@
1
+ <h1><%= I18n.t('activerecord.models.city.one') %></h1>
2
+
3
+ <%= render 'form', city: @city %>
4
+
5
+ <%= link_to I18n.t('views.misc.actions.back'), cities_path, class: 'btn btn-sm btn-square btn-default' %>
6
+
@@ -0,0 +1,43 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong><%= I18n.t 'activerecord.attributes.city.name' %>:</strong>
5
+ <%= @city.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong><%= I18n.t 'activerecord.attributes.city.cdg_ibge' %>:</strong>
10
+ <%= @city.cdg_ibge %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong><%= I18n.t 'activerecord.attributes.city.state' %>:</strong>
15
+ <%= @city.state_name %>
16
+ </p>
17
+
18
+ <p>
19
+ <strong><%= I18n.t 'activerecord.attributes.city.population_2010' %> :</strong>
20
+ <%= @city.population_2010 %>
21
+ </p>
22
+
23
+ <p>
24
+ <strong><%= I18n.t 'activerecord.attributes.city.demographic_density' %> :</strong>
25
+ <%= @city.demographic_density %>
26
+ </p>
27
+
28
+ <p>
29
+ <strong><%= I18n.t 'activerecord.attributes.city.gentle' %>:</strong>
30
+ <%= @city.gentle %>
31
+ </p>
32
+
33
+ <p>
34
+ <strong><%= I18n.t 'activerecord.attributes.city.area' %>:</strong>
35
+ <%= @city.area %>
36
+ </p>
37
+
38
+
39
+
40
+ <%= link_to I18n.t('views.misc.actions.back'), cities_path, class: 'btn btn-sm btn-square btn-default' %>
41
+ <%= link_to I18n.t('views.misc.actions.edit'),edit_city_path(@city), class: 'btn btn-sm btn-square btn-default' %>
42
+ <%= link_to I18n.t('views.misc.actions.destroy'),cities_path(@city), method: :destroy, data: {confirm: I18n.t('views.misc.actions.confirm') }, class: 'btn btn-sm btn-square btn-default' %>
43
+