ree 1.0.38 → 1.0.40

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: 35a162c69a00597f108ee30e405a86ec0d5758e94d7110b3f904b5b3b7b7970c
4
- data.tar.gz: 5a33fe4850f595f0ad3da5e10acea452d3ca515d47b82003f45e2365f5b5e7b2
3
+ metadata.gz: c806baccc97f2a671627bb9988a5019e1827f0ecad6781b4936adb9dfeaa8337
4
+ data.tar.gz: 65786f392d68aa7213a25a46d25c9b5fcdca2161a8ba1647c925fca63e2c885b
5
5
  SHA512:
6
- metadata.gz: 4cf7b6cb449a213fbbce8498702a79349133744e91be63de7e171696319d26565e9ec292a3b4403e765ce18cd326a86f1241f41602feb14b80025da24c76f91b
7
- data.tar.gz: aa570fbba3f9f361d81196252b969a35b9ed359a5ff400bdc31cb316de9af17e394312f445f8c9922fffa2983454c4cc3a8ace6cd14d70c3f06a63fb29cff41d
6
+ metadata.gz: 963769f03216f645f0454512eb671eca21d6525967e88179c974dd1cc66a35f9c1be0460288c0fc74f0816037931d93a679d32b019f13aaba156aaa49b518b16
7
+ data.tar.gz: fbb55a02c5bf9a385a469da241863c0f2f327183075f02061c59f250f1df3428b9201457c1139cd4f3007ca28b6b0ca4df1cf32588514114645b50e5424f10fc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.38)
4
+ ree (1.0.40)
5
5
  commander (~> 5.0.0)
6
6
 
7
7
  GEM
data/exe/ree CHANGED
@@ -140,58 +140,6 @@ class ReeCliRunner
140
140
  end
141
141
  end
142
142
 
143
- command :"gen.schema_json" do |c|
144
- c.syntax = 'ree gen.schema_json PACKAGE_NAME OBJECT_PATH'
145
- c.description = 'generates Schema.json for specified object in specified package'
146
- c.summary = '> ' + c.description
147
- c.example 'ree gen.schema_json accounts commands/create_account_cmd.rb', ''
148
- c.option '--silence', String, 'Silence all logs'
149
- c.option '--project_path [ROOT_PROJECT_DIR]', String, 'Root project dir path'
150
- c.action do |args, options|
151
- package_name = args[0]
152
- object_path = args[1]
153
- options_hash = options.__hash__
154
-
155
- if options_hash[:project_path]
156
- options_hash[:project_path] = File.expand_path(options_hash[:project_path])
157
- end
158
-
159
- default_options = {
160
- package_name: package_name,
161
- object_path: object_path,
162
- project_path: options_hash[:project_path] || File.expand_path(Dir.pwd),
163
- silence: options_hash.has_key?(:silence)
164
- }
165
-
166
- Ree::CLI::GenerateObjectSchema.run(**default_options)
167
- end
168
- end
169
-
170
- command :"delete.schema_json" do |c|
171
- c.syntax = 'ree delete.schema_json OBJECT_PATH'
172
- c.description = 'removes Schema.json for specified object '
173
- c.summary = '> ' + c.description
174
- c.example 'ree delete.schema_json commands/create_account_cmd.rb', ''
175
- c.option '--silence', String, 'Silence all logs'
176
- c.option '--project_path [ROOT_PROJECT_DIR]', String, 'Root project dir path'
177
- c.action do |args, options|
178
- object_path = args[0]
179
- options_hash = options.__hash__
180
-
181
- if options_hash[:project_path]
182
- options_hash[:project_path] = File.expand_path(options_hash[:project_path])
183
- end
184
-
185
- default_options = {
186
- object_path: object_path,
187
- project_path: options_hash[:project_path] || File.expand_path(Dir.pwd),
188
- silence: options_hash.has_key?(:silence)
189
- }
190
-
191
- Ree::CLI::DeleteObjectSchema.run(**default_options)
192
- end
193
- end
194
-
195
143
  command :"gen.template" do |c|
196
144
  c.syntax = "ree gen.template TEMPLATE_NAME [options]"
197
145
  c.description = "generates template from ROOT/.ree/templates folder with specified variables"
data/lib/ree/cli.rb CHANGED
@@ -5,8 +5,6 @@ module Ree
5
5
  autoload :Init, 'ree/cli/init'
6
6
  autoload :GeneratePackagesSchema, 'ree/cli/generate_packages_schema'
7
7
  autoload :GeneratePackageSchema, 'ree/cli/generate_package_schema'
8
- autoload :GenerateObjectSchema, 'ree/cli/generate_object_schema'
9
- autoload :DeleteObjectSchema, 'ree/cli/delete_object_schema'
10
8
  autoload :GeneratePackage, 'ree/cli/generate_package'
11
9
  autoload :GenerateTemplate, 'ree/cli/generate_template'
12
10
  autoload :Indexing, 'ree/cli/indexing'
data/lib/ree/link_dsl.rb CHANGED
@@ -40,12 +40,16 @@ module Ree::LinkDSL
40
40
  # @param [Nilor[Symbol]] as
41
41
  # @param [Nilor[Symbol]] from
42
42
  # @param [Nilor[Proc]] import
43
- def _link_object(object_name, as: nil, from: nil, import: nil)
43
+ def _link_object(object_name, as: nil, from: nil, target: nil, import: nil)
44
44
  check_arg(object_name, :object_name, Symbol)
45
45
  check_arg(as, :as, Symbol) if as
46
46
  check_arg(from, :from, Symbol) if from
47
47
  check_arg(import, :import, Proc) if import
48
48
 
49
+ if target && ![:object, :class, :both].include?(target)
50
+ raise Ree::Error.new("target should be one of [:object, :class, :both]", :invalid_dsl_usage)
51
+ end
52
+
49
53
  package_name = Ree::StringUtils.underscore(self.name.split('::').first).to_sym
50
54
  link_package_name = from.nil? ? package_name : from
51
55
  link_object_name = object_name
@@ -69,33 +73,54 @@ module Ree::LinkDSL
69
73
  .packages_facade
70
74
  .load_package_object(link_package_name, link_object_name)
71
75
 
76
+ target ||= obj.target
77
+
78
+ if target == :both
79
+ mount_obj(obj, link_as, true)
80
+ mount_obj(obj, link_as, false)
81
+ elsif target == :class
82
+ mount_obj(obj, link_as, true)
83
+ elsif target == :object
84
+ mount_obj(obj, link_as, false)
85
+ end
86
+ end
87
+
88
+ def mount_obj(obj, link_as, mount_self)
72
89
  if obj.fn?
73
90
  if obj.with_caller?
74
91
  self.class_eval %Q(
92
+ #{mount_self ? "class << self" : ""}
75
93
  private def #{link_as}(*args, **kwargs, &block)
76
94
  #{obj.klass}.new.set_caller(self).call(*args, **kwargs, &block)
77
95
  end
96
+ #{mount_self ? "end" : ""}
78
97
  )
79
98
  else
80
99
  self.class_eval %Q(
100
+ #{mount_self ? "class << self" : ""}
81
101
  private def #{link_as}(*args, **kwargs, &block)
82
102
  @#{link_as} ||= #{obj.klass}.new
83
103
  @#{link_as}.call(*args, **kwargs, &block)
84
104
  end
105
+ #{mount_self ? "end" : ""}
85
106
  )
86
107
  end
87
108
  else
88
109
  if obj.with_caller?
89
110
  self.class_eval %Q(
111
+ #{mount_self ? "class << self" : ""}
90
112
  private def #{link_as}
91
113
  #{obj.klass}.new.set_caller(self)
92
114
  end
115
+ #{mount_self ? "end" : ""}
93
116
  )
94
117
  else
95
118
  self.class_eval %Q(
119
+ #{mount_self ? "class << self" : ""}
96
120
  private def #{link_as}
97
121
  @#{link_as} ||= #{obj.klass}.new
98
122
  end
123
+ #{mount_self ? "end" : ""}
99
124
  )
100
125
  end
101
126
  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.38"
4
+ VERSION = "1.0.40"
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.38
4
+ version: 1.0.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-29 00:00:00.000000000 Z
11
+ date: 2024-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -63,8 +63,6 @@ files:
63
63
  - lib/ree/args.rb
64
64
  - lib/ree/bean_dsl.rb
65
65
  - lib/ree/cli.rb
66
- - lib/ree/cli/delete_object_schema.rb
67
- - lib/ree/cli/generate_object_schema.rb
68
66
  - lib/ree/cli/generate_package.rb
69
67
  - lib/ree/cli/generate_package_schema.rb
70
68
  - lib/ree/cli/generate_packages_schema.rb
@@ -1,43 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Ree
4
- module CLI
5
- class DeleteObjectSchema
6
- class << self
7
- def run(object_path:, project_path:, silence: false)
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
- object_name = object_path.split('/')[-1].split('.').first.to_sym
16
-
17
- puts("Deleting old #{object_name}.schema.json") if !silence
18
-
19
- schema_path = Ree::PathHelper.object_schema_rpath(object_path)
20
- abs_schema_path = File.join(dir, schema_path)
21
-
22
- if File.exist?(abs_schema_path)
23
- FileUtils.rm(abs_schema_path)
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
-
35
- puts(" #{schema_path}: is deleted") if !silence
36
- end
37
-
38
- puts("done") if !silence
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,49 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Ree
4
- module CLI
5
- class GenerateObjectSchema
6
- class << self
7
- def run(package_name:, object_path:, project_path:, silence: false)
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
- package_name = package_name.to_sym
16
- object_name = object_path.split('/')[-1].split('.').first.to_sym
17
-
18
- puts("Generating #{object_name}.schema.json in #{package_name} package") if !silence
19
-
20
- facade = Ree.container.packages_facade
21
- Ree.load_package(package_name)
22
-
23
- package = facade.get_package(package_name)
24
-
25
- if facade.has_object?(package_name, object_name)
26
- object = facade.load_package_object(package_name, object_name)
27
- Ree.write_object_schema(package.name, object.name)
28
- facade.dump_package_schema(package_name)
29
- else
30
- file_path = File.join(dir, object_path)
31
-
32
- if File.exist?(file_path)
33
- facade.load_file(file_path, package_name)
34
- facade.dump_package_schema(package_name)
35
-
36
- if facade.has_object?(package_name, object_name)
37
- Ree.write_object_schema(package_name, object_name)
38
- end
39
- else
40
- raise Ree::Error.new("package file not found: #{file_path}")
41
- end
42
- end
43
-
44
- puts("done") if !silence
45
- end
46
- end
47
- end
48
- end
49
- end