rixml 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rixml.rb +12 -20
- data/rixml.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20cca52a1d30a894e95eeceed322f062f382bf6a
|
4
|
+
data.tar.gz: 0bf86162ce9a93da4d7cb8ad51b4f360f9071c91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e005de2177272d0893508810b39077c03c2c6ca2d8e162f50283157624e3d9be29d0c44413ebf15f6647574f4f9dc5b840788c7c199b95eaf3ed74de64d5baa
|
7
|
+
data.tar.gz: 4992aa24a2a0eb0eccb824e6693f5406dc8f7068973eec828542ec60089635a93786e13a1b81849df1421c6f399f8dacb0c080958986152f43ac4637cf8c2974
|
data/lib/rixml.rb
CHANGED
@@ -9,24 +9,24 @@ class RIXML
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def product_id
|
12
|
-
|
12
|
+
@attrs.dig('Research', 'Product', 'productID')
|
13
13
|
end
|
14
14
|
|
15
15
|
def status
|
16
|
-
|
16
|
+
@attrs.dig('Research', 'Product', 'StatusInfo', 'statusType')&.downcase&.to_sym || :published
|
17
17
|
end
|
18
18
|
|
19
19
|
def publication_date
|
20
|
-
time_str =
|
20
|
+
time_str = @attrs.dig('Research', 'Product', 'StatusInfo', 'statusDateTime') || DateTime.now.to_s
|
21
21
|
DateTime.strptime(time_str)
|
22
22
|
end
|
23
23
|
|
24
24
|
def authors
|
25
|
-
org =
|
25
|
+
org = @attrs.dig('Research', 'Product', 'Source', 'Organization') || {}
|
26
26
|
if org.is_a? Array
|
27
27
|
org = org.find { |v| v['primaryIndicator'] == 'Yes' } || org.first
|
28
28
|
end
|
29
|
-
authors =
|
29
|
+
authors = org.dig('PersonGroup', 'PersonGroupMember') || []
|
30
30
|
authors = [authors] unless authors.is_a? Array
|
31
31
|
|
32
32
|
authors.map do |author|
|
@@ -37,23 +37,23 @@ class RIXML
|
|
37
37
|
middle_name: person['MiddleName'],
|
38
38
|
last_name: person['FamilyName'],
|
39
39
|
job_title: person['JobTitle'],
|
40
|
-
email: person['ContactInfo']
|
40
|
+
email: person['ContactInfo']&.dig('Email')&.downcase
|
41
41
|
}
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
def report_info
|
46
|
-
content =
|
46
|
+
content = @attrs.dig('Research', 'Product', 'Content')
|
47
47
|
{
|
48
48
|
title: content['Title'],
|
49
49
|
abstract: content['Abstract'],
|
50
|
-
file_name: content['Resource']
|
51
|
-
pages: content['Resource']
|
50
|
+
file_name: content['Resource']&.dig('Name'),
|
51
|
+
pages: content['Resource']&.dig('Length').to_i
|
52
52
|
}
|
53
53
|
end
|
54
54
|
|
55
55
|
def context
|
56
|
-
context =
|
56
|
+
context = @attrs.dig('Research', 'Product', 'Context')
|
57
57
|
context_info = {
|
58
58
|
companies: RIXML.extract_companies_from_context(context),
|
59
59
|
sectors: RIXML.extract_sectors_from_context(context)
|
@@ -70,14 +70,6 @@ class RIXML
|
|
70
70
|
|
71
71
|
private
|
72
72
|
|
73
|
-
def self.deep_value(attrs, *keys)
|
74
|
-
keys.reduce(attrs) { |v, key| v.try(:[], key) }
|
75
|
-
end
|
76
|
-
|
77
|
-
def deep_value(*keys)
|
78
|
-
RIXML.deep_value(@attrs, *keys)
|
79
|
-
end
|
80
|
-
|
81
73
|
def self.read_file filename
|
82
74
|
body = ''
|
83
75
|
File.open(filename, 'r') do |infile|
|
@@ -94,10 +86,10 @@ class RIXML
|
|
94
86
|
return [] if list.nil?
|
95
87
|
list = [list] unless list.is_a? Array
|
96
88
|
list.select { |c| c['issuerType'] == 'Corporate' }.each do |company|
|
97
|
-
securities = company
|
89
|
+
securities = company.dig('SecurityDetails', 'Security', 'SecurityID')
|
98
90
|
securities = [securities] unless securities.is_a? Array
|
99
91
|
isin = securities.find { |security| security['idType'] == 'ISIN' }
|
100
|
-
companies << { isin: isin['idValue'] } unless isin.nil?
|
92
|
+
companies << { isin: isin['idValue'] } unless isin&.dig('idValue').nil?
|
101
93
|
end
|
102
94
|
companies
|
103
95
|
end
|
data/rixml.gemspec
CHANGED