ree 1.0.28 → 1.0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ree/dsl/import_dsl.rb +46 -8
- data/lib/ree/version.rb +1 -1
- 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: 8a9bafffedbc153f633b682e9a7ecbce4ad38a75dbbb9a7436798a3766d57735
|
4
|
+
data.tar.gz: 4b2562f2fb06c0afc492cce67abf5044b160c900057b5c24e14eb76104bf9049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad6eddfb2656ed64223758a2b3f9a720597ba9bbca3edddbccb7ca4b284770db9fa03e3b5c81cdd5d771858bfff3e2b39566820a993eaa4f02baf3e821e3f116
|
7
|
+
data.tar.gz: 14ecf3e59cdc5d0b3a78f9fcddc74ea39cc6fb7ff77bbe2a23d6a693cf4d98f47141cfb750b4d60f9a8e09c3971e070f25d70ccff11e76121187b80e603e1666
|
data/Gemfile.lock
CHANGED
data/lib/ree/dsl/import_dsl.rb
CHANGED
@@ -4,12 +4,12 @@ class Ree::ImportDsl
|
|
4
4
|
def execute(klass, proc)
|
5
5
|
self.class.instance_exec(&proc)
|
6
6
|
rescue Ree::ImportDsl::UnlinkConstError => e
|
7
|
-
const_removed =
|
7
|
+
const_removed = remove_or_assign_const(klass, e.const)
|
8
8
|
|
9
9
|
retry if const_removed
|
10
10
|
rescue NoMethodError => e
|
11
11
|
if e.name == :&
|
12
|
-
const_removed =
|
12
|
+
const_removed = remove_or_assign_const(klass, e.receiver)
|
13
13
|
|
14
14
|
if const_removed
|
15
15
|
retry
|
@@ -29,7 +29,7 @@ class Ree::ImportDsl
|
|
29
29
|
|
30
30
|
class UnlinkConstError < StandardError
|
31
31
|
attr_reader :const
|
32
|
-
|
32
|
+
|
33
33
|
def initialize(const)
|
34
34
|
@const = const
|
35
35
|
end
|
@@ -82,25 +82,63 @@ class Ree::ImportDsl
|
|
82
82
|
|
83
83
|
private
|
84
84
|
|
85
|
-
def
|
86
|
-
|
85
|
+
def remove_or_assign_const(klass, constant)
|
86
|
+
retry_after = false
|
87
87
|
|
88
88
|
klass.constants.each do |const_sym|
|
89
89
|
const = klass.const_get(const_sym)
|
90
|
+
next if const.is_a?(ClassConstant)
|
90
91
|
|
91
92
|
if constant.is_a?(Class) || constant.is_a?(Module)
|
92
93
|
if (const.is_a?(Class) || const.is_a?(Module)) && const.name == constant.name
|
93
94
|
klass.send(:remove_const, const_sym)
|
94
|
-
|
95
|
+
retry_after = true
|
95
96
|
break
|
96
97
|
end
|
97
98
|
elsif const == constant
|
98
99
|
klass.send(:remove_const, const_sym)
|
99
|
-
|
100
|
+
retry_after = true
|
100
101
|
break
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
|
-
|
105
|
+
return true if retry_after
|
106
|
+
|
107
|
+
const_name = if constant.is_a?(String)
|
108
|
+
constant.to_sym
|
109
|
+
elsif constant.is_a?(Class) || constant.is_a?(Module)
|
110
|
+
constant.name
|
111
|
+
else
|
112
|
+
raise ArgumentError.new("unknown constant: #{constant.inspect}")
|
113
|
+
end
|
114
|
+
|
115
|
+
if parent_constant?(klass, const_name)
|
116
|
+
klass.const_set(const_name, ClassConstant.new(const_name.to_s))
|
117
|
+
retry_after = true
|
118
|
+
end
|
119
|
+
|
120
|
+
retry_after
|
121
|
+
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def parent_constant?(klass, const_name)
|
126
|
+
modules = klass.to_s.split("::")[0..-2]
|
127
|
+
|
128
|
+
result = modules.each_with_index.any? do |mod, index|
|
129
|
+
mod = Object.const_get(modules[0..index].join("::"))
|
130
|
+
mod.constants.include?(const_name)
|
131
|
+
end
|
132
|
+
|
133
|
+
result || acnchestor_constant?(klass, const_name)
|
134
|
+
end
|
135
|
+
|
136
|
+
def acnchestor_constant?(klass, const_name)
|
137
|
+
return false if klass.ancestors.include?(klass) && klass.ancestors.size == 1
|
138
|
+
|
139
|
+
klass.ancestors.any? do |anchestor|
|
140
|
+
next if anchestor == klass
|
141
|
+
anchestor.constants.include?(const_name) || acnchestor_constant?(anchestor, const_name)
|
142
|
+
end
|
105
143
|
end
|
106
144
|
end
|
data/lib/ree/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|