selections 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/.gitignore +18 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile +4 -0
  4. data/{MIT-LICENSE → LICENSE.txt} +4 -2
  5. data/README.md +237 -0
  6. data/Rakefile +3 -29
  7. data/lib/selections.rb +22 -6
  8. data/lib/selections/belongs_to_selection.rb +20 -0
  9. data/lib/selections/form_builder_extensions.rb +86 -0
  10. data/lib/selections/selectable.rb +125 -0
  11. data/lib/selections/version.rb +1 -1
  12. data/selections.gemspec +38 -0
  13. data/spec/selections/selectable_spec.rb +220 -0
  14. data/spec/selections/selections_tag_spec.rb +203 -0
  15. data/spec/spec_helper.rb +30 -21
  16. metadata +99 -177
  17. data/README.rdoc +0 -3
  18. data/app/assets/javascripts/selections/application.js +0 -9
  19. data/app/assets/javascripts/selections/selections.js +0 -2
  20. data/app/assets/stylesheets/scaffold.css +0 -56
  21. data/app/assets/stylesheets/selections/application.css +0 -7
  22. data/app/assets/stylesheets/selections/selections.css +0 -4
  23. data/app/controllers/selections/application_controller.rb +0 -4
  24. data/app/controllers/selections/selections_controller.rb +0 -45
  25. data/app/helpers/selections/application_helper.rb +0 -4
  26. data/app/helpers/selections/selectors_helper.rb +0 -4
  27. data/app/models/selections/selection.rb +0 -83
  28. data/app/views/layouts/selections/application.html.erb +0 -1
  29. data/app/views/selections/selections/_form.html.erb +0 -41
  30. data/app/views/selections/selections/edit.html.erb +0 -6
  31. data/app/views/selections/selections/index.html.erb +0 -33
  32. data/app/views/selections/selections/new.html.erb +0 -5
  33. data/app/views/selections/selections/show.html.erb +0 -35
  34. data/config/initializers/selections.rb +0 -1
  35. data/config/routes.rb +0 -5
  36. data/db/migrate/20120114024459_create_selections_selections.rb +0 -15
  37. data/lib/selections/engine.rb +0 -5
  38. data/lib/selections/selection_select.rb +0 -24
  39. data/lib/tasks/selections_tasks.rake +0 -4
  40. data/spec/controllers/companies_controller_spec.rb +0 -10
  41. data/spec/controllers/selections/selections_controller_spec.rb +0 -165
  42. data/spec/dummy/Rakefile +0 -7
  43. data/spec/dummy/app/assets/javascripts/application.js +0 -9
  44. data/spec/dummy/app/assets/javascripts/companies.js +0 -2
  45. data/spec/dummy/app/assets/stylesheets/application.css +0 -7
  46. data/spec/dummy/app/assets/stylesheets/companies.css +0 -4
  47. data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -56
  48. data/spec/dummy/app/controllers/application_controller.rb +0 -2
  49. data/spec/dummy/app/controllers/companies_controller.rb +0 -83
  50. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  51. data/spec/dummy/app/helpers/companies_helper.rb +0 -2
  52. data/spec/dummy/app/models/company.rb +0 -7
  53. data/spec/dummy/app/views/companies/_form.html.erb +0 -3
  54. data/spec/dummy/app/views/companies/edit.html.erb +0 -4
  55. data/spec/dummy/app/views/companies/index.html.erb +0 -27
  56. data/spec/dummy/app/views/companies/new.html.erb +0 -5
  57. data/spec/dummy/app/views/companies/show.html.erb +0 -20
  58. data/spec/dummy/app/views/layouts/application.html.erb +0 -11
  59. data/spec/dummy/config.ru +0 -4
  60. data/spec/dummy/config/application.rb +0 -45
  61. data/spec/dummy/config/boot.rb +0 -10
  62. data/spec/dummy/config/database.yml +0 -25
  63. data/spec/dummy/config/environment.rb +0 -5
  64. data/spec/dummy/config/environments/development.rb +0 -30
  65. data/spec/dummy/config/environments/production.rb +0 -60
  66. data/spec/dummy/config/environments/test.rb +0 -42
  67. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  68. data/spec/dummy/config/initializers/inflections.rb +0 -10
  69. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  70. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  71. data/spec/dummy/config/initializers/session_store.rb +0 -8
  72. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  73. data/spec/dummy/config/locales/en.yml +0 -5
  74. data/spec/dummy/config/routes.rb +0 -6
  75. data/spec/dummy/db/development.sqlite3 +0 -0
  76. data/spec/dummy/db/migrate/20120114125226_create_selections_selections.rb +0 -15
  77. data/spec/dummy/db/migrate/20120115055119_create_companies.rb +0 -12
  78. data/spec/dummy/db/schema.rb +0 -38
  79. data/spec/dummy/db/test.sqlite3 +0 -0
  80. data/spec/dummy/log/development.log +0 -94
  81. data/spec/dummy/log/test.log +0 -26360
  82. data/spec/dummy/public/404.html +0 -26
  83. data/spec/dummy/public/422.html +0 -26
  84. data/spec/dummy/public/500.html +0 -26
  85. data/spec/dummy/public/favicon.ico +0 -0
  86. data/spec/dummy/script/rails +0 -6
  87. data/spec/helpers/selections/selections_helper_spec.rb +0 -15
  88. data/spec/models/company_spec.rb +0 -7
  89. data/spec/models/selections/selection_spec.rb +0 -219
  90. data/spec/routing/selections/selections_routing_spec.rb +0 -35
  91. data/spec/support/controller_route_fix.rb +0 -33
  92. data/spec/support/factories/company_factory.rb +0 -5
  93. data/spec/support/factories/selection_factory.rb +0 -5
  94. data/spec/views/companies/edit.html.erb_spec.rb +0 -76
  95. data/spec/views/companies/new.html.erb_spec.rb +0 -78
  96. data/spec/views/selections/selections/edit.html.erb_spec.rb +0 -28
  97. data/spec/views/selections/selections/index.html.erb_spec.rb +0 -40
  98. data/spec/views/selections/selections/new.html.erb_spec.rb +0 -28
  99. data/spec/views/selections/selections/show.html.erb_spec.rb +0 -30
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env rake
2
- # Add your own tasks in files placed in lib/tasks ending in .rake,
3
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
-
5
- require File.expand_path('../config/application', __FILE__)
6
-
7
- Dummy::Application.load_tasks
@@ -1,9 +0,0 @@
1
- // This is a manifest file that'll be compiled into including all the files listed below.
2
- // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
- // be included in the compiled file accessible from http://example.com/assets/application.js
4
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
- // the compiled file.
6
- //
7
- //= require jquery
8
- //= require jquery_ujs
9
- //= require_tree .
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,7 +0,0 @@
1
- /*
2
- * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
- * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
- * the top of the compiled file, but it's generally better to create a new file per style scope.
5
- *= require_self
6
- *= require_tree .
7
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,56 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -1,83 +0,0 @@
1
- class CompaniesController < ApplicationController
2
- # GET /companies
3
- # GET /companies.json
4
- def index
5
- @companies = Company.all
6
-
7
- respond_to do |format|
8
- format.html # index.html.erb
9
- format.json { render json: @companies }
10
- end
11
- end
12
-
13
- # GET /companies/1
14
- # GET /companies/1.json
15
- def show
16
- @company = Company.find(params[:id])
17
-
18
- respond_to do |format|
19
- format.html # show.html.erb
20
- format.json { render json: @company }
21
- end
22
- end
23
-
24
- # GET /companies/new
25
- # GET /companies/new.json
26
- def new
27
- @company = Company.new
28
-
29
- respond_to do |format|
30
- format.html # new.html.erb
31
- format.json { render json: @company }
32
- end
33
- end
34
-
35
- # GET /companies/1/edit
36
- def edit
37
- @company = Company.find(params[:id])
38
- end
39
-
40
- # POST /companies
41
- # POST /companies.json
42
- def create
43
- @company = Company.new(params[:company])
44
-
45
- respond_to do |format|
46
- if @company.save
47
- format.html { redirect_to @company, notice: 'Company was successfully created.' }
48
- format.json { render json: @company, status: :created, location: @company }
49
- else
50
- format.html { render action: "new" }
51
- format.json { render json: @company.errors, status: :unprocessable_entity }
52
- end
53
- end
54
- end
55
-
56
- # PUT /companies/1
57
- # PUT /companies/1.json
58
- def update
59
- @company = Company.find(params[:id])
60
-
61
- respond_to do |format|
62
- if @company.update_attributes(params[:company])
63
- format.html { redirect_to @company, notice: 'Company was successfully updated.' }
64
- format.json { head :ok }
65
- else
66
- format.html { render action: "edit" }
67
- format.json { render json: @company.errors, status: :unprocessable_entity }
68
- end
69
- end
70
- end
71
-
72
- # DELETE /companies/1
73
- # DELETE /companies/1.json
74
- def destroy
75
- @company = Company.find(params[:id])
76
- @company.destroy
77
-
78
- respond_to do |format|
79
- format.html { redirect_to companies_url }
80
- format.json { head :ok }
81
- end
82
- end
83
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,2 +0,0 @@
1
- module CompaniesHelper
2
- end
@@ -1,7 +0,0 @@
1
- class Company < ActiveRecord::Base
2
-
3
- #TODO make this into selection_belongs_to
4
- belongs_to :genre, :class_name => "Selection"
5
- belongs_to :state, :class_name => "Selections::Selection"
6
-
7
- end
@@ -1,3 +0,0 @@
1
- <%= form_for(@company) do |f| %>
2
- <%= f.selections @field, @options, @html_options %>
3
- <% end %>
@@ -1,4 +0,0 @@
1
- <h1>Editing company</h1>
2
-
3
- <%= render 'form' %>
4
-
@@ -1,27 +0,0 @@
1
- <h1>Listing companies</h1>
2
-
3
- <table>
4
- <tr>
5
- <th>Name</th>
6
- <th>State</th>
7
- <th>Genre</th>
8
- <th></th>
9
- <th></th>
10
- <th></th>
11
- </tr>
12
-
13
- <% @companies.each do |company| %>
14
- <tr>
15
- <td><%= company.name %></td>
16
- <td><%= company.state %></td>
17
- <td><%= company.genre %></td>
18
- <td><%= link_to 'Show', company %></td>
19
- <td><%= link_to 'Edit', edit_company_path(company) %></td>
20
- <td><%= link_to 'Destroy', company, confirm: 'Are you sure?', method: :delete %></td>
21
- </tr>
22
- <% end %>
23
- </table>
24
-
25
- <br />
26
-
27
- <%= link_to 'New Company', new_company_path %>
@@ -1,5 +0,0 @@
1
- <h1>New company</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', companies_path %>
@@ -1,20 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <b>Name:</b>
5
- <%= @company.name %>
6
- </p>
7
-
8
- <p>
9
- <b>State:</b>
10
- <%= @company.state %>
11
- </p>
12
-
13
- <p>
14
- <b>Genre:</b>
15
- <%= @company.genre %>
16
- </p>
17
-
18
-
19
- <%= link_to 'Edit', edit_company_path(@company) %> |
20
- <%= link_to 'Back', companies_path %>
@@ -1,11 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- </head>
6
- <body>
7
-
8
- <%= yield %>
9
-
10
- </body>
11
- </html>
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Dummy::Application
@@ -1,45 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require
6
- require "selections"
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Custom directories with classes and modules you want to be autoloadable.
15
- # config.autoload_paths += %W(#{config.root}/extras)
16
-
17
- # Only load the plugins named here, in the order given (default is alphabetical).
18
- # :all can be used as a placeholder for all plugins not explicitly named.
19
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
-
21
- # Activate observers that should always be running.
22
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
-
24
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
- # config.time_zone = 'Central Time (US & Canada)'
27
-
28
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
- # config.i18n.default_locale = :de
31
-
32
- # Configure the default encoding used in templates for Ruby 1.9.
33
- config.encoding = "utf-8"
34
-
35
- # Configure sensitive parameters which will be filtered from the log file.
36
- config.filter_parameters += [:password]
37
-
38
- # Enable the asset pipeline
39
- config.assets.enabled = true
40
-
41
- # Version of your assets, change this if you want to expire all your assets
42
- config.assets.version = '1.0'
43
- end
44
- end
45
-
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
9
-
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,25 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: db/test.sqlite3
18
- pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
@@ -1,30 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger
20
- config.active_support.deprecation = :log
21
-
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Do not compress assets
26
- config.assets.compress = false
27
-
28
- # Expands the lines which load the assets
29
- config.assets.debug = true
30
- end
@@ -1,60 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Full error reports are disabled and caching is turned on
8
- config.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
-
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
13
-
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
16
-
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
18
- config.assets.compile = false
19
-
20
- # Generate digests for assets URLs
21
- config.assets.digest = true
22
-
23
- # Defaults to Rails.root.join("public/assets")
24
- # config.assets.manifest = YOUR_PATH
25
-
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
-
30
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
- # config.force_ssl = true
32
-
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
35
-
36
- # Use a different logger for distributed setups
37
- # config.logger = SyslogLogger.new
38
-
39
- # Use a different cache store in production
40
- # config.cache_store = :mem_cache_store
41
-
42
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
- # config.action_controller.asset_host = "http://assets.example.com"
44
-
45
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
- # config.assets.precompile += %w( search.js )
47
-
48
- # Disable delivery errors, bad email addresses will be ignored
49
- # config.action_mailer.raise_delivery_errors = false
50
-
51
- # Enable threaded mode
52
- # config.threadsafe!
53
-
54
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
- # the I18n.default_locale when a translation can not be found)
56
- config.i18n.fallbacks = true
57
-
58
- # Send deprecation notices to registered listeners
59
- config.active_support.deprecation = :notify
60
- end