typed_data 0.1.4 → 0.1.5

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: aacd139f2162dbafa7dfc5115fc3e8c4c9e3d0d82b3acef434a06cc328ea922b
4
- data.tar.gz: 169159cc3576bf950650e5dd172cdd91020be9897a8115e6d700dee3414e0dce
3
+ metadata.gz: 8328e9cdeaee3bbab6b796988ff1436fc913aa8be6078b99848fe96a4d109156
4
+ data.tar.gz: f3b471b2a4cbc86c8a8a3b07d038c373ca7272f5417f7dd4301cd25a187d4383
5
5
  SHA512:
6
- metadata.gz: fd1a5a2c93f60f0ed90495063c80a09106426072d93823455ee3d9ef6d9cdb3b5d9b4d43a1b67e512e017519c3e540809f22ffa31e2a25fdb7df3ed89956cc23
7
- data.tar.gz: '057891e5525f5b8e39af706e5913c0c1ec1451d6764d2c150458f6a7038cf799a0566bdaa379d1141591ee5d4c5a7ea9edbd1c2091d58440d99cdc403a485b23'
6
+ metadata.gz: 15cf75777af9064e4804709b3c4aef5b3f29d867d29eefa4c93e20a5216b75c1e988809ecf985bf285178e2f1e36ff513316aeb69f179c695f196a511ce439e6
7
+ data.tar.gz: a00c6feb6091ed05d0e28c1afb26d386cab86aa3c110792423bd17f03c8637fb8fab500ea0e220c2c6dc8942f3b6fdc8a86f3668eb23c817d53c847de9495afe
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TypedData
2
2
 
3
- ![](https://github.com/abicky/ecsmec/workflows/test/badge.svg?branch=master)
3
+ ![](https://github.com/abicky/typed_data/workflows/CI/badge.svg?branch=master)
4
4
 
5
5
  TypedData is a library that converts hash objects managed by an Avro schema so that the objects can be loaded into BigQuery.
6
6
 
@@ -97,11 +97,7 @@ module TypedData
97
97
  when Schema::NullType
98
98
  converted_value = nil
99
99
  else
100
- if type.nullable_single?
101
- converted_value = subtype.coerce(value)
102
- else
103
- converted_value = subtype.coerce(value).to_s
104
- end
100
+ converted_value = subtype.coerce(value)
105
101
  end
106
102
 
107
103
  if type.nullable_single?
@@ -4,6 +4,7 @@ module TypedData
4
4
  class Schema
5
5
  class IntType < Type
6
6
  VALUE_RANGE = -2**31 .. 2**31 - 1
7
+ SUPPORTED_LOGICAL_TYPES = %w[date time-millis]
7
8
 
8
9
  def to_s
9
10
  if @logical_type
@@ -3,6 +3,8 @@
3
3
  module TypedData
4
4
  class Schema
5
5
  class LongType < Type
6
+ SUPPORTED_LOGICAL_TYPES = %w[time-micros timestamp-millis timestamp-micros]
7
+
6
8
  def to_s
7
9
  if @logical_type
8
10
  "#{@name}_#{@logical_type.gsub("-", "_")}"
@@ -3,6 +3,8 @@
3
3
  module TypedData
4
4
  class Schema
5
5
  class StringType < Type
6
+ SUPPORTED_LOGICAL_TYPES = %w[uuid]
7
+
6
8
  def primitive?
7
9
  true
8
10
  end
@@ -1,10 +1,16 @@
1
1
  # frozen_string_literal: true
2
+ require "typed_data/schema/errors"
2
3
 
3
4
  module TypedData
4
5
  class Schema
5
6
  class Type
7
+ SUPPORTED_LOGICAL_TYPES = []
8
+
6
9
  def initialize(name, logical_type = nil)
7
10
  @name = name
11
+ if logical_type && !self.class::SUPPORTED_LOGICAL_TYPES.include?(logical_type)
12
+ raise UnsupportedType, %Q{#{name} doesn't support the logical type "#{logical_type}"}
13
+ end
8
14
  @logical_type = logical_type
9
15
  end
10
16
 
@@ -1,3 +1,3 @@
1
1
  module TypedData
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - abicky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2021-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubygems_version: 3.1.2
99
+ rubygems_version: 3.1.4
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: A library that converts hash objects managed by an Avro schema