ree 1.0.8 → 1.0.10

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: 6d3080db0341788d95f77d172fec9b207e3c27a98d31e785a977d245942298eb
4
- data.tar.gz: d6eedaf9b82609693d2c3c8b3131e45ae59e6fbc04a9038e6f5e6edc762bf60e
3
+ metadata.gz: c1b2264b5461e4f29c6a6a09d71b4f594607777e30b7fd9ee04eb581f8ca4c27
4
+ data.tar.gz: f56ccea02c51d34be30d0a53da9cb2a855265510b6167d19986b4ceb708a92f7
5
5
  SHA512:
6
- metadata.gz: bce075c79b1fec9acf13f397acff99edb159d2ba0074ed314b5a959be9688d0093eb46e18e59801e2f9be1fea358cd8596b1220ec8e40340b745e9bdf112e071
7
- data.tar.gz: adcf4a8b7d7e94c0b9e89c8ee4ff98fe193f7fc76c6c62578f421a0e20c6bbd5c686e59481785669f42c26988fd5280c09a3ca7212524ac0486b0c6724b00a76
6
+ metadata.gz: c423007aa3b01f9251f820eb432186ef18d909dbfc06c52d6c6748eddc7ab6d35e1d38c337ad5afcefea302a0b057832ec29eb50dda7dd4ba053bdc9ddee7913
7
+ data.tar.gz: f3f0ed83742454c2f4ae91c7eb47be2a1cbce89ee2775ef220c5a73682bed9b051f9c79196b46990ab800783c630e5ef015fd9ab665a727ef9f8b8ef9b04b723
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.8)
4
+ ree (1.0.10)
5
5
  commander (~> 4.6.0)
6
6
 
7
7
  GEM
data/exe/ree CHANGED
@@ -148,7 +148,7 @@ class ReeCliRunner
148
148
  c.option '--silence', String, 'Silence all logs'
149
149
  c.option '--project_path [ROOT_PROJECT_DIR]', String, 'Root project dir path'
150
150
  c.action do |args, options|
151
- package_name = args[0]&.to_sym
151
+ package_name = args[0]
152
152
  object_path = args[1]
153
153
  options_hash = options.__hash__
154
154
 
@@ -251,7 +251,7 @@ class ReeCliRunner
251
251
  package_abs_path = Ree::PathHelper.abs_package_dir(package)
252
252
  exec_abs_path = Pathname.new(package_abs_path).join(Pathname.new(executable_path)).to_s
253
253
 
254
- raise Ree::Error.new("File #{exec_abs_path} not found") unless File.exists?(exec_abs_path)
254
+ raise Ree::Error.new("File #{exec_abs_path} not found") unless File.exist?(exec_abs_path)
255
255
 
256
256
  system("chmod +x #{exec_abs_path}") if run_chmod_x
257
257
  system(exec_abs_path)
@@ -19,7 +19,7 @@ module Ree
19
19
  schema_path = Ree::PathHelper.object_schema_rpath(object_path)
20
20
  abs_schema_path = File.join(dir, schema_path)
21
21
 
22
- if File.exists?(abs_schema_path)
22
+ if File.exist?(abs_schema_path)
23
23
  FileUtils.rm(abs_schema_path)
24
24
 
25
25
  puts(" #{schema_path}: is deleted") if !silence
@@ -25,12 +25,11 @@ module Ree
25
25
  if facade.has_object?(package_name, object_name)
26
26
  object = facade.load_package_object(package_name, object_name)
27
27
  Ree.write_object_schema(package.name, object.name)
28
-
29
- obj_path = Ree::PathHelper.abs_object_schema_path(object)
28
+ facade.dump_package_schema(package_name)
30
29
  else
31
30
  file_path = File.join(dir, object_path)
32
31
 
33
- if File.exists?(file_path)
32
+ if File.exist?(file_path)
34
33
  facade.load_file(file_path, package_name)
35
34
  facade.dump_package_schema(package_name)
36
35
 
@@ -25,7 +25,7 @@ module Ree
25
25
 
26
26
  facade = Ree.container.packages_facade
27
27
  facade.load_packages_schema
28
- Ree.load_package(package_name)
28
+ facade.load_entire_package(package_name)
29
29
  facade.write_package_schema(package_name)
30
30
 
31
31
  package = facade.get_package(package_name)
@@ -6,16 +6,14 @@ require_relative 'engine_proxy'
6
6
 
7
7
  module Ree::Contracts
8
8
  module Contractable
9
- if !Ree::Contracts.no_contracts?
10
- def method_added(name)
11
- MethodDecorator.new(name, false, self).call
12
- super
13
- end
9
+ def method_added(name)
10
+ MethodDecorator.new(name, false, self).call
11
+ super
12
+ end
14
13
 
15
- def singleton_method_added(name)
16
- MethodDecorator.new(name, true, self).call
17
- super
18
- end
14
+ def singleton_method_added(name)
15
+ MethodDecorator.new(name, true, self).call
16
+ super
19
17
  end
20
18
 
21
19
  def doc(str)
@@ -38,11 +38,6 @@ class Ree::PackageLoader
38
38
  @loaded_packages[name] = true
39
39
  package = @packages_store.get(name)
40
40
 
41
- if package.dir.nil?
42
- package.set_schema_loaded
43
- return package
44
- end
45
-
46
41
  if !package
47
42
  raise Ree::Error.new(
48
43
  "Package :#{name} was not found. Did you mistype the name? Run `ree gen.packages_json` to update Packages.schema.json",
@@ -50,6 +45,11 @@ class Ree::PackageLoader
50
45
  )
51
46
  end
52
47
 
48
+ if package.dir.nil?
49
+ package.set_schema_loaded
50
+ return package
51
+ end
52
+
53
53
  not_loaded = Set.new(
54
54
  [name, package.deps.map(&:name)]
55
55
  .uniq
@@ -46,7 +46,7 @@ class Ree::PackageSchemaLoader
46
46
  # @param [Nilor[Ree::Package]] existing_package Loaded package
47
47
  # @return [Ree::Package]
48
48
  def call(abs_schema_path, existing_package = nil)
49
- if !File.exists?(abs_schema_path)
49
+ if !File.exist?(abs_schema_path)
50
50
  raise Ree::Error.new("File not found: #{abs_schema_path}", :invalid_package_schema)
51
51
  end
52
52
 
@@ -6,7 +6,7 @@ class Ree::PackagesDetector
6
6
  # @param [String] dir Packages root dir
7
7
  # @return [ArrayOf[{name: String, entry_path: String, package_schema_path: String, gem_name: Nilor[String]}]]
8
8
  def call(dir, gem_name = nil)
9
- if !Dir.exists?(dir)
9
+ if !Dir.exist?(dir)
10
10
  raise Ree::Error.new("dir does not exist: #{dir}", :invalid_dir)
11
11
  end
12
12
 
@@ -22,7 +22,7 @@ class Ree::PackagesDetector
22
22
  name = package_schema_path.split('/')[-2]
23
23
  entry_path = Ree::PathHelper.package_entry_path(package_schema_path)
24
24
 
25
- if !File.exists?(File.join(dir, entry_path))
25
+ if !File.exist?(File.join(dir, entry_path))
26
26
  Ree.logger.error("Entry file does not exist for '#{name}' package: #{entry_path}")
27
27
  end
28
28
 
@@ -25,7 +25,7 @@ class Ree::PackagesSchemaLoader
25
25
  # @param Nilor[Ree::PackagesStore] packages_store Existing packages store
26
26
  # @return [Ree::PackagesStore]
27
27
  def call(abs_schema_path, packages_store = nil, gem_name = nil)
28
- if !File.exists?(abs_schema_path)
28
+ if !File.exist?(abs_schema_path)
29
29
  raise Ree::Error.new("File not found: #{abs_schema_path}", :invalid_packages_schema)
30
30
  end
31
31
 
@@ -165,10 +165,10 @@ class Ree::ObjectDsl
165
165
  Ree::PACKAGE, path
166
166
  )
167
167
 
168
- if !File.exists?(file_path)
168
+ if !File.exist?(file_path)
169
169
  file_path = "#{file_path}.rb"
170
170
 
171
- if !File.exists?(file_path)
171
+ if !File.exist?(file_path)
172
172
  raise_error("Unable to link '#{path}'. File not found #{file_path}")
173
173
  end
174
174
  end
@@ -223,7 +223,7 @@ class Ree::ObjectDsl
223
223
  raise Ree::Error.new("Mount as should be one of #{MOUNT_AS.inspect}", :invalid_dsl_usage)
224
224
  end
225
225
 
226
- object_name_from_path = if File.exists?(path) && !Ree.irb_mode?
226
+ object_name_from_path = if File.exist?(path) && !Ree.irb_mode?
227
227
  File.basename(path, ".*").to_sym
228
228
  end
229
229
 
@@ -12,11 +12,11 @@ def package_require(path)
12
12
  Ree::PathHelper.abs_package_module_dir(package), list.join('/')
13
13
  )
14
14
 
15
- if !File.exists?(path)
15
+ if !File.exist?(path)
16
16
  path = path + '.rb'
17
17
  end
18
18
 
19
- if !File.exists?(path)
19
+ if !File.exist?(path)
20
20
  raise Ree::Error.new("file not found: #{path}")
21
21
  end
22
22
 
@@ -37,8 +37,8 @@ def package_file_exists?(path)
37
37
  Ree::PathHelper.abs_package_module_dir(package), list.join('/')
38
38
  )
39
39
 
40
- return true if File.exists?(path)
40
+ return true if File.exist?(path)
41
41
 
42
42
  path = path + '.rb'
43
- File.exists?(path)
43
+ File.exist?(path)
44
44
  end
@@ -78,7 +78,7 @@ class Ree::PackagesFacade
78
78
  if package.dir
79
79
  schema_path = Ree::PathHelper.abs_package_schema_path(package)
80
80
 
81
- if !File.exists?(schema_path)
81
+ if !File.exist?(schema_path)
82
82
  raise Ree::Error.new("File does not exist: #{schema_path}", :invalid_path)
83
83
  end
84
84
 
@@ -101,7 +101,7 @@ class Ree::PackagesFacade
101
101
  if package.dir
102
102
  schema_path = Ree::PathHelper.abs_package_schema_path(package)
103
103
 
104
- if !File.exists?(schema_path)
104
+ if !File.exist?(schema_path)
105
105
  raise Ree::Error.new("File does not exist: #{schema_path}", :invalid_path)
106
106
  end
107
107
 
@@ -126,7 +126,7 @@ class Ree::PackagesFacade
126
126
 
127
127
  schema_path = Ree::PathHelper.abs_object_schema_path(object)
128
128
 
129
- if !File.exists?(schema_path)
129
+ if !File.exist?(schema_path)
130
130
  only_dir_path = schema_path.split('/')[0..-2]
131
131
  FileUtils.mkdir_p(File.join(only_dir_path))
132
132
  end
@@ -80,7 +80,7 @@ class Ree::TemplateHandler
80
80
  rendered_abs_path = Ree::TemplateRenderer.handle(get_destination_path(path), @locals)
81
81
  rendered_rel_path = Pathname.new(rendered_abs_path).relative_path_from Pathname.new(project_path)
82
82
 
83
- if File.file?(rendered_abs_path) && File.exists?(rendered_abs_path)
83
+ if File.file?(rendered_abs_path) && File.exist?(rendered_abs_path)
84
84
  @stdout.puts "Warning! #{rendered_rel_path} already exists. Skipping file creation..."
85
85
  next
86
86
  end
data/lib/ree/link_dsl.rb CHANGED
@@ -107,10 +107,10 @@ module Ree::LinkDSL
107
107
  Ree::PACKAGE, path
108
108
  )
109
109
 
110
- if !File.exists?(file_path)
110
+ if !File.exist?(file_path)
111
111
  file_path = "#{file_path}.rb"
112
112
 
113
- if !File.exists?(file_path)
113
+ if !File.exist?(file_path)
114
114
  _raise_error("Unable to link '#{path}'. File not found #{file_path}")
115
115
  end
116
116
  end
@@ -1,19 +1,61 @@
1
1
  module Ree::RSpecLinkDSL
2
- def link(obj_name, as: nil, from:)
3
- obj = Ree.container.compile(from, obj_name)
2
+ def link(obj_name, import_proc = nil, as: nil, from: nil)
3
+ if obj_name.is_a?(Symbol)
4
+ obj = link_object(from, obj_name)
4
5
 
5
- if obj.nil?
6
- raise Ree::Error.new("object :#{obj_name} was not found for package :#{from}")
7
- end
8
-
9
- as ||= obj_name
10
-
11
- define_method as do |*args, **kwargs, &proc|
12
- if obj.object?
13
- obj.klass.new
14
- else
15
- obj.klass.new.call(*args, **kwargs, &proc)
6
+ if obj.nil?
7
+ raise Ree::Error.new("object :#{obj_name} was not found for package :#{from}")
8
+ end
9
+
10
+ as ||= obj_name
11
+
12
+ define_method as do |*args, **kwargs, &proc|
13
+ if obj.object?
14
+ obj.klass.new
15
+ else
16
+ obj.klass.new.call(*args, **kwargs, &proc)
17
+ end
16
18
  end
19
+ elsif obj_name.is_a?(String)
20
+ const_list = link_file(from, obj_name, import_proc)
21
+ const_list.each do |const|
22
+ Object.const_set(const.name, self.const_get(const.name))
23
+ end
24
+ else
25
+ raise Ree::Error.new("Invalid link DSL usage. Args should be Hash or String")
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def link_object(from_package_name, obj_name)
32
+ Ree.container.compile(from_package_name, obj_name)
33
+ end
34
+
35
+ def link_file(from_package_name, path, import_proc)
36
+ Ree.container.packages_facade.load_package_entry(from_package_name)
37
+ package = Ree.container.packages_facade.get_package(from_package_name)
38
+
39
+ file_path = File.join(
40
+ Ree::PathHelper.abs_package_dir(package),
41
+ Ree::PACKAGE, path
42
+ )
43
+ Ree.container.packages_facade.load_file(file_path, package.name)
44
+
45
+ const_list = path.split('/').map { |_| Ree::StringUtils.camelize(_) }
46
+ const_short = [const_list[0], const_list.last].join("::")
47
+ const_long = const_list.join("::")
48
+
49
+ file_const = if Object.const_defined?(const_long)
50
+ Object.const_get(const_long)
51
+ elsif Object.const_defined?(const_short)
52
+ Object.const_get(const_short)
53
+ else
54
+ raise Ree::Error.new("Unable to link '#{path}'. #{const_long} or #{const_short} was not defined in #{file_path}")
17
55
  end
56
+
57
+ const_list = Ree::LinkImportBuilder
58
+ .new(Ree.container.packages_facade)
59
+ .build_for_const(self, file_const, import_proc)
18
60
  end
19
61
  end
@@ -26,7 +26,7 @@ class Ree::TemplateDetector
26
26
  def template_file_path(template_name, relative_path)
27
27
  file_path = [detect_template_folder(template_name), DEFAULT_TEMPLATES_DIRECTORY]
28
28
  .map {|folder| File.join(folder, relative_path)}
29
- .detect {|file| File.exists?(file)}
29
+ .detect {|file| File.exist?(file)}
30
30
 
31
31
  raise Ree::Error.new('Template does not exist') if file_path.nil?
32
32
 
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.8"
4
+ VERSION = "1.0.10"
5
5
  end
data/lib/ree.rb CHANGED
@@ -144,7 +144,7 @@ module Ree
144
144
  def init(dir, irb: false)
145
145
  check_arg(dir, :dir, String)
146
146
 
147
- if !Dir.exists?(dir)
147
+ if !Dir.exist?(dir)
148
148
  raise Ree::Error.new("Dir does not exist: #{dir}", :invalid_root_dir)
149
149
  end
150
150
 
@@ -153,7 +153,7 @@ module Ree
153
153
 
154
154
  ree_setup_path = File.join(@root_dir, REE_SETUP)
155
155
 
156
- if File.exists?(ree_setup_path)
156
+ if File.exist?(ree_setup_path)
157
157
  require(ree_setup_path)
158
158
  end
159
159
 
@@ -192,7 +192,7 @@ module Ree
192
192
  raise Ree::Error.new("Ree already registered gem `#{name}`", :duplicate_gem)
193
193
  end
194
194
 
195
- if !Dir.exists?(dir)
195
+ if !Dir.exist?(dir)
196
196
  raise Ree::Error.new("Dir does not exist: #{dir}", :invalid_gem_dir)
197
197
  end
198
198
 
@@ -201,7 +201,7 @@ module Ree
201
201
  gem_dir = Pathname.new(packages_schema_path).dirname.to_s
202
202
  ree_setup_path = File.join(gem_dir, REE_SETUP)
203
203
 
204
- if File.exists?(ree_setup_path)
204
+ if File.exist?(ree_setup_path)
205
205
  require(ree_setup_path)
206
206
  end
207
207
 
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.8
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-25 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  - !ruby/object:Gem::Version
210
210
  version: '0'
211
211
  requirements: []
212
- rubygems_version: 3.3.7
212
+ rubygems_version: 3.3.24
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: Ruby framework to create modular applications