ajax-datatables-rails 0.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +8 -0
  3. data/.github/workflows/ci.yml +128 -0
  4. data/.gitignore +23 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +58 -0
  7. data/Appraisals +28 -0
  8. data/CHANGELOG.md +102 -7
  9. data/Gemfile +4 -1
  10. data/Guardfile +16 -0
  11. data/LICENSE +17 -18
  12. data/README.md +595 -404
  13. data/Rakefile +4 -2
  14. data/ajax-datatables-rails.gemspec +41 -25
  15. data/appraisal.yml +56 -0
  16. data/bin/_guard-core +29 -0
  17. data/bin/appraisal +29 -0
  18. data/bin/bundle +114 -0
  19. data/bin/guard +29 -0
  20. data/bin/rackup +27 -0
  21. data/bin/rake +29 -0
  22. data/bin/rspec +29 -0
  23. data/bin/rubocop +29 -0
  24. data/config.ru +7 -0
  25. data/doc/migrate.md +97 -0
  26. data/doc/webpack.md +55 -0
  27. data/gemfiles/rails_5.2.8.gemfile +21 -0
  28. data/gemfiles/rails_6.0.6.gemfile +21 -0
  29. data/gemfiles/rails_6.1.7.gemfile +21 -0
  30. data/gemfiles/rails_7.0.4.gemfile +21 -0
  31. data/lib/ajax-datatables-rails/active_record.rb +7 -0
  32. data/lib/ajax-datatables-rails/base.rb +114 -149
  33. data/lib/ajax-datatables-rails/datatable/column/date_filter.rb +68 -0
  34. data/lib/ajax-datatables-rails/datatable/column/order.rb +29 -0
  35. data/lib/ajax-datatables-rails/datatable/column/search.rb +125 -0
  36. data/lib/ajax-datatables-rails/datatable/column.rb +123 -0
  37. data/lib/ajax-datatables-rails/datatable/datatable.rb +91 -0
  38. data/lib/ajax-datatables-rails/datatable/simple_order.rb +59 -0
  39. data/lib/ajax-datatables-rails/datatable/simple_search.rb +23 -0
  40. data/lib/ajax-datatables-rails/datatable.rb +6 -0
  41. data/lib/ajax-datatables-rails/error.rb +9 -0
  42. data/lib/ajax-datatables-rails/orm/active_record.rb +60 -0
  43. data/lib/ajax-datatables-rails/orm.rb +6 -0
  44. data/lib/ajax-datatables-rails/version.rb +15 -1
  45. data/lib/ajax-datatables-rails.rb +11 -7
  46. data/lib/generators/rails/datatable_generator.rb +11 -22
  47. data/lib/generators/rails/templates/datatable.rb +13 -15
  48. data/spec/ajax-datatables-rails/base_spec.rb +223 -0
  49. data/spec/ajax-datatables-rails/datatable/column_spec.rb +222 -0
  50. data/spec/ajax-datatables-rails/datatable/datatable_spec.rb +127 -0
  51. data/spec/ajax-datatables-rails/datatable/simple_order_spec.rb +62 -0
  52. data/spec/ajax-datatables-rails/datatable/simple_search_spec.rb +19 -0
  53. data/spec/ajax-datatables-rails/orm/active_record_filter_records_spec.rb +639 -0
  54. data/spec/ajax-datatables-rails/orm/active_record_paginate_records_spec.rb +67 -0
  55. data/spec/ajax-datatables-rails/orm/active_record_sort_records_spec.rb +80 -0
  56. data/spec/dummy/app/assets/config/manifest.js +0 -0
  57. data/spec/dummy/config/database.yml +25 -0
  58. data/spec/dummy/config/routes.rb +5 -0
  59. data/spec/dummy/config/storage.yml +3 -0
  60. data/spec/dummy/db/schema.rb +13 -0
  61. data/spec/dummy/log/.gitignore +1 -0
  62. data/spec/dummy/public/favicon.ico +0 -0
  63. data/spec/factories/user.rb +11 -0
  64. data/spec/install_oracle.sh +18 -0
  65. data/spec/spec_helper.rb +85 -6
  66. data/spec/support/datatables/complex_datatable.rb +33 -0
  67. data/spec/support/datatables/complex_datatable_array.rb +16 -0
  68. data/spec/support/datatables/datatable_cond_date.rb +7 -0
  69. data/spec/support/datatables/datatable_cond_numeric.rb +53 -0
  70. data/spec/support/datatables/datatable_cond_proc.rb +13 -0
  71. data/spec/support/datatables/datatable_cond_string.rb +43 -0
  72. data/spec/support/datatables/datatable_cond_unknown.rb +7 -0
  73. data/spec/support/datatables/datatable_custom_column.rb +17 -0
  74. data/spec/support/datatables/datatable_order_nulls_last.rb +7 -0
  75. data/spec/support/helpers/params.rb +80 -0
  76. data/spec/support/models/user.rb +7 -0
  77. metadata +249 -48
  78. data/lib/ajax-datatables-rails/config.rb +0 -25
  79. data/lib/ajax-datatables-rails/extensions/kaminari.rb +0 -12
  80. data/lib/ajax-datatables-rails/extensions/simple_paginator.rb +0 -12
  81. data/lib/ajax-datatables-rails/extensions/will_paginate.rb +0 -12
  82. data/lib/ajax-datatables-rails/models.rb +0 -6
  83. data/lib/generators/datatable/config_generator.rb +0 -17
  84. data/lib/generators/datatable/templates/ajax_datatables_rails_config.rb +0 -7
  85. data/spec/ajax-datatables-rails/ajax_datatables_rails_spec.rb +0 -351
  86. data/spec/ajax-datatables-rails/kaminari_spec.rb +0 -35
  87. data/spec/ajax-datatables-rails/models_spec.rb +0 -10
  88. data/spec/ajax-datatables-rails/simple_paginator_spec.rb +0 -32
  89. data/spec/ajax-datatables-rails/will_paginate_spec.rb +0 -28
  90. data/spec/schema.rb +0 -35
  91. data/spec/test_models.rb +0 -21
data/Rakefile CHANGED
@@ -1,14 +1,16 @@
1
- #!/usr/bin/env rake
1
+ # frozen_string_literal: true
2
+
2
3
  require 'bundler/gem_tasks'
3
4
  require 'rspec/core/rake_task'
4
5
 
5
6
  RSpec::Core::RakeTask.new(:spec)
6
- task :default => :spec
7
+ task default: :spec
7
8
 
8
9
  task :console do
9
10
  require 'pry'
10
11
  require 'rails'
11
12
  require 'ajax-datatables-rails'
13
+ puts 'Loaded AjaxDatatablesRails'
12
14
  ARGV.clear
13
15
  Pry.start
14
16
  end
@@ -1,30 +1,46 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ajax-datatables-rails/version'
1
+ # frozen_string_literal: true
5
2
 
6
- Gem::Specification.new do |gem|
7
- gem.name = "ajax-datatables-rails"
8
- gem.version = AjaxDatatablesRails::VERSION
9
- gem.authors = ["Joel Quenneville"]
10
- gem.email = ["joel.quenneville@collegeplus.org"]
11
- gem.description = %q{A gem that simplifies using datatables and hundreds of records via ajax}
12
- gem.summary = %q{A wrapper around datatable's ajax methods that allow synchronization with server-side pagination in a rails app}
13
- gem.homepage = ""
14
- gem.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
3
+ require_relative 'lib/ajax-datatables-rails/version'
15
4
 
16
- gem.files = Dir["{lib,spec}/**/*", "[A-Z]*"] - ["Gemfile.lock"]
17
- gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_path = "lib"
5
+ Gem::Specification.new do |s|
6
+ s.name = 'ajax-datatables-rails'
7
+ s.version = AjaxDatatablesRails::VERSION::STRING
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Joel Quenneville', 'Antonio Antillon']
10
+ s.email = ['joel.quenneville@collegeplus.org', 'antillas21@gmail.com']
11
+ s.homepage = 'https://github.com/jbox-web/ajax-datatables-rails'
12
+ s.summary = 'A gem that simplifies using datatables and hundreds of records via ajax'
13
+ s.description = "A wrapper around datatable's ajax methods that allow synchronization with server-side pagination in a rails app"
14
+ s.license = 'MIT'
15
+ s.metadata = {
16
+ 'homepage_uri' => 'https://github.com/jbox-web/ajax-datatables-rails',
17
+ 'changelog_uri' => 'https://github.com/jbox-web/ajax-datatables-rails/blob/master/CHANGELOG.md',
18
+ 'source_code_uri' => 'https://github.com/jbox-web/ajax-datatables-rails',
19
+ 'bug_tracker_uri' => 'https://github.com/jbox-web/ajax-datatables-rails/issues',
20
+ }
20
21
 
21
- gem.add_dependency 'railties', '>= 3.1'
22
+ s.required_ruby_version = '>= 2.7.0'
22
23
 
23
- gem.add_development_dependency "rspec"
24
- gem.add_development_dependency "generator_spec"
25
- gem.add_development_dependency "pry"
26
- gem.add_development_dependency "rake"
27
- gem.add_development_dependency "sqlite3"
28
- gem.add_development_dependency "rails", ">= 3.1.0"
29
- gem.add_development_dependency "activerecord", ">= 4.1.6"
24
+ s.files = `git ls-files`.split("\n")
25
+
26
+ s.add_runtime_dependency 'rails', '>= 5.2'
27
+ s.add_runtime_dependency 'zeitwerk'
28
+
29
+ s.add_development_dependency 'activerecord-oracle_enhanced-adapter'
30
+ s.add_development_dependency 'appraisal'
31
+ s.add_development_dependency 'combustion', '~> 1.3'
32
+ s.add_development_dependency 'database_cleaner'
33
+ s.add_development_dependency 'factory_bot'
34
+ s.add_development_dependency 'faker'
35
+ s.add_development_dependency 'generator_spec'
36
+ s.add_development_dependency 'guard-rspec'
37
+ s.add_development_dependency 'pg'
38
+ s.add_development_dependency 'pry'
39
+ s.add_development_dependency 'puma'
40
+ s.add_development_dependency 'rake'
41
+ s.add_development_dependency 'rspec'
42
+ s.add_development_dependency 'rspec-retry'
43
+ s.add_development_dependency 'rubocop'
44
+ s.add_development_dependency 'simplecov'
45
+ s.add_development_dependency 'sqlite3', '~> 1.4.0'
30
46
  end
data/appraisal.yml ADDED
@@ -0,0 +1,56 @@
1
+ ---
2
+ 5.2.8:
3
+ sqlite3:
4
+ version: ~> 1.3.0
5
+ install_if: '-> { ENV["DB_ADAPTER"] == "sqlite3" }'
6
+ mysql2:
7
+ version: ''
8
+ install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
9
+ activerecord-oracle_enhanced-adapter:
10
+ version: ~> 5.2.0
11
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
12
+ ruby-oci8:
13
+ version: ''
14
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
15
+
16
+ 6.0.6:
17
+ sqlite3:
18
+ version: ~> 1.4.0
19
+ install_if: '-> { ENV["DB_ADAPTER"] == "sqlite3" }'
20
+ mysql2:
21
+ version: ''
22
+ install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
23
+ activerecord-oracle_enhanced-adapter:
24
+ version: ~> 6.0.0
25
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
26
+ ruby-oci8:
27
+ version: ''
28
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
29
+
30
+ 6.1.7:
31
+ sqlite3:
32
+ version: ~> 1.4.0
33
+ install_if: '-> { ENV["DB_ADAPTER"] == "sqlite3" }'
34
+ mysql2:
35
+ version: ''
36
+ install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
37
+ activerecord-oracle_enhanced-adapter:
38
+ version: ~> 6.1.0
39
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
40
+ ruby-oci8:
41
+ version: ''
42
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
43
+
44
+ 7.0.4:
45
+ sqlite3:
46
+ version: ~> 1.4.0
47
+ install_if: '-> { ENV["DB_ADAPTER"] == "sqlite3" }'
48
+ mysql2:
49
+ version: ''
50
+ install_if: '-> { ENV["DB_ADAPTER"] == "mysql2" }'
51
+ activerecord-oracle_enhanced-adapter:
52
+ version: ~> 7.0.0
53
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
54
+ ruby-oci8:
55
+ version: ''
56
+ install_if: '-> { ENV["DB_ADAPTER"] == "oracle_enhanced" }'
data/bin/_guard-core ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application '_guard-core' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "_guard-core")
data/bin/appraisal ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'appraisal' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("appraisal", "appraisal")
data/bin/bundle ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
data/bin/guard ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'guard' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "guard")
data/bin/rackup ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rackup' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
14
+
15
+ if File.file?(bundle_binstub)
16
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
17
+ load(bundle_binstub)
18
+ else
19
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21
+ end
22
+ end
23
+
24
+ require "rubygems"
25
+ require "bundler/setup"
26
+
27
+ load Gem.bin_path("rack", "rackup")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
data/config.ru ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Bundler.require :default, :development
4
+
5
+ Combustion.path = 'spec/dummy'
6
+ Combustion.initialize! :all
7
+ run Combustion::Application
data/doc/migrate.md ADDED
@@ -0,0 +1,97 @@
1
+ ## To migrate from `v1.x` to `v1.3.0`
2
+
3
+ The *v1.3.0* version has some breaking changes :
4
+
5
+ * `AjaxDatatablesRails.config.db_adapter=` is removed and is configured per datatable class now. It defaults to Rails DB adapter. (fixes [#364](https://github.com/jbox-web/ajax-datatables-rails/issues/364))
6
+
7
+ This change is transparent for everyone. Just remove `AjaxDatatablesRails.config.db_adapter=` from your configuration (if exists) and it should work fine.
8
+
9
+ Now you can use AjaxDatatablesRails in multi-db environments.
10
+
11
+ * `AjaxDatatablesRails.config.nulls_last=` is removed and is configured per datatable class now (or by column). It defaults to false.
12
+
13
+ This change is easy to mitigate : add `self.nulls_last = true` in [`ApplicationDatatable`](https://github.com/jbox-web/ajax-datatables-rails#create-a-master-parent-class-easy) and remove `AjaxDatatablesRails.config.nulls_last=`
14
+
15
+ ```ruby
16
+ class ApplicationDatatable < AjaxDatatablesRails::ActiveRecord
17
+ self.nulls_last = true
18
+ # puts commonly used methods here
19
+ end
20
+ ```
21
+
22
+ * `AjaxDatatablesRails.config` is removed with no replacement
23
+
24
+ Fix the two changes above and remove any configuration file about AjaxDatatablesRails. The gem is now configless :)
25
+
26
+ ## To migrate from `v0.4.x` to `v1.0.0`
27
+
28
+ The *v1.0.0* version is a **major break** from *v0.4*.
29
+
30
+ * Datatables no longer inherits from `AjaxDatatablesRails::Base` but from `AjaxDatatablesRails::ActiveRecord` (this solves [#228](https://github.com/jbox-web/ajax-datatables-rails/issues/228))
31
+ * The `view_context` is no longer injected in Datatables but only the `params` hash (see the [example](#4-setup-the-controller-action)). This will break calls to helpers methods.
32
+
33
+ 1) To mitigate the first change (Datatables no longer inherits from `AjaxDatatablesRails::Base` but from `AjaxDatatablesRails::ActiveRecord`)
34
+
35
+ Create a new `ApplicationDatatable` class and make all your classes inherits from it :
36
+
37
+ ```ruby
38
+ class ApplicationDatatable < AjaxDatatablesRails::ActiveRecord
39
+ end
40
+
41
+ class PostDatatable < ApplicationDatatable
42
+ end
43
+ ```
44
+
45
+ **Note :** This is now in the [ProTips™](https://github.com/jbox-web/ajax-datatables-rails#protips) section of the documentation.
46
+
47
+ 2) To mitigate the second change (The `view_context` is no longer injected in Datatables)
48
+
49
+ Update the `ApplicationDatatable` class :
50
+
51
+ ```ruby
52
+ class ApplicationDatatable < AjaxDatatablesRails::ActiveRecord
53
+ extend Forwardable
54
+ attr_reader :view
55
+ def initialize(params, opts = {})
56
+ @view = opts[:view_context]
57
+ super
58
+ end
59
+ end
60
+ ```
61
+
62
+ and update your controllers :
63
+
64
+ ```ruby
65
+ # before
66
+ respond_to do |format|
67
+ format.json { render json: UserDatatable.new(view_context) }
68
+ end
69
+
70
+ # after
71
+ respond_to do |format|
72
+ format.json { render json: UserDatatable.new(params, view_context: view_context) }
73
+ end
74
+
75
+ # if you need to inject some options
76
+ respond_to do |format|
77
+ format.json { render json: UserDatatable.new(params, view_context: view_context, my: 'options') }
78
+ end
79
+ ```
80
+
81
+ This way, you can still use `def_delegators` in your datatables [as in the documentation](https://github.com/jbox-web/ajax-datatables-rails#using-view-helpers).
82
+
83
+ Note that the recommanded way is to use [Draper gem](https://github.com/drapergem/draper) to separate filtering logic from view/presentation logic [as in the documentation](https://github.com/jbox-web/ajax-datatables-rails#using-view-decorators).
84
+
85
+ ## To migrate from `v0.3.x` to `v0.4.x`
86
+
87
+ The *v0.4* version is a **major break** from *v0.3*.
88
+
89
+ The core has been rewriten to remove dependency on [Kaminari](https://github.com/kaminari/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate).
90
+
91
+ It also brings a new (more natural) way of defining columns, based on hash definitions (and not arrays) and add some filtering options for column search.
92
+
93
+ To migrate on the v0.4 you'll need to :
94
+
95
+ * update your DataTables classes to remove all the `extend` directives
96
+ * switch to hash definitions of `view_columns`
97
+ * update your views to declare your columns bindings ([See here](https://github.com/jbox-web/ajax-datatables-rails#5-wire-up-the-javascript))
data/doc/webpack.md ADDED
@@ -0,0 +1,55 @@
1
+ ### Webpack
2
+
3
+ We assume here that Bootstrap and FontAwesome are already installed with Webpack.
4
+
5
+ Inspired by https://datatables.net/download and completed :
6
+
7
+ Add npm packages :
8
+ ```sh
9
+ $ yarn add imports-loader
10
+ ```
11
+ ```sh
12
+ $ yarn add datatables.net
13
+ $ yarn add datatables.net-bs
14
+ $ yarn add datatables.net-buttons
15
+ $ yarn add datatables.net-buttons-bs
16
+ $ yarn add datatables.net-responsive
17
+ $ yarn add datatables.net-responsive-bs
18
+ $ yarn add datatables.net-select
19
+ $ yarn add datatables.net-select-bs
20
+ ```
21
+
22
+ In `config/webpack/loaders/datatables.js` :
23
+
24
+ ```js
25
+ module.exports = {
26
+ test: /datatables\.net.*/,
27
+ loader: 'imports-loader',
28
+ options: {
29
+ additionalCode: 'var define = false;'
30
+ }
31
+ }
32
+ ```
33
+
34
+ In `config/webpack/environment.js` :
35
+
36
+ ```js
37
+ const { environment } = require('@rails/webpacker')
38
+ const datatables = require('./loaders/datatables')
39
+ environment.loaders.append('datatables', datatables)
40
+ module.exports = environment
41
+ ```
42
+
43
+ in `app/javascript/pack/application.js` :
44
+
45
+ ```js
46
+ // Load Datatables
47
+ require('datatables.net-bs')(window, $)
48
+ require('datatables.net-buttons-bs')(window, $)
49
+ require('datatables.net-buttons/js/buttons.colVis.js')(window, $)
50
+ require('datatables.net-buttons/js/buttons.html5.js')(window, $)
51
+ require('datatables.net-buttons/js/buttons.print.js')(window, $)
52
+ require('datatables.net-responsive-bs')(window, $)
53
+ require('datatables.net-select')(window, $)
54
+ // require('yadcf')(window, $) // Uncomment if you use yadcf (need a recent version of yadcf)
55
+ ```
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", git: "https://github.com/n-rodriguez/appraisal.git", branch: "wip/combustion"
6
+ gem "rails", "5.2.8"
7
+
8
+ install_if -> { ENV["DB_ADAPTER"] == "sqlite3" } do
9
+ gem "sqlite3", "~> 1.3.0"
10
+ end
11
+
12
+ install_if -> { ENV["DB_ADAPTER"] == "mysql2" } do
13
+ gem "mysql2"
14
+ end
15
+
16
+ install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
17
+ gem "activerecord-oracle_enhanced-adapter", "~> 5.2.0"
18
+ gem "ruby-oci8"
19
+ end
20
+
21
+ gemspec path: "../"
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", git: "https://github.com/n-rodriguez/appraisal.git", branch: "wip/combustion"
6
+ gem "rails", "6.0.6"
7
+
8
+ install_if -> { ENV["DB_ADAPTER"] == "sqlite3" } do
9
+ gem "sqlite3", "~> 1.4.0"
10
+ end
11
+
12
+ install_if -> { ENV["DB_ADAPTER"] == "mysql2" } do
13
+ gem "mysql2"
14
+ end
15
+
16
+ install_if -> { ENV["DB_ADAPTER"] == "oracle_enhanced" } do
17
+ gem "activerecord-oracle_enhanced-adapter", "~> 6.0.0"
18
+ gem "ruby-oci8"
19
+ end
20
+
21
+ gemspec path: "../"