Skip to content

Commit c0ab4f8

Browse files
committed
Support erb in config file
1 parent 4a8f395 commit c0ab4f8

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

CONFIG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum:
4545
```
4646
4747
## Full configuration file
48-
[config/default.yml](config/default.yml) is used by https://github.com/ruby-go-gem/go-gem-wrapper to generate bindings for Go.
48+
[config/default.yml.erb](config/default.yml.erb) is used by https://github.com/ruby-go-gem/go-gem-wrapper to generate bindings for Go.
4949
5050
## `function.include_name`, `struct.include_name`, `type.include_name`, `enum.include_name`
5151
Return functions and structures that match the condition with a [RubyHeaderParser::Parser](lib/ruby_header_parser/parser.rb)

lib/ruby_header_parser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "yaml"
44
require "tmpdir"
5+
require "erb"
56

67
require_relative "ruby_header_parser/version"
78

lib/ruby_header_parser/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class Config
1111
#
1212
# @note See [CONFIG.md](../file.CONFIG.html) for config file details
1313
def initialize(config_file)
14-
yaml = File.read(config_file)
14+
erb = File.read(config_file)
15+
yaml = ERB.new(erb).result
1516
@data = YAML.safe_load(yaml, aliases: true, permitted_classes: [Regexp])
1617
end
1718

spec/ruby_header_parser/config_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
describe "#function_arg_pointer_hint" do
77
subject { config.function_arg_pointer_hint(function_name:, pos:) }
88

9-
context "found in config/default.yml" do
9+
context "found in config/default.yml.erb" do
1010
let(:function_name) { "rb_funcallv" }
1111
let(:pos) { 4 }
1212

1313
it { should eq :array }
1414
end
1515

16-
context "not found in config/default.yml" do
16+
context "not found in config/default.yml.erb" do
1717
let(:function_name) { "rb_funcallv" }
1818
let(:pos) { 5 }
1919

@@ -24,13 +24,13 @@
2424
describe "#function_self_pointer_hint" do
2525
subject { config.function_self_pointer_hint(function_name) }
2626

27-
context "found in default.yml" do
27+
context "found in default.yml.erb" do
2828
let(:function_name) { "RSTRING_PTR" }
2929

3030
it { should eq :raw }
3131
end
3232

33-
context "not found in config/default.yml" do
33+
context "not found in config/default.yml.erb" do
3434
let(:function_name) { "rb_class2name" }
3535

3636
it { should eq :ref }

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929

3030
# @return [String]
3131
def default_config_file
32-
File.expand_path("../config/default.yml", __dir__)
32+
File.expand_path("../config/default.yml.erb", __dir__)
3333
end

0 commit comments

Comments
 (0)