ree 1.0.22 → 1.0.24

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: 972811cf5375f041b94d6b27312ec7abf79301c5d3bf84e28e2bd386250ff069
4
- data.tar.gz: 5da92138c93885000b6dad4b0f6a380ef1ab3edec2967b1a814fac8a9419128c
3
+ metadata.gz: 75a8e8d614b00dc9aaba38993d3e2532f4189eca0f83e1dbc8cc5fa63fcee1a4
4
+ data.tar.gz: ebc2988db12701721dde74ffc845b5c608debf2255f9d9d57e52749c6458d7af
5
5
  SHA512:
6
- metadata.gz: e3e656e9eb4edfde775740363105ec9fb08ecd53ab0d1dcae016c1d3d29580601a4f41b3d0474932996edb1c6807c971950babf2397df753db9883227897c698
7
- data.tar.gz: 126671be60919618cedc2381cf5aaff4b3a4fb4b65c2d1e50a8821c5394612cdf93b845df4ac5df2d371521ed3b2e7334b8280108d2ab42d5d1eda3274e2b7d6
6
+ metadata.gz: cc915972d2b9306d431e8ef813b5105dc635f35826daaf59775385db5ca7a5f51b411d60d2ee82c4eaa9a6c0906aba94a3f79d4542551985c85b751d5e161a38
7
+ data.tar.gz: bc9f8776cfc0ae0b1d995d3ee3c40f0b27fd2d903391d7558263a2f0dd74bc1833589cb31837435bb97229cbcaaf58f2d45f064604364c87668905ee4a1b80dc
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
@@ -53,14 +53,14 @@ module Ree
53
53
  end
54
54
 
55
55
  next if package.dir.nil?
56
-
56
+
57
57
  facade.load_entire_package(package.name)
58
58
 
59
59
  package_hsh = Ree::CLI::IndexPackage.send(:index_package_entry, package)
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,71 @@ 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, mod_index)
105
+ return if !mod.is_a?(Module)
106
+ return if mod_index[mod]
107
+
108
+ mod_index[mod] = true
109
+
110
+ mod.constants.each do |const_name|
111
+ const = mod.const_get(const_name)
112
+
113
+ recursively_index_module(const, index_hsh, package, mod_index)
114
+
115
+ next if !const.is_a?(Class)
116
+ next if package.objects.any? { |o| o.klass == const }
117
+ next if index_hsh[:classes].has_key?(demodulize(const.name))
118
+
119
+ const_abs_path = mod.const_source_location(const.name).first
120
+ next if !const_abs_path
121
+
122
+ rpath = Pathname.new(const_abs_path).relative_path_from(Ree.root_dir).to_s
123
+ hsh = index_class(const, rpath, package.name)
124
+ class_name = demodulize(const.name)
125
+
126
+ index_hsh[:classes][class_name] ||= []
127
+ index_hsh[:classes][class_name] << hsh
128
+ end
129
+ end
130
+
131
+ def index_class(klass, rpath, package_name)
130
132
  all_methods = klass.public_instance_methods(false)
131
133
  orig_methods = all_methods.grep(/original/)
134
+
132
135
  methods = (all_methods - orig_methods) # remove aliases defined by contracts
133
136
  .map { |m|
134
137
  orig_method_name = orig_methods.find { |om| om.match(/original_#{Regexp.escape(m.name)}_[0-9a-fA-F]+/) }
135
138
  orig_method = orig_method_name ? klass.public_instance_method(orig_method_name) : nil
139
+
136
140
  {
137
141
  name: m,
138
142
  parameters: orig_method&.parameters&.map { |param| { name: param.last, required: param.first } },
@@ -140,20 +144,14 @@ module Ree
140
144
  }
141
145
  }
142
146
 
143
- rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
144
-
145
147
  {
146
- path: rpath_from_root_file_path,
148
+ path: rpath,
147
149
  package: package_name,
148
150
  methods: methods
149
151
  }
150
152
  end
151
153
 
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)
154
+ def index_dao(klass, rpath, package_name)
157
155
  filters = klass
158
156
  .instance_variable_get(:@filters)
159
157
  .map {
@@ -164,10 +162,8 @@ module Ree
164
162
  }
165
163
  }
166
164
 
167
- rpath_from_root_file_path = Pathname.new(file_name).relative_path_from(Pathname.new(root_dir)).to_s
168
-
169
165
  {
170
- path: rpath_from_root_file_path,
166
+ path: rpath,
171
167
  package: package_name,
172
168
  methods: filters
173
169
  }
@@ -175,7 +171,7 @@ module Ree
175
171
 
176
172
  def index_exceptions(errors_package, index_hash)
177
173
  errors_package.objects.each do |obj|
178
- const_name = obj.class_name.split("::")[-1]
174
+ const_name = demodulize(obj.class_name)
179
175
  file_name = File.join(
180
176
  Ree::PathHelper.abs_package_module_dir(errors_package),
181
177
  obj.name.to_s + ".rb"
@@ -193,6 +189,10 @@ module Ree
193
189
 
194
190
  index_hash
195
191
  end
192
+
193
+ def demodulize(str)
194
+ str.split("::").last
195
+ end
196
196
  end
197
197
  end
198
198
  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.24"
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.24
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