Skip to content

Commit

Permalink
add RelatonBib#gramma_hash method
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Dec 8, 2022
1 parent 4367bc2 commit 5e908ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/relaton_bib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_bib/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RelatonBib
VERSION = "1.14.0".freeze
VERSION = "1.14.1".freeze
end
6 changes: 6 additions & 0 deletions spec/relaton_bib_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5e908ff

Please sign in to comment.