trk_datatables 0.2.15 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,13 +7,18 @@ module TrkDatatables
7
7
 
8
8
  def self.determine_db_type_for_column
9
9
  # converts TrkDatatables::IntegerCalculatedInDb to :integer
10
- name.sub('TrkDatatables::', '').sub('CalculatedInDb', '').downcase.to_sym
10
+ name.sub("TrkDatatables::", "").sub("CalculatedInDb", "").downcase.to_sym
11
11
  end
12
12
  end
13
+
13
14
  class StringCalculatedInDb < CalculatedInDb; end
15
+
14
16
  class IntegerCalculatedInDb < CalculatedInDb; end
17
+
15
18
  class DateCalculatedInDb < CalculatedInDb; end
19
+
16
20
  class DatetimeCalculatedInDb < CalculatedInDb; end
21
+
17
22
  class BooleanCalculatedInDb < CalculatedInDb; end
18
23
 
19
24
  class ColumnKeyOptions
@@ -55,10 +60,10 @@ module TrkDatatables
55
60
  # for 'columns' that are calculated in Ruby you need to disable search and
56
61
  # order and than it will not be used in queries
57
62
 
58
- STRING_TYPE_CAST_POSTGRES = 'VARCHAR'.freeze
59
- STRING_TYPE_CAST_MYSQL = 'CHAR'.freeze
60
- STRING_TYPE_CAST_SQLITE = 'TEXT'.freeze
61
- STRING_TYPE_CAST_ORACLE = 'VARCHAR2(4000)'.freeze
63
+ STRING_TYPE_CAST_POSTGRES = "VARCHAR".freeze
64
+ STRING_TYPE_CAST_MYSQL = "CHAR".freeze
65
+ STRING_TYPE_CAST_SQLITE = "TEXT".freeze
66
+ STRING_TYPE_CAST_ORACLE = "VARCHAR2(4000)".freeze
62
67
 
63
68
  DB_ADAPTER_STRING_TYPE_CAST = {
64
69
  postgresql: STRING_TYPE_CAST_POSTGRES,
@@ -88,12 +93,12 @@ module TrkDatatables
88
93
  # In case first element is hash than we will use that hash
89
94
  if cols.is_a? Array
90
95
  cols = if cols.first.is_a? Hash
91
- cols.first
92
- else
93
- cols.each_with_object({}) do |column_key, hash|
94
- hash[column_key.to_sym] = {}
95
- end
96
- end
96
+ cols.first
97
+ else
98
+ cols.each_with_object({}) do |column_key, hash|
99
+ hash[column_key.to_sym] = {}
100
+ end
101
+ end
97
102
  end
98
103
  _set_data(cols)
99
104
  _set_global_search_cols(global_search_cols)
@@ -102,26 +107,28 @@ module TrkDatatables
102
107
 
103
108
  def _set_data(cols)
104
109
  @data = cols.each_with_object([]) do |(column_key, column_options), arr|
105
- raise Error, 'Column options needs to be a Hash' unless column_options.is_a? Hash
110
+ raise Error, "Column options needs to be a Hash" unless column_options.is_a? Hash
106
111
 
107
112
  column_options.assert_valid_keys(*COLUMN_OPTIONS)
108
- table_name, column_name = column_key.to_s.split '.'
109
- if table_name.present? && table_name.ends_with?('_calculated_in_db')
113
+ table_name, column_name = column_key.to_s.split "."
114
+ if table_name.present? && table_name.end_with?("_calculated_in_db")
110
115
  # in calculated columns table_name is used only to determine type
111
116
  column_key = column_name
112
117
  elsif table_name.present? && column_name.nil?
113
- raise Error, 'Unless table name ends with _calculated_in_db, column key needs to have one dot for example: posts.name'
118
+ raise Error,
119
+ "Unless table name ends with _calculated_in_db, column key needs to have one dot for example: posts.name"
114
120
  end
115
121
 
116
122
  if table_name.blank?
117
- column_name = column_options[TITLE_OPTION] || 'actions' # some default name for a title
123
+ column_name = column_options[TITLE_OPTION] || "actions" # some default name for a title
118
124
  column_options[SEARCH_OPTION] = false
119
125
  column_options[ORDER_OPTION] = false
120
126
  else
121
127
  table_class = _determine_table_class table_name, column_options[CLASS_NAME]
122
128
 
123
129
  unless column_options[SEARCH_OPTION] == false && column_options[ORDER_OPTION] == false
124
- column_type_in_db = column_options[COLUMN_TYPE_IN_DB] || _determine_db_type_for_column(table_class, column_name)
130
+ column_type_in_db = column_options[COLUMN_TYPE_IN_DB] || _determine_db_type_for_column(table_class,
131
+ column_name)
125
132
  end
126
133
  end
127
134
  arr << {
@@ -132,7 +139,7 @@ module TrkDatatables
132
139
  column_type_in_db: column_type_in_db,
133
140
  # the following are used for RenderHtml
134
141
  title: column_options[TITLE_OPTION] || _determine_column_name(table_class, column_name),
135
- html_options: html_options(column_options, column_type_in_db),
142
+ html_options: html_options(column_options, column_type_in_db)
136
143
  }
137
144
  end
138
145
  end
@@ -145,7 +152,7 @@ module TrkDatatables
145
152
  # note that when class is not eager loaded than const_defined? returns false
146
153
  if class_name.present?
147
154
  class_name.constantize
148
- elsif table_name.ends_with? '_calculated_in_db'
155
+ elsif table_name.end_with? "_calculated_in_db"
149
156
  "TrkDatatables::#{table_name.classify}".constantize
150
157
  else
151
158
  table_name.classify.constantize
@@ -153,10 +160,13 @@ module TrkDatatables
153
160
  end
154
161
 
155
162
  def _set_global_search_cols(global_search_cols)
156
- raise Error, 'global_search_cols should be array, for example %w[users.name]' unless global_search_cols.is_a? Array
163
+ unless global_search_cols.is_a? Array
164
+ raise Error,
165
+ "global_search_cols should be array, for example %w[users.name]"
166
+ end
157
167
 
158
168
  @global_search_cols = global_search_cols.each_with_object([]) do |column_key, arr|
159
- table_name, column_name = column_key.to_s.split '.'
169
+ table_name, column_name = column_key.to_s.split "."
160
170
  table_class = _determine_table_class table_name
161
171
  column_type_in_db = _determine_db_type_for_column(table_class, column_name)
162
172
  arr << {
@@ -164,7 +174,7 @@ module TrkDatatables
164
174
  column_options: {},
165
175
  table_class: table_class,
166
176
  column_name: column_name,
167
- column_type_in_db: column_type_in_db,
177
+ column_type_in_db: column_type_in_db
168
178
  }
169
179
  end
170
180
  end
@@ -173,13 +183,13 @@ module TrkDatatables
173
183
  def _determine_string_type_cast # :nodoc:
174
184
  if defined?(::ActiveRecord::Base)
175
185
  current_adapter = if ::ActiveRecord::Base.respond_to?(:connection_db_config)
176
- ::ActiveRecord::Base.connection_db_config.configuration_hash[:adapter]
177
- else
178
- ::ActiveRecord::Base.connection_config[:adapter]
179
- end
186
+ ::ActiveRecord::Base.connection_db_config.configuration_hash[:adapter]
187
+ else
188
+ ::ActiveRecord::Base.connection_config[:adapter]
189
+ end
180
190
  DB_ADAPTER_STRING_TYPE_CAST[current_adapter.to_sym]
181
191
  else
182
- 'not_used'
192
+ "not_used"
183
193
  end
184
194
  end
185
195
 
@@ -196,7 +206,7 @@ module TrkDatatables
196
206
  elsif defined?(::Neo4j::ActiveNode)
197
207
  (table_class.declared_properties[column_name][:type] || String).name.downcase
198
208
  else
199
- raise NotImplementedError, 'I work only with ActiveRecord and Neo4j'
209
+ raise NotImplementedError, "I work only with ActiveRecord and Neo4j"
200
210
  end
201
211
  end
202
212
 
@@ -235,27 +245,27 @@ module TrkDatatables
235
245
  i = @data.find_index do |column_key_option|
236
246
  column_key_option[:column_key] == column_key.to_sym
237
247
  end
238
- raise Error, "Can't find index for #{column_key} in #{@data.map { |d| d[:column_key] }.join(', ')}" if i.nil?
248
+ raise Error, "Can't find index for #{column_key} in #{@data.map { |d| d[:column_key] }.join(", ")}" if i.nil?
239
249
 
240
250
  i
241
251
  end
242
252
 
243
253
  def html_options(column_options, column_type_in_db)
244
254
  res = {}
245
- res['data-searchable'] = false if column_options[SEARCH_OPTION] == false
246
- res['data-orderable'] = false if column_options[ORDER_OPTION] == false
247
- res['data-datatable-hidden-column'] = true if column_options[HIDE_OPTION] == true
248
- res['data-datatable-checkbox'] = true if column_type_in_db == :boolean
255
+ res["data-searchable"] = false if column_options[SEARCH_OPTION] == false
256
+ res["data-orderable"] = false if column_options[ORDER_OPTION] == false
257
+ res["data-datatable-hidden-column"] = true if column_options[HIDE_OPTION] == true
258
+ res["data-datatable-checkbox"] = true if column_type_in_db == :boolean
249
259
  if %i[date datetime].include? column_type_in_db
250
- res['data-datatable-range'] = column_type_in_db == :datetime ? :datetime : true
260
+ res["data-datatable-range"] = (column_type_in_db == :datetime) ? :datetime : true
251
261
  if column_options[PREDEFINED_RANGES].present? ||
252
262
  (@predefined_ranges.try(:[], column_type_in_db).present? && column_options[PREDEFINED_RANGES] != false)
253
- res['data-datatable-predefined-ranges'] = if column_options[PREDEFINED_RANGES].is_a? Hash
254
- column_options[PREDEFINED_RANGES]
255
- else
256
- @predefined_ranges[column_type_in_db]
257
- end
258
- res['data-datatable-predefined-ranges'].transform_values! do |range|
263
+ res["data-datatable-predefined-ranges"] = if column_options[PREDEFINED_RANGES].is_a? Hash
264
+ column_options[PREDEFINED_RANGES]
265
+ else
266
+ @predefined_ranges[column_type_in_db]
267
+ end
268
+ res["data-datatable-predefined-ranges"].transform_values! do |range|
259
269
  [range.first.to_s, range.last.to_s]
260
270
  end
261
271
  end
@@ -40,12 +40,12 @@ module TrkDatatables
40
40
  @dt_orders = []
41
41
  return @dt_orders if @params[:order].blank?
42
42
 
43
- @dt_orders = \
43
+ @dt_orders =
44
44
  @params[:order].each_with_object([]) do |(_index, dt_order), a|
45
45
  # for order we ignore key (_index) since order is preserved
46
46
  a << [
47
47
  dt_order[:column].to_i,
48
- dt_order[:dir]&.to_s&.casecmp('ASC')&.zero? ? :asc : :desc,
48
+ dt_order[:dir]&.to_s&.casecmp("ASC")&.zero? ? :asc : :desc
49
49
  ]
50
50
  end
51
51
  @dt_orders
@@ -69,9 +69,9 @@ module TrkDatatables
69
69
  @params[:columns].each.map do |(dt_position, dt_column)|
70
70
  @dt_columns[dt_position.to_i] = {
71
71
  index: dt_position.to_i,
72
- searchable: dt_column[:searchable].to_s != 'false', # if nil as it is in set_params, than use true
73
- orderable: dt_column[:orderable].to_s != 'false', # if nil as it is in set_params, than use true
74
- search_value: (dt_column[:search] && dt_column[:search][:value]) || '',
72
+ searchable: dt_column[:searchable].to_s != "false", # if nil as it is in set_params, than use true
73
+ orderable: dt_column[:orderable].to_s != "false", # if nil as it is in set_params, than use true
74
+ search_value: (dt_column[:search] && dt_column[:search][:value]) || ""
75
75
  }
76
76
  end
77
77
  @dt_columns.each_with_index do |dt_column, i|
@@ -81,20 +81,20 @@ module TrkDatatables
81
81
  index: i,
82
82
  searchable: true,
83
83
  orderable: true,
84
- search_value: '',
84
+ search_value: ""
85
85
  }
86
86
  end
87
87
  end
88
88
 
89
89
  def search_all
90
- @params.dig(:search, :value) || ''
90
+ @params.dig(:search, :value) || ""
91
91
  rescue TypeError => e
92
92
  raise Error, e.message + '. Global search is in a format: { "search": { "value": "ABC" } }'
93
93
  end
94
94
 
95
95
  def as_json(all_count, filtered_count, data, additional = {})
96
96
  additional = {} if additional.nil?
97
- raise Error, 'additional_data_for_json needs to be a hash' unless additional.is_a? Hash
97
+ raise Error, "additional_data_for_json needs to be a hash" unless additional.is_a? Hash
98
98
 
99
99
  draw = @params[:draw].to_i
100
100
  {
@@ -102,7 +102,7 @@ module TrkDatatables
102
102
  recordsTotal: all_count,
103
103
  recordsFiltered: filtered_count,
104
104
  **additional,
105
- data: data,
105
+ data: data
106
106
  }
107
107
  end
108
108
 
@@ -111,7 +111,7 @@ module TrkDatatables
111
111
  end
112
112
 
113
113
  def self.order_set(column_index, direction)
114
- {order: {'0': {column: column_index, dir: direction}}}
114
+ {order: {"0": {column: column_index, dir: direction}}}
115
115
  end
116
116
 
117
117
  def self.form_field_name(column_index)
@@ -121,51 +121,52 @@ module TrkDatatables
121
121
  def param_get(column_index)
122
122
  @params.dig :columns, column_index.to_s, :search, :value
123
123
  rescue TypeError => e
124
- raise Error, "#{e.message}. Column search is in a format: { \"columns\": { \"0\": { \"search\": { \"value\": { \"ABC\" } } } } }"
124
+ raise Error,
125
+ "#{e.message}. Column search is in a format: { \"columns\": { \"0\": { \"search\": { \"value\": { \"ABC\" } } } } }"
125
126
  end
126
127
 
127
128
  def self.sample_view_params(options = {})
128
129
  OpenStruct.new(
129
- params: sample_params(options),
130
+ params: sample_params(options)
130
131
  )
131
132
  end
132
133
 
133
134
  def self.sample_params(options = {})
134
135
  HashWithIndifferentAccess.new(
135
- draw: '1',
136
- start: '0',
137
- length: '10',
136
+ draw: "1",
137
+ start: "0",
138
+ length: "10",
138
139
  search: {
139
- value: '', regex: 'false'
140
+ value: "", regex: "false"
140
141
  },
141
142
  order: {
142
- '0': {column: '0', dir: 'desc'}
143
+ "0": {column: "0", dir: "desc"}
143
144
  },
144
145
  # [:columns] should have the same size as column_key_options since we
145
146
  # ignore keys, and use positions
146
147
  columns: {
147
- '0': {
148
- searchable: 'true',
149
- orderable: 'true',
148
+ "0": {
149
+ searchable: "true",
150
+ orderable: "true",
150
151
  search: {
151
- value: '', regex: 'false'
152
+ value: "", regex: "false"
152
153
  }
153
154
  },
154
- '1': {
155
- searchable: 'true',
156
- orderable: 'true',
155
+ "1": {
156
+ searchable: "true",
157
+ orderable: "true",
157
158
  search: {
158
- value: '', regex: 'false'
159
+ value: "", regex: "false"
159
160
  }
160
161
  },
161
- '2': {
162
- searchable: 'true',
163
- orderable: 'false',
162
+ "2": {
163
+ searchable: "true",
164
+ orderable: "false",
164
165
  search: {
165
- value: '', regex: 'false'
166
+ value: "", regex: "false"
166
167
  }
167
- },
168
- },
168
+ }
169
+ }
169
170
  ).merge options
170
171
  end
171
172
  end
@@ -6,7 +6,7 @@ module TrkDatatables
6
6
  # https://neo4jrb.readthedocs.io/en/stable/QueryClauseMethods.html?highlight=where#where
7
7
  sql = @column_key_options.searchable_and_global_search.map do |column_key_option|
8
8
  "#{column_key_option[:column_key]} =~ ?"
9
- end.join(' or ')
9
+ end.join(" or ")
10
10
 
11
11
  filtered.where sql, ".*#{@dt_params.search_all}.*"
12
12
  end
@@ -17,8 +17,7 @@ module TrkDatatables
17
17
 
18
18
  def order_and_paginate_items(filtered)
19
19
  filtered = order_items filtered
20
- filtered = filtered.offset(@dt_params.dt_offset).limit(dt_per_page_or_default)
21
- filtered
20
+ filtered.offset(@dt_params.dt_offset).limit(dt_per_page_or_default)
22
21
  end
23
22
 
24
23
  def order_items(filtered)
@@ -28,7 +27,7 @@ module TrkDatatables
28
27
 
29
28
  queries << "#{column_key_option[:column_key]} #{direction}"
30
29
  end
31
- filtered.order(order_by.join(', '))
30
+ filtered.order(order_by.join(", "))
32
31
  end
33
32
  end
34
33
  end
@@ -1,6 +1,6 @@
1
1
  module TrkDatatables
2
2
  class Preferences
3
- KEY_IN_PREFERENCES = :trk_datatables
3
+ KEY_IN_PREFERENCES = "trk_datatables"
4
4
  def initialize(holder, field, class_name)
5
5
  @holder = holder
6
6
  @field = field
@@ -13,18 +13,34 @@ module TrkDatatables
13
13
  def get(key, check_value = nil)
14
14
  return unless @holder
15
15
 
16
- result = @holder.send(@field).dig KEY_IN_PREFERENCES, @class_name, key
16
+ values = @holder.send(@field).dig KEY_IN_PREFERENCES, @class_name
17
+ result = values&.fetch(key, nil) || values&.fetch(key.to_s, nil)
17
18
  return result if check_value.nil?
18
- return result if check_value.call result
19
+ result if check_value.call result
19
20
  end
20
21
 
21
22
  def set(key, value)
22
23
  return unless @holder
23
24
 
24
- h = {KEY_IN_PREFERENCES => {@class_name => {key => value}}}
25
- @holder.send("#{@field}=", {}) if @holder.send(@field).nil?
25
+ h = {KEY_IN_PREFERENCES => {@class_name => {key.to_s => _value_for_serialization(value)}}}
26
+ @holder.send(:"#{@field}=", {}) if @holder.send(@field).nil?
26
27
  @holder.send(@field).deep_merge! h
27
28
  @holder.save!
28
29
  end
30
+
31
+ private
32
+
33
+ def _value_for_serialization(value)
34
+ case value
35
+ when Array
36
+ value.map { |v| _value_for_serialization v }
37
+ when Hash
38
+ value.transform_values { |v| _value_for_serialization v }
39
+ when Symbol
40
+ value.to_s
41
+ else
42
+ value
43
+ end
44
+ end
29
45
  end
30
46
  end
@@ -43,16 +43,16 @@ module TrkDatatables
43
43
  inline = true
44
44
  end
45
45
  self.class.indent += 1
46
- html = "#{' ' * self.class.indent}<#{tag}".html_safe
46
+ html = "#{" " * self.class.indent}<#{tag}".html_safe
47
47
  options.each do |attribute, value|
48
48
  value = value.to_json if value.is_a?(Hash) || value.is_a?(Array)
49
49
  html << " #{attribute}='".html_safe << replace_quote(value) << "'".html_safe
50
50
  end
51
51
  html << if inline
52
- '>'.html_safe << content.to_s << "</#{tag}>\n".html_safe
53
- else
54
- ">\n".html_safe << yield << "\n#{' ' * self.class.indent}</#{tag}>".html_safe
55
- end
52
+ ">".html_safe << content.to_s << "</#{tag}>\n".html_safe
53
+ else
54
+ ">\n".html_safe << yield << "\n#{" " * self.class.indent}</#{tag}>".html_safe
55
+ end
56
56
  self.class.indent -= 1 if self.class.indent > 1
57
57
  html
58
58
  end
@@ -62,7 +62,7 @@ module TrkDatatables
62
62
  def _select_find_options(options, search_value)
63
63
  selected = search_value.to_s.split(MULTIPLE_OPTION_SEPARATOR)
64
64
  options.map do |key, value|
65
- {key: key, value: value}.merge(selected.include?(value.to_s) ? {selected: 'selected'} : {})
65
+ {key: key, value: value}.merge(selected.include?(value.to_s) ? {selected: "selected"} : {})
66
66
  end
67
67
  end
68
68
 
@@ -82,14 +82,14 @@ module TrkDatatables
82
82
  _content_tag(
83
83
  :table,
84
84
  class: "table table-bordered table-striped #{@html_options[:class]}",
85
- 'data-datatable': true,
86
- 'data-datatable-ajax-url': @search_link,
87
- 'data-datatable-page-length': @datatable.dt_per_page_or_default,
88
- 'data-datatable-order': @datatable.dt_orders_or_default_index_and_direction.to_json,
85
+ "data-datatable": true,
86
+ "data-datatable-ajax-url": @search_link,
87
+ "data-datatable-page-length": @datatable.dt_per_page_or_default,
88
+ "data-datatable-order": @datatable.dt_orders_or_default_index_and_direction.to_json,
89
89
  # for initial page load we do not have ability to show recordsTotal
90
90
  # https://github.com/trkin/trk_datatables_js/issues/1
91
- 'data-datatable-total-length': @datatable.filtered_items_count,
92
- 'data-datatable-dom': @html_options[:'data-datatable-dom'] || '<"trk-global-search-wrapper"f>rtp<"trk-move-up"il>',
91
+ "data-datatable-total-length": @datatable.filtered_items_count,
92
+ "data-datatable-dom": @html_options[:"data-datatable-dom"] || '<"trk-global-search-wrapper"f>rtp<"trk-move-up"il>'
93
93
  ) do
94
94
  thead << "\n".html_safe << tbody
95
95
  end +
@@ -102,11 +102,14 @@ module TrkDatatables
102
102
  safe_join(@datatable.column_key_options.map do |column_key_option|
103
103
  options = column_key_option[:html_options]
104
104
  # add eventual value from params
105
- search_value = @datatable.param_get(column_key_option[:column_key]) if options['data-searchable'] != false
106
- options['data-datatable-search-value'] = search_value if search_value.present?
105
+ search_value = @datatable.param_get(column_key_option[:column_key]) if options["data-searchable"] != false
106
+ options["data-datatable-search-value"] = search_value if search_value.present?
107
107
  # add eventual select element
108
108
  select_options = column_key_option[:column_options][ColumnKeyOptions::SELECT_OPTIONS]
109
- options['data-datatable-multiselect'] = _select_find_options select_options, search_value if select_options.present?
109
+ if select_options.present?
110
+ options["data-datatable-multiselect"] =
111
+ _select_find_options select_options, search_value
112
+ end
110
113
  # all other options are pulled from column_key_option[:html_options]
111
114
  _content_tag :th, options, column_key_option[:title]
112
115
  end)
@@ -148,7 +151,7 @@ module TrkDatatables
148
151
  # # https://github.com/trkin/trk_datatables_js/issues/1
149
152
  # 'data-datatable-total-length': @datatable.filtered_items_count,
150
153
  # ) do
151
- ''
154
+ ""
152
155
  end
153
156
  end
154
157
  end
@@ -1,3 +1,3 @@
1
1
  module TrkDatatables
2
- VERSION = '0.2.15'.freeze
2
+ VERSION = "0.2.18".freeze
3
3
  end
@@ -1,22 +1,24 @@
1
- require 'trk_datatables/version'
2
- # modules
3
- require 'trk_datatables/preferences.rb'
4
- require 'trk_datatables/base_helpers'
5
- require 'trk_datatables/base'
6
- require 'trk_datatables/active_record'
7
- require 'trk_datatables/neo4j'
8
- require 'trk_datatables/dt_params'
9
- require 'trk_datatables/column_key_options.rb'
10
- require 'trk_datatables/render_html.rb'
11
-
1
+ require "trk_datatables/version"
12
2
  # libs
13
- require 'active_support/core_ext/hash/indifferent_access'
14
- require 'active_support/core_ext/hash/keys'
15
- require 'active_support/core_ext/string/inflections'
16
- require 'active_support/core_ext/string/output_safety'
17
- require 'active_support/core_ext/time/zones'
3
+ require "active_support"
4
+ require "active_support/core_ext/hash/indifferent_access"
5
+ require "active_support/core_ext/hash/keys"
6
+ require "active_support/core_ext/string/inflections"
7
+ require "active_support/core_ext/string/output_safety"
8
+ require "active_support/core_ext/time/zones"
18
9
 
10
+ require "ostruct"
19
11
  # we need to define here since some conventions will look for definition in this file
12
+ # modules
13
+ require "trk_datatables/preferences"
14
+ require "trk_datatables/base_helpers"
15
+ require "trk_datatables/base"
16
+ require "trk_datatables/active_record"
17
+ require "trk_datatables/neo4j"
18
+ require "trk_datatables/dt_params"
19
+ require "trk_datatables/column_key_options"
20
+ require "trk_datatables/render_html"
21
+
20
22
  module TrkDatatables
21
23
  class Error < StandardError
22
24
  def message
@@ -1,31 +1,30 @@
1
- lib = File.expand_path('lib', __dir__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'trk_datatables/version'
3
+ require "trk_datatables/version"
4
4
 
5
- # rubocop:disable Metrics/BlockLength
6
5
  Gem::Specification.new do |spec|
7
- spec.name = 'trk_datatables'
8
- spec.version = TrkDatatables::VERSION
9
- spec.authors = ['Dusan Orlovic']
10
- spec.email = ['duleorlovic@gmail.com']
6
+ spec.name = "trk_datatables"
7
+ spec.version = TrkDatatables::VERSION
8
+ spec.authors = ["Dusan Orlovic"]
9
+ spec.email = ["duleorlovic@gmail.com"]
11
10
 
12
- spec.summary = 'Gem that simplify using datatables with Ruby on Rails and Sinatra.'
13
- spec.description = 'Html render first page, sort and filter...'
14
- spec.homepage = 'https://github.com/trkin/trk_datatables'
15
- spec.license = 'MIT'
11
+ spec.summary = "Gem that simplify using datatables with Ruby on Rails and Sinatra."
12
+ spec.description = "Html render first page, sort and filter..."
13
+ spec.homepage = "https://github.com/trkin/trk_datatables"
14
+ spec.license = "MIT"
16
15
 
17
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
17
  # to allow pushing to a single host or delete this section to allow pushing to any host.
19
18
  if spec.respond_to?(:metadata)
20
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
20
 
22
- spec.metadata['homepage_uri'] = spec.homepage
23
- spec.metadata['source_code_uri'] = 'https://github.com/trkin/trk_datatables'
24
- spec.metadata['changelog_uri'] = 'https://github.com/trkin/trk_datatables/blob/master/CHANGELOG.md'
25
- spec.metadata['yard.run'] = 'yri' # use "yard" to build full HTML docs.
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/trkin/trk_datatables"
23
+ spec.metadata["changelog_uri"] = "https://github.com/trkin/trk_datatables/blob/master/CHANGELOG.md"
24
+ spec.metadata["yard.run"] = "yri" # use "yard" to build full HTML docs.
26
25
  else
27
- raise 'RubyGems 2.0 or newer is required to protect against ' \
28
- 'public gem pushes.'
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
29
28
  end
30
29
 
31
30
  # Specify which files should be added to the gem when it is released.
@@ -33,22 +32,23 @@ Gem::Specification.new do |spec|
33
32
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
34
33
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
35
34
  end
36
- spec.bindir = 'exe'
37
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
- spec.require_paths = ['lib']
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
39
38
 
40
39
  # for HashWithIndifferentAccess
41
- spec.add_dependency 'activesupport'
40
+ spec.add_dependency "activesupport"
42
41
 
43
- spec.add_development_dependency 'activerecord', '~> 6.0'
44
- spec.add_development_dependency 'bundler', '~> 2.0'
45
- spec.add_development_dependency 'byebug'
46
- spec.add_development_dependency 'database_cleaner'
47
- spec.add_development_dependency 'minitest', '~> 5.0'
48
- spec.add_development_dependency 'minitest-color'
49
- spec.add_development_dependency 'timecop'
50
- spec.add_development_dependency 'pg'
51
- spec.add_development_dependency 'rake', '~> 10.0'
52
- spec.add_development_dependency 'sqlite3'
42
+ spec.add_development_dependency "activerecord", ">= 5.0"
43
+ spec.add_development_dependency "bundler", "~> 2.0"
44
+ spec.add_development_dependency "byebug"
45
+ spec.add_development_dependency "database_cleaner"
46
+ spec.add_development_dependency "minitest", "~> 5.0"
47
+ spec.add_development_dependency "minitest-color"
48
+ spec.add_development_dependency "pg"
49
+ spec.add_development_dependency "rake", ">= 10.0"
50
+ spec.add_development_dependency "sqlite3", ">= 1.4"
51
+ spec.add_development_dependency "timecop"
52
+ spec.add_development_dependency "standard"
53
+ spec.add_development_dependency "appraisal"
53
54
  end
54
- # rubocop:enable Metrics/BlockLength