ree 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/ree +44 -0
- data/lib/ree/cli/index_file.rb +71 -0
- data/lib/ree/cli/index_project.rb +70 -0
- data/lib/ree/cli.rb +2 -0
- data/lib/ree/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ab958ee043c81bd88eb63c97ae9bb27a93e653e0488f14f46d9ec6d6b1e3e31
|
4
|
+
data.tar.gz: 7f41c692cafddc219cbb9a9ba3191b930a59b204d2a20d1ad873291dfdb335f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a93a7e5cc610dad542897ca0f35c61650a93b13dd784a1030c7f94d794e24bae48bb3cc3a11c652737e27902418e67c35089064a0ce66547c745f557ba4166
|
7
|
+
data.tar.gz: 16b33f81947babead599ac94c95746915a05e858d3b9be38c45761b3425cdf5be868e93279378b37c6af523b6b0928a6f476f701b596b454df21430d933e087a
|
data/Gemfile.lock
CHANGED
data/exe/ree
CHANGED
@@ -309,6 +309,50 @@ class ReeCliRunner
|
|
309
309
|
end
|
310
310
|
end
|
311
311
|
|
312
|
+
command :"gen.index_project" do |c|
|
313
|
+
c.syntax = 'ree gen.index_project'
|
314
|
+
c.description = 'generate index schema of methods'
|
315
|
+
c.summary = '> ' + c.description
|
316
|
+
c.example 'ree gen.index_project --project_path=/project_dir/', ''
|
317
|
+
c.option '--project_path [ROOT_PROJECT_DIR]', String, 'Root project dir path'
|
318
|
+
c.action do |args, options|
|
319
|
+
options_hash = options.__hash__
|
320
|
+
|
321
|
+
if options_hash[:project_path]
|
322
|
+
options_hash[:project_path] = File.expand_path(options_hash[:project_path])
|
323
|
+
end
|
324
|
+
|
325
|
+
default_options = {
|
326
|
+
project_path: options_hash[:project_path] || File.expand_path(Dir.pwd)
|
327
|
+
}
|
328
|
+
|
329
|
+
puts Ree::CLI::IndexProject.run(**default_options)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
command :"gen.index_file" do |c|
|
334
|
+
c.syntax = 'ree gen.index_file FILE_PATH'
|
335
|
+
c.description = 'generate index schema of methods'
|
336
|
+
c.summary = '> ' + c.description
|
337
|
+
c.example 'ree gen.index /app/bc/accounts/commands/create_account_cmd.rb --project_path=/project_dir/', ''
|
338
|
+
c.option '--project_path [ROOT_PROJECT_DIR]', String, 'Root project dir path'
|
339
|
+
c.action do |args, options|
|
340
|
+
file_path = args[0]
|
341
|
+
options_hash = options.__hash__
|
342
|
+
|
343
|
+
if options_hash[:project_path]
|
344
|
+
options_hash[:project_path] = File.expand_path(options_hash[:project_path])
|
345
|
+
end
|
346
|
+
|
347
|
+
default_options = {
|
348
|
+
file_path: file_path,
|
349
|
+
project_path: options_hash[:project_path] || File.expand_path(Dir.pwd)
|
350
|
+
}
|
351
|
+
|
352
|
+
puts Ree::CLI::IndexFile.run(**default_options)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
312
356
|
run!
|
313
357
|
end
|
314
358
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Ree
|
4
|
+
module CLI
|
5
|
+
class IndexFile
|
6
|
+
class << self
|
7
|
+
def run(file_path:, project_path:)
|
8
|
+
ENV['REE_SKIP_ENV_VARS_CHECK'] = 'true'
|
9
|
+
|
10
|
+
path = Ree.locate_packages_schema(project_path)
|
11
|
+
dir = Pathname.new(path).dirname.to_s
|
12
|
+
|
13
|
+
Ree.init(dir)
|
14
|
+
|
15
|
+
file_path = File.join(dir, file_path)
|
16
|
+
|
17
|
+
current_package_schema = self.find_package(File.dirname(file_path))
|
18
|
+
|
19
|
+
return {} unless current_package_schema
|
20
|
+
|
21
|
+
package_schema = JSON.load_file(current_package_schema)
|
22
|
+
current_package_name = package_schema["name"].to_sym
|
23
|
+
|
24
|
+
facade = Ree.container.packages_facade
|
25
|
+
Ree.load_package(current_package_name)
|
26
|
+
|
27
|
+
package = facade.get_package(current_package_name)
|
28
|
+
objects_class_names = package.objects.map(&:class_name)
|
29
|
+
file_name_const_string = Ree::StringUtils.camelize(file_path.split('/')[-1].split('.rb')[0])
|
30
|
+
const_string_with_module = "#{package.module}::#{file_name_const_string}"
|
31
|
+
|
32
|
+
return {} if objects_class_names.include?(const_string_with_module) # skip objects
|
33
|
+
|
34
|
+
klass = Object.const_get(const_string_with_module)
|
35
|
+
|
36
|
+
methods = klass
|
37
|
+
.public_instance_methods(false)
|
38
|
+
.reject { _1.match?(/original/) } # remove aliases defined by contracts
|
39
|
+
.map {
|
40
|
+
{
|
41
|
+
name: _1,
|
42
|
+
location: klass.public_instance_method(_1).source_location&.last,
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
hsh = {
|
47
|
+
path: file_path,
|
48
|
+
package: current_package_name,
|
49
|
+
methods: methods
|
50
|
+
}
|
51
|
+
|
52
|
+
JSON.pretty_generate({ file_name_const_string => hsh })
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_package(dir)
|
56
|
+
package_schema = File.join(dir, Ree::PACKAGE_SCHEMA_FILE)
|
57
|
+
|
58
|
+
if File.exist?(package_schema)
|
59
|
+
return package_schema
|
60
|
+
end
|
61
|
+
|
62
|
+
if dir == '/'
|
63
|
+
return nil
|
64
|
+
end
|
65
|
+
|
66
|
+
find_package(File.expand_path('..', dir))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Ree
|
2
|
+
module CLI
|
3
|
+
class IndexProject
|
4
|
+
class << self
|
5
|
+
def run(project_path:)
|
6
|
+
ENV['REE_SKIP_ENV_VARS_CHECK'] = 'true'
|
7
|
+
|
8
|
+
path = Ree.locate_packages_schema(project_path)
|
9
|
+
dir = Pathname.new(path).dirname.to_s
|
10
|
+
|
11
|
+
Ree.init(dir)
|
12
|
+
|
13
|
+
index_hash = {}
|
14
|
+
index_hash[:classes] = {}
|
15
|
+
|
16
|
+
facade = Ree.container.packages_facade
|
17
|
+
|
18
|
+
facade.packages_store.packages.each do |package|
|
19
|
+
next if package.gem?
|
20
|
+
next if package.dir.nil?
|
21
|
+
|
22
|
+
facade.load_entire_package(package.name)
|
23
|
+
|
24
|
+
objects_class_names = package.objects.map(&:class_name)
|
25
|
+
|
26
|
+
files = Dir[
|
27
|
+
File.join(
|
28
|
+
Ree::PathHelper.abs_package_module_dir(package), '**/*.rb'
|
29
|
+
)
|
30
|
+
]
|
31
|
+
|
32
|
+
files.each do |file_name|
|
33
|
+
begin
|
34
|
+
file_name_const_string = Ree::StringUtils.camelize(file_name.split('/')[-1].split('.rb')[0])
|
35
|
+
const_string_with_module = "#{package.module}::#{file_name_const_string}"
|
36
|
+
|
37
|
+
next if objects_class_names.include?(const_string_with_module) # skip objects
|
38
|
+
|
39
|
+
klass = Object.const_get(const_string_with_module)
|
40
|
+
|
41
|
+
methods = klass
|
42
|
+
.public_instance_methods(false)
|
43
|
+
.reject { _1.match?(/original/) } # remove aliases defined by contracts
|
44
|
+
.map {
|
45
|
+
{
|
46
|
+
name: _1,
|
47
|
+
location: klass.public_instance_method(_1).source_location&.last,
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
hsh = {
|
52
|
+
path: file_name,
|
53
|
+
package: package.name,
|
54
|
+
methods: methods
|
55
|
+
}
|
56
|
+
|
57
|
+
index_hash[:classes][file_name_const_string] ||= []
|
58
|
+
index_hash[:classes][file_name_const_string] << hsh
|
59
|
+
rescue NameError
|
60
|
+
next
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
JSON.pretty_generate(index_hash)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/ree/cli.rb
CHANGED
@@ -9,6 +9,8 @@ module Ree
|
|
9
9
|
autoload :DeleteObjectSchema, 'ree/cli/delete_object_schema'
|
10
10
|
autoload :GeneratePackage, 'ree/cli/generate_package'
|
11
11
|
autoload :GenerateTemplate, 'ree/cli/generate_template'
|
12
|
+
autoload :IndexProject, 'ree/cli/index_project'
|
13
|
+
autoload :IndexFile, 'ree/cli/index_file'
|
12
14
|
autoload :SpecRunner, 'ree/cli/spec_runner'
|
13
15
|
end
|
14
16
|
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.11
|
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-11-
|
11
|
+
date: 2022-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -69,6 +69,8 @@ files:
|
|
69
69
|
- lib/ree/cli/generate_package_schema.rb
|
70
70
|
- lib/ree/cli/generate_packages_schema.rb
|
71
71
|
- lib/ree/cli/generate_template.rb
|
72
|
+
- lib/ree/cli/index_file.rb
|
73
|
+
- lib/ree/cli/index_project.rb
|
72
74
|
- lib/ree/cli/init.rb
|
73
75
|
- lib/ree/cli/spec_runner.rb
|
74
76
|
- lib/ree/container.rb
|