ieee-idams 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06d58a9aa3b3a3ccd9ab8a0461cb7233396850a29398ce6c0e89be557df54246
4
- data.tar.gz: 7bc31dc47ef127f14e45080b804116b5c3472062c856c49a3545cffb5b2f9d2f
3
+ metadata.gz: b5426f224202e3d0628c645a7a63c35bb6cabbaf03fc232b90b9b10fdb465846
4
+ data.tar.gz: cfe9ccfd4d43d7ff52972000250fded0d956dcd80f8ffe1e169e841c2827a200
5
5
  SHA512:
6
- metadata.gz: f72179b7512dfcc2c84193b50af14263a41060f96f6fcc4b7275947a87487de9a09cfce396ace85409b8c3995d9a8b7c61db2cc847d97cebcc808fc7cae8fabd
7
- data.tar.gz: 912f4a55250cd6281ccb88151aa5b35c854cf0d5abac42160fca0d59eac589c2e9df8525f0f9d6350360885232303796ce71e8f76f1ba18cff904c77a843f7a7
6
+ metadata.gz: fff72da7ab2f7f968c5bb93cbd0922428283de0a93ab7d2f85f3e10cb6113d82e863fb2bf551e8038758dabd2b07c4deb14aae5a9a71b426900e48bcdd2aecd7
7
+ data.tar.gz: 3cf86d915db7a1ada5ccf238759228cba31b112c5adbd27c432321a9b22410eecd7f2395cf5cf7cd12d11f47a8a72333e6e21fe0aa5ec45eea5ec579df031e3d
@@ -0,0 +1,137 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ieee
4
+ module Idams
5
+ # Represents an IEEE IDAMS publication record
6
+ class PubModel
7
+ DATETYPES = { "OriginalPub" => "created", "ePub" => "published", "LastInspecUpd" => "updated" }.freeze
8
+
9
+ attr_accessor :title, :normtitle, :standardsfamilytitle, :publicationinfo, :volume
10
+
11
+ def btitle
12
+ t = []
13
+ content = CGI.unescapeHTML volume.article.title
14
+ t << { content: Regexp.last_match(1), type: "title-main" } if content =~ /\A(.+)\s[-\u2014]\sredline\z/i
15
+ t << { content: content, type: "main" }
16
+ end
17
+
18
+ def bdate # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
19
+ dates = volume.article.articleinfo.date.map do |d|
20
+ date_array = [d.year]
21
+ if d.month
22
+ /^(?:(?<day>\d{1,2})\s)?(?<mon>\w+)/ =~ d.month
23
+ month = Date::ABBR_MONTHNAMES.index(mon) || Date::MONTHNAMES.index(mon) || d.month
24
+ date_array << month.to_s.rjust(2, "0")
25
+ end
26
+ day = d.day || day
27
+ date_array << day.rjust(2, "0") if day
28
+ on = date_array.compact.join "-"
29
+ { type: DATETYPES[d.datetype], on: on }
30
+ end
31
+ if publicationinfo.pubapprovaldate
32
+ issued = parse_date_string publicationinfo.pubapprovaldate
33
+ dates << { type: "issued", on: issued }
34
+ end
35
+ dates
36
+ end
37
+
38
+ #
39
+ # @return [Arry<Hash>] array of hashes with keys :id and :type
40
+ #
41
+ def isbn_doi
42
+ ids = []
43
+ isbn = publicationinfo.isbn
44
+ ids << { id: isbn.first.content, type: "ISBN" } if isbn.any?
45
+ doi = volume.article.articleinfo.articledoi
46
+ ids << { id: doi, type: "DOI" } if doi
47
+ ids
48
+ end
49
+
50
+ #
51
+ # @return [Array<String, Array>] publisher name and address
52
+ #
53
+ def contrib_name_addr
54
+ addr = contrib_addres(publicationinfo.publisher.address).map { |a| block_given? ? yield(a) : a }
55
+ [publicationinfo.publisher.publishername, addr]
56
+ end
57
+
58
+ #
59
+ # @return [Array<Array, Object>] array of arrays with owner and year of given block result
60
+ #
61
+ def copyright
62
+ publicationinfo.copyrightgroup.copyright.map do |copy|
63
+ owner = copy.holder.split("/")
64
+ year = copy.year.to_s
65
+ block_given? ? yield(owner, year) : [owner, year]
66
+ end
67
+ end
68
+
69
+ def docstatus
70
+ return unless %w[Draft Approved Superseded Withdrawn].include?(standard_modifier)
71
+
72
+ args = { stage: standard_modifier.downcase }
73
+ block_given? ? yield(args) : args
74
+ end
75
+
76
+ def link
77
+ id = volume.article.articleinfo.amsid
78
+ url = "https://ieeexplore.ieee.org/document/#{id}"
79
+ [block_given? ? yield(url) : url]
80
+ end
81
+
82
+ def keyword
83
+ volume.article.articleinfo.keywordset[0]&.keyword&.map(&:keywordterm)
84
+ end
85
+
86
+ def ics
87
+ return [] unless publicationinfo.ics_codes
88
+
89
+ publicationinfo.ics_codes.code_term.map do |ics|
90
+ attrs = { code: ics.codenum, text: ics.name }
91
+ block_given? ? yield(attrs) : attrs
92
+ end
93
+ end
94
+
95
+ def editorialgroup
96
+ committee = publicationinfo.pubsponsoringcommitteeset&.pubsponsoringcommittee
97
+ return unless committee
98
+
99
+ block_given? ? yield(committee) : committee
100
+ end
101
+
102
+ def standard_modifier
103
+ publicationinfo.standard_modifier_set&.standard_modifier
104
+ end
105
+
106
+ def doctype
107
+ standard_modifier == "Redline" ? "redline" : "standard"
108
+ end
109
+
110
+ private
111
+
112
+ def contrib_addres(address)
113
+ return [] unless address&.city
114
+
115
+ city, state = address.city.split(", ")
116
+ country = address.country || "USA"
117
+ return [] unless city && country
118
+
119
+ [{ street: [], city: city, state: state, country: country }]
120
+ end
121
+
122
+ #
123
+ # Convert date string with month name to numeric date
124
+ #
125
+ # @param [String] date_str source date
126
+ #
127
+ # @return [String] numeric date
128
+ #
129
+ def parse_date_string(date_str)
130
+ case date_str
131
+ when /^\d{4}$/ then date_str
132
+ when /^\d{1,2}\s\w+\.?\s\d{4}/ then Date.parse(date_str).to_s
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
@@ -2,11 +2,14 @@
2
2
 
3
3
  require_relative "publication_info"
4
4
  require_relative "volume"
5
+ require_relative "pub_model"
5
6
 
6
7
  module Ieee
7
8
  module Idams
8
9
  # Represents an IEEE IDAMS publication record
9
10
  class Publication < Lutaml::Model::Serializable
11
+ model PubModel
12
+
10
13
  # Publication title
11
14
  # @return [String] normalized title
12
15
  attribute :title, :string
@@ -4,7 +4,7 @@ module Ieee
4
4
  module Idams
5
5
  # Represents a set of standard modifiers
6
6
  class StandardModifierSet < Lutaml::Model::Serializable
7
- attribute :standard_modifier, :string, collection: true
7
+ attribute :standard_modifier, :string
8
8
 
9
9
  xml do
10
10
  root "standardmodifierset"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ieee
4
4
  module Idams
5
- VERSION = "0.2.8"
5
+ VERSION = "0.2.10"
6
6
  end
7
7
  end
@@ -12,8 +12,8 @@ module Ieee
12
12
  attribute :volumeinfo, VolumeInfo
13
13
 
14
14
  # List of articles
15
- # @return [Array<Article>] articles in volume
16
- attribute :article, Article, collection: true
15
+ # @return [Article] articles in volume
16
+ attribute :article, Article
17
17
 
18
18
  xml do
19
19
  root "volume"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ieee-idams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-22 00:00:00.000000000 Z
11
+ date: 2024-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -163,6 +163,7 @@ files:
163
163
  - lib/ieee/idams/multimedia_compressed.rb
164
164
  - lib/ieee/idams/package_member_set.rb
165
165
  - lib/ieee/idams/product_number.rb
166
+ - lib/ieee/idams/pub_model.rb
166
167
  - lib/ieee/idams/pub_sponsor.rb
167
168
  - lib/ieee/idams/pub_sponsoring_committee_set.rb
168
169
  - lib/ieee/idams/pub_topical_browse_set.rb