mix-rails-addresses 0.24.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 +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +29 -0
- data/app/controllers/cities_controller.rb +12 -0
- data/app/controllers/states_controller.rb +11 -0
- data/app/models/address.rb +13 -0
- data/app/models/city.rb +8 -0
- data/app/models/state.rb +9 -0
- data/config/locales/addresses.pt-BR.yml +3 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20130306144900_create_states.rb +10 -0
- data/db/migrate/20130306145007_create_cities.rb +12 -0
- data/db/migrate/20130306172839_create_addresses.rb +17 -0
- data/db/migrate/20130311130844_add_latitude_longitude_to_address.rb +6 -0
- data/db/seeds.rb +31 -0
- data/lib/mix-rails-addresses/engine.rb +8 -0
- data/lib/mix-rails-addresses/version.rb +10 -0
- data/lib/mix-rails-addresses.rb +4 -0
- data/lib/tasks/mix-rails-addresses_tasks.rake +4 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 59a594509f8dee7e604eb4a3b630c5e6b7575b1c
|
4
|
+
data.tar.gz: c318febb3c4d4c9e2973e669310231687da1bb5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 14d3097ce0cc0b2fa094e3ef89e929e708c43fcb66505b55340e3f26aa60e11550159fb895c89b8d23a2c77cf62cb478583720e230f3416aefe55c558511fe6b
|
7
|
+
data.tar.gz: e78bd877f2bf88b69709d5305213381d02ec7fafef5370309d9f4b7cd2458d3ddfc887ccc271e95f02738db7ecd3bde192477cdc9df309ec624325a2566a121c
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
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.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'MixRailsAddresses'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Address < ActiveRecord::Base
|
2
|
+
belongs_to :city
|
3
|
+
delegate :state, :to => :city, :allow_nil => true
|
4
|
+
belongs_to :addressable, polymorphic: true
|
5
|
+
attr_accessible :address, :complement, :description, :district, :number, :zipcode, :latitude, :longitude
|
6
|
+
|
7
|
+
|
8
|
+
def to_s
|
9
|
+
"#{address}, #{number} - #{district} - #{city}/#{state}"
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
end
|
data/app/models/city.rb
ADDED
data/app/models/state.rb
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateAddresses < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :addresses do |t|
|
4
|
+
t.string :description
|
5
|
+
t.string :zipcode
|
6
|
+
t.string :address
|
7
|
+
t.string :number
|
8
|
+
t.string :complement
|
9
|
+
t.string :district
|
10
|
+
t.references :city
|
11
|
+
t.references :addressable, polymorphic: true
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
add_index :addresses, :city_id
|
16
|
+
end
|
17
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https' # for ruby 1.8.7
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module BRPopulate
|
6
|
+
def self.states
|
7
|
+
http = Net::HTTP.new('raw.github.com', 443); http.use_ssl = true
|
8
|
+
JSON.parse http.get('/celsodantas/br_populate/master/states.json').body
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.capital?(city, state)
|
12
|
+
city["name"] == state["capital"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.populate
|
16
|
+
states.each do |state|
|
17
|
+
state_obj = State.new(:acronym => state["acronym"], :name => state["name"])
|
18
|
+
state_obj.save
|
19
|
+
|
20
|
+
state["cities"].each do |city|
|
21
|
+
c = City.new
|
22
|
+
c.name = city
|
23
|
+
c.state = state_obj
|
24
|
+
c.capital = capital?(city, state)
|
25
|
+
c.save
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
BRPopulate.populate
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mix-rails-addresses
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.24.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sadjow Leão
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.13.rc1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.13.rc1
|
27
|
+
description: A plugin for mix-rails
|
28
|
+
email:
|
29
|
+
- sadjow@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- app/controllers/states_controller.rb
|
35
|
+
- app/controllers/cities_controller.rb
|
36
|
+
- app/models/city.rb
|
37
|
+
- app/models/state.rb
|
38
|
+
- app/models/address.rb
|
39
|
+
- config/locales/addresses.pt-BR.yml
|
40
|
+
- config/routes.rb
|
41
|
+
- db/seeds.rb
|
42
|
+
- db/migrate/20130306145007_create_cities.rb
|
43
|
+
- db/migrate/20130306144900_create_states.rb
|
44
|
+
- db/migrate/20130311130844_add_latitude_longitude_to_address.rb
|
45
|
+
- db/migrate/20130306172839_create_addresses.rb
|
46
|
+
- lib/tasks/mix-rails-addresses_tasks.rake
|
47
|
+
- lib/mix-rails-addresses/version.rb
|
48
|
+
- lib/mix-rails-addresses/engine.rb
|
49
|
+
- lib/mix-rails-addresses.rb
|
50
|
+
- MIT-LICENSE
|
51
|
+
- Rakefile
|
52
|
+
- README.rdoc
|
53
|
+
homepage: https://github.com/mixinternet/mix-rails-addresses
|
54
|
+
licenses: []
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.0.0
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: A plugin for mix-rails
|
76
|
+
test_files: []
|