large_text_field 1.0.2 → 1.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. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +25 -17
  4. data/Rakefile +2 -1
  5. data/config/brakeman.ignore +12 -0
  6. data/db/migrate/20110217210640_add_large_text_fields.rb +2 -0
  7. data/lib/large_text_field/application_record.rb +7 -0
  8. data/lib/large_text_field/named_text_value.rb +3 -1
  9. data/lib/large_text_field/owner.rb +22 -6
  10. data/lib/large_text_field/version.rb +1 -1
  11. data/lib/large_text_field.rb +5 -4
  12. metadata +24 -81
  13. data/test/dummy/README.rdoc +0 -261
  14. data/test/dummy/Rakefile +0 -9
  15. data/test/dummy/app/assets/config/manifest.js +0 -1
  16. data/test/dummy/app/models/library.rb +0 -23
  17. data/test/dummy/config/application.rb +0 -54
  18. data/test/dummy/config/boot.rb +0 -12
  19. data/test/dummy/config/database.yml +0 -37
  20. data/test/dummy/config/environment.rb +0 -7
  21. data/test/dummy/config/environments/development.rb +0 -38
  22. data/test/dummy/config/environments/production.rb +0 -71
  23. data/test/dummy/config/environments/test.rb +0 -41
  24. data/test/dummy/config.ru +0 -6
  25. data/test/dummy/db/development.sqlite3 +0 -0
  26. data/test/dummy/db/migrate/20160217033529_create_libraries.rb +0 -13
  27. data/test/dummy/db/schema.rb +0 -29
  28. data/test/dummy/db/test.sqlite3 +0 -0
  29. data/test/dummy/log/development.log +0 -39
  30. data/test/dummy/log/test.log +0 -2893
  31. data/test/dummy/script/rails +0 -8
  32. data/test/dummy/test/fixtures/text_field_owners.yml +0 -11
  33. data/test/fixtures/large_text_field/named_text_values.yml +0 -11
  34. data/test/large_text_field_test.rb +0 -9
  35. data/test/reports/TEST-LargeTextField-LibraryTest.xml +0 -9
  36. data/test/reports/TEST-LargeTextField-NamedTextValueTest.xml +0 -15
  37. data/test/reports/TEST-LargeTextField-OwnerTest.xml +0 -53
  38. data/test/reports/TEST-LargeTextFieldTest.xml +0 -7
  39. data/test/test_helper.rb +0 -46
  40. data/test/unit/dummy/library_test.rb +0 -25
  41. data/test/unit/large_text_field/name_text_value_test.rb +0 -49
  42. data/test/unit/large_text_field/owner_test.rb +0 -317
@@ -1 +0,0 @@
1
- {}
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Library < ActiveRecord::Base
4
- include LargeTextField::Owner
5
-
6
- # Schema
7
- # name :string, :limit => 255
8
-
9
- large_text_field :description, singularize_errors: true
10
- large_text_field :catalog, maximum: 500, singularize_errors: true
11
- large_text_field :notes
12
-
13
- cattr_accessor :default_notes
14
-
15
- set_callback(:large_text_field_save, :before, :save_preprocess)
16
-
17
- def save_preprocess
18
- if self.class.default_notes
19
- self.notes = self.class.default_notes == :nil ? nil : self.class.default_notes
20
- end
21
- end
22
-
23
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('boot', __dir__)
4
-
5
- require 'rails/all'
6
-
7
- Bundler.require(*Rails.groups)
8
- require "large_text_field"
9
-
10
- module Dummy
11
- class Application < Rails::Application
12
- # Settings in config/environments/* take precedence over those specified here.
13
- # Application configuration should go into files in config/initializers
14
- # -- all .rb files in that directory are automatically loaded.
15
-
16
- # Custom directories with classes and modules you want to be autoloadable.
17
- # config.autoload_paths += %W(#{config.root}/extras)
18
-
19
- # Only load the plugins named here, in the order given (default is alphabetical).
20
- # :all can be used as a placeholder for all plugins not explicitly named.
21
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
22
-
23
- # Activate observers that should always be running.
24
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
25
-
26
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
27
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
28
- # config.time_zone = 'Central Time (US & Canada)'
29
-
30
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
31
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
32
- # config.i18n.default_locale = :de
33
-
34
- # Configure the default encoding used in templates for Ruby 1.9.
35
- config.encoding = "utf-8"
36
-
37
- # Configure sensitive parameters which will be filtered from the log file.
38
- config.filter_parameters += [:password]
39
-
40
- # Enable escaping HTML in JSON.
41
- config.active_support.escape_html_entities_in_json = true
42
-
43
- # Use SQL instead of Active Record's schema dumper when creating the database.
44
- # This is necessary if your schema can't be completely dumped by the schema dumper,
45
- # like if you have constraints or database-specific column types
46
- # config.active_record.schema_format = :sql
47
-
48
- # Enable the asset pipeline
49
- config.assets.enabled = true
50
-
51
- # Version of your assets, change this if you want to expire all your assets
52
- config.assets.version = '1.0'
53
- end
54
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- gemfile = File.expand_path('../../../Gemfile', __dir__)
5
-
6
- if File.exist?(gemfile)
7
- ENV['BUNDLE_GEMFILE'] = gemfile
8
- require 'bundler'
9
- Bundler.setup
10
- end
11
-
12
- $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -1,37 +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
- <% if ENV["USE_MYSQL_DB"] %>
16
- test:
17
- adapter: mysql2
18
- encoding: utf8
19
- reconnect: false
20
- database: large_text_field_test
21
- pool: 5
22
- username: <%= ENV['DATABASE_MYSQL_USERNAME'] || 'root' %>
23
- password: <%= ENV['DATABASE_MYSQL_PASSWORD'] || '' %>
24
- host: <%= ENV['DATABASE_MYSQL_HOST'] || 'localhost' %>
25
- <% else %>
26
- test:
27
- adapter: sqlite3
28
- database: <%= ENV['TEST_DB'].presence || 'db/test.sqlite3' %>
29
- pool: 5
30
- timeout: 5000
31
- <% end %>
32
-
33
- production:
34
- adapter: sqlite3
35
- database: db/production.sqlite3
36
- pool: 5
37
- timeout: 5000
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Load the rails application
4
- require File.expand_path('application', __dir__)
5
-
6
- # Initialize the rails application
7
- Dummy::Application.initialize!
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Dummy::Application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb
5
-
6
- # In the development environment your application's code is reloaded on
7
- # every request. This slows down response time but is perfect for development
8
- # since you don't have to restart the web server when you make code changes.
9
- config.cache_classes = false
10
-
11
- # Log error messages when you accidentally call methods on nil.
12
- config.whiny_nils = true
13
-
14
- # Show full error reports and disable caching
15
- config.consider_all_requests_local = true
16
- config.action_controller.perform_caching = false
17
-
18
- # Don't care if the mailer can't send
19
- config.action_mailer.raise_delivery_errors = false
20
-
21
- # Print deprecation notices to the Rails logger
22
- config.active_support.deprecation = :log
23
-
24
- # Only use best-standards-support built into browsers
25
- config.action_dispatch.best_standards_support = :builtin
26
-
27
- # Log the query plan for queries taking more than this (works
28
- # with SQLite, MySQL, and PostgreSQL)
29
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
30
-
31
- # Do not compress assets
32
- config.assets.compress = false
33
-
34
- # Expands the lines which load the assets
35
- config.assets.debug = true
36
-
37
- config.eager_load = false
38
- end
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Dummy::Application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb
5
-
6
- # Code is not reloaded between requests
7
- config.cache_classes = true
8
-
9
- # Full error reports are disabled and caching is turned on
10
- config.consider_all_requests_local = false
11
- config.action_controller.perform_caching = true
12
-
13
- # Disable Rails's static asset server (Apache or nginx will already do this)
14
- config.serve_static_files = false
15
-
16
- # Compress JavaScripts and CSS
17
- config.assets.compress = true
18
-
19
- # Don't fallback to assets pipeline if a precompiled asset is missed
20
- config.assets.compile = false
21
-
22
- # Generate digests for assets URLs
23
- config.assets.digest = true
24
-
25
- config.eager_load = true
26
-
27
- # Defaults to nil and saved in location specified by config.assets.prefix
28
- # config.assets.manifest = YOUR_PATH
29
-
30
- # Specifies the header that your server uses for sending files
31
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
32
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
33
-
34
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
35
- # config.force_ssl = true
36
-
37
- # See everything in the log (default is :info)
38
- # config.log_level = :debug
39
-
40
- # Prepend all log lines with the following tags
41
- # config.log_tags = [ :subdomain, :uuid ]
42
-
43
- # Use a different logger for distributed setups
44
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
45
-
46
- # Use a different cache store in production
47
- # config.cache_store = :mem_cache_store
48
-
49
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
50
- # config.action_controller.asset_host = "http://assets.example.com"
51
-
52
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
53
- # config.assets.precompile += %w( search.js )
54
-
55
- # Disable delivery errors, bad email addresses will be ignored
56
- # config.action_mailer.raise_delivery_errors = false
57
-
58
- # Enable threaded mode
59
- # config.threadsafe!
60
-
61
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
62
- # the I18n.default_locale when a translation can not be found)
63
- config.i18n.fallbacks = true
64
-
65
- # Send deprecation notices to registered listeners
66
- config.active_support.deprecation = :notify
67
-
68
- # Log the query plan for queries taking more than this (works
69
- # with SQLite, MySQL, and PostgreSQL)
70
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
71
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Dummy::Application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb
5
-
6
- # The test environment is used exclusively to run your application's
7
- # test suite. You never need to work with it otherwise. Remember that
8
- # your test database is "scratch space" for the test suite and is wiped
9
- # and recreated between test runs. Don't rely on the data there!
10
- config.cache_classes = true
11
-
12
- # Configure static asset server for tests with Cache-Control for performance
13
- config.serve_static_files = true
14
- config.static_cache_control = "public, max-age=3600"
15
-
16
- # Log error messages when you accidentally call methods on nil
17
- config.whiny_nils = true
18
-
19
- # Show full error reports and disable caching
20
- config.consider_all_requests_local = true
21
- config.action_controller.perform_caching = false
22
-
23
- # Raise exceptions instead of rendering exception templates
24
- config.action_dispatch.show_exceptions = false
25
-
26
- # Disable request forgery protection in test environment
27
- config.action_controller.allow_forgery_protection = false
28
-
29
- # Tell Action Mailer not to deliver emails to the real world.
30
- # The :test delivery method accumulates sent emails in the
31
- # ActionMailer::Base.deliveries array.
32
- config.action_mailer.delivery_method = :test
33
-
34
- # Print deprecation notices to the stderr
35
- config.active_support.deprecation = :stderr
36
-
37
- # set test order
38
- config.active_support.test_order = :sorted
39
-
40
- config.eager_load = true
41
- end
data/test/dummy/config.ru DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file is used by Rack-based servers to start the application.
4
-
5
- require ::File.expand_path('../config/environment', __FILE__)
6
- run Dummy::Application
File without changes
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateLibraries < ActiveRecord::Migration
4
- def self.up
5
- create_table :libraries do |t|
6
- t.string :name, null: false
7
- end
8
- end
9
-
10
- def self.down
11
- drop_table :libraries
12
- end
13
- end
@@ -1,29 +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 that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 20160217033529) do
15
-
16
- create_table "large_text_fields", force: :cascade do |t|
17
- t.string "field_name", limit: 255, null: false
18
- t.text "value", limit: 16777215
19
- t.integer "owner_id", limit: 4, null: false
20
- t.string "owner_type", limit: 255, null: false
21
- end
22
-
23
- add_index "large_text_fields", ["owner_type", "owner_id", "field_name"], name: "large_text_field_by_owner_field", unique: true, using: :btree
24
-
25
- create_table "libraries", force: :cascade do |t|
26
- t.string "name", limit: 255, null: false
27
- end
28
-
29
- end
Binary file
@@ -1,39 +0,0 @@
1
-  (2.3ms) CREATE TABLE "large_text_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "field_name" varchar NOT NULL, "value" text(16777215), "owner_id" integer NOT NULL, "owner_type" varchar NOT NULL) 
2
-  (0.1ms) select sqlite_version(*)
3
-  (1.7ms) CREATE UNIQUE INDEX "large_text_field_by_owner_field" ON "large_text_fields" ("owner_type", "owner_id", "field_name")
4
-  (1.7ms) CREATE TABLE "libraries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL)
5
-  (1.5ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL) 
6
-  (1.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
7
-  (0.1ms) SELECT version FROM "schema_migrations"
8
-  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20160217033529')
9
-  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20110217210640')
10
-  (1.8ms) DROP TABLE "large_text_fields"
11
-  (1.4ms) CREATE TABLE "large_text_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "field_name" varchar NOT NULL, "value" text(16777215), "owner_id" integer NOT NULL, "owner_type" varchar NOT NULL) 
12
-  (0.1ms) select sqlite_version(*)
13
-  (6.1ms) CREATE UNIQUE INDEX "large_text_field_by_owner_field" ON "large_text_fields" ("owner_type", "owner_id", "field_name")
14
-  (1.3ms) DROP TABLE "libraries"
15
-  (1.6ms) CREATE TABLE "libraries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL) 
16
-  (0.1ms) SELECT version FROM "schema_migrations"
17
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
18
-  (1.6ms) DROP TABLE "large_text_fields"
19
-  (1.1ms) CREATE TABLE "large_text_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "field_name" varchar NOT NULL, "value" text(16777215), "owner_id" integer NOT NULL, "owner_type" varchar NOT NULL)
20
-  (0.0ms) select sqlite_version(*)
21
-  (1.2ms) CREATE UNIQUE INDEX "large_text_field_by_owner_field" ON "large_text_fields" ("owner_type", "owner_id", "field_name")
22
-  (1.2ms) DROP TABLE "libraries"
23
-  (1.0ms) CREATE TABLE "libraries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL)
24
-  (0.3ms) SELECT version FROM "schema_migrations"
25
-  (1.2ms) DROP TABLE "large_text_fields"
26
-  (1.2ms) CREATE TABLE "large_text_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "field_name" varchar NOT NULL, "value" text(16777215), "owner_id" integer NOT NULL, "owner_type" varchar NOT NULL) 
27
-  (0.0ms) select sqlite_version(*)
28
-  (1.1ms) CREATE UNIQUE INDEX "large_text_field_by_owner_field" ON "large_text_fields" ("owner_type", "owner_id", "field_name")
29
-  (1.1ms) DROP TABLE "libraries"
30
-  (1.2ms) CREATE TABLE "libraries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL) 
31
-  (0.1ms) SELECT version FROM "schema_migrations"
32
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
33
-  (1.4ms) DROP TABLE "large_text_fields"
34
-  (1.2ms) CREATE TABLE "large_text_fields" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "field_name" varchar NOT NULL, "value" text(16777215), "owner_id" integer NOT NULL, "owner_type" varchar NOT NULL)
35
-  (0.0ms) select sqlite_version(*)
36
-  (1.1ms) CREATE UNIQUE INDEX "large_text_field_by_owner_field" ON "large_text_fields" ("owner_type", "owner_id", "field_name")
37
-  (1.1ms) DROP TABLE "libraries"
38
-  (0.9ms) CREATE TABLE "libraries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL)
39
-  (0.1ms) SELECT version FROM "schema_migrations"