emp_json 1.2.0 → 1.3.0.pre.g9596e781b

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: 1be366fe90935e2183bfcebab791742f36bda1eb0d2b4b957d3f8712c8e5021a
4
- data.tar.gz: 1e5def92984e8327e5a46712e9c3c615093535eed826f5cd7e406122036274b1
3
+ metadata.gz: 84cc8976cd03cf429641613fd5467538ea535c49e88c71809061f4c3090cb84d
4
+ data.tar.gz: da8634f8408c17d6d32ec1cca6681016a455f36d51a1c22a96005339a39a392b
5
5
  SHA512:
6
- metadata.gz: 53fdb4ad35c3cb6229bc91f0c78db2ebbf29bcfb7286c905b136f4d0f68282fd32701e7df7159dc9517bbeda1b27659b54e9ce9be4763d8d6f188bc14f34029f
7
- data.tar.gz: d3b8fd2957612cb2fe6a7c508dceb09b9583d1fc9eae67fc065c357b6278de13e0cc6e6a94ca2e9ee9aab757b743a0f354134bde14a0000795a34c619166a887
6
+ metadata.gz: b549efd7b3131794ec10737312dd71ccef5f8b2ac64aeaa3ecc15662e3fd18fe87813c6493b89db8cb2f932f557e51b239bbbfbccddfb10cef4bcaee75a1c271
7
+ data.tar.gz: 812cb4fe6c46d2b823e7a1f50422762f3289912a304299dd865a7ce15ab8935c83f7798f96921439f554f0d6eb623e66a0c14c142509a8b6893a080590a8bc87
data/Gemfile CHANGED
@@ -16,3 +16,5 @@ gem "activemodel", "~> 7"
16
16
  gem "activesupport", "~> 7"
17
17
 
18
18
  gem "rdf"
19
+
20
+ gem "rbs"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- emp_json (1.2.0)
4
+ emp_json (1.3.0.pre.g9596e781b)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -24,6 +24,7 @@ GEM
24
24
  ast (~> 2.4.1)
25
25
  rainbow (3.1.1)
26
26
  rake (13.0.6)
27
+ rbs (2.6.0)
27
28
  rdf (3.2.7)
28
29
  link_header (~> 0.0, >= 0.0.8)
29
30
  regexp_parser (2.3.1)
@@ -55,6 +56,7 @@ DEPENDENCIES
55
56
  emp_json!
56
57
  minitest (~> 5.0)
57
58
  rake (~> 13.0)
59
+ rbs
58
60
  rdf
59
61
  rubocop (~> 1.21)
60
62
 
data/emp-json-rb.gemspec CHANGED
@@ -3,8 +3,11 @@
3
3
  require_relative "lib/empathy/emp_json/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
+ prerelease = ENV.fetch("PUBLISH_PRERELEASE", false)
7
+ env_version = ENV.fetch("GITHUB_SHA", "")[0..8]
8
+
6
9
  spec.name = "emp_json"
7
- spec.version = Empathy::EmpJson::VERSION
10
+ spec.version = prerelease ? "#{Empathy::EmpJson::VERSION}-g#{env_version}" : Empathy::EmpJson::VERSION
8
11
  spec.authors = ["Thom van Kalkeren"]
9
12
  spec.email = ["thom@ontola.io"]
10
13
 
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adds to_emp_json to Hash
4
+ class Hash
5
+ # Converts hash to emp_json
6
+ class EmpConverter
7
+ extend Empathy::EmpJson::Helpers::Primitives
8
+
9
+ class << self
10
+ def convert(hash)
11
+ hash.each_with_object({}) do |(key, value), slice|
12
+ slice[key.to_s] = value.transform_keys(&:to_s).transform_values do |v|
13
+ case v
14
+ when Hash
15
+ v
16
+ when Array
17
+ v.map(&method(:object_to_value))
18
+ else
19
+ object_to_value(v)
20
+ end
21
+ end
22
+ slice[key.to_s]["_id"] = object_to_value(key)
23
+ slice
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def to_emp_json
30
+ EmpConverter.convert(self)
31
+ end
32
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Empathy
4
+ module EmpJson
5
+ module Helpers
6
+ # Functions relating to parsing emp_json.
7
+ module Parsing
8
+ include Primitives
9
+
10
+ def emp_to_primitive(emp_value) # rubocop:disable Metrics/MethodLength
11
+ type = emp_value.with_indifferent_access[:type]
12
+ value = emp_value.with_indifferent_access[:v]
13
+
14
+ case type
15
+ when EMP_TYPE_GLOBAL_ID
16
+ RDF::URI(value)
17
+ when EMP_TYPE_LOCAL_ID
18
+ RDF::Node(value.split(":").last)
19
+ when EMP_TYPE_DATE
20
+ Date.iso8601(value)
21
+ when EMP_TYPE_DATETIME
22
+ Time.iso8601(value)
23
+ when EMP_TYPE_BOOL
24
+ value == "true"
25
+ when EMP_TYPE_INTEGER, EMP_TYPE_LONG
26
+ value.to_i
27
+ when EMP_TYPE_PRIMITIVE
28
+ use_rdf_rb_for_parsing(value, emp_value[:dt])
29
+ when EMP_TYPE_STRING, EMP_TYPE_LANGSTRING
30
+ value
31
+ else
32
+ throw_unknown_emp_type(type, value)
33
+ end
34
+ end
35
+
36
+ def use_rdf_rb_for_parsing(value, datatype)
37
+ RDF::Literal(value, datatype: datatype).object
38
+ end
39
+
40
+ def throw_unknown_emp_type(type, value)
41
+ throw "unknown emp type: #{type} (#{value})"
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -6,9 +6,10 @@ module Empathy
6
6
  module EmpJson
7
7
  module Helpers
8
8
  # Functions relating to serializing primitives.
9
- module Primitives
9
+ module Primitives # rubocop:disable Metrics/ModuleLength
10
10
  EMP_TYPE_GLOBAL_ID = "id"
11
11
  EMP_TYPE_LOCAL_ID = "lid"
12
+ EMP_TYPE_DATE = "date"
12
13
  EMP_TYPE_DATETIME = "dt"
13
14
  EMP_TYPE_STRING = "s"
14
15
  EMP_TYPE_BOOL = "b"
@@ -21,7 +22,9 @@ module Empathy
21
22
  RDF_RDFV_LANGSTRING = "#{RDF_RDFV}langString"
22
23
  RDF_RDFS = "http://www.w3.org/2000/01/rdf-schema#"
23
24
  RDF_XSD = "http://www.w3.org/2001/XMLSchema#"
25
+ RDF_XSD_TOKEN = "#{RDF_XSD}token"
24
26
  RDF_XSD_STRING = "#{RDF_XSD}string"
27
+ RDF_XSD_DATE = "#{RDF_XSD}date"
25
28
  RDF_XSD_DATETIME = "#{RDF_XSD}dateTime"
26
29
  RDF_XSD_BOOLEAN = "#{RDF_XSD}boolean"
27
30
  RDF_XSD_INTEGER = "#{RDF_XSD}integer"
@@ -38,7 +41,7 @@ module Empathy
38
41
  shorthand(EMP_TYPE_LOCAL_ID, "_:#{value.id}")
39
42
  end
40
43
 
41
- def primitive_to_value(value) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
44
+ def primitive_to_value(value) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
42
45
  throw_unknown_ruby_object(value) if value.nil?
43
46
 
44
47
  case value
@@ -48,6 +51,8 @@ module Empathy
48
51
  shorthand(EMP_TYPE_GLOBAL_ID, value.to_s)
49
52
  when DateTime, ActiveSupport::TimeWithZone
50
53
  shorthand(EMP_TYPE_DATETIME, value.iso8601)
54
+ when Date
55
+ shorthand(EMP_TYPE_DATE, value.iso8601)
51
56
  when String, Symbol
52
57
  shorthand(EMP_TYPE_STRING, value.to_s)
53
58
  when true, false
@@ -74,7 +79,7 @@ module Empathy
74
79
  end
75
80
  end
76
81
 
77
- def rdf_literal_to_value(value)
82
+ def rdf_literal_to_value(value) # rubocop:disable Metrics/AbcSize
78
83
  case value.datatype.to_s
79
84
  when RDF_RDFV_LANGSTRING
80
85
  {
@@ -82,8 +87,10 @@ module Empathy
82
87
  l: value.language.to_s,
83
88
  v: value.value
84
89
  }
85
- when RDF_XSD_STRING
90
+ when RDF_XSD_STRING, RDF_XSD_TOKEN
86
91
  shorthand(EMP_TYPE_STRING, value.value)
92
+ when RDF_XSD_DATE
93
+ shorthand(EMP_TYPE_DATE, value.value)
87
94
  when RDF_XSD_DATETIME
88
95
  shorthand(EMP_TYPE_DATETIME, value.value)
89
96
  when RDF_XSD_BOOLEAN
@@ -91,7 +98,7 @@ module Empathy
91
98
  when RDF_XSD_INTEGER
92
99
  integer_to_value(value.to_i)
93
100
  else
94
- throw "unknown RDF::Literal: #{value.datatype}"
101
+ throw "unknown RDF::Literal"
95
102
  end
96
103
  end
97
104
 
@@ -10,18 +10,18 @@ module Empathy
10
10
  loop do
11
11
  list_item_to_record(slice, elem, symbolize)
12
12
 
13
- break if elem.rest_subject == NS.rdfv.nil
13
+ break if elem.rest_subject == RDF::RDFV.nil
14
14
 
15
15
  elem = elem.rest
16
16
  end
17
17
  end
18
18
 
19
- def list_item_to_record(slice, elem, symbolize) # rubocop:disable Metrics/AbcSize
19
+ def list_item_to_record(slice, elem, symbolize)
20
20
  rid = add_record_to_slice(slice, elem)
21
- add_attribute_to_record(slice, rid, NS.rdfv.type, NS.rdfv.List, symbolize)
21
+ add_attribute_to_record(slice, rid, RDF::RDFV.type, RDF::RDFV.List, symbolize)
22
22
  first = elem.first.is_a?(RDF::Term) ? elem.first : retrieve_id(elem.first)
23
- add_attribute_to_record(slice, rid, NS.rdfv.first, first, symbolize)
24
- add_attribute_to_record(slice, rid, NS.rdfv.rest, elem.rest_subject, symbolize)
23
+ add_attribute_to_record(slice, rid, RDF::RDFV.first, first, symbolize)
24
+ add_attribute_to_record(slice, rid, RDF::RDFV.rest, elem.rest_subject, symbolize)
25
25
  end
26
26
  end
27
27
  end
@@ -56,7 +56,7 @@ module Empathy
56
56
  end
57
57
 
58
58
  def retrieve_id(resource)
59
- return resource.to_s if resource.is_a?(URI) || resource.is_a?(RDF::URI)
59
+ return resource.to_s if resource.is_a?(URI) || resource.is_a?(RDF::URI) || resource.is_a?(RDF::Node)
60
60
 
61
61
  resource.try(:iri) || resource.try(:subject) || resource.try(:id) || resource
62
62
  end
@@ -71,12 +71,6 @@ module Empathy
71
71
  values.is_a?(Array) ? values.map(&:with_indifferent_access) : values&.with_indifferent_access
72
72
  end
73
73
 
74
- def expand(slice, website_iri = current_tenant)
75
- return slice unless website_iri.present?
76
-
77
- slice.transform_keys { |k| k.start_with?("/") ? website_iri + k : k }
78
- end
79
-
80
74
  def field_to_symbol(uri)
81
75
  (uri.fragment || uri.path.split("/").last).camelize(:lower)
82
76
  end
@@ -11,7 +11,7 @@ module Empathy
11
11
  when LinkedRails::Sequence
12
12
  collect_sequence_and_members(nested_resources, slice, resource, value, serialization_params)
13
13
  when RDF::List
14
- nested_resources.push value unless value.subject == NS.rdfv.nil
14
+ nested_resources.push value unless value.subject == RDF::RDFV.nil
15
15
  when Array
16
16
  collect_array_members(nested_resources, slice, resource, value, serialization_params)
17
17
  else
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Empathy
4
4
  module EmpJson
5
- VERSION = "1.2.0"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
@@ -4,6 +4,8 @@ require "empathy/emp_json/helpers/primitives"
4
4
  require "empathy/emp_json/helpers/rdf_list"
5
5
  require "empathy/emp_json/helpers/slices"
6
6
  require "empathy/emp_json/helpers/values"
7
+ require "empathy/emp_json/helpers/parsing"
8
+ require "empathy/emp_json/helpers/hash"
7
9
  require "empathy/emp_json/serializer"
8
10
 
9
11
  module Empathy
@@ -0,0 +1,88 @@
1
+ ---
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+ path: ".gem_rbs_collection"
8
+ gems:
9
+ - name: activemodel
10
+ version: '6.0'
11
+ source:
12
+ type: git
13
+ name: ruby/gem_rbs_collection
14
+ revision: e59b7d94d326a1ac66c6bce8cb82cbabf1734726
15
+ remote: https://github.com/ruby/gem_rbs_collection.git
16
+ repo_dir: gems
17
+ - name: activesupport
18
+ version: '6.0'
19
+ source:
20
+ type: git
21
+ name: ruby/gem_rbs_collection
22
+ revision: e59b7d94d326a1ac66c6bce8cb82cbabf1734726
23
+ remote: https://github.com/ruby/gem_rbs_collection.git
24
+ repo_dir: gems
25
+ - name: ast
26
+ version: '2.4'
27
+ source:
28
+ type: git
29
+ name: ruby/gem_rbs_collection
30
+ revision: e59b7d94d326a1ac66c6bce8cb82cbabf1734726
31
+ remote: https://github.com/ruby/gem_rbs_collection.git
32
+ repo_dir: gems
33
+ - name: i18n
34
+ version: '1.10'
35
+ source:
36
+ type: git
37
+ name: ruby/gem_rbs_collection
38
+ revision: e59b7d94d326a1ac66c6bce8cb82cbabf1734726
39
+ remote: https://github.com/ruby/gem_rbs_collection.git
40
+ repo_dir: gems
41
+ - name: minitest
42
+ version: '0'
43
+ source:
44
+ type: stdlib
45
+ - name: parallel
46
+ version: '1.20'
47
+ source:
48
+ type: git
49
+ name: ruby/gem_rbs_collection
50
+ revision: e59b7d94d326a1ac66c6bce8cb82cbabf1734726
51
+ remote: https://github.com/ruby/gem_rbs_collection.git
52
+ repo_dir: gems
53
+ - name: rainbow
54
+ version: '3.0'
55
+ source:
56
+ type: git
57
+ name: ruby/gem_rbs_collection
58
+ revision: e59b7d94d326a1ac66c6bce8cb82cbabf1734726
59
+ remote: https://github.com/ruby/gem_rbs_collection.git
60
+ repo_dir: gems
61
+ - name: monitor
62
+ version: '0'
63
+ source:
64
+ type: stdlib
65
+ - name: date
66
+ version: '0'
67
+ source:
68
+ type: stdlib
69
+ - name: singleton
70
+ version: '0'
71
+ source:
72
+ type: stdlib
73
+ - name: logger
74
+ version: '0'
75
+ source:
76
+ type: stdlib
77
+ - name: mutex_m
78
+ version: '0'
79
+ source:
80
+ type: stdlib
81
+ - name: time
82
+ version: '0'
83
+ source:
84
+ type: stdlib
85
+ - name: pathname
86
+ version: '0'
87
+ source:
88
+ type: stdlib
@@ -0,0 +1,17 @@
1
+ # Download sources
2
+ sources:
3
+ - name: ruby/gem_rbs_collection
4
+ remote: https://github.com/ruby/gem_rbs_collection.git
5
+ revision: main
6
+ repo_dir: gems
7
+
8
+ # A directory to install the downloaded RBSs
9
+ path: .gem_rbs_collection
10
+
11
+ gems:
12
+ # Skip loading rbs gem's RBS.
13
+ # It's unnecessary if you don't use rbs as a library.
14
+ - name: rbs
15
+ ignore: true
16
+ - name: emp_json
17
+ ignore: true
@@ -0,0 +1,11 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Helpers
4
+ module Parsing
5
+ def emp_to_primitive: (Primitives::shorthand | Primitives::primitive emp_value) -> (RDF::URI | RDF::Node | RDF::Literal | Date | Time | bool | Numeric | String)
6
+
7
+ def use_rdf_rb_for_parsing: (string value, string datatype) -> untyped
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,70 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Helpers
4
+ module Primitives
5
+ EMP_TYPE_GLOBAL_ID: "id"
6
+
7
+ EMP_TYPE_LOCAL_ID: "lid"
8
+
9
+ EMP_TYPE_DATE: "date"
10
+
11
+ EMP_TYPE_DATETIME: "dt"
12
+
13
+ EMP_TYPE_STRING: "s"
14
+
15
+ EMP_TYPE_BOOL: "b"
16
+
17
+ EMP_TYPE_INTEGER: "i"
18
+
19
+ EMP_TYPE_LONG: "l"
20
+
21
+ EMP_TYPE_PRIMITIVE: "p"
22
+
23
+ EMP_TYPE_LANGSTRING: "ls"
24
+
25
+ RDF_RDFV: "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
26
+
27
+ RDF_RDFV_LANGSTRING: "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
28
+
29
+ RDF_RDFS: "http://www.w3.org/2000/01/rdf-schema#"
30
+
31
+ RDF_XSD: "http://www.w3.org/2001/XMLSchema#"
32
+
33
+ RDF_XSD_TOKEN: "http://www.w3.org/2001/XMLSchema#token"
34
+
35
+ RDF_XSD_STRING: "http://www.w3.org/2001/XMLSchema#string"
36
+
37
+ RDF_XSD_DATE: "http://www.w3.org/2001/XMLSchema#date"
38
+
39
+ RDF_XSD_DATETIME: "http://www.w3.org/2001/XMLSchema#datetime"
40
+
41
+ RDF_XSD_BOOLEAN: "http://www.w3.org/2001/XMLSchema#boolean"
42
+
43
+ RDF_XSD_INTEGER: "http://www.w3.org/2001/XMLSchema#integer"
44
+
45
+ type shorthand = { type: string, v: string }
46
+ type primitive = { type: string, dt: string, v: string }
47
+
48
+ def serialize_emp: (Hash[untyped, untyped] hash) -> Slices::slice
49
+
50
+ def object_to_value: (untyped value) -> shorthand
51
+
52
+ def node_to_local_id: (untyped value) -> shorthand
53
+
54
+ def primitive_to_value: (untyped value) -> shorthand
55
+
56
+ def integer_to_value: (Integer value) -> shorthand
57
+
58
+ def rdf_literal_to_value: (untyped value) -> shorthand
59
+
60
+ def use_rdf_rb_for_primitive: (untyped value) -> primitive
61
+
62
+ def shorthand: (string `type`, string value) -> shorthand
63
+
64
+ def primitive: (untyped datatype, untyped value) -> primitive
65
+
66
+ def throw_unknown_ruby_object: (untyped value) -> untyped
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,11 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Helpers
4
+ module RDFList
5
+ def add_rdf_list_to_slice: (Slices::slice slice, Serializer::symbolize symbolize, **Serializer::Serializing::emp_options options) -> void
6
+
7
+ def list_item_to_record: (Slices::slice slice, untyped elem, Serializer::symbolize symbolize) -> void
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Helpers
4
+ module Slices
5
+ type record = Hash[string | Symbol, Primitives::shorthand | Primitives::primitive]
6
+ type slice = Hash[string | Symbol, record]
7
+ type id = String | RDF::URI
8
+
9
+ def all_values_from_slice: (slice slice, id field, ?untyped? _website_iri) -> untyped
10
+
11
+ def add_record_to_slice: (slice slice, untyped resource) -> untyped
12
+
13
+ def values_from_slice: (slice slice, untyped id, id field, ?untyped? website_iri) -> untyped
14
+
15
+ def field_from_slice: (slice slice, untyped id, id field, ?untyped? website_iri) -> (nil | untyped)
16
+
17
+ def record_from_slice: (slice slice, untyped id, ?untyped? website_iri) -> untyped
18
+
19
+ def field_from_record: (untyped record, id field) -> untyped
20
+
21
+ def retrieve_id: (untyped resource) -> untyped
22
+
23
+ def absolutized_id: (untyped id, ?untyped? website_iri) -> untyped
24
+
25
+ def normalise_slice_values: (untyped values) -> untyped
26
+
27
+ def field_to_symbol: (untyped uri) -> untyped
28
+
29
+ def slice_includes_record?: (slice slice, untyped resource) -> untyped
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Helpers
4
+ module Values
5
+ def add_attribute_to_record: (Slices::slice slice, untyped rid, untyped key, untyped value, Serializer::symbolize symbolize) -> (nil | untyped)
6
+
7
+ def wrap_relation_in_sequence: (untyped value, untyped resource) -> untyped
8
+
9
+ def uri_to_symbol: (untyped uri, Serializer::symbolize symbolize) -> untyped
10
+
11
+ def value_to_emp_value: (untyped value) -> untyped
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Serializer
4
+ module Fields
5
+ def serialize_attributes_to_record: (untyped serializer, Helpers::Slices::slice slice, untyped resource, untyped rid, Serializing::serialization_params serialization_params) -> (::Array[untyped] | untyped)
6
+
7
+ def serialize_statements: (untyped serializer, Helpers::Slices::slice slice, untyped resource, Serializing::serialization_params serialization_params) -> untyped
8
+
9
+ def serialize_relations_to_record: (untyped serializer, Helpers::Slices::slice slice, untyped resource, untyped rid, Serializing::serialization_params serialization_params) -> (::Array[untyped] | untyped)
10
+
11
+ def value_for_attribute: (untyped attr, untyped resource, Serializing::serialization_params serialization_params) -> untyped
12
+
13
+ def value_for_relation: (untyped relation, untyped resource, Serializing::serialization_params serialization_params) -> (nil | untyped)
14
+
15
+ def unpack_relation_value: (untyped relation, untyped resource, Serializing::serialization_params serialization_params) -> untyped
16
+
17
+ def unpack_statement: (untyped statement) -> ::Array[untyped]
18
+
19
+ def predicate_to_symbol: (untyped attr) -> untyped
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Serializer
4
+ module Inclusion
5
+ def collect_nested_resources: (untyped nested_resources, Helpers::Slices::slice slice, untyped resource, untyped value, Serializing::serialization_params serialization_params) -> untyped
6
+
7
+ def collect_sequence_and_members: (untyped nested_resources, Helpers::Slices::slice slice, untyped resource, untyped value, Serializing::serialization_params serialization_params) -> untyped
8
+
9
+ def collect_array_members: (untyped nested_resources, Helpers::Slices::slice slice, untyped resource, untyped value, Serializing::serialization_params serialization_params) -> untyped
10
+
11
+ def blank_value?: (untyped value) -> untyped
12
+
13
+ def nested_resource?: (untyped resource, untyped value) -> untyped
14
+
15
+ def process_includes: (Helpers::Slices::slice slice, Serializing::serialization_params serialization_params, **Serializer::Serializing::emp_options options) -> untyped
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Serializer
4
+ module Records
5
+ def serialize_record: (Helpers::Slices::slice slice, Serializing::serialization_params serialization_params, **Serializer::Serializing::emp_options options) -> untyped
6
+
7
+ def serialize_record_fields: (untyped serializer, Helpers::Slices::slice slice, untyped resource, untyped rid, Serializing::serialization_params serialization_params) -> untyped
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Serializer
4
+ module Sequence
5
+ attr_accessor symbolize: Serializer::symbolize
6
+
7
+ def add_sequence_to_slice: (Helpers::Slices::slice slice, Serializing::serialization_params serialization_params, **Serializing::emp_options options) -> untyped
8
+
9
+ def process_sequence_members: (untyped serializer, Helpers::Slices::slice slice, untyped resource, untyped rid, Serializing::serialization_params serialization_params, **Serializing::emp_options options) -> untyped
10
+
11
+ def process_sequence_member: (untyped member, untyped index, untyped nested, untyped serializer, Helpers::Slices::slice slice, untyped resource, untyped rid, Serializing::serialization_params serialization_params) -> untyped
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Serializer
4
+ module Serializing
5
+ type serialization_params = Hash[string, untyped]
6
+ type emp_options = {includes: untyped?, resource: untyped?, serializer_class: untyped?}
7
+
8
+ def render_emp_json: (?untyped resource) -> string
9
+
10
+ def emp_json_hash: (?untyped _resource) -> Helpers::Slices::slice
11
+
12
+ def create_slice: (untyped resources) -> Helpers::Slices::slice
13
+
14
+ def resource_to_emp_json: (Helpers::Slices::slice slice, serialization_params serialization_params, **emp_options options) -> void
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ module Empathy
2
+ module EmpJson
3
+ module Serializer
4
+ # extend ActiveSupport::Concern
5
+
6
+ include Helpers::Primitives
7
+
8
+ include Helpers::RDFList
9
+
10
+ include Helpers::Slices
11
+
12
+ include Helpers::Values
13
+
14
+ include Fields
15
+
16
+ include Inclusion
17
+
18
+ include Records
19
+
20
+ include Sequence
21
+
22
+ include Serializing
23
+
24
+ type symbolize = :class | bool
25
+
26
+ attr_accessor symbolize: symbolize
27
+
28
+ # def initialize: (untyped resource, ?::Hash[untyped, untyped] opts) -> void
29
+
30
+ def dump: (*untyped args, **untyped options) -> untyped
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,12 @@
1
+ module Empathy
2
+ module EmpJson
3
+ SUPPORTS_RDF_RB: bool
4
+
5
+ SUPPORTS_SEQUENCE: bool
6
+
7
+ SUPPORTS_AR: bool
8
+
9
+ class Error < StandardError
10
+ end
11
+ end
12
+ end
data/sig/lib/rdf.rbs ADDED
@@ -0,0 +1,261 @@
1
+ module RDF
2
+ module Value
3
+ def graph?: (*untyped args) -> false
4
+ def statement?: (*untyped args) -> false
5
+ def list?: -> false
6
+ def term?: (*untyped args) -> false
7
+ def resource?: -> false
8
+ def literal?: -> false
9
+ def node?: -> false
10
+ def iri?: -> false
11
+ def uri?: -> false
12
+ def variable?: (*untyped args) -> false
13
+ def constant?: -> true
14
+ def anonymous?: -> false
15
+ def valid?: -> true
16
+ def invalid?: -> bool
17
+ def validate!: -> Value
18
+ def start_with?: (String? string) -> bool
19
+ def canonicalize: -> untyped
20
+ def canonicalize!: -> Value
21
+ def to_rdf: -> Value
22
+ def to_term: -> Term
23
+ def inspect: -> untyped
24
+ def inspect!: -> untyped
25
+ def type_error: (untyped message) -> false
26
+ end
27
+
28
+ module Term
29
+ include Comparable
30
+ include Value
31
+
32
+ def <=>: (untyped other) -> untyped
33
+ def ==: (untyped other) -> bool
34
+ def eql?: (untyped other) -> untyped
35
+ def term?: (*untyped args) -> bool
36
+ def to_term: -> Term
37
+ def terms: -> [Term]
38
+ def to_base: -> untyped
39
+ def compatible?: (untyped other) -> false
40
+ def escape: (string string) -> untyped
41
+ end
42
+
43
+ module Resource
44
+ include Term
45
+
46
+ def self.new: (*untyped args) -> URI
47
+ def resource?: -> true
48
+ end
49
+
50
+ class Literal
51
+ TRUE: Literal
52
+ FALSE: Literal
53
+ ZERO: Literal
54
+
55
+ include RDF::Term
56
+
57
+ def self.inherited: (untyped child) -> untyped
58
+ def self.datatype_map: () -> untyped
59
+ def self.datatyped_class: (untyped uri) -> untyped
60
+ def self.new: (untyped value, ?language: untyped?, ?datatype: untyped?, ?lexical: untyped?, ?validate: bool, ?canonicalize: bool, **untyped options) -> untyped
61
+
62
+
63
+ attr_accessor language: untyped
64
+ attr_accessor datatype: untyped
65
+
66
+ def initialize: (untyped value, ?language: untyped?, ?datatype: untyped?, ?lexical: untyped?, ?validate: bool, ?canonicalize: bool, **untyped options) -> void
67
+ def value: () -> String?
68
+ def object: () -> untyped
69
+ def literal?: () -> true
70
+ def compatible?: (Literal other) -> bool
71
+ def hash: () -> Integer
72
+ def value_hash: () -> untyped
73
+ def freeze: () -> untyped
74
+ def eql?: (Literal other) -> bool
75
+ def ==: (Literal other) -> untyped
76
+ alias === ==
77
+ def <=>: (Literal other) -> untyped
78
+ def plain?: () -> bool
79
+ def simple?: () -> bool
80
+ def language?: () -> bool
81
+ alias has_language? language?
82
+ def datatype?: () -> bool
83
+ alias has_datatype? datatype?
84
+ alias typed? datatype?
85
+ alias datatyped? datatype?
86
+ def valid?: () -> bool
87
+ def validate!: () -> self
88
+ def comperable_datatype?: (Literal other) -> bool
89
+ def comperable_datatype2?: (Literal other) -> bool
90
+ def canonicalize!: () -> self
91
+ def squish: (*untyped other_string) -> untyped
92
+ def squish!: () -> self
93
+ def escape: (string string) -> untyped
94
+ def to_s: () -> String
95
+ def humanize: (?::Symbol lang) -> untyped
96
+ def inspect: () -> untyped
97
+ def method_missing: (untyped name, *untyped args) -> untyped
98
+ def respond_to_missing?: (untyped name, ?bool include_private) -> (true | untyped)
99
+ end
100
+
101
+ class URI
102
+ UCSCHAR: Regexp
103
+ IPRIVATE: Regexp
104
+ SCHEME: Regexp
105
+ PORT: Regexp
106
+ IP_literal: Regexp
107
+ PCT_ENCODED: Regexp
108
+ GEN_DELIMS: Regexp
109
+ SUB_DELIMS: Regexp
110
+ RESERVED: Regexp
111
+ UNRESERVED: Regexp
112
+ IUNRESERVED: Regexp
113
+ IPCHAR: Regexp
114
+ IQUERY: Regexp
115
+ IFRAGMENT: Regexp
116
+ ISEGMENT: Regexp
117
+ ISEGMENT_NZ: Regexp
118
+ ISEGMENT_NZ_NC: Regexp
119
+ IPATH_ABEMPTY: Regexp
120
+ IPATH_ABSOLUTE: Regexp
121
+ IPATH_NOSCHEME: Regexp
122
+ IPATH_ROOTLESS: Regexp
123
+ IPATH_EMPTY: Regexp
124
+ IREG_NAME: Regexp
125
+ IHOST: Regexp
126
+ IUSERINFO: Regexp
127
+ IAUTHORITY: Regexp
128
+ IRELATIVE_PART: Regexp
129
+ IRELATIVE_REF: Regexp
130
+ IHIER_PART: Regexp
131
+ IRI: Regexp
132
+ IRI_PARTS: Regexp
133
+ RDS_2A: Regexp
134
+ RDS_2B1: Regexp
135
+ RDS_2B2: Regexp
136
+ RDS_2C1: Regexp
137
+ RDS_2C2: Regexp
138
+ RDS_2D: Regexp
139
+ RDS_2E: Regexp
140
+ PORT_MAPPING: Hash[String, Integer]
141
+ NON_HIER_SCHEMES: [String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String]
142
+ PN_ESCAPE_CHARS: Regexp
143
+ PN_ESCAPES: Regexp
144
+ HOST_FROM_AUTHORITY_RE: Regexp
145
+ PORT_FROM_AUTHORITY_RE: Regexp
146
+ include Resource
147
+ @hash: Integer?
148
+ @object: {scheme: nil, authority: String?, userinfo: nil, user: String?, password: String?, host: nil, port: nil, path: String?, query: nil, fragment: nil}?
149
+ @value: String?
150
+ @mutex: Thread::Mutex
151
+ self.@cache: untyped
152
+
153
+ def self.cache: -> untyped
154
+ def self.intern: (String str, *untyped args, **untyped) -> URI
155
+ def self.parse: (untyped str) -> URI
156
+ def self.normalize_path: (String? path) -> String
157
+ def initialize: (*String? args, ?validate: (String | false)?, ?canonicalize: (String | false)?, **String?) -> void
158
+ def uri?: -> true
159
+ def urn?: -> bool
160
+ def hier?: -> bool
161
+ def url?: -> bool
162
+ def absolute?: -> bool
163
+ def relative?: -> bool
164
+ def relativize: (untyped base_uri) -> (String | URI)
165
+ def length: -> Integer
166
+ def valid?: -> false
167
+ def validate!: -> URI
168
+ def canonicalize: -> URI
169
+ def canonicalize!: -> URI
170
+ def join: (*untyped uris) -> URI
171
+ def /: (untyped fragment) -> URI
172
+ def +: (untyped other) -> URI
173
+ def root?: -> bool
174
+ def root: -> URI
175
+ def parent?: -> bool
176
+ def parent: -> URI?
177
+ def qname: (?prefixes: nil) -> [:rdf, Symbol?]?
178
+ def pname: (?prefixes: nil) -> String
179
+ def dup: -> URI
180
+ def freeze: -> URI
181
+ def end_with?: (string string) -> bool
182
+ def eql?: (untyped other) -> bool
183
+ def ==: (untyped other) -> bool
184
+ def ===: (untyped other) -> bool
185
+ def =~: (untyped pattern) -> ((Integer | bool)?)
186
+ def to_uri: -> URI
187
+ def to_str: -> String?
188
+ def inspect: -> String
189
+ def value: -> String?
190
+ def hash: -> Integer
191
+ def object: -> {scheme: nil, authority: String?, userinfo: nil, user: String?, password: String?, host: nil, port: nil, path: String?, query: nil, fragment: nil}
192
+ def parse: (String? value) -> {scheme: nil, authority: nil, userinfo: nil, user: String?, password: String?, host: nil, port: nil, path: String?, query: nil, fragment: nil}
193
+ def scheme: -> String?
194
+ def scheme=: (untyped value) -> URI
195
+ def normalized_scheme: -> nil
196
+ def user: -> String?
197
+ def user=: (untyped value) -> URI
198
+ def normalized_user: -> nil
199
+ def password: -> String?
200
+ def password=: (untyped value) -> URI
201
+ def normalized_password: -> nil
202
+ def host: -> String?
203
+ def host=: (untyped value) -> URI
204
+ def normalized_host: -> nil
205
+ def port: -> String?
206
+ def port=: (untyped value) -> URI
207
+ def normalized_port: -> Integer?
208
+ def path: -> String?
209
+ def path=: (String value) -> URI
210
+ def normalized_path: -> nil
211
+ def query: -> String?
212
+ def query=: (nil value) -> URI
213
+ def normalized_query: -> nil
214
+ def fragment: -> String?
215
+ def fragment=: (untyped value) -> URI
216
+ def normalized_fragment: -> nil
217
+ def authority: -> String?
218
+ def authority=: (untyped value) -> URI
219
+ def normalized_authority: -> String?
220
+ def userinfo: -> String?
221
+ def userinfo=: (untyped value) -> URI
222
+ def normalized_userinfo: -> nil
223
+ def query_values: (?singleton(Hash) return_type) -> ((Array[Array[nil]?] | Hash[untyped, Array[nil]?])?)
224
+ def query_values=: (untyped value) -> nil
225
+ def request_uri: -> String?
226
+ def _dump: (untyped level) -> String?
227
+ def self._load: (untyped data) -> URI
228
+
229
+ private
230
+ def normalize_segment: (String? value, untyped expr, ?bool downcase) -> nil
231
+ def format_userinfo: (?String append) -> String
232
+ def format_authority: -> String
233
+ def self.encode: (untyped str, Regexp expr) -> untyped
234
+ def self.decode: (untyped str) -> untyped
235
+ end
236
+
237
+ class Node
238
+ include RDF::Resource
239
+ attr_accessor original: untyped
240
+ attr_accessor id: untyped
241
+
242
+ def self.cache: () -> untyped
243
+ def self.uuid: (?format: ::Symbol) -> untyped
244
+ def self.intern: (untyped id) -> untyped
245
+
246
+ def dup: () -> Node
247
+ def initialize: (?untyped? id) -> void
248
+ def node?: () -> true
249
+ def anonymous?: () -> true
250
+ alias unlabeled? anonymous?
251
+ def labeled?: () -> bool
252
+ def hash: () -> Integer
253
+ def eql?: (Node other) -> bool
254
+ def ==: (Node other) -> untyped
255
+ alias === ==
256
+ def to_unique_base: () -> (untyped | ::String)
257
+ def make_unique!: () -> self
258
+ def to_s: () -> String
259
+ def to_sym: () -> untyped
260
+ end
261
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emp_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0.pre.g9596e781b
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom van Kalkeren
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-21 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Serializer for the EmpJson specification.
14
14
  email:
@@ -27,6 +27,8 @@ files:
27
27
  - Rakefile
28
28
  - emp-json-rb.gemspec
29
29
  - lib/empathy/emp_json.rb
30
+ - lib/empathy/emp_json/helpers/hash.rb
31
+ - lib/empathy/emp_json/helpers/parsing.rb
30
32
  - lib/empathy/emp_json/helpers/primitives.rb
31
33
  - lib/empathy/emp_json/helpers/rdf_list.rb
32
34
  - lib/empathy/emp_json/helpers/slices.rb
@@ -38,7 +40,21 @@ files:
38
40
  - lib/empathy/emp_json/serializer/sequence.rb
39
41
  - lib/empathy/emp_json/serializer/serializing.rb
40
42
  - lib/empathy/emp_json/version.rb
41
- - sig/emp/json/rb.rbs
43
+ - rbs_collection.lock.yaml
44
+ - rbs_collection.yaml
45
+ - sig/lib/empathy/emp_json.rbs
46
+ - sig/lib/empathy/emp_json/helpers/parsing.rbs
47
+ - sig/lib/empathy/emp_json/helpers/primitives.rbs
48
+ - sig/lib/empathy/emp_json/helpers/rdf_list.rbs
49
+ - sig/lib/empathy/emp_json/helpers/slices.rbs
50
+ - sig/lib/empathy/emp_json/helpers/values.rbs
51
+ - sig/lib/empathy/emp_json/serializer.rbs
52
+ - sig/lib/empathy/emp_json/serializer/fields.rbs
53
+ - sig/lib/empathy/emp_json/serializer/inclusion.rbs
54
+ - sig/lib/empathy/emp_json/serializer/records.rbs
55
+ - sig/lib/empathy/emp_json/serializer/sequence.rbs
56
+ - sig/lib/empathy/emp_json/serializer/serializing.rbs
57
+ - sig/lib/rdf.rbs
42
58
  homepage: https://empathy.tools/tools/emp-json
43
59
  licenses:
44
60
  - MIT
@@ -59,9 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
75
  version: 2.7.0.preview1
60
76
  required_rubygems_version: !ruby/object:Gem::Requirement
61
77
  requirements:
62
- - - ">="
78
+ - - ">"
63
79
  - !ruby/object:Gem::Version
64
- version: '0'
80
+ version: 1.3.1
65
81
  requirements: []
66
82
  rubygems_version: 3.3.7
67
83
  signing_key:
data/sig/emp/json/rb.rbs DELETED
@@ -1,8 +0,0 @@
1
- module Emp
2
- module Json
3
- module Rb
4
- VERSION: String
5
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
6
- end
7
- end
8
- end