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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ce24d8f81a853345491ca01f3f152bea7c322e6
4
- data.tar.gz: 699ae7ae471b75260c8975e9762648c4dfaeed03
3
+ metadata.gz: 77208340502bdb2f785d8dfec4074ed2ad29c368
4
+ data.tar.gz: 8597a93d23ceabc2bb2df55fa3407eaa0afc1077
5
5
  SHA512:
6
- metadata.gz: 0a45f164f8639364362fb34546c29ee79a6e352058c14e766958aee088a7e5ffd5bb56cdf9cc5e9986ba277407a45115e2a12bb8508a04aa36442080a7bee7d2
7
- data.tar.gz: 373081fd2648cadfb035bde881e14c71cd69c30d1feb350cf6ff0a831851167cbb24279316520740609bb77cc9d59a1616796309aff2618bf27f5dc51d6ac166
6
+ metadata.gz: 739f0bb19f344589693a8afee826a23b61119941ee6f241a107773f151a97ef64654bf62cffee15429b5a1516622b6aa210eeb846cf166cfa67b6b1d7b4fdb0f
7
+ data.tar.gz: ee228210b7daaed7973b5c56980f30cea2166f3420cff62dfeaf21fd4ea0787617cbd6722b92bcc5774c71226e8a5a926f866ae4ecaeb66c839bc68203189df7
@@ -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.
@@ -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
@@ -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
- str ? instance_eval(str) : instance_eval(&block)
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
- instance_eval(read_file(name))
104
+ file_path = find_file(name)
105
+ instance_eval(File.read(file_path), file_path)
99
106
  end
100
107
  end
101
108
  end
@@ -19,8 +19,6 @@ module Avro
19
19
  File.read(find_file(name))
20
20
  end
21
21
 
22
- private
23
-
24
22
  def find_file(name)
25
23
  # Ensure that the file_name that is searched for begins with a slash (/)
26
24
  # and ends with a .rb extension. Additionally, if the name contains
@@ -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(File.read(dsl_file))
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
@@ -1,5 +1,5 @@
1
1
  module Avro
2
2
  module Builder
3
- VERSION = '0.9.0'.freeze
3
+ VERSION = '0.10.0'.freeze
4
4
  end
5
5
  end
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.9.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-08 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro