ree 1.0.0 → 1.0.3

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: 3b3d64c6833699e7eab9bb131f57e8f6bc6b3d68e609dcdc261b78029a22d070
4
- data.tar.gz: 9092fc80679dd84185e74de7639771b6bb625f904d0d4883b00f46b705c448f4
3
+ metadata.gz: bf5e0c8684516ac9e2c26a6cbad0e0616a5ef1077da9a17952210bee81beaa8b
4
+ data.tar.gz: e35b6f677d0b3d448b68d67479a6ad8d9198387c6608db32f32dd5e38b3fec5e
5
5
  SHA512:
6
- metadata.gz: 18e0f5cf506e899bc269ff31af9941b2e6fe9e47d0d3a36bb1acf7db5335326efb6511f1125434870354a425330f98c5d07f10081b2cd97d8416a7650a0661c5
7
- data.tar.gz: 793ad63ee56c2af4ba302516ae4d1a82da280433a1eb5ac78abcb9217bb74d90f4ecba015066da845ad0828c4a0426bec67c5c1ea2286f80846f6c07fa8cd352
6
+ metadata.gz: 51f84f4eab9cc867af7a9785c9d7556e20a179fb5997800d52a49d4b2eb609a7063396d85ff856e78cd6c39f0c96d0e89ed3b2b47ae93a36948ba7f12cd3b365
7
+ data.tar.gz: dd60d3b7438b9c6a1b2d68a06308921653abe35724d4ed573eff5320ef1035dad87f0f17a5c19e41908cdc68cc6b237dee3b5b69890baccfaf13402a0e28f017
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree (1.0.0)
4
+ ree (1.0.3)
5
5
  commander (~> 4.6.0)
6
6
 
7
7
  GEM
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal = true
2
2
 
3
3
  module Ree::ObjectSchema
4
+ SCHEMA_VERSION_NUMBER = '1.0'
5
+
4
6
  SCHEMA_TYPE = 'schema_type'
5
7
  REE_VERSION = 'ree_version'
8
+ SCHEMA_VERSION = 'schema_version'
6
9
  NAME = 'name'
7
10
  OBJECT = 'object'
8
11
  LINKS = 'links'
@@ -4,23 +4,17 @@ class Ree::ObjectSchemaBuilder
4
4
  Schema = Ree::ObjectSchema
5
5
 
6
6
  # @param [Ree::Object] object
7
- # @param [String] - path to object.schema.json file (ex. /project/bc/accounts/schemas/accounts/accounts_cfg.schema.json)
8
- # @return [String]
9
- def call(object, schema_path)
7
+ # @return [Hash]
8
+ def call(object)
10
9
  Ree.logger.debug("generating object schema for '#{object.name}' package")
11
10
 
12
- if !File.exists?(schema_path)
13
- only_dir_path = schema_path.split('/')[0..-2]
14
- FileUtils.mkdir_p(File.join(only_dir_path))
15
- end
16
-
17
11
  if !object.loaded?
18
12
  raise Ree::Error.new("object `#{object.name}` from package `#{object.package_name}` is not loaded", :invalid_schema)
19
13
  end
20
14
 
21
15
  data = {
22
16
  Schema::SCHEMA_TYPE => Schema::OBJECT,
23
- Schema::REE_VERSION => Ree::VERSION,
17
+ Schema::SCHEMA_VERSION => Schema::SCHEMA_VERSION_NUMBER,
24
18
  Schema::NAME => object.name,
25
19
  Schema::PATH => object.rpath,
26
20
  Schema::MOUNT_AS => object.mount_as,
@@ -37,10 +31,7 @@ class Ree::ObjectSchemaBuilder
37
31
  }
38
32
  }
39
33
 
40
- json = JSON.pretty_generate(data)
41
-
42
- File.write(schema_path, json, mode: 'w')
43
- json
34
+ data
44
35
  end
45
36
 
46
37
  private
@@ -3,11 +3,11 @@
3
3
  require 'pathname'
4
4
 
5
5
  class Ree::Package
6
- attr_reader :ree_version, :name, :schema_rpath, :entry_rpath,
6
+ attr_reader :schema_version, :name, :schema_rpath, :entry_rpath,
7
7
  :module, :tags, :preload, :default_links, :gem_name
8
8
 
9
- def initialize(ree_version, name, entry_rpath, schema_rpath, gem_name = nil)
10
- @ree_version = ree_version
9
+ def initialize(schema_version, name, entry_rpath, schema_rpath, gem_name = nil)
10
+ @schema_version = schema_version
11
11
  @name = name
12
12
  @schema_rpath = schema_rpath
13
13
  @entry_rpath = entry_rpath
@@ -37,8 +37,8 @@ class Ree::Package
37
37
  end
38
38
 
39
39
  # @param [String] val
40
- def set_ree_version(val)
41
- @ree_version = val; self
40
+ def set_schema_version(val)
41
+ @schema_version = val; self
42
42
  end
43
43
 
44
44
  # @param [String] val
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal = true
2
2
 
3
3
  module Ree::PackageSchema
4
+ SCHEMA_VERSION_NUMBER = '1.0'
5
+
4
6
  SCHEMA_TYPE = 'schema_type'
5
7
  REE_VERSION = 'ree_version'
8
+ SCHEMA_VERSION = 'schema_version'
6
9
  NAME = 'name'
7
10
  PACKAGE = 'package'
8
11
  ENTRY_PATH = 'entry_path'
@@ -7,22 +7,17 @@ class Ree::PackageSchemaBuilder
7
7
  Schema = Ree::PackageSchema
8
8
 
9
9
  # @param [Ree::Package] package
10
- # @param [String] - abs_path Absolute path to Package.schema.json file (ex. /project/bc/accounts/Package.schema.json)
11
- # @return [nil]
12
- def call(package, abs_path)
10
+ # @return [Hash]
11
+ def call(package)
13
12
  Ree.logger.debug("generating package schema for '#{package.name}' package")
14
13
 
15
- if !File.exists?(abs_path)
16
- raise Ree::Error.new("File does not exist: #{abs_path}", :invalid_path)
17
- end
18
-
19
14
  if !package.loaded?
20
15
  raise Ree::Error.new("package schema should be loaded", :invalid_schema)
21
16
  end
22
17
 
23
18
  data = {
24
19
  Schema::SCHEMA_TYPE => Schema::PACKAGE,
25
- Schema::REE_VERSION => Ree::VERSION,
20
+ Schema::SCHEMA_VERSION => Schema::SCHEMA_VERSION_NUMBER,
26
21
  Schema::NAME => package.name,
27
22
  Schema::ENTRY_PATH => package.entry_rpath,
28
23
  Schema::TAGS => package.tags,
@@ -45,9 +40,6 @@ class Ree::PackageSchemaBuilder
45
40
  }
46
41
  }
47
42
 
48
- json = JSON.pretty_generate(data)
49
-
50
- File.write(abs_path, json, mode: 'w')
51
- nil
43
+ data
52
44
  end
53
45
  end
@@ -7,7 +7,7 @@ class Ree::PackageSchemaLoader
7
7
  # Sample Package.schema.json
8
8
  # {
9
9
  # "schema_type": "package",
10
- # "ree_version": "1.2.3",
10
+ # "schema_version": "1.2.3",
11
11
  # "name": "accounts",
12
12
  # "entry_path": "package/accounts.rb",
13
13
  # "depends_on": [
@@ -49,7 +49,7 @@ class Ree::PackageSchemaLoader
49
49
  if !File.exists?(abs_schema_path)
50
50
  raise Ree::Error.new("File not found: #{abs_schema_path}", :invalid_package_schema)
51
51
  end
52
-
52
+
53
53
  json_schema = begin
54
54
  JSON.load_file(abs_schema_path)
55
55
  rescue
@@ -57,12 +57,12 @@ class Ree::PackageSchemaLoader
57
57
  end
58
58
 
59
59
  schema_type = json_schema.fetch(Schema::SCHEMA_TYPE)
60
-
60
+
61
61
  if schema_type != Schema::PACKAGE
62
62
  raise Ree::Error.new("Invalid schema type: #{abs_schema_path}", :invalid_package_schema)
63
63
  end
64
64
 
65
- ree_version = json_schema.fetch(Schema::REE_VERSION)
65
+ schema_version = json_schema.fetch(Schema::SCHEMA_VERSION) { Schema::SCHEMA_VERSION_NUMBER }
66
66
  entry_rpath = json_schema.fetch(Schema::ENTRY_PATH)
67
67
  package_name = json_schema.fetch(Schema::NAME).to_sym
68
68
 
@@ -83,12 +83,12 @@ class Ree::PackageSchemaLoader
83
83
 
84
84
  package = if existing_package
85
85
  existing_package
86
- .set_ree_version(ree_version)
86
+ .set_schema_version(schema_version)
87
87
  .set_entry_rpath(entry_rpath)
88
88
  .set_schema_rpath(schema_rpath)
89
89
  else
90
90
  Ree::Package.new(
91
- ree_version,
91
+ schema_version,
92
92
  package_name,
93
93
  entry_rpath,
94
94
  schema_rpath,
@@ -118,7 +118,7 @@ class Ree::PackageSchemaLoader
118
118
  schema_rpath,
119
119
  Ree::PathHelper.object_rpath(schema_rpath),
120
120
  )
121
-
121
+
122
122
  object.set_package(package.name)
123
123
 
124
124
  package.set_object(object)
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal = true
2
2
 
3
3
  module Ree::PackagesSchema
4
+ SCHEMA_VERSION_NUMBER = '1.0'
5
+
4
6
  SCHEMA_TYPE = 'schema_type'
5
7
  REE_VERSION = 'ree_version'
8
+ SCHEMA_VERSION = 'schema_version'
6
9
  PACKAGES = 'packages'
7
10
  GEM_PACKAGES = 'gem_packages'
8
-
11
+
9
12
  module Packages
10
13
  NAME = 'name'
11
14
  SCHEMA = 'schema'
@@ -20,7 +20,7 @@ class Ree::PackagesSchemaBuilder
20
20
  end
21
21
 
22
22
  result = {
23
- Schema::REE_VERSION => Ree::VERSION,
23
+ Schema::SCHEMA_VERSION => Schema::SCHEMA_VERSION_NUMBER,
24
24
  Schema::SCHEMA_TYPE => Schema::PACKAGES,
25
25
  Schema::PACKAGES => packages.sort_by { _1[:name] }.map {
26
26
  {
@@ -36,14 +36,6 @@ class Ree::PackagesSchemaBuilder
36
36
  }
37
37
  },
38
38
  }
39
-
40
- json = JSON.pretty_generate(result)
41
-
42
- File.write(
43
- File.join(Ree.root_dir, Ree::PACKAGES_SCHEMA_FILE),
44
- json,
45
- mode: 'w'
46
- )
47
39
 
48
40
  result
49
41
  end
@@ -6,7 +6,7 @@ class Ree::PackagesSchemaLoader
6
6
  # Sample Packages.schema.json
7
7
  # {
8
8
  # "schema_type": "packages",
9
- # "ree_version": "1.2.3",
9
+ # "schema_version": "1.2.3",
10
10
  # "packages": [
11
11
  # {
12
12
  # "name": "accounts",
@@ -18,9 +18,9 @@ class Ree::PackagesSchemaLoader
18
18
  # }
19
19
  # ]
20
20
  # }
21
-
21
+
22
22
  Schema = Ree::PackagesSchema
23
-
23
+
24
24
  # @param [String] path Absolute path to Packages.schema.json file
25
25
  # @param Nilor[Ree::PackagesStore] packages_store Existing packages store
26
26
  # @return [Ree::PackagesStore]
@@ -36,14 +36,14 @@ class Ree::PackagesSchemaLoader
36
36
  end
37
37
 
38
38
  schema_type = schema.fetch(Schema::SCHEMA_TYPE)
39
-
39
+
40
40
  if schema_type != Schema::PACKAGES
41
41
  raise Ree::Error.new("Invalid schema type: #{abs_schema_path}", :invalid_packages_schema)
42
42
  end
43
43
 
44
- ree_version = schema.fetch(Schema::REE_VERSION)
44
+ schema_version = schema.fetch(Schema::SCHEMA_VERSION) { Schema::SCHEMA_VERSION_NUMBER }
45
45
  data = schema.fetch(Schema::PACKAGES)
46
- packages_store ||= Ree::PackagesStore.new(ree_version)
46
+ packages_store ||= Ree::PackagesStore.new()
47
47
  names = {}
48
48
 
49
49
  data.each do |item|
@@ -62,7 +62,7 @@ class Ree::PackagesSchemaLoader
62
62
  names[name] = true
63
63
 
64
64
  package = Ree::Package.new(
65
- ree_version,
65
+ schema_version,
66
66
  name.to_sym,
67
67
  Ree::PathHelper.package_entry_path(schema_rpath),
68
68
  schema_rpath,
@@ -78,10 +78,10 @@ class Ree::PackagesSchemaLoader
78
78
  raise Ree::Error.new("Unable to add package `#{existing.name}` from `#{package.gem_name}` gem. Package was already added from `#{existing.gem_name}` gem.", :duplicate_package)
79
79
  end
80
80
  end
81
-
81
+
82
82
  packages_store.add_package(
83
83
  Ree::Package.new(
84
- ree_version,
84
+ schema_version,
85
85
  name.to_sym,
86
86
  Ree::PathHelper.package_entry_path(schema_rpath),
87
87
  schema_rpath,
@@ -40,14 +40,12 @@ class Ree::ObjectDsl
40
40
  # @param [Symbol] object_name
41
41
  # @param [Nilor[Symbol]] as
42
42
  # @param [Nilor[Symbol]] from
43
- # @param [Nilor[ArrayOf[Symbol]]] methods
44
43
  # @param [Nilor[Proc]] import
45
- def link_object(object_name, as: nil, from: nil, methods: nil, import: nil)
44
+ def link_object(object_name, as: nil, from: nil, import: nil)
46
45
  check_arg(object_name, :object_name, Symbol)
47
46
  check_arg(as, :as, Symbol) if as
48
47
  check_arg(from, :from, Symbol) if from
49
48
  check_arg(import, :import, Proc) if import
50
- check_arg_array_of(methods, :methods, Symbol) if methods
51
49
 
52
50
  link_package_name = from.nil? ? @object.package_name : from
53
51
  link_object_name = object_name
@@ -13,7 +13,17 @@ class Ree::PackagesFacade
13
13
  class << self
14
14
  def write_packages_schema
15
15
  Ree.logger.debug("write_packages_schema")
16
- Ree::PackagesSchemaBuilder.new.call
16
+ packages_schema = Ree::PackagesSchemaBuilder.new.call
17
+
18
+ json = JSON.pretty_generate(packages_schema)
19
+
20
+ File.write(
21
+ File.join(Ree.root_dir, Ree::PACKAGES_SCHEMA_FILE),
22
+ json,
23
+ mode: 'w'
24
+ )
25
+
26
+ json
17
27
  end
18
28
  end
19
29
 
@@ -60,7 +70,16 @@ class Ree::PackagesFacade
60
70
 
61
71
  if package.dir
62
72
  schema_path = Ree::PathHelper.abs_package_schema_path(package)
63
- Ree::PackageSchemaBuilder.new.call(package, schema_path)
73
+
74
+ if !File.exists?(schema_path)
75
+ raise Ree::Error.new("File does not exist: #{schema_path}", :invalid_path)
76
+ end
77
+
78
+ schema = Ree::PackageSchemaBuilder.new.call(package)
79
+ json = JSON.pretty_generate(schema)
80
+ File.write(schema_path, json, mode: 'w')
81
+
82
+ json
64
83
  end
65
84
  end
66
85
 
@@ -77,7 +96,16 @@ class Ree::PackagesFacade
77
96
 
78
97
  schema_path = Ree::PathHelper.abs_object_schema_path(object)
79
98
 
80
- Ree::ObjectSchemaBuilder.new.call(object, schema_path)
99
+ if !File.exists?(schema_path)
100
+ only_dir_path = schema_path.split('/')[0..-2]
101
+ FileUtils.mkdir_p(File.join(only_dir_path))
102
+ end
103
+
104
+ schema = Ree::ObjectSchemaBuilder.new.call(object)
105
+ json = JSON.pretty_generate(schema)
106
+ File.write(schema_path, json, mode: 'w')
107
+
108
+ json
81
109
  end
82
110
 
83
111
  # @param [Symbol] package_name
data/lib/ree/link_dsl.rb CHANGED
@@ -39,14 +39,12 @@ module Ree::LinkDSL
39
39
  # @param [Symbol] object_name
40
40
  # @param [Nilor[Symbol]] as
41
41
  # @param [Nilor[Symbol]] from
42
- # @param [Nilor[ArrayOf[Symbol]]] methods
43
42
  # @param [Nilor[Proc]] import
44
- def _link_object(object_name, as: nil, from: nil, methods: nil, import: nil)
43
+ def _link_object(object_name, as: nil, from: nil, import: nil)
45
44
  check_arg(object_name, :object_name, Symbol)
46
45
  check_arg(as, :as, Symbol) if as
47
46
  check_arg(from, :from, Symbol) if from
48
47
  check_arg(import, :import, Proc) if import
49
- check_arg_array_of(methods, :methods, Symbol) if methods
50
48
 
51
49
  package_name = Ree::StringUtils.underscore(self.name.split('::').first).to_sym
52
50
  link_package_name = from.nil? ? package_name : from
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.0"
4
+ VERSION = "1.0.3"
5
5
  end
data/lib/ree.rb CHANGED
@@ -244,6 +244,7 @@ module Ree
244
244
  facade.load_packages_schema
245
245
 
246
246
  facade.packages_store.packages.each do |package|
247
+ next if package.gem?
247
248
  puts("Generating Package.schema.json for :#{package.name} package") if !silence
248
249
 
249
250
  facade.load_entire_package(package.name)
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.0
4
+ version: 1.0.3
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-07-23 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -170,13 +170,13 @@ files:
170
170
  - lib/ree/utils/string_utils.rb
171
171
  - lib/ree/version.rb
172
172
  - sig/ree.rbs
173
- homepage: https://github.com/glabix/ree/ree
173
+ homepage: https://github.com/glabix/ree/tree/main/ree
174
174
  licenses:
175
175
  - MIT
176
176
  metadata:
177
- homepage_uri: https://github.com/glabix/ree/ree
178
- source_code_uri: https://github.com/glabix/ree/ree
179
- changelog_uri: https://github.com/glabix/ree/ree/CHANGELOG.md
177
+ homepage_uri: https://github.com/glabix/ree/tree/main/ree
178
+ source_code_uri: https://github.com/glabix/ree/tree/main/ree
179
+ changelog_uri: https://github.com/glabix/ree/blob/main/ree/CHANGELOG.md
180
180
  post_install_message:
181
181
  rdoc_options: []
182
182
  require_paths: