From 5e908ff47a3b8766fef36ad19364e9291a53af0f Mon Sep 17 00:00:00 2001 From: Andrei Kislichenko Date: Wed, 7 Dec 2022 20:43:03 -0500 Subject: [PATCH] add RelatonBib#gramma_hash method --- lib/relaton_bib.rb | 7 +++++++ lib/relaton_bib/version.rb | 2 +- spec/relaton_bib_spec.rb | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/relaton_bib.rb b/lib/relaton_bib.rb index 6f6423d..02cc571 100644 --- a/lib/relaton_bib.rb +++ b/lib/relaton_bib.rb @@ -79,6 +79,13 @@ def parse_yaml(yaml, classes = []) end end + def self.grammar_hash + gem_path = File.expand_path "..", __dir__ + grammars_path = File.join gem_path, "grammars", "*" + grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join + Digest::MD5.hexdigest grammars + end + private # @param array [Array] diff --git a/lib/relaton_bib/version.rb b/lib/relaton_bib/version.rb index 7424f70..a8c70ee 100644 --- a/lib/relaton_bib/version.rb +++ b/lib/relaton_bib/version.rb @@ -1,3 +1,3 @@ module RelatonBib - VERSION = "1.14.0".freeze + VERSION = "1.14.1".freeze end diff --git a/spec/relaton_bib_spec.rb b/spec/relaton_bib_spec.rb index 46bb3b6..3a1e1fa 100644 --- a/spec/relaton_bib_spec.rb +++ b/spec/relaton_bib_spec.rb @@ -3,6 +3,12 @@ expect(RelatonBib::VERSION).not_to be nil end + it "returns grammar hash" do + hash = RelatonBib.grammar_hash + expect(hash).to be_instance_of String + expect(hash.size).to eq 32 + end + context "parse date" do it "February 2012" do expect(RelatonBib.parse_date("February 2012")).to eq "2012-02"