yiffspace 0.1.7 → 0.2.0

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.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -10
  3. data/README.md +18 -1
  4. data/Rakefile +6 -7
  5. data/lib/yiffspace/version.rb +1 -1
  6. data/lib/yiffspace.rb +26 -27
  7. metadata +104 -139
  8. data/app/assets/config/yiffspace_manifest.js +0 -1
  9. data/app/assets/stylesheets/yiffspace/application.css +0 -30
  10. data/app/controllers/yiff_space/application_controller.rb +0 -6
  11. data/app/helpers/yiff_space/application_helper.rb +0 -6
  12. data/app/models/yiff_space/application_record.rb +0 -7
  13. data/app/views/layouts/yiff_space/application.html.erb +0 -17
  14. data/app/views/yiff_space/error.html.erb +0 -3
  15. data/lib/yiffspace/concerns/active_record_extensions.rb +0 -45
  16. data/lib/yiffspace/concerns/api_methods.rb +0 -101
  17. data/lib/yiffspace/concerns/attribute_matchers.rb +0 -100
  18. data/lib/yiffspace/concerns/attribute_methods.rb +0 -39
  19. data/lib/yiffspace/concerns/concurrency_methods.rb +0 -20
  20. data/lib/yiffspace/concerns/conditional_includes.rb +0 -43
  21. data/lib/yiffspace/concerns/current_methods.rb +0 -60
  22. data/lib/yiffspace/concerns/has_bit_flags.rb +0 -59
  23. data/lib/yiffspace/concerns/user_class_methods.rb +0 -32
  24. data/lib/yiffspace/concerns/user_methods.rb +0 -77
  25. data/lib/yiffspace/concerns/user_name_methods.rb +0 -53
  26. data/lib/yiffspace/concerns/user_resolvable_methods.rb +0 -38
  27. data/lib/yiffspace/config_builder.rb +0 -192
  28. data/lib/yiffspace/configuration/images.rb +0 -22
  29. data/lib/yiffspace/configuration.rb +0 -116
  30. data/lib/yiffspace/core_ext/active_record/all.rb +0 -8
  31. data/lib/yiffspace/core_ext/active_record/cross_join_lateral.rb +0 -7
  32. data/lib/yiffspace/core_ext/active_record/cross_unnest.rb +0 -7
  33. data/lib/yiffspace/core_ext/active_record/left_join_lateral.rb +0 -7
  34. data/lib/yiffspace/core_ext/active_record/left_unnest.rb +0 -7
  35. data/lib/yiffspace/core_ext/active_record/unnest.rb +0 -8
  36. data/lib/yiffspace/core_ext/active_record/where_chain.rb +0 -6
  37. data/lib/yiffspace/core_ext/all.rb +0 -8
  38. data/lib/yiffspace/core_ext/arel/all.rb +0 -4
  39. data/lib/yiffspace/core_ext/arel/cross_join_lateral.rb +0 -21
  40. data/lib/yiffspace/core_ext/arel/left_join_lateral.rb +0 -21
  41. data/lib/yiffspace/core_ext/enumerable/all.rb +0 -3
  42. data/lib/yiffspace/core_ext/enumerable/parallel.rb +0 -7
  43. data/lib/yiffspace/core_ext/hash/all.rb +0 -3
  44. data/lib/yiffspace/core_ext/hash/to_open_hash.rb +0 -7
  45. data/lib/yiffspace/core_ext/object/all.rb +0 -4
  46. data/lib/yiffspace/core_ext/object/to_b.rb +0 -7
  47. data/lib/yiffspace/core_ext/object/truthy_falsy.rb +0 -7
  48. data/lib/yiffspace/core_ext/string/all.rb +0 -3
  49. data/lib/yiffspace/core_ext/string/sql.rb +0 -7
  50. data/lib/yiffspace/engine.rb +0 -23
  51. data/lib/yiffspace/extensions/active_record/cross_join_lateral.rb +0 -23
  52. data/lib/yiffspace/extensions/active_record/cross_unnest.rb +0 -15
  53. data/lib/yiffspace/extensions/active_record/left_join_lateral.rb +0 -24
  54. data/lib/yiffspace/extensions/active_record/left_unnest.rb +0 -15
  55. data/lib/yiffspace/extensions/active_record/unnest.rb +0 -20
  56. data/lib/yiffspace/extensions/active_record/where_chain.rb +0 -107
  57. data/lib/yiffspace/extensions/arel/nodes/cross_join_lateral.rb +0 -17
  58. data/lib/yiffspace/extensions/arel/nodes/left_join_lateral.rb +0 -17
  59. data/lib/yiffspace/extensions/arel/table/cross_join_lateral.rb +0 -15
  60. data/lib/yiffspace/extensions/arel/table/left_join_lateral.rb +0 -15
  61. data/lib/yiffspace/extensions/arel/visitors/postgresql/cross_join_lateral.rb +0 -19
  62. data/lib/yiffspace/extensions/arel/visitors/postgresql/left_join_lateral.rb +0 -23
  63. data/lib/yiffspace/extensions/enumerable/parallel.rb +0 -39
  64. data/lib/yiffspace/extensions/hash/to_open_hash.rb +0 -15
  65. data/lib/yiffspace/extensions/object/to_b.rb +0 -22
  66. data/lib/yiffspace/extensions/object/truthy_falsy.rb +0 -35
  67. data/lib/yiffspace/extensions/string/sql.rb +0 -21
  68. data/lib/yiffspace/images/avatar/base.rb +0 -41
  69. data/lib/yiffspace/images/avatar/discord.rb +0 -37
  70. data/lib/yiffspace/images/avatar/gravatar.rb +0 -21
  71. data/lib/yiffspace/images/avatar.rb +0 -33
  72. data/lib/yiffspace/images/banner/base.rb +0 -41
  73. data/lib/yiffspace/images/banner/discord.rb +0 -37
  74. data/lib/yiffspace/images/banner.rb +0 -33
  75. data/lib/yiffspace/images.rb +0 -6
  76. data/lib/yiffspace/include/active_record_extensions.rb +0 -5
  77. data/lib/yiffspace/include/all.rb +0 -31
  78. data/lib/yiffspace/include/api_methods.rb +0 -5
  79. data/lib/yiffspace/include/attribute_matchers.rb +0 -5
  80. data/lib/yiffspace/include/attribute_methods.rb +0 -5
  81. data/lib/yiffspace/include/cache.rb +0 -5
  82. data/lib/yiffspace/include/concurrency_methods.rb +0 -5
  83. data/lib/yiffspace/include/conditional_includes.rb +0 -5
  84. data/lib/yiffspace/include/current.rb +0 -5
  85. data/lib/yiffspace/include/current_methods.rb +0 -5
  86. data/lib/yiffspace/include/duration_parser.rb +0 -5
  87. data/lib/yiffspace/include/has_bit_flags.rb +0 -5
  88. data/lib/yiffspace/include/helpers.rb +0 -5
  89. data/lib/yiffspace/include/open_hash.rb +0 -5
  90. data/lib/yiffspace/include/parameter_builder.rb +0 -5
  91. data/lib/yiffspace/include/parse_value.rb +0 -5
  92. data/lib/yiffspace/include/query_builder.rb +0 -5
  93. data/lib/yiffspace/include/query_dsl.rb +0 -5
  94. data/lib/yiffspace/include/query_helper.rb +0 -5
  95. data/lib/yiffspace/include/routes.rb +0 -5
  96. data/lib/yiffspace/include/table_builder.rb +0 -5
  97. data/lib/yiffspace/include/trace_logger.rb +0 -5
  98. data/lib/yiffspace/include/u2id.rb +0 -5
  99. data/lib/yiffspace/include/user_attribute.rb +0 -5
  100. data/lib/yiffspace/include/user_class_methods.rb +0 -5
  101. data/lib/yiffspace/include/user_like.rb +0 -5
  102. data/lib/yiffspace/include/user_methods.rb +0 -5
  103. data/lib/yiffspace/include/user_name_methods.rb +0 -5
  104. data/lib/yiffspace/include/user_resolvable.rb +0 -5
  105. data/lib/yiffspace/include/user_resolvable_methods.rb +0 -5
  106. data/lib/yiffspace/search/query_builder.rb +0 -83
  107. data/lib/yiffspace/search/query_dsl.rb +0 -119
  108. data/lib/yiffspace/search/query_helper.rb +0 -49
  109. data/lib/yiffspace/serializers/avatar_serializer.rb +0 -21
  110. data/lib/yiffspace/serializers/banner_serializer.rb +0 -21
  111. data/lib/yiffspace/serializers/user_resolvable_serializer.rb +0 -21
  112. data/lib/yiffspace/utils/cache.rb +0 -40
  113. data/lib/yiffspace/utils/current.rb +0 -43
  114. data/lib/yiffspace/utils/duration_parser.rb +0 -24
  115. data/lib/yiffspace/utils/helpers.rb +0 -25
  116. data/lib/yiffspace/utils/open_hash.rb +0 -63
  117. data/lib/yiffspace/utils/parameter_builder.rb +0 -121
  118. data/lib/yiffspace/utils/parse_value.rb +0 -174
  119. data/lib/yiffspace/utils/routes.rb +0 -28
  120. data/lib/yiffspace/utils/set_env_constraint.rb +0 -18
  121. data/lib/yiffspace/utils/table_builder.rb +0 -169
  122. data/lib/yiffspace/utils/trace_logger.rb +0 -91
  123. data/lib/yiffspace/utils/user_attribute.rb +0 -272
  124. data/lib/yiffspace/utils/user_like.rb +0 -8
  125. data/lib/yiffspace/utils/user_resolvable.rb +0 -61
  126. data/lib/yiffspace/utils/user_to_id.rb +0 -11
  127. data/lib/yiffspace/utils.rb +0 -6
@@ -1,192 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require("active_support/hash_with_indifferent_access")
4
-
5
- # This is intended to only be used externally, it is NOT reusable, do not use it within this project, or attempt to use it multiple times!!
6
- module YiffSpace
7
- class ConfigBuilder
8
- include(Singleton)
9
-
10
- cattr_accessor(:list, default: [])
11
- cattr_accessor(:env_set, default: ActiveSupport::HashWithIndifferentAccess.new)
12
- cattr_accessor(:unset, default: [])
13
- cattr_accessor(:required, default: [])
14
- cattr_accessor(:reviver_map, default: ActiveSupport::HashWithIndifferentAccess.new)
15
- cattr_accessor(:subconfigs, default: ActiveSupport::HashWithIndifferentAccess.new { |h, k| h[k] = {} })
16
- cattr_accessor(:env_name, default: "CONFIG")
17
-
18
- def self.config(name, type = :string, env: true, required: false, blank: false, &block)
19
- name = name.to_sym
20
- remove_config(name) if list.include?(name)
21
- list << name
22
- self.required << name if required
23
- if block.nil?
24
- unset << name
25
- block = -> { raise(NotImplementedError, "Config option #{name} is not set") }
26
- end
27
- define_method(name) do |*args|
28
- env_or_value(name, args, blank: blank, &block)
29
- end
30
- if type == :boolean
31
- define_method("#{name}?") do |*args|
32
- public_send(name, *args)
33
- end
34
- end
35
- reviver(name, type) if type && type != :string
36
- env_set[name] = env
37
- end
38
-
39
- def self.remove_config(name, reviver: false)
40
- name = name.to_sym
41
- list.delete(name)
42
- required.delete(name)
43
- unset.delete(name)
44
- reviver_map.delete(name) if reviver
45
- env_set.delete(name)
46
- remove_method(name)
47
- remove_method("#{name}?") if method_defined?("#{name}?")
48
- end
49
-
50
- def env_or_value(name, args, blank: false, &)
51
- value = env(name)
52
- value = nil if !value.nil? && value.blank? && !blank
53
- if value.nil?
54
- instance_exec(*args, &)
55
- else
56
- reviver = reviver_map.fetch(name, proc(&:itself))
57
- instance_exec(value, *args, &reviver)
58
- end
59
- end
60
-
61
- def env(name)
62
- ENV.fetch("#{self.class.env_name}_#{name.to_s.upcase}", nil)
63
- end
64
-
65
- def self.reviver(name, type = nil, &block)
66
- name = name.to_sym
67
- if block
68
- reviver_map[name] = block
69
- return
70
- end
71
- method = case type
72
- when :boolean
73
- ->(v) { !v.match?(/\A(false|f|no|n|off|0)\z/i) }
74
- when :integer, :number
75
- ->(v) { v.to_i }
76
- when :symbol
77
- ->(v) { v.to_sym }
78
- when :array
79
- ->(v) { v.split(/\s*,\s*/) }
80
- else
81
- raise(ArgumentError, "not sure how to revive #{type} for #{method}")
82
- end
83
- reviver_map[name] = method
84
- end
85
-
86
- def self.subconfig(prefix, parent: [], &block)
87
- raise(ArgumentError, "block required") unless block
88
-
89
- prefix = prefix.to_sym
90
- path = parent + [prefix]
91
-
92
- node = subconfigs
93
- path.each do |p|
94
- node[p] ||= {}
95
- node = node[p]
96
- end
97
-
98
- define_method(prefix) { SubconfigProxy.new(self, path) } unless method_defined?(prefix)
99
-
100
- collector = Module.new do
101
- def self.collected
102
- @collected ||= []
103
- end
104
-
105
- def self.config(name, type = :string, env: true, required: false, blank: false, &block)
106
- collected << [:config, name, type, env, required, blank, block]
107
- end
108
-
109
- def self.reviver(name, type = nil, &block)
110
- collected << [:reviver, name, type, block]
111
- end
112
-
113
- def self.subconfig(name, &block)
114
- collected << [:subconfig, name, block]
115
- end
116
- end
117
-
118
- collector.module_eval(&block)
119
-
120
- collector.collected.each do |kind, name, *args|
121
- case kind
122
- when :config
123
- full = (path + [name]).join("_").to_sym
124
- config(full, args[0], env: args[1], required: args[2], blank: args[3], &args[4])
125
- when :reviver
126
- full = (path + [name]).join("_").to_sym
127
- reviver(full, args[0], &args[1])
128
- when :subconfig
129
- subconfig(name, parent: path, &args[0])
130
- end
131
- end
132
- end
133
-
134
- def self.ensure_required_set!
135
- unset = []
136
- required.each do |name|
137
- value = begin
138
- instance.public_send(name)
139
- rescue StandardError
140
- nil
141
- end
142
- unset << name if value.blank?
143
- end
144
-
145
- raise("Missing required configuration options: #{unset.join(', ')}") if unset.any?
146
- end
147
-
148
- def present?(*names)
149
- names.flatten.all? { |name| public_send(name).present? }
150
- end
151
-
152
- class SubconfigProxy
153
- def initialize(owner, path)
154
- @owner = owner
155
- @path = path
156
- end
157
-
158
- def method_missing(name, *, &)
159
- name = name.to_sym
160
- full_path = @path + [name]
161
-
162
- flat = full_path.join("_").to_sym
163
- return @owner.public_send(flat, *, &) if @owner.respond_to?(flat)
164
-
165
- return SubconfigProxy.new(@owner, full_path) if subconfig_path?(full_path)
166
-
167
- super
168
- end
169
-
170
- def respond_to_missing?(name, include_private = false)
171
- name = name.to_sym
172
- flat = (@path + [name]).join("_").to_sym
173
-
174
- @owner.respond_to?(flat, include_private) ||
175
- subconfig_path?(@path + [name]) ||
176
- super
177
- end
178
-
179
- private
180
-
181
- def subconfig_path?(path)
182
- node = ConfigBuilder.subconfigs
183
- path.each do |p|
184
- return false unless node.key?(p)
185
-
186
- node = node[p]
187
- end
188
- true
189
- end
190
- end
191
- end
192
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module YiffSpace
4
- class Configuration
5
- class Images
6
- attr_accessor(:server_url, :update_token, :default_avatar_type, :default_banner_type, :httparty_options)
7
-
8
- def initialize
9
- @server_url = "https://images.yiff.space"
10
- @default_avatar_type = :discord
11
- @default_banner_type = :discord
12
- @httparty_options = {
13
- timeout: 10,
14
- open_timeout: 5,
15
- headers: {
16
- "User-Agent" => "YiffSpaceRuby/#{YiffSpace::VERSION} (https://yiff.space)",
17
- },
18
- }
19
- end
20
- end
21
- end
22
- end
@@ -1,116 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module YiffSpace
4
- class Configuration
5
- # Maximum number of comma-separated values allowed in a multi-value query parameter.
6
- # Used by ParseValue.range and QueryBuilder.
7
- attr_reader(:max_multi_count)
8
-
9
- # Redis URL used by Utils::Cache for direct Redis connections.
10
- attr_reader(:redis_url)
11
-
12
- # The application's User model class. Used by Utils::Current, Search::QueryDSL, etc.
13
- # Falls back to ::User at call time when nil.
14
- attr_writer(:user_class)
15
-
16
- # The application's User model class. Used by Utils::UserResolvable
17
- # Falls back to ::UserLike at call time when nil.
18
- attr_writer(:user_like_class)
19
-
20
- # The application's UserResolvable class. Used by Utils::Current.
21
- # Falls back to ::UserResolvable at call time when nil.
22
- attr_writer(:user_resolvable_class)
23
-
24
- # The CurrentAttributes class used to access the current user in model concerns.
25
- # Defaults to YiffSpace::Utils::Current.
26
- attr_writer(:current_class)
27
-
28
- # The default IP address assigned to Utils::Current when none is present.
29
- attr_accessor(:default_ip_address)
30
-
31
- # The `last_ip_addr` attribute of the User model, used by the UserResolvableMethods concern
32
- attr_accessor(:last_ip_addr_attribute)
33
-
34
- # The anonymous user's name, can be a proc
35
- attr_reader(:anonymous_user_name)
36
-
37
- # Override the proc used to fetch the anonymous user. Must respond to #call.
38
- # Default: -> { (user_class || ::User).anonymous }
39
- attr_writer(:anonymous_user_getter)
40
-
41
- # Override the proc used to fetch the system user. Must respond to #call.
42
- # Default: -> { (user_class || ::User).system }
43
- attr_writer(:system_user_getter)
44
-
45
- # The application's ApplicationRecord class. Used by Concerns::ActiveRecordExtensions & Utils::TableBuilder.
46
- # Falls back to ::ApplicationRecord at call time when nil.
47
- attr_writer(:application_record_class)
48
-
49
- # The application's ApplicationController class. Used by Utils::Helpers & Utils::TableBuilder.
50
- # Falls back to ::ApplicationController at call time when nil.
51
- attr_writer(:application_controller_class)
52
-
53
- def initialize
54
- @max_multi_count = -> { 100 }
55
- @redis_url = -> {}
56
- @user_class = nil
57
- @user_like_class = nil
58
- @user_resolvable_class = nil
59
- @current_class = nil
60
- @default_ip_address = "127.0.0.1"
61
- @last_ip_addr_attribute = :last_ip_addr
62
- @anonymous_user_name = -> { "Anonymous" }
63
- end
64
-
65
- def user_class
66
- @user_class || ::User
67
- end
68
-
69
- def user_like_class
70
- @user_like_class || Utils::UserLike
71
- end
72
-
73
- def user_resolvable_class
74
- @user_resolvable_class || Utils::UserResolvable
75
- end
76
-
77
- # Returns the configured current class, defaulting to YiffSpace::Utils::Current.
78
- def current_class
79
- @current_class || Utils::Current
80
- end
81
-
82
- # Lazily built: calls user_class (or ::User) at invocation time, not config time.
83
- def anonymous_user_getter
84
- @anonymous_user_getter ||= -> { user_class.anonymous }
85
- end
86
-
87
- # Lazily built: calls user_class (or ::User) at invocation time, not config time.
88
- def system_user_getter
89
- @system_user_getter ||= -> { user_class.system }
90
- end
91
-
92
- def redis_url=(value)
93
- @redis_url = value.is_a?(Proc) ? value : -> { value }
94
- end
95
-
96
- def max_multi_count=(value)
97
- @max_multi_count = value.is_a?(Proc) ? value : -> { value }
98
- end
99
-
100
- def anonymous_user_name=(value)
101
- @anonymous_user_name = value.is_a?(Proc) ? value : -> { value }
102
- end
103
-
104
- def application_record_class
105
- @application_record_class || ::ApplicationRecord
106
- end
107
-
108
- def application_controller_class
109
- @application_controller_class || ::ApplicationController
110
- end
111
-
112
- def images
113
- @images ||= Images.new
114
- end
115
- end
116
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
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")
8
- require_relative("where_chain")
@@ -1,7 +0,0 @@
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)
@@ -1,7 +0,0 @@
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)
@@ -1,7 +0,0 @@
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)
@@ -1,7 +0,0 @@
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)
@@ -1,8 +0,0 @@
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)
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require("active_record/relation")
4
- require_relative("../../extensions/active_record/where_chain")
5
-
6
- ActiveRecord::QueryMethods::WhereChain.include(YiffSpace::Extensions::ActiveRecord::WhereChain)
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("active_record/all")
4
- require_relative("arel/all")
5
- require_relative("enumerable/all")
6
- require_relative("hash/all")
7
- require_relative("object/all")
8
- require_relative("string/all")
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("cross_join_lateral")
4
- require_relative("left_join_lateral")
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("../../extensions/arel/nodes/cross_join_lateral")
4
- require_relative("../../extensions/arel/visitors/postgresql/cross_join_lateral")
5
- require_relative("../../extensions/arel/table/cross_join_lateral")
6
-
7
- module Arel
8
- module Nodes
9
- CrossJoinLateral = YiffSpace::Extensions::Arel::Nodes::CrossJoinLateral
10
- end
11
-
12
- module Visitors
13
- class PostgreSQL
14
- include(YiffSpace::Extensions::Arel::Visitors::PostgreSQL::CrossJoinLateral)
15
- end
16
- end
17
-
18
- class Table
19
- include(YiffSpace::Extensions::Arel::Table::CrossJoinLateral)
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("../../extensions/arel/nodes/left_join_lateral")
4
- require_relative("../../extensions/arel/visitors/postgresql/left_join_lateral")
5
- require_relative("../../extensions/arel/table/left_join_lateral")
6
-
7
- module Arel
8
- module Nodes
9
- LeftJoinLateral = YiffSpace::Extensions::Arel::Nodes::LeftJoinLateral
10
- end
11
-
12
- module Visitors
13
- class PostgreSQL
14
- include(YiffSpace::Extensions::Arel::Visitors::PostgreSQL::LeftJoinLateral)
15
- end
16
- end
17
-
18
- class Table
19
- include(YiffSpace::Extensions::Arel::Table::LeftJoinLateral)
20
- end
21
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("parallel")
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("../../extensions/enumerable/parallel")
4
-
5
- module Enumerable
6
- include(YiffSpace::Extensions::Enumerable::Parallel)
7
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("to_open_hash")
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("../../extensions/hash/to_open_hash")
4
-
5
- class Hash
6
- include(YiffSpace::Extensions::Hash::ToOpenHash)
7
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("to_b")
4
- require_relative("truthy_falsy")
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("../../extensions/object/to_b")
4
-
5
- class Object
6
- include(YiffSpace::Extensions::Object::ToB)
7
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("../../extensions/object/truthy_falsy")
4
-
5
- class Object
6
- include(YiffSpace::Extensions::Object::TruthyFalsy)
7
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("sql")
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative("../../extensions/string/sql")
4
-
5
- class String
6
- include(YiffSpace::Extensions::String::Sql)
7
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require("rails")
4
-
5
- module YiffSpace
6
- class Engine < ::Rails::Engine
7
- config.root = File.expand_path("../..", __dir__)
8
-
9
- initializer("yiffspace.assets") do |app|
10
- app.config.assets.precompile += %w[yiffspace/application.css] if app.config.respond_to?(:assets)
11
- end
12
-
13
- initializer("yiffspace.serializers") do
14
- ActiveSupport.on_load(:active_job) do
15
- ActiveJob::Serializers.add_serializers(
16
- Serializers::AvatarSerializer,
17
- Serializers::BannerSerializer,
18
- Serializers::UserResolvableSerializer,
19
- )
20
- end
21
- end
22
- end
23
- end
@@ -1,23 +0,0 @@
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
@@ -1,15 +0,0 @@
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
@@ -1,24 +0,0 @@
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
@@ -1,15 +0,0 @@
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
@@ -1,20 +0,0 @@
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