formatted_length 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/.gitignore +4 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +4 -0
  5. data/README.md +1 -18
  6. data/Rakefile +4 -36
  7. data/formatted_length.gemspec +30 -0
  8. data/lib/formatted_length.rb +4 -4
  9. data/lib/formatted_length/formatted_length.rb +21 -0
  10. data/lib/formatted_length/model_additions.rb +12 -0
  11. data/lib/formatted_length/railtie.rb +9 -0
  12. data/lib/formatted_length/version.rb +1 -1
  13. data/spec/formatted_length/formatted_length_spec.rb +36 -0
  14. data/spec/formatted_length/model_additions_spec.rb +39 -0
  15. data/spec/spec_helper.rb +2 -0
  16. metadata +51 -115
  17. data/lib/formatted_length/acts_as_formatted_length.rb +0 -38
  18. data/test/acts_as_formatted_length_test.rb +0 -61
  19. data/test/dummy/Rakefile +0 -7
  20. data/test/dummy/app/assets/javascripts/application.js +0 -9
  21. data/test/dummy/app/assets/stylesheets/application.css +0 -7
  22. data/test/dummy/app/controllers/application_controller.rb +0 -3
  23. data/test/dummy/app/helpers/application_helper.rb +0 -2
  24. data/test/dummy/app/models/model_with_default_length_field.rb +0 -3
  25. data/test/dummy/app/models/model_with_length_field_and_setter.rb +0 -3
  26. data/test/dummy/app/models/model_with_non_default_length_field.rb +0 -3
  27. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  28. data/test/dummy/config.ru +0 -4
  29. data/test/dummy/config/application.rb +0 -45
  30. data/test/dummy/config/boot.rb +0 -10
  31. data/test/dummy/config/database.yml +0 -25
  32. data/test/dummy/config/environment.rb +0 -5
  33. data/test/dummy/config/environments/development.rb +0 -30
  34. data/test/dummy/config/environments/production.rb +0 -60
  35. data/test/dummy/config/environments/test.rb +0 -42
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  37. data/test/dummy/config/initializers/inflections.rb +0 -10
  38. data/test/dummy/config/initializers/mime_types.rb +0 -5
  39. data/test/dummy/config/initializers/secret_token.rb +0 -7
  40. data/test/dummy/config/initializers/session_store.rb +0 -8
  41. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  42. data/test/dummy/config/locales/en.yml +0 -5
  43. data/test/dummy/config/routes.rb +0 -58
  44. data/test/dummy/db/development.sqlite3 +0 -0
  45. data/test/dummy/db/migrate/20111026123348_create_model_with_default_length_fields.rb +0 -9
  46. data/test/dummy/db/migrate/20111026123424_create_model_with_non_default_length_fields.rb +0 -9
  47. data/test/dummy/db/migrate/20111026144756_create_model_with_length_field_and_setters.rb +0 -9
  48. data/test/dummy/db/schema.rb +0 -34
  49. data/test/dummy/db/test.sqlite3 +0 -0
  50. data/test/dummy/log/development.log +0 -33
  51. data/test/dummy/log/test.log +0 -2
  52. data/test/dummy/public/404.html +0 -26
  53. data/test/dummy/public/422.html +0 -26
  54. data/test/dummy/public/500.html +0 -26
  55. data/test/dummy/public/favicon.ico +0 -0
  56. data/test/dummy/script/rails +0 -6
  57. data/test/dummy/test/fixtures/model_with_default_length_fields.yml +0 -7
  58. data/test/dummy/test/fixtures/model_with_length_field_and_setters.yml +0 -7
  59. data/test/dummy/test/fixtures/model_with_non_default_length_fields.yml +0 -7
  60. data/test/dummy/test/unit/model_with_default_length_field_test.rb +0 -7
  61. data/test/dummy/test/unit/model_with_length_field_and_setter_test.rb +0 -7
  62. data/test/dummy/test/unit/model_with_non_default_length_field_test.rb +0 -7
  63. data/test/formatted_length_test.rb +0 -7
  64. data/test/test_helper.rb +0 -10
@@ -1,14 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
9
- end
10
-
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
14
- end
@@ -1,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
@@ -1,58 +0,0 @@
1
- Dummy::Application.routes.draw do
2
- # The priority is based upon order of creation:
3
- # first created -> highest priority.
4
-
5
- # Sample of regular route:
6
- # match 'products/:id' => 'catalog#view'
7
- # Keep in mind you can assign values other than :controller and :action
8
-
9
- # Sample of named route:
10
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
- # This route can be invoked with purchase_url(:id => product.id)
12
-
13
- # Sample resource route (maps HTTP verbs to controller actions automatically):
14
- # resources :products
15
-
16
- # Sample resource route with options:
17
- # resources :products do
18
- # member do
19
- # get 'short'
20
- # post 'toggle'
21
- # end
22
- #
23
- # collection do
24
- # get 'sold'
25
- # end
26
- # end
27
-
28
- # Sample resource route with sub-resources:
29
- # resources :products do
30
- # resources :comments, :sales
31
- # resource :seller
32
- # end
33
-
34
- # Sample resource route with more complex sub-resources
35
- # resources :products do
36
- # resources :comments
37
- # resources :sales do
38
- # get 'recent', :on => :collection
39
- # end
40
- # end
41
-
42
- # Sample resource route within a namespace:
43
- # namespace :admin do
44
- # # Directs /admin/products/* to Admin::ProductsController
45
- # # (app/controllers/admin/products_controller.rb)
46
- # resources :products
47
- # end
48
-
49
- # You can have the root of your site routed with "root"
50
- # just remember to delete public/index.html.
51
- # root :to => 'welcome#index'
52
-
53
- # See how all your routes lay out with "rake routes"
54
-
55
- # This is a legacy wild controller route that's not recommended for RESTful applications.
56
- # Note: This route will make all actions in every controller accessible via GET requests.
57
- # match ':controller(/:action(/:id(.:format)))'
58
- end
@@ -1,9 +0,0 @@
1
- class CreateModelWithDefaultLengthFields < ActiveRecord::Migration
2
- def change
3
- create_table :model_with_default_length_fields do |t|
4
- t.integer :length
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class CreateModelWithNonDefaultLengthFields < ActiveRecord::Migration
2
- def change
3
- create_table :model_with_non_default_length_fields do |t|
4
- t.integer :foo
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class CreateModelWithLengthFieldAndSetters < ActiveRecord::Migration
2
- def change
3
- create_table :model_with_length_field_and_setters do |t|
4
- t.integer :length
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,34 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended to check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(:version => 20111026144756) do
15
-
16
- create_table "model_with_default_length_fields", :force => true do |t|
17
- t.integer "length"
18
- t.datetime "created_at"
19
- t.datetime "updated_at"
20
- end
21
-
22
- create_table "model_with_length_field_and_setters", :force => true do |t|
23
- t.integer "length"
24
- t.datetime "created_at"
25
- t.datetime "updated_at"
26
- end
27
-
28
- create_table "model_with_non_default_length_fields", :force => true do |t|
29
- t.integer "foo"
30
- t.datetime "created_at"
31
- t.datetime "updated_at"
32
- end
33
-
34
- end
Binary file
@@ -1,33 +0,0 @@
1
-  (0.1ms) select sqlite_version(*)
2
-  (2.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
3
-  (0.0ms) PRAGMA index_list("schema_migrations")
4
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
5
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
6
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
7
- Migrating to CreateModelWithDefaultLengthFields (20111026123348)
8
-  (0.0ms) select sqlite_version(*)
9
-  (0.4ms) CREATE TABLE "model_with_default_length_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "length" integer, "created_at" datetime, "updated_at" datetime) 
10
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111026123348')
11
- Migrating to CreateModelWithNonDefaultLengthFields (20111026123424)
12
-  (0.3ms) CREATE TABLE "model_with_non_default_length_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "foo" integer, "created_at" datetime, "updated_at" datetime) 
13
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111026123424')
14
- Migrating to CreateModelWithLengthFieldAndSetters (20111026144756)
15
-  (0.3ms) CREATE TABLE "model_with_length_field_and_setters" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "length" integer, "created_at" datetime, "updated_at" datetime) 
16
-  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20111026144756')
17
-  (0.2ms) select sqlite_version(*)
18
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations"
19
-  (0.0ms) PRAGMA index_list("model_with_default_length_fields")
20
-  (0.0ms) PRAGMA index_list("model_with_length_field_and_setters")
21
-  (0.0ms) PRAGMA index_list("model_with_non_default_length_fields")
22
-  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
23
-  (0.2ms) select sqlite_version(*)
24
-  (1.3ms) CREATE TABLE "model_with_default_length_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "length" integer, "created_at" datetime, "updated_at" datetime) 
25
-  (1.1ms) CREATE TABLE "model_with_length_field_and_setters" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "length" integer, "created_at" datetime, "updated_at" datetime)
26
-  (1.2ms) CREATE TABLE "model_with_non_default_length_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "foo" integer, "created_at" datetime, "updated_at" datetime) 
27
-  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
28
-  (0.0ms) PRAGMA index_list("schema_migrations")
29
-  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
30
-  (0.1ms) SELECT version FROM "schema_migrations"
31
-  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20111026144756')
32
-  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20111026123348')
33
-  (1.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20111026123424')
@@ -1,2 +0,0 @@
1
-  (0.1ms) begin transaction
2
-  (0.0ms) rollback transaction
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
- </div>
25
- </body>
26
- </html>
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- length: 1
5
-
6
- two:
7
- length: 1
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- length: 1
5
-
6
- two:
7
- length: 1
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- foo: 1
5
-
6
- two:
7
- foo: 1
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ModelWithDefaultLengthFieldTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ModelWithLengthFieldAndSetterTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ModelWithNonDefaultLengthFieldTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class FormattedLengthTest < ActiveSupport::TestCase
4
- test "truth" do
5
- assert_kind_of Module, FormattedLength
6
- end
7
- end
@@ -1,10 +0,0 @@
1
- # Configure Rails Environment
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
- require "rails/test_help"
6
-
7
- Rails.backtrace_cleaner.remove_silencers!
8
-
9
- # Load support files
10
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }