rixml 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b18fdbd91422325cb981369044b17ee46cdd0201
4
- data.tar.gz: b05a6505d3473d5162361a1126d6d9507233291f
3
+ metadata.gz: efdea886c93b2d88eb5ad25f1de042825be18090
4
+ data.tar.gz: 899bdbcc9cdaeec9987532b0882c2b7a92d2e1c4
5
5
  SHA512:
6
- metadata.gz: 271ef7e5317b2e41d8d019cf2ad36d920834e92922337da8dfad77ea95ffa5e9837709f3506b0e475dc5a026a1116854dc4a80308f067837a538e6b9a578b2e4
7
- data.tar.gz: 23600a0bf97cee375dee8d25e3ce89721e31d3e6e836af3266f4eae92205da97f40fc773361db72203652ad9538584aa979c14f0ddacfe9c2e41ec1c03048c4e
6
+ metadata.gz: 9332413709a18573b7fe3e515b5053db9ac2947ad730dda9481536fc41c1edcb5e0fe1d910eeb2db0cff24e3630301da51776c68443a2c819b773f870d963f39
7
+ data.tar.gz: b3200cf9d2fea205a2c5c446e501b569769b844be53fa749126892a497289ad631e50c4eb5197e23a78b5b0d07636a6ee7d3eeeb335da8ec945023c63df08037
@@ -4,6 +4,8 @@ Metrics/ClassLength:
4
4
  Max: 120
5
5
  Metrics/LineLength:
6
6
  Max: 120
7
+ Metrics/AbcSize:
8
+ Max: 18
7
9
  AllCops:
8
10
  TargetRubyVersion: 2.3
9
11
  DisplayCopNames: true
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rixml (0.1.0)
4
+ rixml (0.1.1)
5
5
  activesupport (>= 4.0.0)
6
6
  nokogiri (~> 1.5)
7
7
 
@@ -55,7 +55,7 @@ class RIXML
55
55
  end
56
56
 
57
57
  def context
58
- context = @attrs.dig('Research', 'Product', 'Context')
58
+ context = @attrs.dig('Research', 'Product', 'Context') || {}
59
59
  {
60
60
  companies: parse_companies_from_context(context),
61
61
  sectors: parse_sectors_from_context(context),
@@ -87,7 +87,7 @@ class RIXML
87
87
  end
88
88
 
89
89
  def parse_countries_from_context(context)
90
- [context['ProductClassifications']&.dig('Country')].flatten.map do |country|
90
+ [context['ProductClassifications']&.dig('Country')].flatten.compact.map do |country|
91
91
  { code: country['code'].upcase }
92
92
  end
93
93
  end
@@ -95,11 +95,8 @@ class RIXML
95
95
  def parse_companies_from_context(context)
96
96
  companies = []
97
97
  [context['IssuerDetails']].flatten.compact.each do |issuer|
98
- list = issuer.try(:[], 'Issuer')
99
- next if list.nil?
100
- list = [list] unless list.is_a? Array
101
- list.select { |c| c['issuerType'] == 'Corporate' }.each do |company|
102
- companies << parse_company_info(company)
98
+ [issuer['Issuer']].flatten.compact.select { |c| c['issuerType'] == 'Corporate' }.each do |company|
99
+ companies << parse_company_info(company).merge(primary: company['primaryIndicator'] == 'Yes')
103
100
  end
104
101
  end
105
102
  companies
@@ -107,11 +104,11 @@ class RIXML
107
104
 
108
105
  def parse_company_info(company)
109
106
  security_ids = company.dig('SecurityDetails', 'Security', 'SecurityID')
110
- security_ids = [security_ids] unless security_ids.is_a? Array
111
- ids = security_ids.map do |security_id|
107
+ security_ids = [security_ids].compact unless security_ids.is_a? Array
108
+ ids = security_ids&.map do |security_id|
112
109
  { security_id['idType'].underscore.to_sym => security_id['idValue'] }
113
- end.reduce({}, :merge)
114
- info = { name: (company.dig('IssuerName') || [])['NameValue'] }
110
+ end&.reduce({}, :merge) || []
111
+ info = { name: (company.dig('IssuerName') || {})['NameValue'] }
115
112
  info.merge(ids)
116
113
  end
117
114
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'rixml'
4
- s.version = '0.1.1'
4
+ s.version = '0.1.2'
5
5
  s.date = '2016-12-01'
6
6
  s.summary = 'RIXML Parser'
7
7
  s.description = 'Parse RIXML files'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rixml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Correia Santos