Skip to content
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

Parse and render ISP type #171

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/pubid/iso.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Iso
require_relative "iso/transformer"
require_relative "iso/identifier/base"
require_relative "iso/identifier/international_standard"
require_relative "iso/identifier/international_standardized_profile"
require_relative "iso/identifier/technical_report"
require_relative "iso/identifier/technical_specification"
require_relative "iso/identifier/technical_committee"
Expand Down Expand Up @@ -45,3 +46,4 @@ module Iso
require_relative "iso/renderer/publicly_available_specification"
require_relative "iso/renderer/guide"
require_relative "iso/renderer/recommendation"
require_relative "iso/renderer/international_standardized_profile"
28 changes: 28 additions & 0 deletions lib/pubid/iso/identifier/international_standardized_profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Pubid::Iso
module Identifier
class InternationalStandardizedProfile < Base
def_delegators 'Pubid::Iso::Identifier::InternationalStandardizedProfile', :type

TYPED_STAGES = {
dis: {
abbr: "DISP",
name: "Draft International Standardized Profile",
harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93],
},
fdis: {
abbr: "FDISP",
name: "Final Draft International Standardized Profile",
harmonized_stages: %w[50.00 50.20 50.60 50.92],
},
}.freeze

def self.type
:isp
end

def self.get_renderer_class
Renderer::InternationalStandardizedProfile
end
end
end
end
16 changes: 16 additions & 0 deletions lib/pubid/iso/renderer/international_standardized_profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Pubid::Iso::Renderer
class InternationalStandardizedProfile < Base
def omit_post_publisher_symbol?(_typed_stage, _stage, _opts)
# always need post publisher symbol, because we always have to add "TR"
false
end

def render_identifier(params, _opts)
type_prefix = (params[:typed_stage].nil? || params[:typed_stage].empty?) ? "ISP" : ""

type_prefix = " #{type_prefix}" if params[:stage] && !params[:stage].empty?

"%{publisher}%{typed_stage}%{stage}#{type_prefix} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{edition}" % params
end
end
end
6 changes: 6 additions & 0 deletions spec/pubid_iso/identifier/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ module Identifier
it_behaves_like "converts pubid to pubid"
end

context "ISO/IEC ISP 10611-3:2003" do
let(:pubid) { "ISO/IEC ISP 10611-3:2003" }

it_behaves_like "converts pubid to pubid"
end

describe "#parse_from_title" do
subject { described_class.parse_from_title(title) }
let(:title) { "#{pubid} Geographic information — Metadata — Part 1: Fundamentals" }
Expand Down