coactive 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +8 -2
- data/CHANGELOG.md +8 -0
- data/lib/coactive/coactants.rb +33 -0
- data/lib/coactive/coaction.rb +9 -0
- data/lib/coactive/coactions.rb +33 -0
- data/lib/coactive/coactor.rb +4 -4
- data/lib/coactive/loader.rb +21 -5
- data/lib/coactive/lookups/base.rb +1 -0
- data/lib/coactive/lookups/name.rb +2 -5
- data/lib/coactive/lookups/object.rb +3 -3
- data/lib/coactive/railtie.rb +2 -0
- data/lib/coactive/version.rb +1 -1
- metadata +6 -6
- data/lib/coactive/coactors/coactants.rb +0 -35
- data/lib/coactive/coactors/coaction.rb +0 -11
- data/lib/coactive/coactors/coactions.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15dae4695420734d0486669dd7f88d7eeceb8815932dc5f47d37cedf0dd4c61
|
4
|
+
data.tar.gz: cd7f7aae30957f69c76230b8cb97ca846ad4d4c99f6c02045f54b9c866d2ec68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eebff4ac3fdb067eb44a59ffc634e4fdda567663e6be2c30923828a311f29a52679ea2aaf3295e17412ee492ef3705c1ff200a0065f5bfee03bbf36a045dd007
|
7
|
+
data.tar.gz: e94206eda575c397edc5686fe012cf7ebd66074fa74b1a4215c733d7462b01099a9e2d537041749a039bcfe079bbf4ade6c71d4c2a249e65fa2849175ed94532
|
data/.github/workflows/ci.yml
CHANGED
@@ -8,7 +8,7 @@ jobs:
|
|
8
8
|
strategy:
|
9
9
|
fail-fast: false
|
10
10
|
matrix:
|
11
|
-
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1]
|
11
|
+
ruby: [2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, 3.2]
|
12
12
|
gemfile: ['rails50', 'rails51', 'rails52', 'rails60', 'rails61', 'rails70']
|
13
13
|
exclude:
|
14
14
|
- ruby: 2.3
|
@@ -39,6 +39,12 @@ jobs:
|
|
39
39
|
gemfile: rails51
|
40
40
|
- ruby: 3.1
|
41
41
|
gemfile: rails52
|
42
|
+
- ruby: 3.2
|
43
|
+
gemfile: rails50
|
44
|
+
- ruby: 3.2
|
45
|
+
gemfile: rails51
|
46
|
+
- ruby: 3.2
|
47
|
+
gemfile: rails52
|
42
48
|
|
43
49
|
name: ruby ${{ matrix.ruby }}, ${{ matrix.gemfile }}
|
44
50
|
|
@@ -46,7 +52,7 @@ jobs:
|
|
46
52
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
47
53
|
|
48
54
|
steps:
|
49
|
-
- uses: actions/checkout@
|
55
|
+
- uses: actions/checkout@v3
|
50
56
|
- uses: ruby/setup-ruby@v1
|
51
57
|
with:
|
52
58
|
ruby-version: ${{ matrix.ruby }}
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Coactive
|
4
|
+
module Coactants
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
class_attribute :_coactants
|
9
|
+
self._coactants = []
|
10
|
+
end
|
11
|
+
|
12
|
+
class_methods do
|
13
|
+
def coact(*coactants, **options, &block)
|
14
|
+
if block
|
15
|
+
self._coactants = _coactants + [block]
|
16
|
+
elsif options[:before]
|
17
|
+
index = self._coactants.index { |coactant| coactant == options[:before] }
|
18
|
+
self._coactants = self._coactants.insert(index, *coactants)
|
19
|
+
else
|
20
|
+
self._coactants = _coactants + coactants
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def coactants
|
25
|
+
self._coactants
|
26
|
+
end
|
27
|
+
|
28
|
+
def clear_coactants
|
29
|
+
self._coactants = []
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'coaction'
|
4
|
+
|
5
|
+
module Coactive
|
6
|
+
module Coactions
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
class << self
|
10
|
+
class_attribute :registry
|
11
|
+
self.registry = {}
|
12
|
+
|
13
|
+
def [](base, name)
|
14
|
+
registry.dig(base, name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def []=(base, name, array)
|
18
|
+
registry[base] ||= {}
|
19
|
+
registry[base][name] = array
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class_methods do
|
24
|
+
def coaction(*names, **options)
|
25
|
+
base = coactive_config.base_class
|
26
|
+
names.each do |name|
|
27
|
+
coactions = Coactions[base, name].to_a + [Coaction.new(self, name, options)]
|
28
|
+
Coactions[base, name] = coactions.sort_by.with_index { |coaction, i| [coaction.priority, i] }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/coactive/coactor.rb
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require_relative 'loader'
|
4
4
|
require_relative 'lookup'
|
5
|
-
require_relative '
|
6
|
-
require_relative '
|
5
|
+
require_relative 'coactants'
|
6
|
+
require_relative 'coactions'
|
7
7
|
|
8
8
|
module Coactive
|
9
9
|
module Coactor
|
10
10
|
extend ActiveSupport::Concern
|
11
|
-
include
|
12
|
-
include
|
11
|
+
include Coactants
|
12
|
+
include Coactions
|
13
13
|
|
14
14
|
def coactors
|
15
15
|
self.class._coactants.map do |coactant|
|
data/lib/coactive/loader.rb
CHANGED
@@ -3,18 +3,34 @@
|
|
3
3
|
module Coactive
|
4
4
|
module Loader
|
5
5
|
class << self
|
6
|
+
class_attribute :loaded
|
7
|
+
self.loaded = {}
|
8
|
+
|
6
9
|
def call(paths)
|
7
10
|
return unless defined?(Rails)
|
8
|
-
return if Rails.application.config.eager_load
|
9
|
-
|
11
|
+
return if Rails.application.config.eager_load || paths.blank?
|
12
|
+
|
13
|
+
Array.wrap(paths).each do |path|
|
14
|
+
unless loaded[path]
|
15
|
+
load(path)
|
16
|
+
loaded[path] = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
10
22
|
|
11
|
-
|
12
|
-
|
13
|
-
Dir["#{engine.root}
|
23
|
+
def load(path)
|
24
|
+
rails_engines.each do |engine|
|
25
|
+
Dir["#{engine.root}/#{path}/**/*.rb"].each do |file|
|
14
26
|
require_dependency file
|
15
27
|
end
|
16
28
|
end
|
17
29
|
end
|
30
|
+
|
31
|
+
def rails_engines
|
32
|
+
[Rails] + Rails::Engine.subclasses.map(&:instance)
|
33
|
+
end
|
18
34
|
end
|
19
35
|
end
|
20
36
|
end
|
@@ -11,14 +11,11 @@ module Coactive
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def load_files
|
14
|
-
|
14
|
+
Loader.call(@config.load_paths)
|
15
15
|
end
|
16
16
|
|
17
17
|
def lookup
|
18
|
-
@
|
19
|
-
coaction = coactor.coactions.detect { |coaction| coaction.name == @coactant }
|
20
|
-
hash[[coaction.priority || 1 << 63, i]] = coactor if coaction
|
21
|
-
end.sort.map { |x| x[1] }
|
18
|
+
Coactions[@config.base_class, @coactant].to_a.map(&:coactor)
|
22
19
|
end
|
23
20
|
|
24
21
|
class << self
|
@@ -14,13 +14,13 @@ module Coactive
|
|
14
14
|
|
15
15
|
if coactant.name.present? && (coactor = resolve(coactant))
|
16
16
|
coactor
|
17
|
-
elsif @
|
17
|
+
elsif @config.lookup_superclass_for_object && coactant.superclass
|
18
18
|
lookup(coactant.superclass)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def terminate?(coactant)
|
23
|
-
coactant.name.to_s.in?(@
|
23
|
+
coactant.name.to_s.in?(@config.lookup_superclass_until)
|
24
24
|
end
|
25
25
|
|
26
26
|
def resolve(coactant)
|
@@ -30,7 +30,7 @@ module Coactive
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def resolve_name(coactant)
|
33
|
-
suffix = @
|
33
|
+
suffix = @config.class_suffix
|
34
34
|
namespace = @klass.name.to_s.sub(/#{suffix}$/, '').to_s
|
35
35
|
[namespace, "#{coactant.name}#{suffix}"].join('::')
|
36
36
|
end
|
data/lib/coactive/railtie.rb
CHANGED
data/lib/coactive/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshikazu Kaneta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -120,10 +120,10 @@ files:
|
|
120
120
|
- gemfiles/rails70.gemfile
|
121
121
|
- lib/coactive.rb
|
122
122
|
- lib/coactive/base.rb
|
123
|
+
- lib/coactive/coactants.rb
|
124
|
+
- lib/coactive/coaction.rb
|
125
|
+
- lib/coactive/coactions.rb
|
123
126
|
- lib/coactive/coactor.rb
|
124
|
-
- lib/coactive/coactors/coactants.rb
|
125
|
-
- lib/coactive/coactors/coaction.rb
|
126
|
-
- lib/coactive/coactors/coactions.rb
|
127
127
|
- lib/coactive/config.rb
|
128
128
|
- lib/coactive/configure.rb
|
129
129
|
- lib/coactive/context.rb
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
162
|
+
rubygems_version: 3.3.3
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Make classes coactive
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Coactive
|
4
|
-
module Coactors
|
5
|
-
module Coactants
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
class_attribute :_coactants
|
10
|
-
self._coactants = []
|
11
|
-
end
|
12
|
-
|
13
|
-
class_methods do
|
14
|
-
def coact(*coactants, **options, &block)
|
15
|
-
if block
|
16
|
-
self._coactants = _coactants + [block]
|
17
|
-
elsif options[:before]
|
18
|
-
index = self._coactants.index { |coactant| coactant == options[:before] }
|
19
|
-
self._coactants = self._coactants.insert(index, *coactants)
|
20
|
-
else
|
21
|
-
self._coactants = _coactants + coactants
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def coactants
|
26
|
-
self._coactants
|
27
|
-
end
|
28
|
-
|
29
|
-
def clear_coactants
|
30
|
-
self._coactants = []
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'coaction'
|
4
|
-
|
5
|
-
module Coactive
|
6
|
-
module Coactors
|
7
|
-
module Coactions
|
8
|
-
extend ActiveSupport::Concern
|
9
|
-
|
10
|
-
included do
|
11
|
-
class_attribute :_coactions
|
12
|
-
self._coactions = []
|
13
|
-
end
|
14
|
-
|
15
|
-
class_methods do
|
16
|
-
def coaction(*names, **options)
|
17
|
-
self._coactions = _coactions + names.map { |name| Coaction.new(name, options) }
|
18
|
-
end
|
19
|
-
|
20
|
-
def coactions
|
21
|
-
self._coactions
|
22
|
-
end
|
23
|
-
|
24
|
-
def clear_coactions
|
25
|
-
self._coactions = []
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|