ree 1.0.11 → 1.0.13

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: 4ab958ee043c81bd88eb63c97ae9bb27a93e653e0488f14f46d9ec6d6b1e3e31
4
- data.tar.gz: 7f41c692cafddc219cbb9a9ba3191b930a59b204d2a20d1ad873291dfdb335f2
3
+ metadata.gz: f161bd31a19bf61834065dd4dab0a875d275eaa6bde5c29941d8ea8ec8b267cf
4
+ data.tar.gz: 3d8350795235645b86bd4abcd926d6de5818aebf75e9622c99427047572bf075
5
5
  SHA512:
6
- metadata.gz: a6a93a7e5cc610dad542897ca0f35c61650a93b13dd784a1030c7f94d794e24bae48bb3cc3a11c652737e27902418e67c35089064a0ce66547c745f557ba4166
7
- data.tar.gz: 16b33f81947babead599ac94c95746915a05e858d3b9be38c45761b3425cdf5be868e93279378b37c6af523b6b0928a6f476f701b596b454df21430d933e087a
6
+ metadata.gz: 3e72a0f2728261d609c943a07292f93ef076818cba7fe0502517006b1b18b2fa65bbab5b0e1019737bf5f6ad1c2f49c22caf5597feddeec6566c242f187c0d7e
7
+ data.tar.gz: 541cebae73096e5b4798d7580d8bd11f21ca7fcdf3bf7ccc28c33b423ae587b4c246ed93a25d5e67535ef4316905dade9987e64c48fee82b5818969baacb73df
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.11)
4
+ ree (1.0.13)
5
5
  commander (~> 4.6.0)
6
6
 
7
7
  GEM
@@ -25,6 +25,15 @@ module Ree
25
25
  Ree.load_package(current_package_name)
26
26
 
27
27
  package = facade.get_package(current_package_name)
28
+
29
+ files = Dir[
30
+ File.join(
31
+ Ree::PathHelper.abs_package_module_dir(package), '**/*.rb'
32
+ )
33
+ ]
34
+
35
+ return {} if !files.include?(file_path)
36
+
28
37
  objects_class_names = package.objects.map(&:class_name)
29
38
  file_name_const_string = Ree::StringUtils.camelize(file_path.split('/')[-1].split('.rb')[0])
30
39
  const_string_with_module = "#{package.module}::#{file_name_const_string}"
@@ -10,8 +10,9 @@ module Ree
10
10
 
11
11
  Ree.init(dir)
12
12
 
13
- index_hash = {}
14
- index_hash[:classes] = {}
13
+ @index_hash = {}
14
+ @index_hash[:classes] = {}
15
+ @index_hash[:objects] = {}
15
16
 
16
17
  facade = Ree.container.packages_facade
17
18
 
@@ -31,38 +32,114 @@ module Ree
31
32
 
32
33
  files.each do |file_name|
33
34
  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}"
35
+ const_string_from_file_name = Ree::StringUtils.camelize(file_name.split('/')[-1].split('.rb')[0])
36
+ const_string_with_module = "#{package.module}::#{const_string_from_file_name}"
37
+ klass = Object.const_get(const_string_with_module)
36
38
 
37
- next if objects_class_names.include?(const_string_with_module) # skip objects
39
+ if klass.include?(ReeEnum::DSL)
40
+ index_enum(klass, file_name, package.name, dir, const_string_from_file_name)
38
41
 
39
- klass = Object.const_get(const_string_with_module)
42
+ next
43
+ end
44
+
45
+ if klass.include?(ReeDao::DSL)
46
+ index_dao(klass, file_name, package.name, dir, const_string_from_file_name)
47
+ next
48
+ end
40
49
 
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
50
+ if klass.include?(ReeMapper::DSL)
51
+ # TODO
52
+ next
53
+ end
54
+
55
+ if !objects_class_names.include?(const_string_with_module)
56
+ index_class(klass, file_name, package.name, dir, const_string_from_file_name)
57
+
58
+ next
59
+ end
59
60
  rescue NameError
60
61
  next
61
62
  end
62
63
  end
63
64
  end
64
65
 
65
- JSON.pretty_generate(index_hash)
66
+ if facade.get_package(:ree_errors, false)
67
+ index_exceptions(facade.get_package(:ree_errors))
68
+ end
69
+
70
+
71
+ JSON.pretty_generate(@index_hash)
72
+ end
73
+
74
+ private
75
+
76
+ def index_class(klass, file_name, package_name, root_dir, hash_key)
77
+ methods = klass
78
+ .public_instance_methods(false)
79
+ .reject { _1.match?(/original/) } # remove aliases defined by contracts
80
+ .map {
81
+ {
82
+ name: _1,
83
+ location: klass.public_instance_method(_1).source_location&.last,
84
+ }
85
+ }
86
+
87
+ rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
88
+ hsh = {
89
+ path: rpath_from_root_file_path,
90
+ package: package_name,
91
+ methods: methods
92
+ }
93
+
94
+ @index_hash[:classes][hash_key] ||= []
95
+ @index_hash[:classes][hash_key] << hsh
96
+ end
97
+
98
+ def index_enum(klass, file_name, package_name, root_dir, hash_key)
99
+ index_class(klass, file_name, package_name, root_dir, hash_key)
100
+ end
101
+
102
+ def index_dao(klass, file_name, package_name, root_dir, hash_key)
103
+ filters = klass
104
+ .instance_variable_get(:@filters)
105
+ .map {
106
+ {
107
+ name: _1.name,
108
+ parameters: _1.proc.parameters.map { |param| { name: param.last, required: param.first } },
109
+ location: _1.proc&.source_location&.last
110
+ }
111
+ }
112
+
113
+ obj_name_key = Ree::StringUtils.underscore(hash_key)
114
+ rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
115
+
116
+ hsh = {
117
+ path: rpath_from_root_file_path,
118
+ package: package_name,
119
+ methods: filters
120
+ }
121
+
122
+ @index_hash[:objects][obj_name_key] ||= []
123
+ @index_hash[:objects][obj_name_key] << hsh
124
+ end
125
+
126
+ def index_exceptions(errors_package)
127
+ errors_package.objects.each do |obj|
128
+ const_name = obj.class_name.split("::")[-1]
129
+ file_name = File.join(
130
+ Ree::PathHelper.abs_package_module_dir(errors_package),
131
+ obj.name.to_s + ".rb"
132
+ )
133
+
134
+ hsh = {
135
+ path: file_name,
136
+ package: errors_package.name,
137
+ methods: []
138
+ }
139
+
140
+ @index_hash[:classes][const_name] ||= []
141
+ @index_hash[:classes][const_name] << hsh
142
+ end
66
143
  end
67
144
  end
68
145
  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.11"
4
+ VERSION = "1.0.13"
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.11
4
+ version: 1.0.13
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-23 00:00:00.000000000 Z
11
+ date: 2022-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander