ree 1.0.42 → 1.0.44
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/exe/ree +0 -3
- data/lib/ree/cli/generate_package_schema.rb +1 -16
- data/lib/ree/cli/spec_runner.rb +2 -2
- data/lib/ree/core/package_loader.rb +3 -3
- data/lib/ree/dsl/build_package_dsl.rb +1 -1
- data/lib/ree/dsl/domain_error.rb +4 -0
- data/lib/ree/facades/packages_facade.rb +7 -25
- data/lib/ree/link_dsl.rb +21 -48
- data/lib/ree/version.rb +1 -1
- data/lib/ree.rb +1 -17
- metadata +3 -3
- data/lib/ree/core/object_schema_builder.rb +0 -102
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c43c3e1b979b49169f1b33067b14987b9871eea52b4925d31d952c7112dc05b
|
4
|
+
data.tar.gz: fc4d2351614b71835912930c7e971d587ae83d397277438bcfbc057dfdcf6d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2e4e9846094f89f07dc3ac2ea2ff2a37f1ecccb245a5708d58dcc0274aa32d31f395e05e54d26fa7243b2004715e4e86a654b2fc842405d577a254622b5380
|
7
|
+
data.tar.gz: 2d39527fb3b6abd0b355794e8b485c154b04ba74d5acba2f3f2c1a751b08243a0bc20b219670668eb2c97095779c9d60f441c9a5988861efbcaf6bbf1b2d9e7e
|
data/Gemfile.lock
CHANGED
data/exe/ree
CHANGED
@@ -89,7 +89,6 @@ class ReeCliRunner
|
|
89
89
|
Ree::CLI::GeneratePackageSchema.run(
|
90
90
|
package_name: options_with_defaults[:package_name],
|
91
91
|
project_path: options_with_defaults[:project_path],
|
92
|
-
include_objects: false,
|
93
92
|
silence: false
|
94
93
|
)
|
95
94
|
end
|
@@ -118,7 +117,6 @@ class ReeCliRunner
|
|
118
117
|
c.description = 'generates Package.schema.json for specific package'
|
119
118
|
c.summary = '> ' + c.description
|
120
119
|
c.example 'ree gen.package_json PACKAGE_NAME', ''
|
121
|
-
c.option '--skip_objects', String, 'Skip generation of object schemas'
|
122
120
|
c.option '--silence', String, 'Silence all logs'
|
123
121
|
c.option '--project_path [ROOT_PROJECT_DIR]', String, 'Root project dir path'
|
124
122
|
c.action do |args, options|
|
@@ -132,7 +130,6 @@ class ReeCliRunner
|
|
132
130
|
default_options = {
|
133
131
|
package_name: package_name,
|
134
132
|
project_path: options_hash[:project_path] || File.expand_path(Dir.pwd),
|
135
|
-
include_objects: !options_hash.has_key?(:skip_objects),
|
136
133
|
silence: options_hash.has_key?(:silence)
|
137
134
|
}
|
138
135
|
|
@@ -4,7 +4,7 @@ module Ree
|
|
4
4
|
module CLI
|
5
5
|
class GeneratePackageSchema
|
6
6
|
class << self
|
7
|
-
def run(package_name:, project_path:,
|
7
|
+
def run(package_name:, project_path:, silence: false)
|
8
8
|
ENV['REE_SKIP_ENV_VARS_CHECK'] = 'true'
|
9
9
|
|
10
10
|
path = Ree.locate_packages_schema(project_path)
|
@@ -31,21 +31,6 @@ module Ree
|
|
31
31
|
package = facade.get_package(package_name)
|
32
32
|
schema_path = Ree::PathHelper.abs_package_schema_path(package)
|
33
33
|
|
34
|
-
if include_objects
|
35
|
-
schemas_path = Ree::PathHelper.abs_package_schemas_dir(package)
|
36
|
-
|
37
|
-
FileUtils.rm_rf(schemas_path)
|
38
|
-
FileUtils.mkdir_p(schemas_path)
|
39
|
-
|
40
|
-
package.objects.each do |object|
|
41
|
-
Ree.write_object_schema(package.name, object.name)
|
42
|
-
|
43
|
-
path = Ree::PathHelper.abs_object_schema_path(object)
|
44
|
-
|
45
|
-
puts(" #{object.name}: #{path}") if !silence
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
34
|
puts("output: #{schema_path}") if !silence
|
50
35
|
puts("done") if !silence
|
51
36
|
end
|
data/lib/ree/cli/spec_runner.rb
CHANGED
@@ -107,7 +107,7 @@ module Ree
|
|
107
107
|
def project_packages(packages)
|
108
108
|
packages.reject(&:gem?)
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
def non_existent_packages
|
112
112
|
@package_names ? @package_names - packages.map(&:name) : []
|
113
113
|
end
|
@@ -148,7 +148,7 @@ module Ree
|
|
148
148
|
|
149
149
|
unless acc.include?(package.name)
|
150
150
|
acc << package.name
|
151
|
-
|
151
|
+
|
152
152
|
package.deps.map(&:name).each do |pack|
|
153
153
|
next if !packages_set.include?(pack)
|
154
154
|
recursively_find_children_packages(pack, acc)
|
@@ -35,9 +35,8 @@ class Ree::PackageLoader
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def recursively_load_package(name, loaded_packages)
|
38
|
+
@loaded_packages[name] = true
|
38
39
|
package = @packages_store.get(name)
|
39
|
-
return package if @loaded_packages[name]
|
40
|
-
@loaded_packages[name] = package
|
41
40
|
|
42
41
|
if !package
|
43
42
|
raise Ree::Error.new(
|
@@ -90,6 +89,7 @@ class Ree::PackageLoader
|
|
90
89
|
end
|
91
90
|
|
92
91
|
package.set_schema_loaded
|
93
|
-
|
92
|
+
|
93
|
+
@loaded_packages[name] = package
|
94
94
|
end
|
95
95
|
end
|
@@ -127,7 +127,7 @@ class Ree::BuildPackageDsl
|
|
127
127
|
name = Ree::StringUtils.underscore(list[0]).to_sym
|
128
128
|
|
129
129
|
if !Ree.irb_mode? && name != name_from_path
|
130
|
-
raise Ree::Error.new("Package module '#{module_name}' does not correspond to package name 'name'. Fix file name or module name.")
|
130
|
+
raise Ree::Error.new("Package module '#{module_name}' does not correspond to package name '#{name}'. Fix file name or module name.")
|
131
131
|
end
|
132
132
|
|
133
133
|
package = @packages_facade.get_package(name, false)
|
@@ -113,31 +113,6 @@ class Ree::PackagesFacade
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
# @param [Symbol] package_name
|
117
|
-
# @param [Symbol] object_name
|
118
|
-
# @return [String]
|
119
|
-
def write_object_schema(package_name, object_name)
|
120
|
-
Ree.logger.debug("write_object_schema(package_name: #{package_name}, object_name: #{object_name})")
|
121
|
-
object = get_object(package_name, object_name)
|
122
|
-
|
123
|
-
if !object || (object && !object&.schema_rpath)
|
124
|
-
raise Ree::Error.new("Object :#{object_name} schema path not found")
|
125
|
-
end
|
126
|
-
|
127
|
-
schema_path = Ree::PathHelper.abs_object_schema_path(object)
|
128
|
-
|
129
|
-
if !File.exist?(schema_path)
|
130
|
-
only_dir_path = schema_path.split('/')[0..-2]
|
131
|
-
FileUtils.mkdir_p(File.join(only_dir_path))
|
132
|
-
end
|
133
|
-
|
134
|
-
schema = Ree::ObjectSchemaBuilder.new.call(object)
|
135
|
-
json = JSON.pretty_generate(schema)
|
136
|
-
File.write(schema_path, json, mode: 'w')
|
137
|
-
|
138
|
-
json
|
139
|
-
end
|
140
|
-
|
141
116
|
# @param [Symbol] package_name
|
142
117
|
# @return nil
|
143
118
|
def load_package_entry(package_name)
|
@@ -232,6 +207,13 @@ class Ree::PackagesFacade
|
|
232
207
|
@packages_store
|
233
208
|
end
|
234
209
|
|
210
|
+
# @param [Symbol] package_name
|
211
|
+
# @return [Bool]
|
212
|
+
def has_package?(package_name)
|
213
|
+
check_arg(package_name, :package_name, Symbol)
|
214
|
+
!!@packages_store.get(package_name)
|
215
|
+
end
|
216
|
+
|
235
217
|
# @param [Symbol] package_name
|
236
218
|
# @return [Ree::Package]
|
237
219
|
def get_package(package_name, raise_if_missing = true)
|
data/lib/ree/link_dsl.rb
CHANGED
@@ -50,29 +50,18 @@ module Ree::LinkDSL
|
|
50
50
|
raise Ree::Error.new("target should be one of [:object, :class, :both]", :invalid_dsl_usage)
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
link_package_name = from
|
53
|
+
packages = Ree.container.packages_facade
|
54
|
+
link_package_name = get_link_package_name(from, object_name)
|
55
55
|
link_object_name = object_name
|
56
56
|
link_as = as ? as : object_name
|
57
57
|
|
58
|
-
_check_package_dependency_added(link_package_name, package_name)
|
59
|
-
|
60
58
|
if import
|
61
|
-
Ree::LinkImportBuilder
|
62
|
-
|
63
|
-
|
64
|
-
self,
|
65
|
-
link_package_name,
|
66
|
-
link_object_name,
|
67
|
-
import
|
68
|
-
)
|
59
|
+
Ree::LinkImportBuilder.new(packages).build(
|
60
|
+
self, link_package_name, link_object_name, import
|
61
|
+
)
|
69
62
|
end
|
70
63
|
|
71
|
-
obj =
|
72
|
-
.container
|
73
|
-
.packages_facade
|
74
|
-
.load_package_object(link_package_name, link_object_name)
|
75
|
-
|
64
|
+
obj = packages.load_package_object(link_package_name, link_object_name)
|
76
65
|
target ||= obj.target
|
77
66
|
|
78
67
|
if target == :both
|
@@ -133,12 +122,9 @@ module Ree::LinkDSL
|
|
133
122
|
|
134
123
|
list = path.split('/')
|
135
124
|
package_name = File.basename(list[0], ".*").to_sym
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
Ree.container.packages_facade.load_package_entry(package_name)
|
141
|
-
package = Ree.container.packages_facade.get_package(package_name)
|
125
|
+
packages = Ree.container.packages_facade
|
126
|
+
packages.load_package_entry(package_name)
|
127
|
+
package = packages.get_package(package_name)
|
142
128
|
|
143
129
|
file_path = File.join(
|
144
130
|
Ree::PathHelper.abs_package_dir(package),
|
@@ -153,7 +139,7 @@ module Ree::LinkDSL
|
|
153
139
|
end
|
154
140
|
end
|
155
141
|
|
156
|
-
|
142
|
+
packages.load_file(file_path, package.name)
|
157
143
|
|
158
144
|
const_list = path.split('/').map { |_| Ree::StringUtils.camelize(_) }
|
159
145
|
const_short = [const_list[0], const_list.last].join("::")
|
@@ -168,13 +154,9 @@ module Ree::LinkDSL
|
|
168
154
|
end
|
169
155
|
|
170
156
|
if import_proc
|
171
|
-
Ree::LinkImportBuilder
|
172
|
-
|
173
|
-
|
174
|
-
self,
|
175
|
-
file_const,
|
176
|
-
import_proc
|
177
|
-
)
|
157
|
+
Ree::LinkImportBuilder.new(packages).build_for_const(
|
158
|
+
self, file_const, import_proc
|
159
|
+
)
|
178
160
|
end
|
179
161
|
|
180
162
|
nil
|
@@ -182,33 +164,24 @@ module Ree::LinkDSL
|
|
182
164
|
|
183
165
|
def _raise_error(text, code = :invalid_dsl_usage)
|
184
166
|
msg = <<~DOC
|
185
|
-
|
186
|
-
path: #{Ree::PathHelper.abs_object_path(@object)}
|
167
|
+
class: :#{self}
|
187
168
|
error: #{text}
|
188
169
|
DOC
|
189
170
|
|
190
171
|
raise Ree::Error.new(msg, code)
|
191
172
|
end
|
192
173
|
|
193
|
-
def
|
194
|
-
return if
|
195
|
-
|
196
|
-
facade = Ree.container.packages_facade
|
197
|
-
facade.load_package_entry(package_name)
|
198
|
-
facade.load_package_entry(current_package_name)
|
174
|
+
def get_link_package_name(from, object_name)
|
175
|
+
return from if from
|
199
176
|
|
200
|
-
|
177
|
+
package_name = Ree::StringUtils.underscore(self.name.split('::').first).to_sym
|
178
|
+
result = Ree.container.packages_facade.has_package?(package_name) ? package_name : nil
|
201
179
|
|
202
|
-
|
203
|
-
|
180
|
+
if result.nil?
|
181
|
+
raise Ree::Error.new("package is not provided for link :#{object_name}", :invalid_dsl_usage)
|
204
182
|
end
|
205
183
|
|
206
|
-
|
207
|
-
raise Ree::Error.new(
|
208
|
-
"Package :#{package_name} is not added as dependency for :#{current_package_name} package\npackage path: #{File.join(Ree.root_dir, current_package.entry_rpath || "")}\nclass:#{self.name}",
|
209
|
-
:invalid_dsl_usage
|
210
|
-
)
|
211
|
-
end
|
184
|
+
result
|
212
185
|
end
|
213
186
|
end
|
214
187
|
end
|
data/lib/ree/version.rb
CHANGED
data/lib/ree.rb
CHANGED
@@ -11,6 +11,7 @@ module Ree
|
|
11
11
|
autoload :CLI, 'ree/cli'
|
12
12
|
autoload :Container, 'ree/container'
|
13
13
|
autoload :Contracts, 'ree/contracts'
|
14
|
+
autoload :DomainError, 'ree/dsl/domain_error'
|
14
15
|
autoload :Error, 'ree/error'
|
15
16
|
autoload :ErrorDsl, 'ree/dsl/error_dsl'
|
16
17
|
autoload :FnDSL, 'ree/fn_dsl'
|
@@ -26,7 +27,6 @@ module Ree
|
|
26
27
|
autoload :ObjectError, 'ree/core/object_error'
|
27
28
|
autoload :ObjectLink, 'ree/core/object_link'
|
28
29
|
autoload :ObjectSchema, 'ree/core/object_schema'
|
29
|
-
autoload :ObjectSchemaBuilder, 'ree/core/object_schema_builder'
|
30
30
|
autoload :Package, 'ree/core/package'
|
31
31
|
autoload :PackageDep, 'ree/core/package_dep'
|
32
32
|
autoload :BuildPackageDsl, 'ree/dsl/build_package_dsl'
|
@@ -229,12 +229,6 @@ module Ree
|
|
229
229
|
@root_dir || (raise Ree::Error.new(ROOT_DIR_MESSAGE, :invalid_root_dir))
|
230
230
|
end
|
231
231
|
|
232
|
-
def write_object_schema(package_name, object_name)
|
233
|
-
check_arg(package_name, :package_name, Symbol)
|
234
|
-
check_arg(object_name, :object_name, Symbol)
|
235
|
-
container.packages_facade.write_object_schema(package_name, object_name)
|
236
|
-
end
|
237
|
-
|
238
232
|
def generate_schemas_for_all_packages(silence = false)
|
239
233
|
Ree.logger.debug("generate_schemas_for_all_packages") if !silence
|
240
234
|
facade = container.packages_facade
|
@@ -249,16 +243,6 @@ module Ree
|
|
249
243
|
|
250
244
|
facade.load_entire_package(package.name)
|
251
245
|
facade.write_package_schema(package.name)
|
252
|
-
|
253
|
-
schemas_path = Ree::PathHelper.abs_package_schemas_dir(package)
|
254
|
-
|
255
|
-
FileUtils.rm_rf(schemas_path)
|
256
|
-
FileUtils.mkdir_p(schemas_path)
|
257
|
-
|
258
|
-
package.objects.each do |object|
|
259
|
-
next if !object.schema_rpath
|
260
|
-
write_object_schema(package.name, object.name)
|
261
|
-
end
|
262
246
|
end
|
263
247
|
end
|
264
248
|
end
|
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.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -124,7 +124,6 @@ files:
|
|
124
124
|
- lib/ree/core/object_error.rb
|
125
125
|
- lib/ree/core/object_link.rb
|
126
126
|
- lib/ree/core/object_schema.rb
|
127
|
-
- lib/ree/core/object_schema_builder.rb
|
128
127
|
- lib/ree/core/package.rb
|
129
128
|
- lib/ree/core/package_dep.rb
|
130
129
|
- lib/ree/core/package_env_var.rb
|
@@ -140,6 +139,7 @@ files:
|
|
140
139
|
- lib/ree/core/packages_store.rb
|
141
140
|
- lib/ree/core/path_helper.rb
|
142
141
|
- lib/ree/dsl/build_package_dsl.rb
|
142
|
+
- lib/ree/dsl/domain_error.rb
|
143
143
|
- lib/ree/dsl/error_dsl.rb
|
144
144
|
- lib/ree/dsl/import_dsl.rb
|
145
145
|
- lib/ree/dsl/link_import_builder.rb
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Ree::ObjectSchemaBuilder
|
4
|
-
Schema = Ree::ObjectSchema
|
5
|
-
|
6
|
-
# @param [Ree::Object] object
|
7
|
-
# @return [Hash]
|
8
|
-
def call(object)
|
9
|
-
Ree.logger.debug("generating object schema for '#{object.name}' package")
|
10
|
-
|
11
|
-
if !object.loaded?
|
12
|
-
raise Ree::Error.new("object `#{object.name}` from package `#{object.package_name}` is not loaded", :invalid_schema)
|
13
|
-
end
|
14
|
-
|
15
|
-
data = {
|
16
|
-
Schema::SCHEMA_TYPE => Schema::OBJECT,
|
17
|
-
Schema::SCHEMA_VERSION => Schema::SCHEMA_VERSION_NUMBER,
|
18
|
-
Schema::NAME => object.name,
|
19
|
-
Schema::PATH => object.rpath,
|
20
|
-
Schema::MOUNT_AS => object.mount_as,
|
21
|
-
Schema::CLASS => object.klass.name,
|
22
|
-
Schema::FACTORY => object.factory,
|
23
|
-
Schema::METHODS => map_object_methods(object),
|
24
|
-
Schema::LINKS => object.links.sort_by(&:object_name).map { |link|
|
25
|
-
{
|
26
|
-
Schema::Links::TARGET => link.object_name,
|
27
|
-
Schema::Links::PACKAGE_NAME => link.package_name,
|
28
|
-
Schema::Links::AS => link.as,
|
29
|
-
Schema::Links::IMPORTS => link.constants
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
data
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
Arg = Ree::Contracts::CalledArgsValidator::Arg
|
40
|
-
|
41
|
-
def map_object_methods(object)
|
42
|
-
if !object.fn?
|
43
|
-
return []
|
44
|
-
end
|
45
|
-
|
46
|
-
klass = object.klass
|
47
|
-
|
48
|
-
method_decorator = Ree::Contracts.get_method_decorator(
|
49
|
-
klass, :call, scope: :instance
|
50
|
-
)
|
51
|
-
|
52
|
-
begin
|
53
|
-
if method_decorator.nil?
|
54
|
-
parameters = klass.instance_method(:call).parameters
|
55
|
-
|
56
|
-
args = parameters.inject({}) do |res, param|
|
57
|
-
res[param.last] = Arg.new(
|
58
|
-
param.last, param.first, nil, nil
|
59
|
-
)
|
60
|
-
|
61
|
-
res
|
62
|
-
end
|
63
|
-
else
|
64
|
-
parameters = method_decorator.args.params
|
65
|
-
args = method_decorator.args.get_args
|
66
|
-
end
|
67
|
-
rescue NameError
|
68
|
-
raise Ree::Error.new("method call is not defined for #{klass}")
|
69
|
-
end
|
70
|
-
|
71
|
-
arg_list = parameters.map do |param|
|
72
|
-
arg = args[param.last]
|
73
|
-
validator = arg.validator
|
74
|
-
arg_type = arg.type
|
75
|
-
|
76
|
-
type = if validator
|
77
|
-
validator.to_s
|
78
|
-
else
|
79
|
-
if arg_type == :block
|
80
|
-
"Block"
|
81
|
-
else
|
82
|
-
"Any"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
{
|
87
|
-
Schema::Methods::Args::ARG => arg.name,
|
88
|
-
Schema::Methods::Args::ARG_TYPE => arg.type,
|
89
|
-
Schema::Methods::Args::TYPE => type
|
90
|
-
}
|
91
|
-
end
|
92
|
-
|
93
|
-
[
|
94
|
-
{
|
95
|
-
Schema::Methods::DOC => method_decorator&.doc || "",
|
96
|
-
Schema::Methods::THROWS => method_decorator&.errors&.map { _1.name } || [],
|
97
|
-
Schema::Methods::RETURN => method_decorator&.contract_definition&.return_contract || "Any",
|
98
|
-
Schema::Methods::ARGS => arg_list
|
99
|
-
}
|
100
|
-
]
|
101
|
-
end
|
102
|
-
end
|