largentinas 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.document +5 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +20 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +53 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/departamentos_controller.rb +83 -0
  9. data/app/controllers/localidads_controller.rb +83 -0
  10. data/app/controllers/provincias_controller.rb +83 -0
  11. data/app/helpers/localidads_helper.rb +8 -0
  12. data/app/models/departamento.rb +12 -0
  13. data/app/models/localidad.rb +27 -0
  14. data/app/models/provincia.rb +3 -0
  15. data/app/views/departamentos/_form.html.erb +25 -0
  16. data/app/views/departamentos/edit.html.erb +6 -0
  17. data/app/views/departamentos/index.html.erb +25 -0
  18. data/app/views/departamentos/new.html.erb +5 -0
  19. data/app/views/departamentos/show.html.erb +30 -0
  20. data/app/views/localidads/_form.html.erb +25 -0
  21. data/app/views/localidads/edit.html.erb +6 -0
  22. data/app/views/localidads/index.html.erb +41 -0
  23. data/app/views/localidads/index.xml.builder +9 -0
  24. data/app/views/localidads/new.html.erb +5 -0
  25. data/app/views/localidads/show.html.erb +20 -0
  26. data/app/views/provincias/_form.html.erb +21 -0
  27. data/app/views/provincias/edit.html.erb +6 -0
  28. data/app/views/provincias/index.html.erb +23 -0
  29. data/app/views/provincias/new.html.erb +5 -0
  30. data/app/views/provincias/show.html.erb +26 -0
  31. data/config/routes.rb +15 -0
  32. data/lib/generators/largentinas/largentinas_generator.rb +77 -0
  33. data/lib/generators/largentinas/templates/db/migrate/create_departamentos.rb +14 -0
  34. data/lib/generators/largentinas/templates/db/migrate/create_localidads.rb +14 -0
  35. data/lib/generators/largentinas/templates/db/migrate/create_provincias.rb +13 -0
  36. data/lib/generators/largentinas/templates/db/migrate/departamento_data.rb +585 -0
  37. data/lib/generators/largentinas/templates/db/migrate/localidad_data.rb +5449 -0
  38. data/lib/generators/largentinas/templates/db/migrate/provincia_data.rb +11 -0
  39. data/lib/largentinas.rb +5 -0
  40. data/test/helper.rb +18 -0
  41. data/test/test_largentinas.rb +7 -0
  42. metadata +162 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.1"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.1)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+ rcov (0.9.9)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.5.1)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Oldani Pablo
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
@@ -0,0 +1,19 @@
1
+ = largentinas
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to largentinas
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Oldani Pablo. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "largentinas"
16
+ gem.homepage = "http://github.com/olvap/largentinas"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{todavia no se que es summary}
19
+ gem.description = %Q{mvc de las localidades departamento y provincias de la Argentina (migraciones con todas).}
20
+ gem.email = "magicche@hotmail.com"
21
+ gem.authors = ["Oldani Pablo"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "largentinas #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,83 @@
1
+ class DepartamentosController < ApplicationController
2
+ # GET /departamentos
3
+ # GET /departamentos.xml
4
+ def index
5
+ @departamentos = Departamento.all
6
+
7
+ respond_to do |format|
8
+ format.html
9
+ format.xml { render :xml => @departamentos }
10
+ end
11
+ end
12
+
13
+ # GET /departamentos/1
14
+ # GET /departamentos/1.xml
15
+ def show
16
+ @departamento = Departamento.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @departamento }
21
+ end
22
+ end
23
+
24
+ # GET /departamentos/new
25
+ # GET /departamentos/new.xml
26
+ def new
27
+ @departamento = Departamento.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @departamento }
32
+ end
33
+ end
34
+
35
+ # GET /departamentos/1/edit
36
+ def edit
37
+ @departamento = Departamento.find(params[:id])
38
+ end
39
+
40
+ # POST /departamentos
41
+ # POST /departamentos.xml
42
+ def create
43
+ @departamento = Departamento.new(params[:departamento])
44
+
45
+ respond_to do |format|
46
+ if @departamento.save
47
+ format.html { redirect_to(@departamento, :notice => 'Departamento was successfully created.') }
48
+ format.xml { render :xml => @departamento, :status => :created, :location => @departamento }
49
+ else
50
+ format.html { render :action => "new" }
51
+ format.xml { render :xml => @departamento.errors, :status => :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /departamentos/1
57
+ # PUT /departamentos/1.xml
58
+ def update
59
+ @departamento = Departamento.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @departamento.update_attributes(params[:departamento])
63
+ format.html { redirect_to(@departamento, :notice => 'Departamento was successfully updated.') }
64
+ format.xml { head :ok }
65
+ else
66
+ format.html { render :action => "edit" }
67
+ format.xml { render :xml => @departamento.errors, :status => :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /departamentos/1
73
+ # DELETE /departamentos/1.xml
74
+ def destroy
75
+ @departamento = Departamento.find(params[:id])
76
+ @departamento.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to(departamentos_url) }
80
+ format.xml { head :ok }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,83 @@
1
+ class LocalidadsController < ApplicationController
2
+ # GET /localidads
3
+ # GET /localidads.xml
4
+ def index
5
+ @search = Localidad.search(params[:search])
6
+ @localidads = @search.paginate :page => params[:page], :per_page =>20
7
+ respond_to do |format|
8
+ format.html
9
+ format.xml
10
+ end
11
+ end
12
+
13
+ # GET /localidads/1
14
+ # GET /localidads/1.xml
15
+ def show
16
+ @localidad = Localidad.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @localidad }
21
+ end
22
+ end
23
+
24
+ # GET /localidads/new
25
+ # GET /localidads/new.xml
26
+ def new
27
+ @localidad = Localidad.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @localidad }
32
+ end
33
+ end
34
+
35
+ # GET /localidads/1/edit
36
+ def edit
37
+ @localidad = Localidad.find(params[:id])
38
+ end
39
+
40
+ # POST /localidads
41
+ # POST /localidads.xml
42
+ def create
43
+ @localidad = Localidad.new(params[:localidad])
44
+
45
+ respond_to do |format|
46
+ if @localidad.save
47
+ format.html { redirect_to(@localidad, :notice => 'Localidad was successfully created.') }
48
+ format.xml { render :xml => @localidad, :status => :created, :location => @localidad }
49
+ else
50
+ format.html { render :action => "new" }
51
+ format.xml { render :xml => @localidad.errors, :status => :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /localidads/1
57
+ # PUT /localidads/1.xml
58
+ def update
59
+ @localidad = Localidad.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @localidad.update_attributes(params[:localidad])
63
+ format.html { redirect_to(@localidad, :notice => 'Localidad was successfully updated.') }
64
+ format.xml { head :ok }
65
+ else
66
+ format.html { render :action => "edit" }
67
+ format.xml { render :xml => @localidad.errors, :status => :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /localidads/1
73
+ # DELETE /localidads/1.xml
74
+ def destroy
75
+ @localidad = Localidad.find(params[:id])
76
+ @localidad.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to(localidads_url) }
80
+ format.xml { head :ok }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,83 @@
1
+ class ProvinciasController < ApplicationController
2
+ # GET /provincias
3
+ # GET /provincias.xml
4
+ def index
5
+ @provincias = Provincia.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @provincias }
10
+ end
11
+ end
12
+
13
+ # GET /provincias/1
14
+ # GET /provincias/1.xml
15
+ def show
16
+ @provincia = Provincia.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @provincia }
21
+ end
22
+ end
23
+
24
+ # GET /provincias/new
25
+ # GET /provincias/new.xml
26
+ def new
27
+ @provincia = Provincia.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @provincia }
32
+ end
33
+ end
34
+
35
+ # GET /provincias/1/edit
36
+ def edit
37
+ @provincia = Provincia.find(params[:id])
38
+ end
39
+
40
+ # POST /provincias
41
+ # POST /provincias.xml
42
+ def create
43
+ @provincia = Provincia.new(params[:provincia])
44
+
45
+ respond_to do |format|
46
+ if @provincia.save
47
+ format.html { redirect_to(@provincia, :notice => 'Provincia was successfully created.') }
48
+ format.xml { render :xml => @provincia, :status => :created, :location => @provincia }
49
+ else
50
+ format.html { render :action => "new" }
51
+ format.xml { render :xml => @provincia.errors, :status => :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /provincias/1
57
+ # PUT /provincias/1.xml
58
+ def update
59
+ @provincia = Provincia.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @provincia.update_attributes(params[:provincia])
63
+ format.html { redirect_to(@provincia, :notice => 'Provincia was successfully updated.') }
64
+ format.xml { head :ok }
65
+ else
66
+ format.html { render :action => "edit" }
67
+ format.xml { render :xml => @provincia.errors, :status => :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /provincias/1
73
+ # DELETE /provincias/1.xml
74
+ def destroy
75
+ @provincia = Provincia.find(params[:id])
76
+ @provincia.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to(provincias_url) }
80
+ format.xml { head :ok }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,8 @@
1
+ module LocalidadsHelper
2
+ def autocomplete(table)
3
+ html =""
4
+ html << javascript_include_tag('autocomplete')
5
+ html << "<input id='#{table}_name' class='autocomplete' table='#{table}' />"
6
+ raw html
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ class Departamento < ActiveRecord::Base
2
+ has_many :localidads
3
+ belongs_to :provincia
4
+
5
+ def p
6
+ try(:provincia)
7
+ end
8
+
9
+ def pname
10
+ try(:provincia).try(:name)
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ class Localidad < ActiveRecord::Base
2
+ belongs_to :departamento
3
+
4
+ scope :dpto, joins('left join departamentos on (localidads.departamento_id = departamentos.id)') &
5
+ select('localidads.*, departamentos.name as dpto')
6
+
7
+ def pname
8
+ try(:departamento).try(:provincia).try(:name)
9
+ end
10
+
11
+ def p
12
+ try(:departamento).try(:provincia)
13
+ end
14
+
15
+ def d
16
+ try(:departamento)
17
+ end
18
+
19
+ def dname
20
+ try(:departamento).try(:name)
21
+ end
22
+
23
+ def lname
24
+ try(:name)
25
+ end
26
+
27
+ end