ree 1.0.43 → 1.0.45

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: 2673db96f54aa11d629b50c4edd402fcf44caebc3f41f64b0214aed053a70ab7
4
- data.tar.gz: b71fe02e9ef5c6394d122b9ca300ee6fcb71c72912eef455a75bd49ede91441d
3
+ metadata.gz: 210b89e5324ca6f5db8822df39deebd8e0d3d4b83c199196a271b0cb0bfc81cd
4
+ data.tar.gz: 8fff42665a010ef7951cd9d154ed2d77215e68ade7f332e1bb7d7227a1c328de
5
5
  SHA512:
6
- metadata.gz: 5144f814a5dce7e8b2a6a552c9b34ffeec076284e19f6950e34f2b9c1d19b22ecbaebb32b943365823ed3125517c273e562e5fcbf9153a0b7b4b4abcf19716ee
7
- data.tar.gz: 22ad163ff20029f24232be9b98b51503f15ba0ce1c273a1c0b33461776e6ac00abf1be91a1432d2f2e6f2060cceea2a451f91c661a1a49b54708e9f825d2084f
6
+ metadata.gz: f26553e3a3d62489d1090c6a38c38f0633ce8f735ae1b77a3e8e809cd4ece9f87b0cd8a31032aee8992e231a52028a96aca8369fcf3249c264dc1dcbaf8d0d37
7
+ data.tar.gz: e627fa0c50ceabea70ec3adc2c9af2d3107dadbad1a0f2aa416f36a1c10e9da49152edaa99cd38c50d9f93f70db540d4f0d30e2864dff23cafaf4e2f11feda07
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.43)
4
+ ree (1.0.45)
5
5
  commander (~> 5.0.0)
6
6
 
7
7
  GEM
@@ -40,26 +40,26 @@ module Ree
40
40
  if !object.fn?
41
41
  return []
42
42
  end
43
-
43
+
44
44
  klass = object.klass
45
45
 
46
46
  object_is_action = object.tags.include?("action")
47
47
  action_caster = object.klass.const_get(:ActionCaster) if object.klass.const_defined?(:ActionCaster)
48
-
48
+
49
49
  method_name = object_is_action ? :__original_call : :call
50
50
  method_decorator = Ree::Contracts.get_method_decorator(
51
51
  klass, method_name, scope: :instance
52
52
  )
53
-
53
+
54
54
  begin
55
55
  if method_decorator.nil?
56
56
  parameters = klass.instance_method(:call).parameters
57
-
57
+
58
58
  args = parameters.inject({}) do |res, param|
59
59
  res[param.last] = Ree::Contracts::CalledArgsValidator::Arg.new(
60
60
  param.last, param.first, nil, nil
61
61
  )
62
-
62
+
63
63
  res
64
64
  end
65
65
  else
@@ -70,7 +70,7 @@ module Ree
70
70
  raise Ree::Error.new("method call is not defined for #{klass}")
71
71
  end
72
72
 
73
-
73
+
74
74
  arg_list = parameters.map do |param|
75
75
  arg = args[param.last]
76
76
  validator = arg.validator
@@ -78,21 +78,21 @@ module Ree
78
78
 
79
79
  type = if object_is_action && action_caster && arg.name == :attrs
80
80
  map_mapper_fields(action_caster.fields).to_s.gsub(/\\*\"/, "").gsub(/\=\>/, ' => ')
81
- else
81
+ else
82
82
  if validator
83
83
  validator.to_s
84
84
  else
85
85
  arg_type == :block ? "Block" : "Any"
86
86
  end
87
87
  end
88
-
88
+
89
89
  {
90
90
  Ree::ObjectSchema::Methods::Args::ARG => arg.name,
91
91
  Ree::ObjectSchema::Methods::Args::ARG_TYPE => arg.type,
92
92
  Ree::ObjectSchema::Methods::Args::TYPE => type
93
93
  }
94
94
  end
95
-
95
+
96
96
  [
97
97
  {
98
98
  Ree::ObjectSchema::Methods::DOC => method_decorator&.doc || "",
@@ -106,6 +106,8 @@ module Ree
106
106
  def index_public_methods_for_package_classes(package, index_hash)
107
107
  package.objects.each do |obj|
108
108
  klass = obj.klass
109
+ next if klass.nil?
110
+
109
111
  klass_name = demodulize(klass.to_s)
110
112
  obj_name = obj.name.to_s
111
113
  rpath = obj.rpath
@@ -137,53 +139,53 @@ module Ree
137
139
  def recursively_index_module(mod, index_hsh, package, mod_index)
138
140
  return if !mod.is_a?(Module)
139
141
  return if mod_index[mod]
140
-
142
+
141
143
  mod_index[mod] = true
142
-
144
+
143
145
  mod.constants.each do |const_name|
144
146
  const = mod.const_get(const_name)
145
-
147
+
146
148
  recursively_index_module(const, index_hsh, package, mod_index)
147
-
149
+
148
150
  next if !const.is_a?(Class)
149
151
  next if package.objects.any? { |o| o.klass == const }
150
152
  next if index_hsh[:classes].has_key?(demodulize(const.name))
151
-
153
+
152
154
  const_abs_path = mod.const_source_location(const.name)&.first
153
155
  next if !const_abs_path
154
-
156
+
155
157
  rpath = Pathname.new(const_abs_path).relative_path_from(Ree.root_dir).to_s
156
158
  hsh = index_class(const, rpath, package.name)
157
159
  class_name = demodulize(const.name)
158
-
160
+
159
161
  index_hsh[:classes][class_name] ||= []
160
162
  index_hsh[:classes][class_name] << hsh
161
163
  end
162
164
  end
163
-
165
+
164
166
  def index_class(klass, rpath, package_name)
165
167
  all_methods = klass.public_instance_methods(false)
166
168
  orig_methods = all_methods.grep(/original/)
167
-
169
+
168
170
  methods = (all_methods - orig_methods) # remove aliases defined by contracts
169
171
  .map { |m|
170
172
  orig_method_name = orig_methods.find { |om| om.match(/original_#{Regexp.escape(m.name)}_[0-9a-fA-F]+/) }
171
173
  orig_method = orig_method_name ? klass.public_instance_method(orig_method_name) : nil
172
-
174
+
173
175
  {
174
176
  name: m,
175
177
  parameters: orig_method&.parameters&.map { |param| { name: param.last, required: param.first } },
176
178
  location: orig_method&.source_location&.last,
177
179
  }
178
180
  }
179
-
181
+
180
182
  {
181
183
  path: rpath,
182
184
  package: package_name,
183
185
  methods: methods
184
186
  }
185
187
  end
186
-
188
+
187
189
  def index_dao(klass, rpath, package_name)
188
190
  filters = (klass.instance_variable_get(:@filters) || []).map do
189
191
  {
@@ -194,14 +196,14 @@ module Ree
194
196
  location: _1.proc&.source_location&.last
195
197
  }
196
198
  end
197
-
199
+
198
200
  {
199
201
  path: rpath,
200
202
  package: package_name,
201
203
  methods: filters
202
204
  }
203
205
  end
204
-
206
+
205
207
  def index_exceptions(errors_package, index_hash)
206
208
  errors_package.objects.each do |obj|
207
209
  const_name = demodulize(obj.class_name)
@@ -209,17 +211,17 @@ module Ree
209
211
  Ree::PathHelper.abs_package_module_dir(errors_package),
210
212
  obj.name.to_s + ".rb"
211
213
  )
212
-
214
+
213
215
  hsh = {
214
216
  path: file_name,
215
217
  package: errors_package.name,
216
218
  methods: []
217
219
  }
218
-
220
+
219
221
  index_hash[:classes][const_name] ||= []
220
222
  index_hash[:classes][const_name] << hsh
221
223
  end
222
-
224
+
223
225
  index_hash
224
226
  end
225
227
 
@@ -262,4 +264,4 @@ module Ree
262
264
  end
263
265
  end
264
266
  end
265
- end
267
+ end
@@ -93,6 +93,8 @@ module Ree
93
93
  @packages_to_run.each do |package|
94
94
  ree_package = Ree.container.packages_facade.get_package(package)
95
95
 
96
+ next if ree_package.dir.nil?
97
+
96
98
  Ree::SpecRunner::Runner.new(
97
99
  path: Ree::PathHelper.project_root_dir(ree_package),
98
100
  package: package,
@@ -107,7 +109,7 @@ module Ree
107
109
  def project_packages(packages)
108
110
  packages.reject(&:gem?)
109
111
  end
110
-
112
+
111
113
  def non_existent_packages
112
114
  @package_names ? @package_names - packages.map(&:name) : []
113
115
  end
@@ -148,7 +150,7 @@ module Ree
148
150
 
149
151
  unless acc.include?(package.name)
150
152
  acc << package.name
151
-
153
+
152
154
  package.deps.map(&:name).each do |pack|
153
155
  next if !packages_set.include?(pack)
154
156
  recursively_find_children_packages(pack, acc)
@@ -35,7 +35,7 @@ class Ree::PackageLoader
35
35
  private
36
36
 
37
37
  def recursively_load_package(name, loaded_packages)
38
- @loaded_packages[name] = true
38
+ loaded_packages[name] = true
39
39
  package = @packages_store.get(name)
40
40
 
41
41
  if !package
@@ -47,7 +47,7 @@ class Ree::PackageLoader
47
47
 
48
48
  if package.dir.nil?
49
49
  package.set_schema_loaded
50
- return package
50
+ return @loaded_packages[name] = package
51
51
  end
52
52
 
53
53
  not_loaded = Set.new(
@@ -92,4 +92,4 @@ class Ree::PackageLoader
92
92
 
93
93
  @loaded_packages[name] = package
94
94
  end
95
- end
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)
@@ -207,6 +207,13 @@ class Ree::PackagesFacade
207
207
  @packages_store
208
208
  end
209
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
+
210
217
  # @param [Symbol] package_name
211
218
  # @return [Ree::Package]
212
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
- package_name = Ree::StringUtils.underscore(self.name.split('::').first).to_sym
54
- link_package_name = from.nil? ? 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
- .new(Ree.container.packages_facade)
63
- .build(
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 = Ree
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
- current_package_name = Ree::StringUtils.underscore(self.name.split('::').first).to_sym
137
-
138
- _check_package_dependency_added(package_name, current_package_name)
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
- Ree.container.packages_facade.load_file(file_path, package.name)
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
- .new(Ree.container.packages_facade)
173
- .build_for_const(
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
- object: :#{@object.name}
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 _check_package_dependency_added(package_name, current_package_name)
194
- return if package_name == current_package_name
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
- current_package = facade.get_package(current_package_name)
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
- dep_package = current_package.deps.detect do |d|
203
- d.name == package_name
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
- if dep_package.nil?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ree
4
- VERSION = "1.0.43"
4
+ VERSION = "1.0.45"
5
5
  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.43
4
+ version: 1.0.45
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-08-06 00:00:00.000000000 Z
11
+ date: 2024-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander