Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Oct 7, 2023
1 parent b7c3f26 commit 00e9b28
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ item.link
[source,ruby]
----
RelatonCalconnect::CcBibliography.get "CC/DIR 10005", "2019", {}
[relaton-calconnect] (CC/DIR 10005) fetching...
[relaton-calconnect] (CC/DIR 10005) found `CC/DIR 10005:2019`
[relaton-calconnect] (CC/DIR 10005) Fetching from Relaton repository ...
[relaton-calconnect] (CC/DIR 10005) Found: `CC/DIR 10005:2019`
=> #<RelatonCalconnect::CcBibliographicItem:0x007f9a73dfa290
...
----
Expand Down
15 changes: 8 additions & 7 deletions lib/relaton_calconnect/cc_bibliography.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/Me
end
end

Util.warn "(#{ref}) fetching..."
Util.warn "(#{ref}) Fetching from Relaton repository ..."
result = search(code, year, opts) || (return nil)
ret = bib_results_filter(result, year)
if ret[:ret]
Util.warn "(#{ref}) found `#{ret[:ret].docidentifier.first.id}`"
Util.warn "(#{ref}) Found: `#{ret[:ret].docidentifier.first.id}`"
ret[:ret]
else
Util.warn "(#{ref}) No found."
fetch_ref_err(code, year, ret[:years])
end
end
Expand Down Expand Up @@ -73,12 +74,12 @@ def bib_results_filter(result, year)
# @param year [String]
# @param missed_years [Array<Strig>]
def fetch_ref_err(code, year, missed_years)
id = year ? "`#{code}` year `#{year}`" : code
Util.warn "WARNING: no match found online for #{id}. " \
"The code must be exactly like it is on the standards website."
# id = year ? "`#{code}` year `#{year}`" : code
# Util.warn "WARNING: No match found online for #{id}. " \
# "The code must be exactly like it is on the standards website."
unless missed_years.empty?
Util.warn "(There was no match for `#{year}`, though there " \
"were matches found for `#{missed_years.join('`, `')}`.)"
Util.warn "There was no match for `#{year}`, though there " \
"were matches found for `#{missed_years.join('`, `')}`."
end
nil
end
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_calconnect/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RelatonCalconnect
VERSION = "1.16.1".freeze
VERSION = "1.16.2".freeze
end
4 changes: 2 additions & 2 deletions spec/relaton_calconnect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
VCR.use_cassette "cc_dir_10005_2019", match_requests_on: [:path] do
expect do
RelatonCalconnect::CcBibliography.get "CC/DIR 10005", "2011"
end.to output(%r{no match found online for `CC/DIR 10005` year `2011`}).to_stderr
end.to output(/\[relaton-calconnect\] There was no match for `2011`, though there were matches found for `2019`\./).to_stderr
end
end
end
Expand All @@ -90,7 +90,7 @@
VCR.use_cassette "data", match_requests_on: [:path] do
expect do
RelatonCalconnect::CcBibliography.get "CC/DIR 123456"
end.to output(/no match found online for CC\/DIR 123456/).to_stderr
end.to output(/\[relaton-calconnect\] \(CC\/DIR 123456\) No found\./).to_stderr
end
end
end
Expand Down
44 changes: 22 additions & 22 deletions spec/vcr_cassettes/cc_dir_10005_2019.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00e9b28

Please sign in to comment.