ree 1.0.21 → 1.0.22

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: ca13d5ef496d85f47eadd745809ae723ecc4753c465aaa3f4ac6765a9d59d613
4
- data.tar.gz: f8aca8861e7fa1cddc8bd254abf4cff4967376284c6df859357daa361bfe1f15
3
+ metadata.gz: 972811cf5375f041b94d6b27312ec7abf79301c5d3bf84e28e2bd386250ff069
4
+ data.tar.gz: 5da92138c93885000b6dad4b0f6a380ef1ab3edec2967b1a814fac8a9419128c
5
5
  SHA512:
6
- metadata.gz: 50493c271f9a3abea47885f3c83308b3e2149891f1f0f0b0dccd4f43a0608b7a8df3f5e43131c109902f19c959e7ff68ea3cd8a669fd0ed48c34c4c5b132dc40
7
- data.tar.gz: e95bc7ba3124029e388ddb34fa4de0d6cf5b1e775df18095ad48ebab1891a4a27944f5bc8ad87265615da5a7e036ac7971ac0f6e6092fc980ed97a0381372a40
6
+ metadata.gz: e3e656e9eb4edfde775740363105ec9fb08ecd53ab0d1dcae016c1d3d29580601a4f41b3d0474932996edb1c6807c971950babf2397df753db9883227897c698
7
+ data.tar.gz: 126671be60919618cedc2381cf5aaff4b3a4fb4b65c2d1e50a8821c5394612cdf93b845df4ac5df2d371521ed3b2e7334b8280108d2ab42d5d1eda3274e2b7d6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.21)
4
+ ree (1.0.22)
5
5
  commander (~> 4.6.0)
6
6
 
7
7
  GEM
@@ -22,6 +22,16 @@ module Ree
22
22
  if File.exist?(abs_schema_path)
23
23
  FileUtils.rm(abs_schema_path)
24
24
 
25
+ facade = Ree.container.packages_facade
26
+ package_name = Ree::PathHelper.package_name_from_dir(File.dirname(object_path))
27
+ if package_name
28
+ package_name = package_name.to_sym
29
+ facade.load_package_entry(package_name)
30
+ package = facade.get_package(package_name)
31
+ package.remove_object(object_name)
32
+ facade.dump_package_schema(package_name)
33
+ end
34
+
25
35
  puts(" #{schema_path}: is deleted") if !silence
26
36
  end
27
37
 
@@ -14,16 +14,25 @@ module Ree
14
14
 
15
15
  facade = Ree.container.packages_facade
16
16
 
17
+ hsh = {}
18
+ hsh[:package_schema] = {}
19
+ hsh[:classes] = {}
20
+ hsh[:objects] = {}
21
+
17
22
  package_name = package_name.to_sym
23
+ facade.load_entire_package(package_name)
18
24
  package = facade.get_loaded_package(package_name)
19
- package_hsh = map_package_entry(package)
25
+ package_hsh = index_package_entry(package)
26
+
27
+ hsh[:package_schema] = package_hsh
28
+ hsh = index_package_files(package, dir, hsh)
20
29
 
21
- JSON.pretty_generate(package_hsh)
30
+ JSON.pretty_generate(hsh)
22
31
  end
23
32
 
24
33
  private
25
34
 
26
- def map_package_entry(package)
35
+ def index_package_entry(package)
27
36
  package_hsh = {}
28
37
  package_hsh[:name] = package.name
29
38
  package_hsh[:schema_rpath] = package.schema_rpath
@@ -110,6 +119,10 @@ module Ree
110
119
  }
111
120
  ]
112
121
  end
122
+
123
+ def index_package_files(package, dir, index_hash)
124
+ Ree::CLI::IndexProject.send(:index_package_files, package, dir, index_hash)
125
+ end
113
126
  end
114
127
  end
115
128
  end
@@ -10,16 +10,15 @@ module Ree
10
10
 
11
11
  Ree.init(dir)
12
12
 
13
- @index_hash = {}
13
+ index_hash = {}
14
14
  # completion/etc data
15
- @index_hash[:classes] = {}
16
- @index_hash[:objects] = {}
15
+ index_hash[:classes] = {}
16
+ index_hash[:objects] = {}
17
17
 
18
18
  # schema data
19
- @index_hash[:gem_paths] = {}
20
- @index_hash[:packages_schema] = {}
21
- @index_hash[:packages_schema][:packages] = []
22
- @index_hash[:packages_schema][:gem_packages] = []
19
+ index_hash[:packages_schema] = {}
20
+ index_hash[:packages_schema][:packages] = []
21
+ index_hash[:packages_schema][:gem_packages] = []
23
22
 
24
23
  facade = Ree.container.packages_facade
25
24
 
@@ -48,7 +47,7 @@ module Ree
48
47
  }
49
48
  }
50
49
 
51
- @index_hash[:packages_schema][:gem_packages] << gem_package_hsh
50
+ index_hash[:packages_schema][:gem_packages] << gem_package_hsh
52
51
 
53
52
  next
54
53
  end
@@ -57,61 +56,76 @@ module Ree
57
56
 
58
57
  facade.load_entire_package(package.name)
59
58
 
60
- package_hsh = Ree::CLI::IndexPackage.send(:map_package_entry, package)
59
+ package_hsh = Ree::CLI::IndexPackage.send(:index_package_entry, package)
61
60
 
62
- @index_hash[:packages_schema][:packages] << package_hsh
61
+ index_hash[:packages_schema][:packages] << package_hsh
63
62
 
64
- objects_class_names = package.objects.map(&:class_name)
63
+ index_hash = index_package_files(package, dir, index_hash)
64
+ end
65
65
 
66
- files = Dir[
67
- File.join(
68
- Ree::PathHelper.abs_package_module_dir(package), '**/*.rb'
69
- )
70
- ]
66
+ if facade.get_package(:ree_errors, false)
67
+ index_hash = index_exceptions(facade.get_package(:ree_errors), index_hash)
68
+ end
71
69
 
72
- files.each do |file_name|
73
- begin
74
- const_string_from_file_name = Ree::StringUtils.camelize(file_name.split('/')[-1].split('.rb')[0])
75
- const_string_with_module = "#{package.module}::#{const_string_from_file_name}"
76
- klass = Object.const_get(const_string_with_module)
70
+ JSON.pretty_generate(index_hash)
71
+ end
77
72
 
78
- if klass.include?(ReeEnum::DSL)
79
- index_enum(klass, file_name, package.name, dir, const_string_from_file_name)
73
+ private
80
74
 
81
- next
82
- end
75
+ def index_package_files(package, dir, index_hash)
76
+ objects_class_names = package.objects.map(&:class_name)
83
77
 
84
- if klass.include?(ReeDao::DSL)
85
- index_dao(klass, file_name, package.name, dir, const_string_from_file_name)
86
- next
87
- end
78
+ files = Dir[
79
+ File.join(
80
+ Ree::PathHelper.abs_package_module_dir(package), '**/*.rb'
81
+ )
82
+ ]
88
83
 
89
- if klass.include?(ReeMapper::DSL)
90
- # TODO
91
- next
92
- end
84
+ files.each do |file_name|
85
+ begin
86
+ const_string_from_file_name = Ree::StringUtils.camelize(file_name.split('/')[-1].split('.rb')[0])
87
+ const_string_with_module = "#{package.module}::#{const_string_from_file_name}"
88
+ klass = Object.const_get(const_string_with_module)
93
89
 
94
- if !objects_class_names.include?(const_string_with_module)
95
- index_class(klass, file_name, package.name, dir, const_string_from_file_name)
90
+ if klass.include?(ReeEnum::DSL)
91
+ hsh = index_enum(klass, file_name, package.name, dir, const_string_from_file_name)
92
+ hash_key = const_string_from_file_name
93
+ index_hash[:classes][hash_key] ||= []
94
+ index_hash[:classes][hash_key] << hsh
96
95
 
97
- next
98
- end
99
- rescue NameError
100
96
  next
101
97
  end
102
- end
103
- end
104
98
 
105
- if facade.get_package(:ree_errors, false)
106
- index_exceptions(facade.get_package(:ree_errors))
99
+ if klass.include?(ReeDao::DSL)
100
+ hsh = index_dao(klass, file_name, package.name, dir, const_string_from_file_name)
101
+ obj_name_key = Ree::StringUtils.underscore(const_string_from_file_name)
102
+ index_hash[:objects][obj_name_key] ||= []
103
+ index_hash[:objects][obj_name_key] << hsh
104
+
105
+ next
106
+ end
107
+
108
+ if klass.include?(ReeMapper::DSL)
109
+ # TODO
110
+ next
111
+ end
112
+
113
+ if !objects_class_names.include?(const_string_with_module)
114
+ hsh = index_class(klass, file_name, package.name, dir, const_string_from_file_name)
115
+ hash_key = const_string_from_file_name
116
+ index_hash[:classes][hash_key] ||= []
117
+ index_hash[:classes][hash_key] << hsh
118
+
119
+ next
120
+ end
121
+ rescue NameError
122
+ next
123
+ end
107
124
  end
108
-
109
125
 
110
- JSON.pretty_generate(@index_hash)
126
+ index_hash
111
127
  end
112
128
 
113
- private
114
-
115
129
  def index_class(klass, file_name, package_name, root_dir, hash_key)
116
130
  all_methods = klass.public_instance_methods(false)
117
131
  orig_methods = all_methods.grep(/original/)
@@ -127,14 +141,12 @@ module Ree
127
141
  }
128
142
 
129
143
  rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
130
- hsh = {
144
+
145
+ {
131
146
  path: rpath_from_root_file_path,
132
147
  package: package_name,
133
148
  methods: methods
134
149
  }
135
-
136
- @index_hash[:classes][hash_key] ||= []
137
- @index_hash[:classes][hash_key] << hsh
138
150
  end
139
151
 
140
152
  def index_enum(klass, file_name, package_name, root_dir, hash_key)
@@ -152,20 +164,16 @@ module Ree
152
164
  }
153
165
  }
154
166
 
155
- obj_name_key = Ree::StringUtils.underscore(hash_key)
156
167
  rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
157
168
 
158
- hsh = {
169
+ {
159
170
  path: rpath_from_root_file_path,
160
171
  package: package_name,
161
172
  methods: filters
162
173
  }
163
-
164
- @index_hash[:objects][obj_name_key] ||= []
165
- @index_hash[:objects][obj_name_key] << hsh
166
174
  end
167
175
 
168
- def index_exceptions(errors_package)
176
+ def index_exceptions(errors_package, index_hash)
169
177
  errors_package.objects.each do |obj|
170
178
  const_name = obj.class_name.split("::")[-1]
171
179
  file_name = File.join(
@@ -179,9 +187,11 @@ module Ree
179
187
  methods: []
180
188
  }
181
189
 
182
- @index_hash[:classes][const_name] ||= []
183
- @index_hash[:classes][const_name] << hsh
190
+ index_hash[:classes][const_name] ||= []
191
+ index_hash[:classes][const_name] << hsh
184
192
  end
193
+
194
+ index_hash
185
195
  end
186
196
  end
187
197
  end
data/lib/ree/cli.rb CHANGED
@@ -9,9 +9,9 @@ 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'
14
- autoload :IndexPackage, 'ree/cli/index_package'
12
+ autoload :IndexProject, 'ree/cli/indexing/index_project'
13
+ autoload :IndexFile, 'ree/cli/indexing/index_file'
14
+ autoload :IndexPackage, 'ree/cli/indexing/index_package'
15
15
  autoload :SpecRunner, 'ree/cli/spec_runner'
16
16
  end
17
17
  end
@@ -165,6 +165,16 @@ class Ree::Package
165
165
  @objects_store[object.name] = object
166
166
  end
167
167
 
168
+ # @param [Symbol] name
169
+ # @return [nil]
170
+ def remove_object(name)
171
+ if @objects_store[name]
172
+ @objects_store.delete(name)
173
+ end
174
+
175
+ nil
176
+ end
177
+
168
178
  # @param [Symbol] name
169
179
  # @return [Nilor[Ree::Object]]
170
180
  def get_object(name)
@@ -52,6 +52,22 @@ class Ree::PathHelper
52
52
  File.join(dir, "#{Ree::PACKAGE}/#{name}.rb")
53
53
  end
54
54
 
55
+ # @param [String] directory inside package
56
+ # @return [String] name of package
57
+ def package_name_from_dir(dir)
58
+ package_schema = File.join(dir, Ree::PACKAGE_SCHEMA_FILE)
59
+
60
+ if File.exist?(package_schema)
61
+ return package_schema.split('/')[-2]
62
+ end
63
+
64
+ if dir == '/'
65
+ return nil
66
+ end
67
+
68
+ package_name_from_dir(File.expand_path('..', dir))
69
+ end
70
+
55
71
  # @param [Ree::Package] package Package schema
56
72
  # @return [String] Absolute package entry path (ex. /data/project/bc/accounts/package/accounts.rb)
57
73
  def abs_package_entry_path(package)
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.21"
4
+ VERSION = "1.0.22"
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.21
4
+ version: 1.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -69,9 +69,9 @@ 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_package.rb
74
- - lib/ree/cli/index_project.rb
72
+ - lib/ree/cli/indexing/index_file.rb
73
+ - lib/ree/cli/indexing/index_package.rb
74
+ - lib/ree/cli/indexing/index_project.rb
75
75
  - lib/ree/cli/init.rb
76
76
  - lib/ree/cli/spec_runner.rb
77
77
  - lib/ree/container.rb