datagrid 1.6.2 → 1.7.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
  SHA256:
3
- metadata.gz: 4accb02f36dc5af245b6dd84008c22293e9bc0f6105b7fdfebe9458b6a7fa1e1
4
- data.tar.gz: 4ca75ebff1804e8eaba5b0e41cae04e32f63c24211baffdc501a93870e1ba7e2
3
+ metadata.gz: cae619097e4bcae30de30bf2b5e9dc949f197146f3b17c01f5a2e4edb17e5ecc
4
+ data.tar.gz: 61751f34844c4127b7fc47bbacdbb2656d61aa015f574855de2a23bfc2dffe4a
5
5
  SHA512:
6
- metadata.gz: e8ab20bbbaec525f993c7e20a1ed5bd0105f6d2fc0c9ab098570401e610b7030a696c263959478b0cb4a39ecf921c81e5621bb76198cbc96060f433f23cbcaa5
7
- data.tar.gz: 9158b9d0f26ee862292a5fdc0d9b596ee2ac70e52006cb559af1bfc043a5d43419c476e1b5a796a42a19e7bc5efcfb9e2b4e37e0fdfa9a8286c795a505aad573
6
+ metadata.gz: 8bcea069b9bafc8b573226366a1abf194910d3fa5798711568b7106428d94ec915b141f23986094d8579ce8450328e1eb5b71932646c4224c0f1f7ac01f9718b
7
+ data.tar.gz: 7a40443171fe84d7b9f22daabdf2d1c182926fc69c9b47fde54e5a2271c394b8b5f7541a512e898c4e1472f93f4e94cf9cb90a7d47a9ad51113ee65efaf80610
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.7.0
2
+
3
+ * Depend on `railties` instead of `rails` to prevent loading of unnecessary frameworks
4
+ * Bugfix `File.exist?` usage for ruby 3.0 [#307](https://github.com/bogdan/datagrid/issues/307)
5
+ * Drop support of old Ruby versions (< 2.7)
6
+ * Drop support of old Rails versions (< 6.0)
7
+
8
+ ## 1.6.3
9
+
10
+ * Fix usage of options spread operator for Ruby 3.0 [#296](https://github.com/bogdan/datagrid/issues/296)
11
+
1
12
  ## 1.6.2
2
13
 
3
14
  * Add `input_options` and `label_options` to `filter` method [#294](https://github.com/bogdan/datagrid/issues/294)
data/Readme.markdown CHANGED
@@ -1,6 +1,6 @@
1
1
  # Datagrid
2
2
 
3
- [![Build Status](https://travis-ci.org/bogdan/datagrid.svg?branch=master)](https://travis-ci.org/bogdan/datagrid)
3
+ [![Build Status](https://github.com/bogdan/datagrid/workflows/CI/badge.svg?branch=master)](https://github.com/bogdan/datagrid/actions)
4
4
 
5
5
  [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid?ref=badge_shield)
6
6
 
@@ -23,10 +23,11 @@ Ruby library that helps you to build and represent table-like data with:
23
23
  [Create an issue](https://github.com/bogdan/datagrid/issues/new) if you want more.
24
24
 
25
25
 
26
- ### Dependencies
26
+ ### Documentation
27
27
 
28
- * Ruby >= 2.0
29
- * Rails >= 3.2
28
+ * [Readme](/Readme.markdown) - this read-me for basic information
29
+ * [Wiki](https://github.com/bogdan/datagrid/wiki) - general reference on how to use the gem
30
+ * [Rdoc](https://rubydoc.info/gems/datagrid) - API reference
30
31
 
31
32
  ### Live Demo
32
33
 
data/datagrid.gemspec CHANGED
@@ -1,14 +1,12 @@
1
1
  # frozen_string_literal: true
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "datagrid/version"
2
+
3
+ require_relative "lib/datagrid/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
6
  s.name = "datagrid"
8
7
  s.version = Datagrid::VERSION
9
8
  s.require_paths = ["lib"]
10
9
  s.authors = ["Bogdan Gusiev"]
11
- s.date = "2020-09-07"
12
10
  s.summary = "Ruby gem to create datagrids"
13
11
  s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
14
12
  s.email = "agresso@gmail.com"
@@ -23,19 +21,17 @@ Gem::Specification.new do |s|
23
21
  "datagrid.gemspec",
24
22
  ]
25
23
  s.files += `git ls-files | grep -E '^(app|lib|templates)'`.split("\n")
26
- s.homepage = "http://github.com/bogdan/datagrid"
24
+ s.homepage = "https://github.com/bogdan/datagrid"
27
25
  s.licenses = ["MIT"]
28
- s.required_ruby_version = Gem::Requirement.new(">= 2.0")
29
- s.rubygems_version = "3.0.8"
30
- url = 'https://github.com/bogdan/datagrid'
26
+ s.required_ruby_version = Gem::Requirement.new(">= 2.7")
31
27
  s.metadata = {
32
- "homepage_uri" => url,
33
- "bug_tracker_uri" => "#{url}/issues",
34
- "documentation_uri" => "#{url}/wiki",
35
- "changelog_uri" => "#{url}/blob/master/CHANGELOG.md",
36
- "source_code_uri" => url,
28
+ "homepage_uri" => s.homepage,
29
+ "bug_tracker_uri" => "#{s.homepage}/issues",
30
+ "documentation_uri" => "#{s.homepage}/wiki",
31
+ "changelog_uri" => "#{s.homepage}/blob/master/CHANGELOG.md",
32
+ "source_code_uri" => s.homepage,
37
33
  }
38
34
 
39
- s.add_dependency(%q<rails>, [">= 4.0"])
35
+ s.add_dependency "railties", ">= 6.0"
40
36
  end
41
37
 
@@ -1,10 +1,7 @@
1
-
2
1
  module Datagrid
3
-
4
2
  # Required to be ActiveModel compatible
5
- # @private
6
- module ActiveModel #:nodoc:
7
-
3
+ module ActiveModel
4
+ # @!visibility private
8
5
  def self.included(base)
9
6
  base.extend ClassMethods
10
7
  base.class_eval do
@@ -18,41 +15,40 @@ module Datagrid
18
15
  extend ::ActiveModel::AttributesAssignment
19
16
  rescue LoadError
20
17
  end
21
-
22
18
  end
23
- base.send :include, InstanceMethods
24
- end # self.included
19
+ end
25
20
 
26
21
  module ClassMethods
22
+ # @return [String] URL query parameter name of the grid class
27
23
  def param_name
28
24
  self.to_s.underscore.tr('/', '_')
29
25
  end
30
- end # ClassMethods
26
+ end
31
27
 
32
- module InstanceMethods
33
- def param_name
34
- self.class.param_name
35
- end
28
+ # @return [String] URL query parameter name of the grid class
29
+ def param_name
30
+ self.class.param_name
31
+ end
36
32
 
37
- def param_key
38
- param_name
39
- end
33
+ # @return [String] URL query parameter name of the grid class
34
+ def param_key
35
+ param_name
36
+ end
40
37
 
41
- def to_key
42
- [self.class.param_name]
43
- end
38
+ def to_key
39
+ [self.class.param_name]
40
+ end
44
41
 
45
- def persisted?
46
- false
47
- end
42
+ def persisted?
43
+ false
44
+ end
48
45
 
49
- def to_model
50
- self
51
- end
46
+ def to_model
47
+ self
48
+ end
52
49
 
53
- def to_param
54
- self.param_name
55
- end
56
- end # InstanceMethods
50
+ def to_param
51
+ self.param_name
52
+ end
57
53
  end
58
54
  end
@@ -21,45 +21,46 @@ module Datagrid
21
21
  # will always present in the grid table and won't be listed
22
22
  # in column names selection
23
23
  # Accepts same options as <tt>:enum</tt> filter
24
- #
25
- # Examples:
26
- #
27
- # column_names_filter(:header => "Choose columns")
28
- #
29
- def column_names_filter(options = {})
30
- filter(:column_names, :enum, {
31
- :select => :optional_columns_select,
32
- :multiple => true,
33
- :dummy => true
34
- }.merge(options || {}))
24
+ # @example
25
+ # column_names_filter(header: "Choose columns")
26
+ # @see Datagrid::Filters::ClassMethods#filter
27
+ def column_names_filter(**options)
28
+ filter(
29
+ :column_names, :enum,
30
+ select: :optional_columns_select,
31
+ multiple: true,
32
+ dummy: true,
33
+ **options,
34
+ )
35
35
  end
36
36
  end
37
37
 
38
- def columns(*args) #:nodoc:
39
- options = args.extract_options!
40
- column_names = selected_column_names(*args)
41
- column_names << options
42
- super(*column_names)
38
+ # @!visibility private
39
+ def columns(*args, **options)
40
+ super(*selected_column_names(*args), **options)
43
41
  end
44
42
 
45
- # Returns a list of enabled columns with <tt>:mandatory => true</tt> option
43
+ # Returns a list of enabled columns with <tt>mandatory: true</tt> option
46
44
  # If no mandatory columns specified than all of them considered mandatory
45
+ # @return [Array<Datagrid::Columns::Column>]
47
46
  def mandatory_columns
48
47
  available_columns.select {|c| c.mandatory? }
49
48
  end
50
49
 
51
50
  # Returns a list of enabled columns without <tt>:mandatory => true</tt> option
51
+ # If no mandatory columns specified than all of them considered mandatory but not optional
52
+ # @return [Array<Datagrid::Columns::Column>]
52
53
  def optional_columns
53
54
  available_columns - mandatory_columns
54
55
  end
55
56
 
56
57
  protected
57
58
 
58
- def optional_columns_select #:nodoc:
59
+ def optional_columns_select
59
60
  optional_columns.map {|c| [c.header, c.name] }
60
61
  end
61
62
 
62
- def selected_column_names(*args)
63
+ def selected_column_names(*args)
63
64
  if args.any?
64
65
  args.compact!
65
66
  args.map!(&:to_sym)
@@ -75,7 +76,7 @@ module Datagrid
75
76
 
76
77
  def columns_visibility_enabled?
77
78
  columns_array.any? do |column|
78
- column.options.key?(:mandatory)
79
+ column.mandatory_explicitly_set?
79
80
  end
80
81
  end
81
82
 
@@ -1,6 +1,8 @@
1
1
  class Datagrid::Columns::Column
2
2
 
3
- class ResponseFormat # :nodoc:
3
+ # Datagrid class holding an information of
4
+ # how a column should be rendered in data/console/csv format and HTML format
5
+ class ResponseFormat
4
6
 
5
7
  attr_accessor :data_block, :html_block
6
8
 
@@ -106,6 +108,10 @@ class Datagrid::Columns::Column
106
108
  !! options[:mandatory]
107
109
  end
108
110
 
111
+ def mandatory_explicitly_set?
112
+ options.key?(:mandatory)
113
+ end
114
+
109
115
  def enabled?(grid)
110
116
  ::Datagrid::Utils.process_availability(grid, options[:if], options[:unless])
111
117
  end