bootstrap_validator_rails 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ae22852750f242da2de0062599a44d2752b675b
4
- data.tar.gz: 87639383c0e9a58bb2410fa0f7bcc8ed801e7de4
3
+ metadata.gz: 4e780af12bf0585ce5098c8116eb2809abe67566
4
+ data.tar.gz: e94b6330c4a6cf18143518c504486d90ec35c67f
5
5
  SHA512:
6
- metadata.gz: 106154f8749865080587a64328cbd05d5f3b55fba277a3df42d76dc381796210606cd2ad3a6edb8c91df3a813834d41bcd42f85a75cec85e01fbf045aec18535
7
- data.tar.gz: 9cc0a295cc85cbf939a7014dbcca71556007509d42a02dff4699e6a3fdbe0f09e8e43b72fb920666ac213f7f0cc26e8963b65fe23ca4ddb1f39845c80082d678
6
+ metadata.gz: 1113fb61f99d957cde4cc9bb311b908f7df89433b142435c59c57b6c2e91ff4f8331324c0ba7b49ffc0fe0e05034a4e651a46a484e583554ee103cd0a722caa9
7
+ data.tar.gz: 03f841a2da5df1f1ec5a6a2286224aa491e67b5a62002661263999e2cd21cde7a9a428b3dd073f570a9fc7a6d3fd09cddcc835d916310fd96a0290cfbbe8e50e
@@ -9,6 +9,7 @@ require 'bootstrap_validator_rails/validators/presence_validator'
9
9
  require 'bootstrap_validator_rails/validators/numericality_validator'
10
10
  require 'bootstrap_validator_rails/validators/length_validator'
11
11
  require 'bootstrap_validator_rails/validators/format_validator'
12
+ require 'bootstrap_validator_rails/validators/acceptance_validator'
12
13
 
13
14
  ActionView::Base.send :include, BootstrapValidatorRails::Helper
14
15
 
@@ -2,4 +2,5 @@ module BootstrapValidatorRails
2
2
  CONFIGURATION = {
3
3
  :unsupported_options => [:if, :unless]
4
4
  }
5
+ VALIDATOR_SUPPORTED = [:presence, :numericality, :length, :format, :acceptance]
5
6
  end
@@ -15,5 +15,13 @@ module BootstrapValidatorRails
15
15
  super(method, options)
16
16
  end
17
17
  end
18
+
19
+ def check_box(method, options = {}, checked_value = "1", unchecked_value = "0", &block)
20
+ options[:data] ||= {}
21
+ attribute = @attributes.validator_data(method)
22
+ options[:data] = options[:data].merge(attribute)
23
+ options[:include_hidden] = false
24
+ content_tag :div, super, class: 'form-group'
25
+ end
18
26
  end
19
27
  end
@@ -0,0 +1,9 @@
1
+ module BootstrapValidatorRails
2
+ module Validators
3
+ class Acceptance < Presence
4
+ def generate_message
5
+ 'should be accepted'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,11 +1,10 @@
1
1
  module BootstrapValidatorRails
2
2
  module Validators
3
3
  class Generator
4
- VALIDATOR_SUPPORTED = [:presence, :numericality, :length, :format]
5
-
6
4
  def initialize(record, validator, method)
7
5
  @record, @validator, @method = record, validator, method
8
6
  @kind = validator.kind
7
+ p @kind
9
8
  end
10
9
 
11
10
  def generate_data(options = {})
@@ -1,3 +1,3 @@
1
1
  module BootstrapValidatorRails
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -4,7 +4,7 @@ class BootstrapValidatorRailsTest < ActionView::TestCase
4
4
  def setup
5
5
  @post = Post.new(title: 'An awesome title')
6
6
  @form = view.bootstrap_validation_form_for(@post, url: '#') do |f|
7
- f.number_field :title
7
+ f.check_box :accepted
8
8
  end
9
9
  end
10
10
 
@@ -2,4 +2,5 @@ class Post < ActiveRecord::Base
2
2
  validates :title, presence: true, length: {within: 20..50}, numericality: {greater_than_or_equal_to: 20}
3
3
  validates :title, format: { with: /\A[a-zA-Z]+\z/, message: "only allows letters" }
4
4
  validates :intro, presence: true, if: :published?
5
+ validates :accepted, acceptance: true
5
6
  end
@@ -3,6 +3,7 @@ class CreatePosts < ActiveRecord::Migration
3
3
  create_table :posts do |t|
4
4
  t.string :title
5
5
  t.string :intro
6
+ t.string :accepted
6
7
  end
7
8
  end
8
9
  end
@@ -16,6 +16,7 @@ ActiveRecord::Schema.define(version: 20140723124112) do
16
16
  create_table "posts", force: true do |t|
17
17
  t.string "title"
18
18
  t.string "intro"
19
+ t.string "accepted"
19
20
  end
20
21
 
21
22
  end
Binary file
@@ -2366,3 +2366,193 @@ BootstrapValidatorRailsTest: test_test_will_be_included_later
2366
2366
   (0.0ms) rollback transaction
2367
2367
   (0.0ms) begin transaction
2368
2368
   (0.1ms) rollback transaction
2369
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
2370
+  (0.1ms) begin transaction
2371
+ -------------------------------------------------------------
2372
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2373
+ -------------------------------------------------------------
2374
+  (0.1ms) rollback transaction
2375
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2376
+  (0.1ms) begin transaction
2377
+  (0.1ms) rollback transaction
2378
+  (0.0ms) begin transaction
2379
+  (0.1ms) rollback transaction
2380
+  (0.0ms) begin transaction
2381
+  (0.0ms) rollback transaction
2382
+  (0.0ms) begin transaction
2383
+  (0.1ms) rollback transaction
2384
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2385
+  (0.1ms) begin transaction
2386
+  (0.1ms) rollback transaction
2387
+  (0.0ms) begin transaction
2388
+  (0.0ms) rollback transaction
2389
+  (0.0ms) begin transaction
2390
+  (0.0ms) rollback transaction
2391
+  (0.0ms) begin transaction
2392
+  (0.1ms) rollback transaction
2393
+ ActiveRecord::SchemaMigration Load (7.7ms) SELECT "schema_migrations".* FROM "schema_migrations"
2394
+  (0.1ms) begin transaction
2395
+ -------------------------------------------------------------
2396
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2397
+ -------------------------------------------------------------
2398
+  (0.1ms) rollback transaction
2399
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2400
+  (0.1ms) begin transaction
2401
+ -------------------------------------------------------------
2402
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2403
+ -------------------------------------------------------------
2404
+  (0.1ms) rollback transaction
2405
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2406
+  (0.1ms) begin transaction
2407
+ -------------------------------------------------------------
2408
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2409
+ -------------------------------------------------------------
2410
+  (0.1ms) rollback transaction
2411
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2412
+  (0.1ms) begin transaction
2413
+ -------------------------------------------------------------
2414
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2415
+ -------------------------------------------------------------
2416
+  (0.2ms) rollback transaction
2417
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2418
+  (0.1ms) begin transaction
2419
+ -------------------------------------------------------------
2420
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2421
+ -------------------------------------------------------------
2422
+  (0.1ms) rollback transaction
2423
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2424
+  (0.1ms) begin transaction
2425
+ -------------------------------------------------------------
2426
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2427
+ -------------------------------------------------------------
2428
+  (0.1ms) rollback transaction
2429
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2430
+  (0.5ms) select sqlite_version(*)
2431
+  (1.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
2432
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2433
+ Migrating to CreatePosts (20140723124112)
2434
+  (0.1ms) begin transaction
2435
+  (0.3ms) CREATE TABLE "posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "intro" varchar(255), "accepted" varchar(255))
2436
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140723124112"]]
2437
+  (0.9ms) commit transaction
2438
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2439
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2440
+  (0.1ms) begin transaction
2441
+ -------------------------------------------------------------
2442
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2443
+ -------------------------------------------------------------
2444
+  (0.1ms) rollback transaction
2445
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2446
+  (0.1ms) begin transaction
2447
+ -------------------------------------------------------------
2448
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2449
+ -------------------------------------------------------------
2450
+  (0.1ms) rollback transaction
2451
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2452
+  (0.1ms) begin transaction
2453
+ -------------------------------------------------------------
2454
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2455
+ -------------------------------------------------------------
2456
+  (0.1ms) rollback transaction
2457
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2458
+  (0.1ms) begin transaction
2459
+ -------------------------------------------------------------
2460
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2461
+ -------------------------------------------------------------
2462
+  (0.1ms) rollback transaction
2463
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2464
+  (0.1ms) begin transaction
2465
+ -------------------------------------------------------------
2466
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2467
+ -------------------------------------------------------------
2468
+  (0.1ms) rollback transaction
2469
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
2470
+  (0.2ms) begin transaction
2471
+ -------------------------------------------------------------
2472
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2473
+ -------------------------------------------------------------
2474
+  (0.1ms) rollback transaction
2475
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2476
+  (0.1ms) begin transaction
2477
+ -------------------------------------------------------------
2478
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2479
+ -------------------------------------------------------------
2480
+  (0.1ms) rollback transaction
2481
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2482
+  (0.1ms) begin transaction
2483
+ -------------------------------------------------------------
2484
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2485
+ -------------------------------------------------------------
2486
+  (0.1ms) rollback transaction
2487
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2488
+  (0.1ms) begin transaction
2489
+ -------------------------------------------------------------
2490
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2491
+ -------------------------------------------------------------
2492
+  (0.1ms) rollback transaction
2493
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2494
+  (0.1ms) begin transaction
2495
+ -------------------------------------------------------------
2496
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2497
+ -------------------------------------------------------------
2498
+  (0.1ms) rollback transaction
2499
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2500
+  (0.1ms) begin transaction
2501
+ -------------------------------------------------------------
2502
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2503
+ -------------------------------------------------------------
2504
+  (0.1ms) rollback transaction
2505
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
2506
+  (0.1ms) begin transaction
2507
+ -------------------------------------------------------------
2508
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2509
+ -------------------------------------------------------------
2510
+  (0.1ms) rollback transaction
2511
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2512
+  (0.1ms) begin transaction
2513
+ -------------------------------------------------------------
2514
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2515
+ -------------------------------------------------------------
2516
+  (0.1ms) rollback transaction
2517
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2518
+  (0.1ms) begin transaction
2519
+ -------------------------------------------------------------
2520
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2521
+ -------------------------------------------------------------
2522
+  (0.1ms) rollback transaction
2523
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2524
+  (0.1ms) begin transaction
2525
+ -------------------------------------------------------------
2526
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2527
+ -------------------------------------------------------------
2528
+  (0.1ms) rollback transaction
2529
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2530
+  (0.1ms) begin transaction
2531
+ -------------------------------------------------------------
2532
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2533
+ -------------------------------------------------------------
2534
+  (0.1ms) rollback transaction
2535
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2536
+  (0.1ms) begin transaction
2537
+ -------------------------------------------------------------
2538
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2539
+ -------------------------------------------------------------
2540
+  (0.1ms) rollback transaction
2541
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2542
+  (0.1ms) begin transaction
2543
+ -------------------------------------------------------------
2544
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2545
+ -------------------------------------------------------------
2546
+  (0.1ms) rollback transaction
2547
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2548
+  (0.1ms) begin transaction
2549
+ -------------------------------------------------------------
2550
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2551
+ -------------------------------------------------------------
2552
+  (0.1ms) rollback transaction
2553
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2554
+  (0.1ms) begin transaction
2555
+ -------------------------------------------------------------
2556
+ BootstrapValidatorRailsTest: test_test_will_be_included_later
2557
+ -------------------------------------------------------------
2558
+  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_validator_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - huynhquancam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-28 00:00:00.000000000 Z
11
+ date: 2014-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap_form
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
- - !ruby/object:Gem::Dependency
28
- name: jquery-rails
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rails
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +81,7 @@ files:
95
81
  - lib/bootstrap_validator_rails/engine.rb
96
82
  - lib/bootstrap_validator_rails/form_builder.rb
97
83
  - lib/bootstrap_validator_rails/helper.rb
84
+ - lib/bootstrap_validator_rails/validators/acceptance_validator.rb
98
85
  - lib/bootstrap_validator_rails/validators/attributes.rb
99
86
  - lib/bootstrap_validator_rails/validators/format_validator.rb
100
87
  - lib/bootstrap_validator_rails/validators/generator.rb