-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
avro:register_all_schemas
task (#19)
* Add avro:register_all_schemas task * Update README.md * Feedback * Exit if no schemas are found
- Loading branch information
Josh Branham
authored
Apr 1, 2022
1 parent
c56e3f5
commit 241cbca
Showing
12 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
module Avrolution | ||
class DiscoverSchemas | ||
def self.discover(path) | ||
vendor_bundle_path = File.join(path, 'vendor/bundle/') | ||
Dir[File.join(path, '**/*.avsc')].reject do |file| | ||
file.start_with?(vendor_bundle_path) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'avrolution/rake/base_task' | ||
|
||
module Avrolution | ||
module Rake | ||
class RegisterAllSchemasTask < BaseTask | ||
|
||
def initialize(**) | ||
super | ||
@name ||= :register_all_schemas | ||
@task_desc ||= 'Register all discovered Avro JSON schemas (using Avrolution.root)' | ||
end | ||
|
||
private | ||
|
||
def perform | ||
schemas = Avrolution::DiscoverSchemas.discover(Avrolution.root) | ||
|
||
if schemas.blank? | ||
puts 'could not find any schemas' | ||
exit(1) | ||
else | ||
Avrolution::RegisterSchemas.call(schemas) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Avrolution | ||
VERSION = '0.7.2' | ||
VERSION = '0.8.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"type" : "record", | ||
"namespace" : "foo", | ||
"name" : "person", | ||
"fields" : [ | ||
{ "name" : "Name" , "type" : "string" }, | ||
{ "name" : "Age" , "type" : "int" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"type" : "record", | ||
"namespace" : "foo", | ||
"name" : "pet", | ||
"fields" : [ | ||
{ "name" : "Name" , "type" : "string" }, | ||
{ "name" : "Age" , "type" : "int" } | ||
] | ||
} |