dominium_stuff 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +22 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/javascripts/dominium/countries.js +2 -0
  5. data/app/assets/javascripts/dominium/states.js +2 -0
  6. data/app/assets/stylesheets/dominium/countries.css +4 -0
  7. data/app/assets/stylesheets/dominium/states.css +4 -0
  8. data/app/assets/stylesheets/scaffold.css +56 -0
  9. data/app/controllers/dominium/countries_controller.rb +65 -0
  10. data/app/controllers/dominium/states_controller.rb +64 -0
  11. data/app/helpers/dominium/countries_helper.rb +2 -0
  12. data/app/helpers/dominium/states_helper.rb +2 -0
  13. data/app/models/dominium.rb +5 -0
  14. data/app/models/dominium/country.rb +4 -0
  15. data/app/models/dominium/state.rb +6 -0
  16. data/app/views/dominium/countries/_form.html.erb +21 -0
  17. data/app/views/dominium/countries/edit.html.erb +6 -0
  18. data/app/views/dominium/countries/index.html.erb +23 -0
  19. data/app/views/dominium/countries/new.html.erb +5 -0
  20. data/app/views/dominium/countries/show.html.erb +10 -0
  21. data/app/views/dominium/states/_form.html.erb +29 -0
  22. data/app/views/dominium/states/edit.html.erb +6 -0
  23. data/app/views/dominium/states/index.html.erb +25 -0
  24. data/app/views/dominium/states/new.html.erb +5 -0
  25. data/app/views/dominium/states/show.html.erb +15 -0
  26. data/config/routes.rb +6 -0
  27. data/db/migrate/20111106194010_create_dominium_countries.rb +8 -0
  28. data/db/migrate/20111106222109_create_dominium_states.rb +9 -0
  29. data/lib/dominium_stuff.rb +4 -0
  30. data/lib/dominium_stuff/engine.rb +4 -0
  31. data/lib/dominium_stuff/version.rb +3 -0
  32. data/lib/tasks/dominium_stuff_tasks.rake +36 -0
  33. data/test/dominium_stuff_test.rb +7 -0
  34. data/test/dummy/Rakefile +7 -0
  35. data/test/dummy/app/assets/javascripts/application.js +9 -0
  36. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  37. data/test/dummy/app/controllers/application_controller.rb +3 -0
  38. data/test/dummy/app/helpers/application_helper.rb +2 -0
  39. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  40. data/test/dummy/config.ru +4 -0
  41. data/test/dummy/config/application.rb +45 -0
  42. data/test/dummy/config/boot.rb +10 -0
  43. data/test/dummy/config/database.yml +25 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +30 -0
  46. data/test/dummy/config/environments/production.rb +60 -0
  47. data/test/dummy/config/environments/test.rb +39 -0
  48. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  49. data/test/dummy/config/initializers/inflections.rb +10 -0
  50. data/test/dummy/config/initializers/mime_types.rb +5 -0
  51. data/test/dummy/config/initializers/secret_token.rb +7 -0
  52. data/test/dummy/config/initializers/session_store.rb +8 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/test/dummy/config/locales/en.yml +5 -0
  55. data/test/dummy/config/routes.rb +58 -0
  56. data/test/dummy/db/development.sqlite3 +0 -0
  57. data/test/dummy/db/schema.rb +28 -0
  58. data/test/dummy/db/test.sqlite3 +0 -0
  59. data/test/dummy/log/development.log +982 -0
  60. data/test/dummy/log/test.log +6019 -0
  61. data/test/dummy/public/404.html +26 -0
  62. data/test/dummy/public/422.html +26 -0
  63. data/test/dummy/public/500.html +26 -0
  64. data/test/dummy/public/favicon.ico +0 -0
  65. data/test/dummy/script/rails +6 -0
  66. data/test/dummy/tmp/cache/assets/CE9/860/sprockets%2F0adfc951841c8b269d1f46e6e8017934 +9068 -0
  67. data/test/dummy/tmp/cache/assets/D13/110/sprockets%2F11df2bbcd3b578a7196fa0699359043f +373 -0
  68. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  69. data/test/dummy/tmp/cache/assets/D43/DE0/sprockets%2Fcc857028c192ec2c22277f4ebb79dc09 +9052 -0
  70. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +10 -0
  71. data/test/dummy/tmp/cache/assets/D74/5A0/sprockets%2F6c0e9a7874a454d7b7abc6a8a283c5b7 +389 -0
  72. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +9427 -0
  73. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  74. data/test/fixtures/dominium/countries.yml +7 -0
  75. data/test/fixtures/dominium/states.yml +9 -0
  76. data/test/functional/dominium/countries_controller_test.rb +57 -0
  77. data/test/functional/dominium/states_controller_test.rb +63 -0
  78. data/test/integration/navigation_test.rb +10 -0
  79. data/test/test_helper.rb +10 -0
  80. data/test/unit/dominium/country_test.rb +24 -0
  81. data/test/unit/dominium/state_test.rb +27 -0
  82. data/test/unit/helpers/dominium/countries_helper_test.rb +4 -0
  83. data/test/unit/helpers/dominium/states_helper_test.rb +4 -0
  84. metadata +219 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 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
@@ -0,0 +1,22 @@
1
+ = This is a rails Plugin
2
+
3
+ This project was created by me, with some basic stuff to use in various rails projects, just for modularize and simplify development.
4
+
5
+ = Installation
6
+
7
+ just copy to rails/vendor/plugins directory
8
+ and run
9
+ rake app:dominium_stuff_engine:install:migrations
10
+
11
+ = Details
12
+
13
+ At this point we have two models
14
+ -Dominium
15
+ - Country (Dominium::Country)
16
+ - States (Dominium::State)
17
+
18
+ = DominiumStuff
19
+
20
+ This project rocks and uses MIT-LICENSE.
21
+
22
+ = Yeah it rocks !
data/Rakefile ADDED
@@ -0,0 +1,39 @@
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 = 'DominiumStuff'
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("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rake/testtask'
30
+
31
+ Rake::TestTask.new(:test) do |t|
32
+ t.libs << 'lib'
33
+ t.libs << 'test'
34
+ t.pattern = 'test/**/*_test.rb'
35
+ t.verbose = false
36
+ end
37
+
38
+
39
+ task :default => :test
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,65 @@
1
+ class Dominium::CountriesController < ApplicationController
2
+
3
+ # GET /dominium/countries
4
+ # GET /dominium/countries.json
5
+ def index
6
+ @dominium_countries = Dominium::Country.all
7
+ end
8
+
9
+ # GET /dominium/countries/1
10
+ # GET /dominium/countries/1.json
11
+ def show
12
+ @dominium_country = Dominium::Country.find(params[:id])
13
+ end
14
+
15
+ # GET /dominium/countries/new
16
+ # GET /dominium/countries/new.json
17
+ def new
18
+ @dominium_country = Dominium::Country.new
19
+ end
20
+
21
+ # GET /dominium/countries/1/edit
22
+ def edit
23
+ @dominium_country = Dominium::Country.find(params[:id])
24
+ end
25
+
26
+ # POST /dominium/countries
27
+ # POST /dominium/countries.json
28
+ def create
29
+ @dominium_country = Dominium::Country.new(params[:dominium_country])
30
+
31
+ respond_to do |format|
32
+ if @dominium_country.save
33
+ format.html { redirect_to @dominium_country, notice: 'Country was successfully created.' }
34
+ format.json { render json: @dominium_country, status: :created, location: @dominium_country }
35
+ else
36
+ format.html { render action: "new" }
37
+ format.json { render json: @dominium_country.errors, status: :unprocessable_entity }
38
+ end
39
+ end
40
+ end
41
+
42
+ # PUT /dominium/countries/1
43
+ # PUT /dominium/countries/1.json
44
+ def update
45
+ @dominium_country = Dominium::Country.find(params[:id])
46
+
47
+ respond_to do |format|
48
+ if @dominium_country.update_attributes(params[:dominium_country])
49
+ format.html { redirect_to @dominium_country, notice: 'Country was successfully updated.' }
50
+ format.json { head :ok }
51
+ else
52
+ format.html { render action: "edit" }
53
+ format.json { render json: @dominium_country.errors, status: :unprocessable_entity }
54
+ end
55
+ end
56
+ end
57
+
58
+ # DELETE /dominium/countries/1
59
+ # DELETE /dominium/countries/1.json
60
+ def destroy
61
+ @dominium_country = Dominium::Country.find(params[:id])
62
+ @dominium_country.destroy
63
+ redirect_to dominium_countries_path, notice: 'Country was sucessfuly deleted'
64
+ end
65
+ end
@@ -0,0 +1,64 @@
1
+ class Dominium::StatesController < ApplicationController
2
+ # GET /dominium/states
3
+ # GET /dominium/states.json
4
+ def index
5
+ @dominium_states = Dominium::State.all
6
+ end
7
+
8
+ # GET /dominium/states/1
9
+ # GET /dominium/states/1.json
10
+ def show
11
+ @dominium_state = Dominium::State.find(params[:id])
12
+ end
13
+
14
+ # GET /dominium/states/new
15
+ # GET /dominium/states/new.json
16
+ def new
17
+ @dominium_state = Dominium::State.new
18
+ end
19
+
20
+ # GET /dominium/states/1/edit
21
+ def edit
22
+ @dominium_state = Dominium::State.find(params[:id])
23
+ end
24
+
25
+ # POST /dominium/states
26
+ # POST /dominium/states.json
27
+ def create
28
+ @dominium_state = Dominium::State.new(params[:dominium_state])
29
+
30
+ respond_to do |format|
31
+ if @dominium_state.save
32
+ format.html { redirect_to @dominium_state, notice: 'State was successfully created.' }
33
+ format.json { render json: @dominium_state, status: :created, location: @dominium_state }
34
+ else
35
+ format.html { render action: "new" }
36
+ format.json { render json: @dominium_state.errors, status: :unprocessable_entity }
37
+ end
38
+ end
39
+ end
40
+
41
+ # PUT /dominium/states/1
42
+ # PUT /dominium/states/1.json
43
+ def update
44
+ @dominium_state = Dominium::State.find(params[:id])
45
+
46
+ respond_to do |format|
47
+ if @dominium_state.update_attributes(params[:dominium_state])
48
+ format.html { redirect_to @dominium_state, notice: 'State was successfully updated.' }
49
+ format.json { head :ok }
50
+ else
51
+ format.html { render action: "edit" }
52
+ format.json { render json: @dominium_state.errors, status: :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # DELETE /dominium/states/1
58
+ # DELETE /dominium/states/1.json
59
+ def destroy
60
+ @dominium_state = Dominium::State.find(params[:id])
61
+ @dominium_state.destroy
62
+ redirect_to dominium_states_url, notice: 'State was successfully deleted'
63
+ end
64
+ end
@@ -0,0 +1,2 @@
1
+ module Dominium::CountriesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module Dominium::StatesHelper
2
+ end
@@ -0,0 +1,5 @@
1
+ module Dominium
2
+ def self.table_name_prefix
3
+ 'dominium_'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ class Dominium::Country < ActiveRecord::Base
2
+ has_many :states, :class_name => "Dominium::Country"
3
+ validates :name, length: 4..254, uniqueness: true, presence: true
4
+ end
@@ -0,0 +1,6 @@
1
+ class Dominium::State < ActiveRecord::Base
2
+ belongs_to :country, :class_name => "Dominium::Country"
3
+ validates :name , length: 4..254, presence: true
4
+ validates :abbr , length: 2..2 , presence: true
5
+ validates :country , presence: true
6
+ end
@@ -0,0 +1,21 @@
1
+ <%= form_for(@dominium_country) do |f| %>
2
+ <% if @dominium_country.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@dominium_country.errors.count, "error") %> prohibited this dominium_country from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @dominium_country.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing dominium_country</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @dominium_country %> |
6
+ <%= link_to 'Back', dominium_countries_path %>
@@ -0,0 +1,23 @@
1
+ <h1>Listing dominium_countries</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Opções</th>
7
+ </tr>
8
+
9
+ <% @dominium_countries.each do |dominium_country| %>
10
+ <tr>
11
+ <td><%= dominium_country.name %></td>
12
+ <td>
13
+ <%= link_to 'Show', dominium_country %>
14
+ <%= link_to 'Edit', edit_dominium_country_path(dominium_country) %>
15
+ <%= link_to 'Destroy', dominium_country, confirm: 'Are you sure?', method: :delete %>
16
+ </td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+
21
+ <br />
22
+
23
+ <%= link_to 'New Country', new_dominium_country_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New dominium_country</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', dominium_countries_path %>
@@ -0,0 +1,10 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Name:</b>
5
+ <%= @dominium_country.name %>
6
+ </p>
7
+
8
+
9
+ <%= link_to 'Edit', edit_dominium_country_path(@dominium_country) %> |
10
+ <%= link_to 'Back', dominium_countries_path %>
@@ -0,0 +1,29 @@
1
+ <%= form_for(@dominium_state) do |f| %>
2
+ <% if @dominium_state.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@dominium_state.errors.count, "error") %> prohibited this dominium_state from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @dominium_state.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :abbr %><br />
20
+ <%= f.text_field :abbr %>
21
+ </div>
22
+ <p>
23
+ <%= f.label :country %>
24
+ <%= collection_select :dominium_state, 'country_id', Dominium::Country.all, :id, :name %>
25
+ </p>
26
+ <div class="actions">
27
+ <%= f.submit %>
28
+ </div>
29
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing dominium_state</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @dominium_state %> |
6
+ <%= link_to 'Back', dominium_states_path %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing dominium_states</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Abbr</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @dominium_states.each do |dominium_state| %>
13
+ <tr>
14
+ <td><%= dominium_state.name %></td>
15
+ <td><%= dominium_state.abbr %></td>
16
+ <td><%= link_to 'Show', dominium_state %></td>
17
+ <td><%= link_to 'Edit', edit_dominium_state_path(dominium_state) %></td>
18
+ <td><%= link_to 'Destroy', dominium_state, confirm: 'Are you sure?', method: :delete %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New State', new_dominium_state_path %>