ree 1.0.22 → 1.0.23

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 972811cf5375f041b94d6b27312ec7abf79301c5d3bf84e28e2bd386250ff069
4
- data.tar.gz: 5da92138c93885000b6dad4b0f6a380ef1ab3edec2967b1a814fac8a9419128c
3
+ metadata.gz: 60b602bd07b9adc8ba5cbcee420750e3b2d5266056c888ad750115cbb393c4ea
4
+ data.tar.gz: 1431632c86f3dacee9ad1f4fee6550e3a56b06dca780d0d3c6c46245c812b407
5
5
  SHA512:
6
- metadata.gz: e3e656e9eb4edfde775740363105ec9fb08ecd53ab0d1dcae016c1d3d29580601a4f41b3d0474932996edb1c6807c971950babf2397df753db9883227897c698
7
- data.tar.gz: 126671be60919618cedc2381cf5aaff4b3a4fb4b65c2d1e50a8821c5394612cdf93b845df4ac5df2d371521ed3b2e7334b8280108d2ab42d5d1eda3274e2b7d6
6
+ metadata.gz: 58c730e7c3930abe99115bdaffa4175b886c29dd67ef7575b196f6284782f192722dfd706e5e6174808b1cdb0ab0126a216cfa1ccfa6d99fe0a287289e63d708
7
+ data.tar.gz: 67ebd3b56bed90000f00033e7a7cd9f2a5959df2dd4acc58f168e5830c49bf989b3ba74fdf77902d3e0ceec921de7180a55185e5665f33294316e8d0074f51ca
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.22)
4
+ ree (1.0.23)
5
5
  commander (~> 4.6.0)
6
6
 
7
7
  GEM
data/lib/ree/bean_dsl.rb CHANGED
@@ -16,6 +16,7 @@ module Ree::BeanDSL
16
16
  )
17
17
 
18
18
  dsl.instance_exec(&proc) if block_given?
19
+ dsl.tags(["object"])
19
20
  dsl.object.set_as_compiled(false)
20
21
 
21
22
  Ree.container.compile(dsl.package, name)
@@ -25,7 +25,7 @@ module Ree
25
25
  package_hsh = index_package_entry(package)
26
26
 
27
27
  hsh[:package_schema] = package_hsh
28
- hsh = index_package_files(package, dir, hsh)
28
+ hsh = index_public_methods_for_package_classes(package, dir, hsh)
29
29
 
30
30
  JSON.pretty_generate(hsh)
31
31
  end
@@ -120,8 +120,8 @@ module Ree
120
120
  ]
121
121
  end
122
122
 
123
- def index_package_files(package, dir, index_hash)
124
- Ree::CLI::IndexProject.send(:index_package_files, package, dir, index_hash)
123
+ def index_public_methods_for_package_classes(package, dir, index_hash)
124
+ Ree::CLI::IndexProject.send(:index_public_methods_for_package_classes, package, index_hash)
125
125
  end
126
126
  end
127
127
  end
@@ -60,7 +60,7 @@ module Ree
60
60
 
61
61
  index_hash[:packages_schema][:packages] << package_hsh
62
62
 
63
- index_hash = index_package_files(package, dir, index_hash)
63
+ index_hash = index_public_methods_for_package_classes(package, index_hash)
64
64
  end
65
65
 
66
66
  if facade.get_package(:ree_errors, false)
@@ -72,67 +72,68 @@ module Ree
72
72
 
73
73
  private
74
74
 
75
- def index_package_files(package, dir, index_hash)
76
- objects_class_names = package.objects.map(&:class_name)
77
-
78
- files = Dir[
79
- File.join(
80
- Ree::PathHelper.abs_package_module_dir(package), '**/*.rb'
81
- )
82
- ]
83
-
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)
89
-
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
95
-
96
- next
97
- end
98
-
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
75
+ def index_public_methods_for_package_classes(package, index_hash)
76
+ package.objects.each do |obj|
77
+ klass = obj.klass
78
+ klass_name = demodulize(klass.to_s)
79
+ obj_name = obj.name.to_s
80
+ rpath = obj.rpath
81
+
82
+ if obj.tags.include?("enum")
83
+ hsh = index_class(klass, rpath, package.name)
84
+ index_hash[:classes][klass_name] ||= []
85
+ index_hash[:classes][klass_name] << hsh
86
+ index_hash[:objects][obj_name] ||= []
87
+ index_hash[:objects][obj_name] << hsh
88
+ elsif obj.tags.include?("dao")
89
+ hsh = index_dao(klass, rpath, package.name)
90
+ index_hash[:objects][obj_name] ||= []
91
+ index_hash[:objects][obj_name] << hsh
92
+ elsif obj.tags.include?("object")
93
+ hsh = index_class(klass, rpath, package.name)
94
+ index_hash[:objects][obj_name] ||= []
95
+ index_hash[:objects][obj_name] << hsh
123
96
  end
124
97
  end
125
98
 
99
+ recursively_index_module(package.module, index_hash, package)
100
+
126
101
  index_hash
127
102
  end
128
103
 
129
- def index_class(klass, file_name, package_name, root_dir, hash_key)
104
+ def recursively_index_module(mod, index_hsh, package)
105
+ return if !mod.is_a?(Module)
106
+
107
+ mod.constants.each do |const_name|
108
+ const = mod.const_get(const_name)
109
+
110
+ recursively_index_module(const, index_hsh, package)
111
+
112
+ next if !const.is_a?(Class)
113
+ next if package.objects.any? { |o| o.klass == const }
114
+ next if index_hsh[:classes].has_key?(demodulize(const.name))
115
+
116
+ const_abs_path = mod.const_source_location(const.name).first
117
+ next if !const_abs_path
118
+
119
+ rpath = Pathname.new(const_abs_path).relative_path_from(Ree.root_dir).to_s
120
+ hsh = index_class(const, rpath, package.name)
121
+ class_name = demodulize(const.name)
122
+
123
+ index_hsh[:classes][class_name] ||= []
124
+ index_hsh[:classes][class_name] << hsh
125
+ end
126
+ end
127
+
128
+ def index_class(klass, rpath, package_name)
130
129
  all_methods = klass.public_instance_methods(false)
131
130
  orig_methods = all_methods.grep(/original/)
131
+
132
132
  methods = (all_methods - orig_methods) # remove aliases defined by contracts
133
133
  .map { |m|
134
134
  orig_method_name = orig_methods.find { |om| om.match(/original_#{Regexp.escape(m.name)}_[0-9a-fA-F]+/) }
135
135
  orig_method = orig_method_name ? klass.public_instance_method(orig_method_name) : nil
136
+
136
137
  {
137
138
  name: m,
138
139
  parameters: orig_method&.parameters&.map { |param| { name: param.last, required: param.first } },
@@ -140,20 +141,14 @@ module Ree
140
141
  }
141
142
  }
142
143
 
143
- rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
144
-
145
144
  {
146
- path: rpath_from_root_file_path,
145
+ path: rpath,
147
146
  package: package_name,
148
147
  methods: methods
149
148
  }
150
149
  end
151
150
 
152
- def index_enum(klass, file_name, package_name, root_dir, hash_key)
153
- index_class(klass, file_name, package_name, root_dir, hash_key)
154
- end
155
-
156
- def index_dao(klass, file_name, package_name, root_dir, hash_key)
151
+ def index_dao(klass, rpath, package_name)
157
152
  filters = klass
158
153
  .instance_variable_get(:@filters)
159
154
  .map {
@@ -164,10 +159,8 @@ module Ree
164
159
  }
165
160
  }
166
161
 
167
- rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
168
-
169
162
  {
170
- path: rpath_from_root_file_path,
163
+ path: rpath,
171
164
  package: package_name,
172
165
  methods: filters
173
166
  }
@@ -175,7 +168,7 @@ module Ree
175
168
 
176
169
  def index_exceptions(errors_package, index_hash)
177
170
  errors_package.objects.each do |obj|
178
- const_name = obj.class_name.split("::")[-1]
171
+ const_name = demodulize(obj.class_name)
179
172
  file_name = File.join(
180
173
  Ree::PathHelper.abs_package_module_dir(errors_package),
181
174
  obj.name.to_s + ".rb"
@@ -193,6 +186,10 @@ module Ree
193
186
 
194
187
  index_hash
195
188
  end
189
+
190
+ def demodulize(str)
191
+ str.split("::").last
192
+ end
196
193
  end
197
194
  end
198
195
  end
@@ -5,7 +5,7 @@ class Ree::Object
5
5
  :package_name, :factory, :after_init,
6
6
  :class_name, :links, :mount_as, :freeze,
7
7
  :errors, :linked_const_list, :compiled_frozen,
8
- :singleton
8
+ :singleton, :tags
9
9
 
10
10
  # @param [Symbol] name Object name
11
11
  # @param [String] schema_rpath Object schema path relative to project root dir
@@ -22,6 +22,7 @@ class Ree::Object
22
22
  @singleton = false
23
23
  @compiled_frozen = @freeze
24
24
  @linked_const_list = []
25
+ @tags = []
25
26
  end
26
27
 
27
28
  def reset
@@ -129,4 +130,9 @@ class Ree::Object
129
130
  def set_after_init(val)
130
131
  @after_init = val; self
131
132
  end
133
+
134
+ def add_tags(list)
135
+ @tags += list
136
+ @tags.uniq!
137
+ end
132
138
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal = true
2
2
 
3
3
  module Ree::ObjectSchema
4
- SCHEMA_VERSION_NUMBER = '1.0'
4
+ SCHEMA_VERSION_NUMBER = '1.1'
5
5
 
6
6
  SCHEMA_TYPE = 'schema_type'
7
7
  REE_VERSION = 'ree_version'
@@ -40,6 +40,7 @@ module Ree::ObjectSchema
40
40
 
41
41
  module Args
42
42
  ARG = 'arg'
43
+ ARG_TYPE = 'arg_type'
43
44
  TYPE = 'type'
44
45
  end
45
46
  end
@@ -85,6 +85,7 @@ class Ree::ObjectSchemaBuilder
85
85
 
86
86
  {
87
87
  Schema::Methods::Args::ARG => arg.name,
88
+ Schema::Methods::Args::ARG_TYPE => arg.type,
88
89
  Schema::Methods::Args::TYPE => type
89
90
  }
90
91
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal = true
2
2
 
3
3
  module Ree::PackageSchema
4
- SCHEMA_VERSION_NUMBER = '1.0'
4
+ SCHEMA_VERSION_NUMBER = '1.1'
5
5
 
6
6
  SCHEMA_TYPE = 'schema_type'
7
7
  REE_VERSION = 'ree_version'
@@ -17,6 +17,7 @@ module Ree::PackageSchema
17
17
  module Objects
18
18
  NAME = 'name'
19
19
  SCHEMA = 'schema'
20
+ TAGS = 'tags'
20
21
  end
21
22
 
22
23
  module DependsOn
@@ -36,6 +36,7 @@ class Ree::PackageSchemaBuilder
36
36
  {
37
37
  Schema::Objects::NAME => object.name,
38
38
  Schema::Objects::SCHEMA => object.schema_rpath,
39
+ Schema::Objects::TAGS => object.tags
39
40
  }
40
41
  }
41
42
  }
@@ -102,6 +102,7 @@ class Ree::PackageSchemaLoader
102
102
  name = item[Schema::Objects::NAME].to_s
103
103
  schema_rpath = item[Schema::Objects::SCHEMA].to_s
104
104
  list = [name, schema_rpath]
105
+ tags = item[Schema::Objects::TAGS] || []
105
106
 
106
107
  if list.reject(&:empty?).size != list.size
107
108
  raise Ree::Error.new("invalid object data for #{item.inspect}: #{abs_schema_path}", :invalid_package_schema)
@@ -119,6 +120,7 @@ class Ree::PackageSchemaLoader
119
120
  Ree::PathHelper.object_rpath(schema_rpath),
120
121
  )
121
122
 
123
+ object.add_tags(tags)
122
124
  object.set_package(package.name)
123
125
 
124
126
  package.set_object(object)
@@ -37,6 +37,10 @@ class Ree::ObjectDsl
37
37
  end
38
38
  end
39
39
 
40
+ def tags(list)
41
+ @object.add_tags(list)
42
+ end
43
+
40
44
  # @param [Symbol] object_name
41
45
  # @param [Nilor[Symbol]] as
42
46
  # @param [Nilor[Symbol]] from
data/lib/ree/fn_dsl.rb CHANGED
@@ -16,6 +16,7 @@ module Ree::FnDSL
16
16
  )
17
17
 
18
18
  dsl.instance_exec(&proc) if block_given?
19
+ dsl.tags(["fn"])
19
20
  dsl.object.set_as_compiled(false)
20
21
 
21
22
  Ree.container.compile(dsl.package, name)
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.22"
4
+ VERSION = "1.0.23"
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.22
4
+ version: 1.0.23
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-02-03 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander