relaton-bib 1.12.3 → 1.12.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_bib/bibliographic_date.rb +2 -2
- data/lib/relaton_bib/bibxml_parser.rb +4 -1
- data/lib/relaton_bib/document_relation.rb +1 -1
- data/lib/relaton_bib/document_relation_collection.rb +16 -1
- data/lib/relaton_bib/document_status.rb +7 -7
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib.rb +21 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff390021e9158da2d1167e55d988d5dd920c7c9deba9e37838435c7f903d8852
|
4
|
+
data.tar.gz: a0fd8d9929ff51df3604243e9dc28770d3b38721950e1886dc6995a90fa95b4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec5005c4ae8ed03918f6933ed7329990977ab1347eb57626dfdaa1a9dddbd60eada93dc5dfdb365bb1ae06aaf60b8f7fd23ab75837022cbd1f3b6ce4009b797c
|
7
|
+
data.tar.gz: 864a6000626e238808513075dc9343debc59a9440e5806092c4af5e90e38e8927e62b3767903e1fc6b65611c8af60e6c4c8b5cb697c91d666f7662501ce0b7ec
|
@@ -109,8 +109,8 @@ module RelatonBib
|
|
109
109
|
# @return [Date]
|
110
110
|
def parse_date(date)
|
111
111
|
case date
|
112
|
-
when /^\d{4}-\d{2}-\d{2}/ then Date.parse(date) # 2012-02-11
|
113
|
-
when /^\d{4}-\d{2}/ then Date.strptime(date, "%Y-%m") # 2012-02
|
112
|
+
when /^\d{4}-\d{1,2}-\d{1,2}/ then Date.parse(date) # 2012-02-11
|
113
|
+
when /^\d{4}-\d{1,2}/ then Date.strptime(date, "%Y-%m") # 2012-02
|
114
114
|
when /^\d{4}/ then Date.strptime(date, "%Y") # 2012
|
115
115
|
else date
|
116
116
|
end
|
@@ -251,7 +251,10 @@ module RelatonBib
|
|
251
251
|
# "front/author[not(@surname)][not(@fullname)]/organization",
|
252
252
|
# ).map do |org|
|
253
253
|
org = contrib.at("./organization")
|
254
|
-
|
254
|
+
orgname = org.text.strip
|
255
|
+
return if orgname.empty?
|
256
|
+
|
257
|
+
name = ORGNAMES[orgname] || orgname
|
255
258
|
{ entity: new_org(name, org[:abbrev]), role: [contributor_role(contrib)] }
|
256
259
|
# end
|
257
260
|
end
|
@@ -6,7 +6,7 @@ module RelatonBib
|
|
6
6
|
extend Forwardable
|
7
7
|
|
8
8
|
def_delegators :@array, :<<, :[], :first, :last, :empty?, :any?, :size,
|
9
|
-
:each, :detect, :map, :reduce, :length, :unshift
|
9
|
+
:each, :detect, :map, :reduce, :length, :unshift, :max_by
|
10
10
|
|
11
11
|
# @param relation [Array<RelatonBib::DocumentRelation, Hash>]
|
12
12
|
# @option relation [String] :type
|
@@ -21,6 +21,21 @@ module RelatonBib
|
|
21
21
|
@array = relation.map { |r| r.is_a?(Hash) ? DocumentRelation.new(**r) : r }
|
22
22
|
end
|
23
23
|
|
24
|
+
#
|
25
|
+
# Returns new DocumentRelationCollection with selected relations.
|
26
|
+
#
|
27
|
+
# @example Select relations with type "obsoletes"
|
28
|
+
# relations.select { |r| r.type == "obsoletes" }
|
29
|
+
# #=> <RelatonBib::DocRelationCollection:0x00007f9a0191d5f0 @array=[...]>
|
30
|
+
#
|
31
|
+
# @return [RelatonBib::DocRelationCollection] new DocumentRelationCollection
|
32
|
+
# with selected relations
|
33
|
+
#
|
34
|
+
def select(&block)
|
35
|
+
arr = @array.select(&block)
|
36
|
+
self.class.new arr
|
37
|
+
end
|
38
|
+
|
24
39
|
# @todo We don't have replace type anymore. Suppose we should update this
|
25
40
|
# method or delete it.
|
26
41
|
#
|
@@ -6,15 +6,15 @@ module RelatonBib
|
|
6
6
|
# @return [RelatonBib::DocumentStatus::Stage]
|
7
7
|
attr_reader :stage
|
8
8
|
|
9
|
-
# @return [RelatonBib::DocumentStatus::Stage,
|
9
|
+
# @return [RelatonBib::DocumentStatus::Stage, nil]
|
10
10
|
attr_reader :substage
|
11
11
|
|
12
|
-
# @return [String,
|
12
|
+
# @return [String, nil]
|
13
13
|
attr_reader :iteration
|
14
14
|
|
15
15
|
# @param stage [String, Hash, RelatonBib::DocumentStatus::Stage]
|
16
|
-
# @param substage [String, Hash,
|
17
|
-
# @param iteration [String,
|
16
|
+
# @param substage [String, Hash, nil, RelatonBib::DocumentStatus::Stage]
|
17
|
+
# @param iteration [String, nil]
|
18
18
|
def initialize(stage:, substage: nil, iteration: nil)
|
19
19
|
@stage = stage_new stage
|
20
20
|
@substage = stage_new substage
|
@@ -51,7 +51,7 @@ module RelatonBib
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
# @param stg [RelatonBib::DocumentStatus::Stage, Hash, String,
|
54
|
+
# @param stg [RelatonBib::DocumentStatus::Stage, Hash, String, nil]
|
55
55
|
# @return [RelatonBib::DocumentStatus::Stage]
|
56
56
|
def stage_new(stg)
|
57
57
|
case stg
|
@@ -65,11 +65,11 @@ module RelatonBib
|
|
65
65
|
# @return [String]
|
66
66
|
attr_reader :value
|
67
67
|
|
68
|
-
# @return [String,
|
68
|
+
# @return [String, nil]
|
69
69
|
attr_reader :abbreviation
|
70
70
|
|
71
71
|
# @param value [String]
|
72
|
-
# @param abbreviation [String,
|
72
|
+
# @param abbreviation [String, nil]
|
73
73
|
def initialize(value:, abbreviation: nil)
|
74
74
|
@value = value
|
75
75
|
@abbreviation = abbreviation
|
data/lib/relaton_bib/version.rb
CHANGED
data/lib/relaton_bib.rb
CHANGED
@@ -23,20 +23,32 @@ module RelatonBib
|
|
23
23
|
|
24
24
|
case date.to_s
|
25
25
|
when /(?<date>\w+\s\d{4})/ # February 2012
|
26
|
-
|
27
|
-
str ? d.strftime("%Y-%m") : d
|
26
|
+
format_date $~[:date], "%B %Y", str, "%Y-%m"
|
28
27
|
when /(?<date>\w+\s\d{1,2},\s\d{4})/ # February 11, 2012
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
str ? $~[:date] : Date.strptime($~[:date], "%Y-%m")
|
28
|
+
format_date $~[:date], "%B %d, %Y", str, "%Y-%m-%d"
|
29
|
+
when /(?<date>\d{4}-\d{1,2}-\d{1,2})/ # 2012-02-03 or 2012-2-3
|
30
|
+
format_date $~[:date], "%Y-%m-%d", str
|
31
|
+
when /(?<date>\d{4}-\d{1,2})/ # 2012-02 or 2012-2
|
32
|
+
format_date $~[:date], "%Y-%m", str
|
35
33
|
when /(?<date>\d{4})/ # 2012
|
36
|
-
|
34
|
+
format_date $~[:date], "%Y", str
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
38
|
+
#
|
39
|
+
# Parse date string to Date object and format it
|
40
|
+
#
|
41
|
+
# @param [String] date date string
|
42
|
+
# @param [String] format format string
|
43
|
+
# @param [Boolean] str return string or Date if true
|
44
|
+
#
|
45
|
+
# @return [Date, String] date object or formatted date string
|
46
|
+
#
|
47
|
+
def format_date(date, format, str, outformat = nil)
|
48
|
+
date = Date.strptime(date, format)
|
49
|
+
str ? date.strftime(outformat || format) : date
|
50
|
+
end
|
51
|
+
|
40
52
|
# @param arr [NilClass, Array, #is_a?]
|
41
53
|
# @return [Array]
|
42
54
|
def array(arr)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|