yiffspace 0.0.6 → 0.0.8
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 +4 -4
- data/lib/yiffspace/auth/engine.rb +1 -1
- data/lib/yiffspace/concerns/user_resolvable_methods.rb +2 -1
- data/lib/yiffspace/configuration.rb +15 -14
- data/lib/yiffspace/core_ext/all.rb +1 -1
- data/lib/yiffspace/utils/user_attribute.rb +5 -4
- data/lib/yiffspace/version.rb +1 -1
- data/lib/yiffspace.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2497994ce627a29453ccde56515d0db05ab0360ceda865487dadc11da38d13ca
|
|
4
|
+
data.tar.gz: fc5df35b9e055ed16c16c67a0c8666e2ffa13121e2bf7898444dde3f6fa3df82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a723d8c6a52acc3d196329c7cc081c8bc3a93df721154870bb2f61bd41187cfa80dd3ea1463b74479a9a618284c4ce9579884ab6d64e2fce41d52750292e21b8
|
|
7
|
+
data.tar.gz: 5434320247ab2f5c5df8e2cee799c670f2b3cd533358f23b68b5676d493da193a8c712a2d2f4979714f39f880f2d7aee9f6d0c13b47b5c1681c1a96236b3e9f2
|
|
@@ -38,7 +38,7 @@ module YiffSpace
|
|
|
38
38
|
subclass.engine_name("yiffspace_auth_#{name}")
|
|
39
39
|
# Inherit isolation settings that aren't copied from the parent class
|
|
40
40
|
subclass.instance_variable_set(:@isolated, true)
|
|
41
|
-
subclass.routes.default_scope = { module: "
|
|
41
|
+
subclass.routes.default_scope = { module: "yiff_space/auth" }
|
|
42
42
|
subclass.routes.draw do
|
|
43
43
|
constraints(SetClientName.new(name)) do
|
|
44
44
|
get(:cb, controller: :root)
|
|
@@ -4,7 +4,8 @@ module YiffSpace
|
|
|
4
4
|
module Concerns
|
|
5
5
|
module UserResolvableMethods
|
|
6
6
|
def resolvable(ip_addr = nil)
|
|
7
|
-
|
|
7
|
+
attr = YiffSpace.config.last_ip_addr_attribute
|
|
8
|
+
UserResolvable.new(self, ip_addr || (attr && respond_to?(attr) ? send(attr) : nil) || YiffSpace.config.default_ip_address)
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def resolve
|
|
@@ -28,6 +28,12 @@ module YiffSpace
|
|
|
28
28
|
# The default IP address assigned to Utils::Current when none is present.
|
|
29
29
|
attr_accessor(:default_ip_address)
|
|
30
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
|
+
|
|
31
37
|
# Override the proc used to fetch the anonymous user. Must respond to #call.
|
|
32
38
|
# Default: -> { (user_class || ::User).anonymous }
|
|
33
39
|
attr_writer(:anonymous_user_getter)
|
|
@@ -36,21 +42,16 @@ module YiffSpace
|
|
|
36
42
|
# Default: -> { (user_class || ::User).system }
|
|
37
43
|
attr_writer(:system_user_getter)
|
|
38
44
|
|
|
39
|
-
# The anonymous user's name, can be a proc
|
|
40
|
-
attr_reader(:anonymous_user_name)
|
|
41
|
-
|
|
42
|
-
# The `last_ip_addr` attribute of the User model, used by the UserResolvableMethods concern
|
|
43
|
-
attr_accessor(:last_ip_addr_attribute)
|
|
44
|
-
|
|
45
45
|
def initialize
|
|
46
|
-
@max_multi_count
|
|
47
|
-
@redis_url
|
|
48
|
-
@user_class
|
|
49
|
-
@user_like_class
|
|
50
|
-
@user_resolvable_class
|
|
51
|
-
@current_class
|
|
52
|
-
@default_ip_address
|
|
53
|
-
@
|
|
46
|
+
@max_multi_count = -> { 100 }
|
|
47
|
+
@redis_url = -> {}
|
|
48
|
+
@user_class = nil
|
|
49
|
+
@user_like_class = nil
|
|
50
|
+
@user_resolvable_class = nil
|
|
51
|
+
@current_class = nil
|
|
52
|
+
@default_ip_address = "127.0.0.1"
|
|
53
|
+
@last_ip_addr_attribute = :last_ip_addr
|
|
54
|
+
@anonymous_user_name = -> { "Anonymous" }
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
def user_class
|
|
@@ -10,7 +10,8 @@ module YiffSpace
|
|
|
10
10
|
class CloneError < StandardError; end
|
|
11
11
|
attr_reader(:klass, :attribute, :db, :ip, :optional, :clones, :overwrite, :aliases, :ignore_nil, :ar_options)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
# noinspection RubyUnusedLocalVariable
|
|
14
|
+
def initialize(klass, attribute, db:, ip: !db, optional: !db, clones: [], clone: [], overwrite: false, aliases: [], alias: [], ignore_nil: false, **ar_options)
|
|
14
15
|
UserAttribute.class_setup(klass)
|
|
15
16
|
@klass = klass
|
|
16
17
|
@attribute = attribute.to_sym
|
|
@@ -18,9 +19,9 @@ module YiffSpace
|
|
|
18
19
|
# noinspection RubySimplifyBooleanInspection
|
|
19
20
|
@ip = ip == true ? :"#{attribute}_ip_addr" : ip
|
|
20
21
|
@optional = optional
|
|
21
|
-
@clones = Array(clones).map(&:to_sym)
|
|
22
|
+
@clones = Array(clones.presence || clone).map(&:to_sym)
|
|
22
23
|
@overwrite = overwrite
|
|
23
|
-
@aliases = Array(aliases).map(&:to_sym)
|
|
24
|
+
@aliases = Array(aliases.presence || binding.local_variable_get(:alias)).map(&:to_sym)
|
|
24
25
|
@ignore_nil = ignore_nil
|
|
25
26
|
@ar_options = ar_options
|
|
26
27
|
if ar_options.any? && !db # rubocop:disable Style/IfUnlessModifier
|
|
@@ -191,7 +192,7 @@ module YiffSpace
|
|
|
191
192
|
klass.instance_exec do
|
|
192
193
|
scope("for_#{ua.attribute}", ->(value) { where(ua.db && ua.ar_options.key?(:foreign_key) ? ua.ar_options[:foreign_key] : "#{ua.attribute}_id" => u2id(value)) }) unless respond_to?("for_#{ua.attribute}")
|
|
193
194
|
scope("for_#{ua.attribute}_id", ->(value) { where(ua.db && ua.ar_options.key?(:foreign_key) ? ua.ar_options[:foreign_key] : "#{ua.attribute}_id" => value) }) unless respond_to?("for_#{ua.attribute}_id")
|
|
194
|
-
scope("for_#{ua.attribute}_name", ->(value) { where(ua.db && ua.ar_options.key?(:foreign_key) ? ua.ar_options[:foreign_key] : "#{ua.attribute}_id" =>
|
|
195
|
+
scope("for_#{ua.attribute}_name", ->(value) { where(ua.db && ua.ar_options.key?(:foreign_key) ? ua.ar_options[:foreign_key] : "#{ua.attribute}_id" => YiffSpace.config.user_class.name_to_id(value)) }) unless respond_to?("for_#{ua.attribute}_name")
|
|
195
196
|
end
|
|
196
197
|
|
|
197
198
|
aliases.each do |alias_attr|
|
data/lib/yiffspace/version.rb
CHANGED
data/lib/yiffspace.rb
CHANGED
|
@@ -21,4 +21,11 @@ loader.inflector.inflect({ "postgresql" => "PostgreSQL", "yiffspace" => "YiffSpa
|
|
|
21
21
|
loader.ignore("#{__dir__}/yiffspace/core_ext")
|
|
22
22
|
loader.ignore("#{__dir__}/yiffspace/include")
|
|
23
23
|
loader.ignore("#{__dir__}/yiffspace/railtie.rb")
|
|
24
|
+
loader.ignore("#{__dir__}/yiffspace/auth/engine.rb")
|
|
24
25
|
loader.setup
|
|
26
|
+
|
|
27
|
+
# Require the auth engine eagerly so it registers with Rails before the host app's
|
|
28
|
+
# active_support.initialize_per_engine_zeitwerk_loaders initializer runs. Without this,
|
|
29
|
+
# the engine is only loaded during route drawing (after Zeitwerk setup) and its
|
|
30
|
+
# app/controllers path is never added to the app's autoload roots.
|
|
31
|
+
require_relative("yiffspace/auth/engine") if defined?(Rails)
|
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.0.
|
|
4
|
+
version: 0.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Donovan_DMC
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-06-
|
|
10
|
+
date: 2026-06-12 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: abbrev
|