ree 1.0.42 → 1.0.43

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74fdedebcc116bb5764720b16d3baa21c017a6a64a815a9df5c9c249dab901be
4
- data.tar.gz: d752901505d14e4964aaaf606773e84f1464a8028f87d1d4d0a7bd6bb3bf3853
3
+ metadata.gz: 2673db96f54aa11d629b50c4edd402fcf44caebc3f41f64b0214aed053a70ab7
4
+ data.tar.gz: b71fe02e9ef5c6394d122b9ca300ee6fcb71c72912eef455a75bd49ede91441d
5
5
  SHA512:
6
- metadata.gz: 2f4c932846abc13daff98dca10dc79082f1837b232b09720ad24c9898dfc96ce3f245cafbe597dc42ecebae6e8da419a5977b84de932c644d09b7adf5e3799a4
7
- data.tar.gz: 1ad6fc938f287e24822b7d86dabbe6ca361e8d3ba9e0d2f6bb8f72dd1031fc8f056c97feb5946a67d2e54e289c53516220328eb4e8cafbfa244069cfd77f2900
6
+ metadata.gz: 5144f814a5dce7e8b2a6a552c9b34ffeec076284e19f6950e34f2b9c1d19b22ecbaebb32b943365823ed3125517c273e562e5fcbf9153a0b7b4b4abcf19716ee
7
+ data.tar.gz: 22ad163ff20029f24232be9b98b51503f15ba0ce1c273a1c0b33461776e6ac00abf1be91a1432d2f2e6f2060cceea2a451f91c661a1a49b54708e9f825d2084f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.42)
4
+ ree (1.0.43)
5
5
  commander (~> 5.0.0)
6
6
 
7
7
  GEM
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:, include_objects: false, silence: false)
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
@@ -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
- package
92
+
93
+ @loaded_packages[name] = package
94
94
  end
95
95
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Ree::DomainError < StandardError
4
+ end
@@ -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)
data/lib/ree/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ree
4
- VERSION = "1.0.42"
4
+ VERSION = "1.0.43"
5
5
  end
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.42
4
+ version: 1.0.43
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-07-30 00:00:00.000000000 Z
11
+ date: 2024-08-06 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