avro-builder 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/avro/builder.rb +4 -4
- data/lib/avro/builder/dsl.rb +10 -3
- data/lib/avro/builder/file_handler.rb +0 -2
- data/lib/avro/builder/rake/avro_generate_task.rb +1 -1
- data/lib/avro/builder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77208340502bdb2f785d8dfec4074ed2ad29c368
|
4
|
+
data.tar.gz: 8597a93d23ceabc2bb2df55fa3407eaa0afc1077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 739f0bb19f344589693a8afee826a23b61119941ee6f241a107773f151a97ef64654bf62cffee15429b5a1516622b6aa210eeb846cf166cfa67b6b1d7b4fdb0f
|
7
|
+
data.tar.gz: ee228210b7daaed7973b5c56980f30cea2166f3420cff62dfeaf21fd4ea0787617cbd6722b92bcc5774c71226e8a5a926f866ae4ecaeb66c839bc68203189df7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# avro-builder changelog
|
2
2
|
|
3
|
+
## v0.10.0
|
4
|
+
- Include DSL file line numbers in stack traces.
|
5
|
+
- Add optional `filename` keyword argument to `Avro::Builder.build` and
|
6
|
+
`.build_schema`. Filename can now be used instead of a DSL string to build
|
7
|
+
schemas. When a filename is used, the file location of any error is included
|
8
|
+
in the stack trace.
|
9
|
+
|
3
10
|
## v0.9.0
|
4
11
|
- Add rake task to generate Avro JSON schema files for all DSL files under a
|
5
12
|
configurable root directory.
|
data/lib/avro/builder.rb
CHANGED
@@ -6,13 +6,13 @@ module Avro
|
|
6
6
|
module Builder
|
7
7
|
|
8
8
|
# Accepts a string or block to eval to define a JSON schema
|
9
|
-
def self.build(str = nil, &block)
|
10
|
-
Avro::Builder::DSL.new(str, &block).to_json
|
9
|
+
def self.build(str = nil, filename: nil, &block)
|
10
|
+
Avro::Builder::DSL.new(str, filename: filename, &block).to_json
|
11
11
|
end
|
12
12
|
|
13
13
|
# Accepts a string or block to eval and returns an Avro::Schema
|
14
|
-
def self.build_schema(str = nil, &block)
|
15
|
-
Avro::Builder::DSL.new(str, &block).as_schema
|
14
|
+
def self.build_schema(str = nil, filename: nil, &block)
|
15
|
+
Avro::Builder::DSL.new(str, filename: filename, &block).as_schema
|
16
16
|
end
|
17
17
|
|
18
18
|
# Add paths that will be searched for definitions
|
data/lib/avro/builder/dsl.rb
CHANGED
@@ -27,8 +27,14 @@ module Avro
|
|
27
27
|
|
28
28
|
# An instance of the DSL is initialized with a string or a block to
|
29
29
|
# evaluate to define Avro schema objects.
|
30
|
-
def initialize(str = nil, &block)
|
31
|
-
|
30
|
+
def initialize(str = nil, filename: nil, &block)
|
31
|
+
if str
|
32
|
+
instance_eval(*[str, filename].compact)
|
33
|
+
elsif filename
|
34
|
+
instance_eval(File.read(filename), filename)
|
35
|
+
else
|
36
|
+
instance_eval(&block)
|
37
|
+
end
|
32
38
|
end
|
33
39
|
|
34
40
|
# Define an Avro schema record
|
@@ -95,7 +101,8 @@ module Avro
|
|
95
101
|
end
|
96
102
|
|
97
103
|
def eval_file(name)
|
98
|
-
|
104
|
+
file_path = find_file(name)
|
105
|
+
instance_eval(File.read(file_path), file_path)
|
99
106
|
end
|
100
107
|
end
|
101
108
|
end
|
@@ -34,7 +34,7 @@ module Avro
|
|
34
34
|
Dir["#{root}/**/*.rb"].each do |dsl_file|
|
35
35
|
puts "Generating Avro schema from #{dsl_file}"
|
36
36
|
output_file = dsl_file.sub('/dsl/', '/schema/').sub(/\.rb$/, '.avsc')
|
37
|
-
schema = Avro::Builder.build(
|
37
|
+
schema = Avro::Builder.build(filename: dsl_file)
|
38
38
|
FileUtils.mkdir_p(File.dirname(output_file))
|
39
39
|
File.write(output_file, schema.end_with?("\n") ? schema : schema << "\n")
|
40
40
|
end
|
data/lib/avro/builder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avro-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Salsify Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro
|