-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pubid nist integration #106
base: main
Are you sure you want to change the base?
Conversation
d = Date.strptime year, "%Y" if year | ||
statuses = %w[draft-public draft-prelim] | ||
ref = "#{@pubid_ref.serie.serie.sub(/^NIST\s|\sPUB$/, '')} #{@pubid_ref.code}" # TODO: Pubid shouldn't have PUB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [117/80]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrew2net can't we move all of these functions into pubid-nist?
|
||
def json_pubid(json) | ||
if json["doi"] | ||
id = json["doi"].split("/").last.sub(/-draft\d*/, "").sub(/\.\wpd/, "").sub(/-(Add\d*)/, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [100/80]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrew2net can't we move all of these functions into pubid-nist?
end | ||
end | ||
|
||
def json_pubid(json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment Branch Condition size for json_pubid is too high. [<17, 33, 15> 40.04/15]
Cyclomatic complexity for json_pubid is too high. [15/6]
Method has too many lines. [19/10]
Perceived complexity for json_pubid is too high. [16/7]
url: h["uri"], status: h["status"], | ||
release_date: release_date, json: h }, self) | ||
Hit.new({ code: json_pubid(h), series: series.upcase, title: title, url: h["uri"], | ||
status: h["status"], release_date: release_date, json: h }, self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [83/80]
Hit.new({ code: docidentifier(h), series: series.upcase, title: title, | ||
url: h["uri"], status: h["status"], | ||
release_date: release_date, json: h }, self) | ||
Hit.new({ code: json_pubid(h), series: series.upcase, title: title, url: h["uri"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [90/80]
iter = doc["iteration"] == "initial" ? 1 : doc["iteration"] | ||
RelatonNist::DocumentStatus.new stage: stage, substage: subst, iteration: iter.to_s | ||
iter = doc["iteration"] == "ipd" ? "1" : doc["iteration"].match(/\d+/)&.to_s | ||
RelatonNist::DocumentStatus.new stage: stage, substage: subst, iteration: iter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [86/80]
@@ -80,8 +80,8 @@ def fetch_docid(hit) | |||
def fetch_status(doc) | |||
stage = doc["status"] | |||
subst = doc["substage"] | |||
iter = doc["iteration"] == "initial" ? 1 : doc["iteration"] | |||
RelatonNist::DocumentStatus.new stage: stage, substage: subst, iteration: iter.to_s | |||
iter = doc["iteration"] == "ipd" ? "1" : doc["iteration"].match(/\d+/)&.to_s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [84/80]
@@ -68,7 +68,7 @@ def fetch_docid(hit) | |||
# json["docidentifier"] | |||
# item_ref ||= "?" | |||
# item_ref.sub!(/\sAddendum$/, "-Add") | |||
ids = [RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "NIST", primary: true)] | |||
ids = [RelatonBib::DocumentIdentifier.new(id: hit[:code].to_s, type: "NIST", primary: true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [100/80]
@@ -19,7 +19,7 @@ | |||
expect(File).to receive(:exist?).with(RelatonNist::PubsExport::DATAFILE).and_return true | |||
ctime = Time.now | |||
expect(File).to receive(:ctime).with(RelatonNist::PubsExport::DATAFILE).and_return ctime | |||
expect(File).to receive(:size).with(RelatonNist::PubsExport::DATAFILE).and_return 0 | |||
expect(File).to receive(:empty?).with(RelatonNist::PubsExport::DATAFILE).and_return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [94/80]
expect(result.id).to eq "NISTSP800-162" | ||
end | ||
# it "final without updated-date", vcr: { cassette_name: "nist_sp_800_162_2014_01" } do | ||
# result = RelatonNist::NistBibliography.get "NIST SP 800-162 (January 2014)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [85/80]
|
||
def json_pubid(json) | ||
if json["doi"] | ||
id = json["doi"].split("/").last.sub(/-draft\d*/, "").sub(/\.\wpd/, "").sub(/-(Add\d*)/, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrew2net can't we move all of these functions into pubid-nist?
if json["doi"] | ||
id = json["doi"].split("/").last.sub(/-draft\d*/, "").sub(/\.\wpd/, "").sub(/-(Add\d*)/, "") | ||
add = Regexp.last_match(1) | ||
id.sub!(/-upd(\d)/, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrew2net can't we move all of these functions into pubid-nist?
when "ipd" then "i" | ||
when "final" then "f" | ||
else iteration.match(/^\d+/)&.to_s | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrew2net can't we move all of these functions into pubid-nist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ronaldtse I've created issues but they have not been solved yet. These are just temp solutions.
d = Date.strptime year, "%Y" if year | ||
statuses = %w[draft-public draft-prelim] | ||
ref = "#{@pubid_ref.serie.serie.sub(/^NIST\s|\sPUB$/, '')} #{@pubid_ref.code}" # TODO: Pubid shouldn't have PUB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrew2net can't we move all of these functions into pubid-nist?
if @opts[:stage]&.include?("PD") | ||
next unless statuses.include? doc["status"] | ||
if @pubid_ref.stage&.type == "pd" | ||
next unless doc["status"] == "draft-public" | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we move the detection of draft-public
to an earlier stage to store in pubid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a loop through all the items in pubs-export dataset. The Parslet, used in Pubid gems, is quite slow. So, parsing every ID in the dataset will slow down serachig. In this loop a few elements seelcted by code and stage. Next, IDs of the selected items are parsed and compared to reference pubid. Does it make sense?
warn "[relaton-nist] WARNING: no match found online for #{id}. " \ | ||
"The code must be exactly like it is on the standards website." | ||
Util.warn "WARNING: no match found online for `#{id}`. " \ | ||
"The code must be exactly like it is on the standards website." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [81/80]
result = RelatonNist::NistBibliography.get "NIST SP 800-162 (January 2014)" | ||
expect(result.id).to eq "NISTSP800-162" | ||
end | ||
# it "final without updated-date", vcr: { cassette_name: "nist_sp_800_162_2014_01" } do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [93/80]
).to_stderr | ||
end | ||
|
||
# it "contains EP at the end" do | ||
# expect { RelatonNist::NistBibliography.get "NIST FIPS 201 EP" }.to output( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [82/80]
@@ -410,41 +407,37 @@ | |||
expect do | |||
RelatonNist::NistBibliography.get("NISTIR 8200", "2017", {}) | |||
end.to output( | |||
/\[relaton-nist\] WARNING: no match found online for NISTIR 8200:2017/, | |||
/\[relaton-nist\] WARNING: no match found online for `NISTIR 8200:2017`/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [83/80]
it "with volume and version", vcr: { cassette_name: "nist_sp_800_60ver2v1" } do | ||
bib = RelatonNist::NistBibliography.get "NIST.SP.800-60.v-1.ver2.eng" | ||
expect(bib.docidentifier[0].id).to eq "NIST SP 800-60 Vol. 1 Ver. 2 Rev. 2" | ||
it "with volume and revision", vcr: { cassette_name: "nist_sp_800_60v1r1" } do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [84/80]
result = RelatonNist::NistBibliography.get("NIST SP 800-189 2PD", nil, {}) | ||
.to_xml bibdata: true | ||
file_path = "spec/examples/draft.xml" | ||
File.write file_path, result, encoding: "UTF-8" unless File.exist? file_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [82/80]
it "a code with an year from json", vcr: { cassette_name: "json_data" } do | ||
result = RelatonNist::NistBibliography.get "FIPS 140-2", "2001" | ||
expect(result.docidentifier.first.id).to eq "NIST FIPS 140-2r2 fpd" | ||
expect(result.date.find { |d| d.type == "published" }.on).to eq "2001-05-25" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [82/80]
@andrew2net can we move forward with this? Thanks! |
@ronaldtse we need to release the latest updates in pubid-nist gem. @mico and I discussed the pubid-nist functionality 2 weeks ago. I'll ask Artur how is the update going on. |
No description provided.