ieee-idams 0.2.9 → 0.2.11

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: 01f00f2f3abec2fa584539aaef0c18c996b452b09b01e58ef0c62a7ad7532c73
4
- data.tar.gz: 8a3d08f058dc4abd6cd3b39521ad8ab0b1813053b0b15dbfe00b5a372f9675da
3
+ metadata.gz: b415563c12d7265e360018ddbea2fc22dd81464d713c5dc867c4b06284dec042
4
+ data.tar.gz: f242ea03fd6ded7baef7472f1654ce94187d485128335147ccfaadd4cf1c7e9b
5
5
  SHA512:
6
- metadata.gz: 84d9e7989f0237fbb8c201cd641a1465a22ac3035d37757a9b58310c19c892f74aafc0dabfb8412e98f63ab72471457991a9f6821841d46ab6e2d8509daa704b
7
- data.tar.gz: c7f4c00195985b602299b1e8d395410c6e0dca1710e00485aa2c87752059b465d76f2152d76369f2bc79c23ff154350f4b9200e8d9d54cf11a201219153477a3
6
+ metadata.gz: bc79f84b2d2e766b72444b1f07551fe56493169168bd55756e1984ec3938f6afd39d68290cb46cbb974b9e40613427183ae39d3674ceb5d406a700da5a4a27ec
7
+ data.tar.gz: 47c859d3448584e57e91ba982d02419b067bd867150ce7b383a2856d804a9141fae6d31ee44c672f61c65b702a8dedd3ed98f2b268f61a61b52708d5b867b35d
@@ -0,0 +1,139 @@
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.inject([]) do |acc, keywordset|
84
+ acc + keywordset.keyword.map(&:keywordterm)
85
+ end.uniq
86
+ end
87
+
88
+ def ics
89
+ return [] unless publicationinfo.ics_codes
90
+
91
+ publicationinfo.ics_codes.code_term.map do |ics|
92
+ attrs = { code: ics.codenum, text: ics.name }
93
+ block_given? ? yield(attrs) : attrs
94
+ end
95
+ end
96
+
97
+ def editorialgroup
98
+ committee = publicationinfo.pubsponsoringcommitteeset&.pubsponsoringcommittee
99
+ return unless committee
100
+
101
+ block_given? ? yield(committee) : committee
102
+ end
103
+
104
+ def standard_modifier
105
+ publicationinfo.standard_modifier_set&.standard_modifier
106
+ end
107
+
108
+ def doctype
109
+ standard_modifier == "Redline" ? "redline" : "standard"
110
+ end
111
+
112
+ private
113
+
114
+ def contrib_addres(address)
115
+ return [] unless address&.city
116
+
117
+ city, state = address.city.split(", ")
118
+ country = address.country || "USA"
119
+ return [] unless city && country
120
+
121
+ [{ street: [], city: city, state: state, country: country }]
122
+ end
123
+
124
+ #
125
+ # Convert date string with month name to numeric date
126
+ #
127
+ # @param [String] date_str source date
128
+ #
129
+ # @return [String] numeric date
130
+ #
131
+ def parse_date_string(date_str)
132
+ case date_str
133
+ when /^\d{4}$/ then date_str
134
+ when /^\d{1,2}\s\w+\.?\s\d{4}/ then Date.parse(date_str).to_s
135
+ end
136
+ end
137
+ end
138
+ end
139
+ 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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ieee
4
4
  module Idams
5
- VERSION = "0.2.9"
5
+ VERSION = "0.2.11"
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.9
4
+ version: 0.2.11
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