ree 1.0.4 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -1
- data/exe/ree +53 -1
- data/lib/ree/cli/delete_object_schema.rb +33 -0
- data/lib/ree/cli/generate_object_schema.rb +50 -0
- data/lib/ree/cli/generate_package_schema.rb +6 -5
- data/lib/ree/cli.rb +2 -0
- data/lib/ree/contracts/arg_contracts/respond_to.rb +33 -0
- data/lib/ree/contracts/arg_contracts.rb +1 -0
- data/lib/ree/core/path_helper.rb +8 -5
- data/lib/ree/facades/packages_facade.rb +30 -0
- data/lib/ree/version.rb +1 -1
- data/lib/ree.rb +2 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d23b7d6e73fd42fb81e6a2f80cae29c8ae8b7b7bace7531734bbff0aaacc4b
|
4
|
+
data.tar.gz: 71c9516f775b0e430e3b7ae180f44b8ffcaddfeed2b76f5d9e66cddf2d7b9361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 348a11eec63932f9b4bbcd536438da8ffaeb05a19c5cfc0c71df9d6655d14394b9034ba2d3892e83e29e1529a101e838932f31b76bc09b5682ce230e7eacabe7
|
7
|
+
data.tar.gz: 9c73938e83e5873bc7886a7854b533136873802758fc403c76da7a45e7dd046d8905b2ba612c60034a15b8a8bfae5f65ef9a946b9098248ba401f4a26cb37691
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ree (1.0.
|
4
|
+
ree (1.0.6)
|
5
5
|
commander (~> 4.6.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -9,9 +9,17 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
commander (4.6.0)
|
11
11
|
highline (~> 2.0.0)
|
12
|
+
debug (1.6.2)
|
13
|
+
irb (>= 1.3.6)
|
14
|
+
reline (>= 0.3.1)
|
12
15
|
diff-lcs (1.5.0)
|
13
16
|
highline (2.0.3)
|
17
|
+
io-console (0.5.11)
|
18
|
+
irb (1.4.2)
|
19
|
+
reline (>= 0.3.0)
|
14
20
|
rake (13.0.6)
|
21
|
+
reline (0.3.1)
|
22
|
+
io-console (~> 0.5)
|
15
23
|
rspec (3.11.0)
|
16
24
|
rspec-core (~> 3.11.0)
|
17
25
|
rspec-expectations (~> 3.11.0)
|
@@ -33,6 +41,7 @@ PLATFORMS
|
|
33
41
|
x86_64-linux
|
34
42
|
|
35
43
|
DEPENDENCIES
|
44
|
+
debug
|
36
45
|
rake (~> 13.0)
|
37
46
|
ree!
|
38
47
|
rspec (~> 3.0)
|
data/exe/ree
CHANGED
@@ -117,7 +117,7 @@ class ReeCliRunner
|
|
117
117
|
c.syntax = 'ree gen.package_json PACKAGE_NAME'
|
118
118
|
c.description = 'generates Package.schema.json for specific package'
|
119
119
|
c.summary = '> ' + c.description
|
120
|
-
c.example 'ree gen.
|
120
|
+
c.example 'ree gen.package_json PACKAGE_NAME', ''
|
121
121
|
c.option '--skip_objects', String, 'Skip generation of object schemas'
|
122
122
|
c.option '--silence', String, 'Silence all logs'
|
123
123
|
c.option '--project_path [ROOT_PROJECT_DIR]', String, 'Root project dir path'
|
@@ -140,6 +140,58 @@ 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]&.to_sym
|
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
|
+
|
143
195
|
command :"gen.template" do |c|
|
144
196
|
c.syntax = "ree gen.template TEMPLATE_NAME [options]"
|
145
197
|
c.description = "generates template from ROOT/.ree/templates folder with specified variables"
|
@@ -0,0 +1,33 @@
|
|
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.exists?(abs_schema_path)
|
23
|
+
FileUtils.rm(abs_schema_path)
|
24
|
+
|
25
|
+
puts(" #{schema_path}: is deleted") if !silence
|
26
|
+
end
|
27
|
+
|
28
|
+
puts("done") if !silence
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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
|
+
|
29
|
+
obj_path = Ree::PathHelper.abs_object_schema_path(object)
|
30
|
+
else
|
31
|
+
file_path = File.join(dir, object_path)
|
32
|
+
|
33
|
+
if File.exists?(file_path)
|
34
|
+
facade.load_file(file_path, package_name)
|
35
|
+
facade.dump_package_schema(package_name)
|
36
|
+
Ree.write_object_schema(package_name, object_name)
|
37
|
+
else
|
38
|
+
raise Ree::Error.new("package file not found: #{file_path}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
puts(" #{object.name}: #{obj_path}") if !silence
|
44
|
+
|
45
|
+
puts("done") if !silence
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -23,15 +23,16 @@ module Ree
|
|
23
23
|
|
24
24
|
package_name = package_name.to_sym
|
25
25
|
|
26
|
-
Ree.container.packages_facade
|
27
|
-
|
28
|
-
Ree.
|
26
|
+
facade = Ree.container.packages_facade
|
27
|
+
facade.load_packages_schema
|
28
|
+
Ree.load_package(package_name)
|
29
|
+
facade.write_package_schema(package_name)
|
29
30
|
|
30
|
-
package =
|
31
|
+
package = facade.get_package(package_name)
|
31
32
|
schema_path = Ree::PathHelper.abs_package_schema_path(package)
|
32
33
|
|
33
34
|
if include_objects
|
34
|
-
schemas_path = Ree::PathHelper.
|
35
|
+
schemas_path = Ree::PathHelper.abs_package_schemas_dir(package)
|
35
36
|
|
36
37
|
FileUtils.rm_rf(schemas_path)
|
37
38
|
FileUtils.mkdir_p(schemas_path)
|
data/lib/ree/cli.rb
CHANGED
@@ -5,6 +5,8 @@ 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'
|
8
10
|
autoload :GeneratePackage, 'ree/cli/generate_package'
|
9
11
|
autoload :GenerateTemplate, 'ree/cli/generate_template'
|
10
12
|
autoload :SpecRunner, 'ree/cli/spec_runner'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ree::Contracts
|
4
|
+
module ArgContracts
|
5
|
+
class RespondTo
|
6
|
+
extend Ree::Contracts::ArgContracts::Squarable
|
7
|
+
|
8
|
+
def initialize(*method_names)
|
9
|
+
@method_names = method_names
|
10
|
+
end
|
11
|
+
|
12
|
+
def valid?(value)
|
13
|
+
get_unrespond_list(value).empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
"RespondTo#{method_names.inspect}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def message(value, name, lvl = 1)
|
21
|
+
unrespond_list = get_unrespond_list(value)
|
22
|
+
"expected to respond to #{unrespond_list.inspect}}"
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def get_unrespond_list(obj)
|
27
|
+
@method_names.reject do |method|
|
28
|
+
obj.respond_to?(method)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -16,6 +16,7 @@ module Ree::Contracts
|
|
16
16
|
autoload :Optblock, 'ree/contracts/arg_contracts/optblock'
|
17
17
|
autoload :Or, 'ree/contracts/arg_contracts/or'
|
18
18
|
autoload :RangeOf, 'ree/contracts/arg_contracts/range_of'
|
19
|
+
autoload :RespondTo, 'ree/contracts/arg_contracts/respond_to'
|
19
20
|
autoload :SetOf, 'ree/contracts/arg_contracts/set_of'
|
20
21
|
autoload :Splat, 'ree/contracts/arg_contracts/splat'
|
21
22
|
autoload :SplatOf, 'ree/contracts/arg_contracts/splat_of'
|
data/lib/ree/core/path_helper.rb
CHANGED
@@ -6,11 +6,6 @@ class Ree::PathHelper
|
|
6
6
|
SCHEMAS_FOLDER = 'schemas'
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def abs_package_object_schemas_path(package)
|
10
|
-
root_dir = project_root_dir(package)
|
11
|
-
File.join(root_dir, SCHEMAS_FOLDER)
|
12
|
-
end
|
13
|
-
|
14
9
|
# @param [Ree::Object] object
|
15
10
|
# @return [String] Absolute object file path
|
16
11
|
def abs_object_path(object)
|
@@ -71,6 +66,14 @@ class Ree::PathHelper
|
|
71
66
|
)
|
72
67
|
end
|
73
68
|
|
69
|
+
# @param [Ree::Package] package Package schema
|
70
|
+
# @return [String] Absolute package schemas folder path (ex. /data/project/bc/accounts/schemas)
|
71
|
+
def abs_package_schemas_dir(package)
|
72
|
+
File.join(
|
73
|
+
project_root_dir(package), package.dir, Ree::SCHEMAS
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
74
77
|
# @param [Ree::Package] package Package schema
|
75
78
|
# @return [String] Absolute package schema path
|
76
79
|
def abs_package_schema_path(package)
|
@@ -60,6 +60,36 @@ class Ree::PackagesFacade
|
|
60
60
|
object
|
61
61
|
end
|
62
62
|
|
63
|
+
def has_object?(package_name, object_name)
|
64
|
+
package = get_loaded_package(package_name)
|
65
|
+
object = package.get_object(object_name)
|
66
|
+
|
67
|
+
!object.nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
# @param [Symbol] package_name
|
71
|
+
# @return nil
|
72
|
+
def dump_package_schema(package_name)
|
73
|
+
Ree.logger.debug("dump_package_schema(:#{package_name})")
|
74
|
+
|
75
|
+
read_package_schema_json(package_name)
|
76
|
+
package = get_package(package_name)
|
77
|
+
|
78
|
+
if package.dir
|
79
|
+
schema_path = Ree::PathHelper.abs_package_schema_path(package)
|
80
|
+
|
81
|
+
if !File.exists?(schema_path)
|
82
|
+
raise Ree::Error.new("File does not exist: #{schema_path}", :invalid_path)
|
83
|
+
end
|
84
|
+
|
85
|
+
schema = Ree::PackageSchemaBuilder.new.call(package)
|
86
|
+
json = JSON.pretty_generate(schema)
|
87
|
+
File.write(schema_path, json, mode: 'w')
|
88
|
+
|
89
|
+
json
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
63
93
|
# @param [Symbol] package_name
|
64
94
|
# @return nil
|
65
95
|
def write_package_schema(package_name)
|
data/lib/ree/version.rb
CHANGED
data/lib/ree.rb
CHANGED
@@ -245,12 +245,13 @@ module Ree
|
|
245
245
|
|
246
246
|
facade.packages_store.packages.each do |package|
|
247
247
|
next if package.gem?
|
248
|
+
next if package.dir.nil?
|
248
249
|
puts("Generating Package.schema.json for :#{package.name} package") if !silence
|
249
250
|
|
250
251
|
facade.load_entire_package(package.name)
|
251
252
|
facade.write_package_schema(package.name)
|
252
253
|
|
253
|
-
schemas_path = Ree::PathHelper.
|
254
|
+
schemas_path = Ree::PathHelper.abs_package_schemas_dir(package)
|
254
255
|
|
255
256
|
FileUtils.rm_rf(schemas_path)
|
256
257
|
FileUtils.mkdir_p(schemas_path)
|
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.
|
4
|
+
version: 1.0.6
|
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
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: debug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Ree makes your ruby life happier
|
28
42
|
email:
|
29
43
|
- ruslan.gatiyatov@gmail.com
|
@@ -49,6 +63,8 @@ files:
|
|
49
63
|
- lib/ree/args.rb
|
50
64
|
- lib/ree/bean_dsl.rb
|
51
65
|
- lib/ree/cli.rb
|
66
|
+
- lib/ree/cli/delete_object_schema.rb
|
67
|
+
- lib/ree/cli/generate_object_schema.rb
|
52
68
|
- lib/ree/cli/generate_package.rb
|
53
69
|
- lib/ree/cli/generate_package_schema.rb
|
54
70
|
- lib/ree/cli/generate_packages_schema.rb
|
@@ -72,6 +88,7 @@ files:
|
|
72
88
|
- lib/ree/contracts/arg_contracts/optblock.rb
|
73
89
|
- lib/ree/contracts/arg_contracts/or.rb
|
74
90
|
- lib/ree/contracts/arg_contracts/range_of.rb
|
91
|
+
- lib/ree/contracts/arg_contracts/respond_to.rb
|
75
92
|
- lib/ree/contracts/arg_contracts/set_of.rb
|
76
93
|
- lib/ree/contracts/arg_contracts/splat.rb
|
77
94
|
- lib/ree/contracts/arg_contracts/splat_of.rb
|