kril 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 5e4c4c69cd458217ed052514aacfc9d5c767052e
4
- data.tar.gz: 32608012a0e06db317cddce8a795b245cc50d095
3
+ metadata.gz: bc4fb4e74341dd64b82019b8091e5d0f9b6fbd80
4
+ data.tar.gz: 44c6ba7c654806acc8c1d3e358c8dc13da67984f
5
5
  SHA512:
6
- metadata.gz: 9958e3b8ed31cd36d027489aab920979482ccebd77ead2cadec32ee88a0753ceaf9f4317e666400f615b3d5c0c1626ae219dbf945f3a524cbf54d42779e1153f
7
- data.tar.gz: 5a8c97bec9425ad459faf5d61d071a27dd2b30054c70670729d5d260aee71eab789d29cdbebbcd5bc965fb52939ead3c97c6e9a52ac7d044c223a16626e47a36
6
+ metadata.gz: d66885a70a4fdccdb79f2431f93805a6e0b0797ba5ae1a1dae9b035bc7895b45d19d60784e727959b1c41952ca061ee2fbe41ca3cca693f70ca9a5f090af9cc6
7
+ data.tar.gz: 2d8542a1b4fa4fd908927d5c6c57f5cb7d833fc58c1c286e8aad44b34c4b5f55fb73d1bcb922467d421a541e308762ba3fa81c310d73ab0f4708ddb6c3419320
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kril (0.1.3)
4
+ kril (0.1.4)
5
5
  avro_turf (~> 0.8.0)
6
6
  clamp (~> 1.2, >= 1.2.1)
7
7
  ruby-kafka (~> 0.5.3)
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/')}" do |path|
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
@@ -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: 'schemas/',
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.new, "Input for #{field['name']} cannot be nil"
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
 
@@ -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: 'schemas/',
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.new, "Not a valid schema: #{path}" unless schema?(schema)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kril
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kril
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Bowman