lib/gherkin/dialect.rb in gherkin-5.1.0 vs lib/gherkin/dialect.rb in gherkin-6.0.10

- old
+ new

@@ -1,11 +1,21 @@ require 'json' +require 'open3' +require 'c21e/exe_file' +require 'gherkin/exe_file_path' module Gherkin - DIALECT_FILE_PATH = File.expand_path("gherkin-languages.json", File.dirname(__FILE__)) - DIALECTS = JSON.parse File.open(DIALECT_FILE_PATH, 'r:UTF-8').read + def self.dialects_json + gherkin_executable = C21e::ExeFile.new(EXE_FILE_PATH).target_file + data, = Open3.capture2e(gherkin_executable, '--dialects') + data + end + private_class_method :dialects_json + + DIALECTS = JSON.parse(dialects_json) + class Dialect def self.for(name) spec = DIALECTS[name] return nil unless spec new(spec) @@ -15,9 +25,13 @@ @spec = spec end def feature_keywords @spec.fetch('feature') + end + + def rule_keywords + @spec.fetch('rule') end def scenario_keywords @spec.fetch('scenario') end