jsonapi-resources-anchor 2.1.0 → 2.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e34fe32b3b500608a9ca5a8b76d788e9d52529776617dc2adfe0b5fc9729227f
|
4
|
+
data.tar.gz: 04be2113fb3fb89ba4c632be707c6eb1fb84384683894574b62419b9a5ef30fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddda9cf3dc36bf3bc8d8d4fc0f0b9e81d8890fc36d517766fe84e7a1b79d1c351ecbdf5a46cb2ab3ceccda4c3f6ab6efbd6e9bd46fb05015cefcd8252a136b27
|
7
|
+
data.tar.gz: a190c28448ada445356f02a3a2eae69200f65b786744ab7394dae83070d1878ed7ab1efee7d04d18b902f478f3b32c3e7ac487210d7ae11d3acde924176a77f6
|
@@ -24,14 +24,15 @@ module Anchor::TypeScript
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def initialize(definition)
|
27
|
+
def initialize(definition, extension: ".ts")
|
28
28
|
@definition = definition
|
29
29
|
@name = definition.name
|
30
30
|
@object = definition.object
|
31
|
+
@extension = extension
|
31
32
|
end
|
32
33
|
|
33
34
|
def name
|
34
|
-
"#{@definition.name}
|
35
|
+
"#{@definition.name}#{@extension}"
|
35
36
|
end
|
36
37
|
|
37
38
|
def to_code(manually_editable: false)
|
@@ -66,7 +67,7 @@ module Anchor::TypeScript
|
|
66
67
|
def relationship_imports
|
67
68
|
relationships_to_import
|
68
69
|
.reject { |type| type.anchor_schema_name == @name }
|
69
|
-
.map { |type| Import.new(file_name: "#{type.anchor_schema_name}
|
70
|
+
.map { |type| Import.new(file_name: "#{type.anchor_schema_name}#{@extension}", type:) }
|
70
71
|
end
|
71
72
|
|
72
73
|
def relationships_to_import
|
@@ -8,11 +8,10 @@ module Anchor::TypeScript
|
|
8
8
|
new(...).call
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(generator:, folder_path:, force: false
|
11
|
+
def initialize(generator:, folder_path:, force: false)
|
12
12
|
@generator = generator
|
13
13
|
@folder_path = folder_path
|
14
14
|
@force = force
|
15
|
-
@resource_file_extension = "." + resource_file_extension.sub(/^\./, "")
|
16
15
|
end
|
17
16
|
|
18
17
|
def call
|
@@ -24,13 +23,7 @@ module Anchor::TypeScript
|
|
24
23
|
private
|
25
24
|
|
26
25
|
def save_result(result)
|
27
|
-
|
28
|
-
resource_file_name(result.name)
|
29
|
-
else
|
30
|
-
result.name
|
31
|
-
end
|
32
|
-
|
33
|
-
path = Rails.root.join(@folder_path, filename)
|
26
|
+
path = Rails.root.join(@folder_path, result.name)
|
34
27
|
|
35
28
|
if @force || !File.exist?(path)
|
36
29
|
File.open(path, "w") { |f| f.write(result.text) }
|
@@ -51,10 +44,6 @@ module Anchor::TypeScript
|
|
51
44
|
File.open(path, "w") { |f| f.write(new_content) }
|
52
45
|
end
|
53
46
|
|
54
|
-
def resource_file_name(name)
|
55
|
-
File.basename(name, ".ts") + @resource_file_extension
|
56
|
-
end
|
57
|
-
|
58
47
|
def manually_editable?(text)
|
59
48
|
!text.match(REGEX).nil?
|
60
49
|
end
|
@@ -7,12 +7,20 @@ module Anchor::TypeScript
|
|
7
7
|
UTIL = "util"
|
8
8
|
end
|
9
9
|
|
10
|
-
def initialize(
|
10
|
+
def initialize( # rubocop:disable Lint/MissingSuper
|
11
|
+
register:,
|
12
|
+
context: {},
|
13
|
+
include_all_fields: false,
|
14
|
+
exclude_fields: nil,
|
15
|
+
manually_editable: true,
|
16
|
+
resource_file_extension: ".ts"
|
17
|
+
)
|
11
18
|
@register = register
|
12
19
|
@context = context
|
13
20
|
@include_all_fields = include_all_fields
|
14
21
|
@exclude_fields = exclude_fields
|
15
22
|
@manually_editable = manually_editable
|
23
|
+
@resource_file_extension = "." + resource_file_extension.sub(/^\./, "")
|
16
24
|
end
|
17
25
|
|
18
26
|
def call
|
@@ -37,7 +45,7 @@ module Anchor::TypeScript
|
|
37
45
|
exclude_fields: @exclude_fields.nil? ? [] : @exclude_fields[r.anchor_schema_name.to_sym],
|
38
46
|
)
|
39
47
|
|
40
|
-
file_structure = ::Anchor::TypeScript::FileStructure.new(definition)
|
48
|
+
file_structure = ::Anchor::TypeScript::FileStructure.new(definition, extension: @resource_file_extension)
|
41
49
|
text = file_structure.to_code(manually_editable: @manually_editable)
|
42
50
|
name = file_structure.name
|
43
51
|
Result.new(name:, text:, type: FileType::RESOURCE)
|
data/lib/anchor/version.rb
CHANGED