kril 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/kril +1 -1
- data/lib/kril/record_builder.rb +2 -2
- data/lib/kril/schema_extractor.rb +1 -1
- data/lib/kril/schema_handler.rb +2 -2
- data/lib/kril/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc4fb4e74341dd64b82019b8091e5d0f9b6fbd80
|
4
|
+
data.tar.gz: 44c6ba7c654806acc8c1d3e358c8dc13da67984f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d66885a70a4fdccdb79f2431f93805a6e0b0797ba5ae1a1dae9b035bc7895b45d19d60784e727959b1c41952ca061ee2fbe41ca3cca693f70ca9a5f090af9cc6
|
7
|
+
data.tar.gz: 2d8542a1b4fa4fd908927d5c6c57f5cb7d833fc58c1c286e8aad44b34c4b5f55fb73d1bcb922467d421a541e308762ba3fa81c310d73ab0f4708ddb6c3419320
|
data/Gemfile.lock
CHANGED
data/bin/kril
CHANGED
@@ -23,7 +23,7 @@ Clamp do
|
|
23
23
|
address_string.split(/,\s*/)
|
24
24
|
end
|
25
25
|
option %w[-g --schema-registry], '', 'address of schema registry', default: 'http://localhost:8081'
|
26
|
-
option %w[-p --schemas-path], '', 'directory of Avro schemas', default: "#{File.join(gem_root, 'schemas
|
26
|
+
option %w[-p --schemas-path], '', 'directory of Avro schemas', default: "#{File.join(gem_root, 'schemas')}" do |path|
|
27
27
|
raise ArgumentError, "Schema path: #{path} is not a directory" unless File.directory?(path)
|
28
28
|
end
|
29
29
|
option %w[-v --verbose], :flag, 'print logs, warnings' do
|
data/lib/kril/record_builder.rb
CHANGED
@@ -4,7 +4,7 @@ module Kril
|
|
4
4
|
# Creates and validates a record based from a defined schema.
|
5
5
|
class RecordBuilder
|
6
6
|
def initialize(schema_file_name: nil,
|
7
|
-
schemas_dir:
|
7
|
+
schemas_dir: nil,
|
8
8
|
schema_path: nil)
|
9
9
|
path = schema_path || File.join(schemas_dir, "#{schema_file_name}.avsc")
|
10
10
|
file = File.read(path)
|
@@ -52,7 +52,7 @@ module Kril
|
|
52
52
|
def check_nullity(datum, field)
|
53
53
|
type = field['values'] || field['items'] || field['type']
|
54
54
|
unless datum || type&.include?('null')
|
55
|
-
raise ArgumentError
|
55
|
+
raise ArgumentError, "Input for #{field['name']} cannot be nil"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -10,7 +10,6 @@ module Kril
|
|
10
10
|
# output_dir - schema repository [String]
|
11
11
|
# returns - [nil]
|
12
12
|
def self.extract(source_dir:, output_dir:)
|
13
|
-
output_dir = File.join(Dir.pwd, output_dir)
|
14
13
|
find_java_files(source_dir) do |file|
|
15
14
|
schema = parse_avro_java_class(file)
|
16
15
|
write_avsc(schema, output_dir) if schema
|
@@ -27,6 +26,7 @@ module Kril
|
|
27
26
|
Dir.glob(java_files) do |file|
|
28
27
|
yield File.new(file)
|
29
28
|
end
|
29
|
+
ensure
|
30
30
|
Dir.chdir(old_dir)
|
31
31
|
end
|
32
32
|
|
data/lib/kril/schema_handler.rb
CHANGED
@@ -5,7 +5,7 @@ module Kril
|
|
5
5
|
class SchemaHandler
|
6
6
|
# schemas_path - directory of schema repository [String]
|
7
7
|
# schema_store - schema store [AvroTurf::SchemaStore]
|
8
|
-
def initialize(schemas_path:
|
8
|
+
def initialize(schemas_path: nil,
|
9
9
|
schema_store: nil)
|
10
10
|
schema_store ||= AvroTurf::SchemaStore.new(path: schemas_path)
|
11
11
|
@schema_store = schema_store
|
@@ -44,7 +44,7 @@ module Kril
|
|
44
44
|
|
45
45
|
def copy_schema_to_store(path)
|
46
46
|
schema = File.read(path)
|
47
|
-
raise ArgumentError
|
47
|
+
raise ArgumentError, "Not a valid schema: #{path}" unless schema?(schema)
|
48
48
|
schema_name = JSON.parse(schema)['name']
|
49
49
|
new_path = File.join(@schemas_path, "#{schema_name}.avsc")
|
50
50
|
FileUtils.copy_file(path, new_path)
|
data/lib/kril/version.rb
CHANGED