yiffspace 0.1.5 → 0.1.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 130a3c2464b516817b5edaccef159b8068125a6a708f2ae6439e9bbedad7551b
4
- data.tar.gz: ca6f878af263b8bb7da0af721c5199b90aae89354d23c288e0d0855776f7dcf4
3
+ metadata.gz: 005aad0fa1bb9ee0b93c116a8ff16ee6b9221393b7218ace6458a0a205edf851
4
+ data.tar.gz: 3184951a3460ebb9c4b3afc7174f2956789d7a1617b6b6bdf0a8c7567298ab71
5
5
  SHA512:
6
- metadata.gz: 3e8ce51323d7ce79a288a5c2670b6257d1f00439f70dea6b1f65509dd60f6751585713e90cddc7712d55772515410467f3c0c74d8c71ad1cbbf2a7f53dd9e99c
7
- data.tar.gz: e51f8637f0b795ffd8da9b0aa0d02d569d4f36a2e07bafa3510ceba0fed96f04888c2a77e57506042e6d6e242593c5944c601732942752483215514eed238e6e
6
+ metadata.gz: c3aedc62b4a752a0124e8a41ac8aa013ea5a54cc7f95d5876afda928bcad70e9b13b0744a42cde382dfb2a7d4af3f7d906493971c28f0813d9f24de7ef70fb23
7
+ data.tar.gz: 0063344df91e5a741fe752be20b1f591b51df35bbc16746a7eb51d155c16b77c8d39824a7a8f0dc7c2f852444c48fe802b84f00ac9a7ab6e34af08c0489b46bc
@@ -1,3 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative("cross_join_lateral")
4
+ require_relative("cross_unnest")
5
+ require_relative("left_join_lateral")
6
+ require_relative("left_unnest")
7
+ require_relative("unnest")
3
8
  require_relative("where_chain")
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("../arel/cross_join_lateral")
5
+ require_relative("../../extensions/active_record/cross_join_lateral")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::CrossJoinLateral)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("unnest")
5
+ require_relative("../../extensions/active_record/cross_unnest")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::CrossUnnest)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("../arel/left_join_lateral")
5
+ require_relative("../../extensions/active_record/left_join_lateral")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::LeftJoinLateral)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("unnest")
5
+ require_relative("../../extensions/active_record/left_unnest")
6
+
7
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::LeftUnnest)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("active_record/relation")
4
+ require_relative("cross_join_lateral")
5
+ require_relative("left_join_lateral")
6
+ require_relative("../../extensions/active_record/unnest")
7
+
8
+ ActiveRecord::Relation.include(YiffSpace::Extensions::ActiveRecord::Unnest)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module CrossJoinLateral
7
+ def cross_join_lateral(relation)
8
+ raise(ArgumentError, "The method .cross_join_lateral() must contain arguments.") if relation.nil?
9
+
10
+ relation = relation.arel if relation.respond_to?(:arel)
11
+ spawn.cross_join_lateral!(relation)
12
+ end
13
+
14
+ def cross_join_lateral!(relation) # :nodoc:
15
+ manager = klass.arel_table.cross_join_lateral(relation)
16
+
17
+ self.joins_values |= [manager.join_sources.first]
18
+ self
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module CrossUnnest
7
+ def cross_unnest(column, as: column.singularize)
8
+ raise(ArgumentError, "The method .cross_unnest() must contain arguments.") if column.nil?
9
+
10
+ spawn.unnest(column, as: as, type: :cross_join_lateral)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module LeftJoinLateral
7
+ def left_join_lateral(relation, on: nil)
8
+ raise(ArgumentError, "The method .left_join_lateral() must contain arguments.") if relation.nil?
9
+
10
+ relation = relation.arel if relation.respond_to?(:arel)
11
+ spawn.left_join_lateral!(relation, on: on)
12
+ end
13
+
14
+ def left_join_lateral!(relation, on: nil) # :nodoc:
15
+ manager = klass.arel_table.left_join_lateral(relation)
16
+ manager.on(on) if on
17
+
18
+ self.joins_values |= [manager.join_sources.first]
19
+ self
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module LeftUnnest
7
+ def left_unnest(column, as: column.singularize)
8
+ raise(ArgumentError, "The method .left_unnest() must contain arguments.") if column.nil?
9
+
10
+ spawn.unnest(column, as: as, type: :left_join_lateral)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YiffSpace
4
+ module Extensions
5
+ module ActiveRecord
6
+ module Unnest
7
+ def unnest(column, as: column.singularize, type: :left_join_lateral)
8
+ raise(ArgumentError, "The method .unnest() must contain arguments.") if column.nil?
9
+
10
+ spawn.unnest!(column, as, type)
11
+ end
12
+
13
+ def unnest!(column, name, type) # :nodoc:
14
+ function = ::Arel::Nodes::NamedFunction.new("unnest", [klass.arel_table[column]]).as(name)
15
+ spawn.send("#{type}!", function, **({ on: ::Arel.sql("TRUE") } if type == :left_join_lateral))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -79,6 +79,29 @@ module YiffSpace
79
79
  end
80
80
  end
81
81
 
82
+ # Represents a custom row in the table body.
83
+ class Row
84
+ attr_reader(:block, :row_attributes)
85
+
86
+ def initialize(row_attributes = {}, &block)
87
+ @row_attributes = row_attributes
88
+ @block = block
89
+ end
90
+
91
+ def custom?
92
+ true
93
+ end
94
+
95
+ def value(index)
96
+ view = block.binding.receiver
97
+ if view.respond_to?(:capture)
98
+ view.capture { block.call(index, self) }
99
+ else
100
+ block.call(index, self)
101
+ end
102
+ end
103
+ end
104
+
82
105
  attr_reader(:columns, :table_attributes, :row_attributes, :items)
83
106
 
84
107
  # Build a table for an array of objects, one object per row.
@@ -122,11 +145,17 @@ module YiffSpace
122
145
  @columns << Column.new(*, **options, &)
123
146
  end
124
147
 
148
+ def row(row_attributes = {}, &)
149
+ @items = @items.to_a unless @items.is_a?(Array)
150
+ @items << Row.new(row_attributes, &)
151
+ end
152
+
125
153
  # Return the HTML attributes for each <tr> tag.
126
154
  # @param item [ApplicationRecord] the item for this row
127
155
  # @param _row [Integer] the row number (unused)
128
156
  # @return [Hash] the <tr> attributes
129
157
  def all_row_attributes(item, _row)
158
+ return item.row_attributes if item.is_a?(Row)
130
159
  return {} unless item.is_a?(YiffSpace.config.application_record_class)
131
160
 
132
161
  {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YiffSpace
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yiffspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan_DMC
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-08-19 00:00:00.000000000 Z
10
+ date: 2026-08-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: abbrev
@@ -43,14 +43,14 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '7.1'
46
+ version: '8.1'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '7.1'
53
+ version: '8.1'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: request_store
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +114,11 @@ files:
114
114
  - lib/yiffspace/configuration.rb
115
115
  - lib/yiffspace/configuration/images.rb
116
116
  - lib/yiffspace/core_ext/active_record/all.rb
117
+ - lib/yiffspace/core_ext/active_record/cross_join_lateral.rb
118
+ - lib/yiffspace/core_ext/active_record/cross_unnest.rb
119
+ - lib/yiffspace/core_ext/active_record/left_join_lateral.rb
120
+ - lib/yiffspace/core_ext/active_record/left_unnest.rb
121
+ - lib/yiffspace/core_ext/active_record/unnest.rb
117
122
  - lib/yiffspace/core_ext/active_record/where_chain.rb
118
123
  - lib/yiffspace/core_ext/all.rb
119
124
  - lib/yiffspace/core_ext/arel/all.rb
@@ -129,6 +134,11 @@ files:
129
134
  - lib/yiffspace/core_ext/string/all.rb
130
135
  - lib/yiffspace/core_ext/string/sql.rb
131
136
  - lib/yiffspace/engine.rb
137
+ - lib/yiffspace/extensions/active_record/cross_join_lateral.rb
138
+ - lib/yiffspace/extensions/active_record/cross_unnest.rb
139
+ - lib/yiffspace/extensions/active_record/left_join_lateral.rb
140
+ - lib/yiffspace/extensions/active_record/left_unnest.rb
141
+ - lib/yiffspace/extensions/active_record/unnest.rb
132
142
  - lib/yiffspace/extensions/active_record/where_chain.rb
133
143
  - lib/yiffspace/extensions/arel/nodes/cross_join_lateral.rb
134
144
  - lib/yiffspace/extensions/arel/nodes/left_join_lateral.rb