rixml 0.0.5 → 0.0.6

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: 20cca52a1d30a894e95eeceed322f062f382bf6a
4
- data.tar.gz: 0bf86162ce9a93da4d7cb8ad51b4f360f9071c91
3
+ metadata.gz: 6f45aee55fc7aa52f1466fb86ac7d59c86b086fe
4
+ data.tar.gz: d8124698b7c21bfeb7cc7125ad92abe1405a617c
5
5
  SHA512:
6
- metadata.gz: 4e005de2177272d0893508810b39077c03c2c6ca2d8e162f50283157624e3d9be29d0c44413ebf15f6647574f4f9dc5b840788c7c199b95eaf3ed74de64d5baa
7
- data.tar.gz: 4992aa24a2a0eb0eccb824e6693f5406dc8f7068973eec828542ec60089635a93786e13a1b81849df1421c6f399f8dacb0c080958986152f43ac4637cf8c2974
6
+ metadata.gz: 24f4059210991529d1908aac481de94b73af48a9485943001fbf6913b77e662446910c660543d661d05f11b0d94886cee05211b8162c61399a36ae2291ffd5c5
7
+ data.tar.gz: 16558436d7c255c44acd5d0bf4880d1d5e4223a7cfa7689acd0fb83f4d3bc9ddbf0784a5c84d7ee42e55000877ec1ba496687af46ab06e2be7be3f674f79be90
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+ Metrics/LineLength:
4
+ Max: 120
5
+ AllCops:
6
+ TargetRubyVersion: 2.3
7
+ DisplayCopNames: true
8
+ DisplayStyleGuide: true
9
+ Exclude:
10
+ - 'test/**/*'
11
+ - 'vendor/**/*'
data/.travis.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.2
5
4
  - 2.3.1
6
- before_install: gem install bundler
5
+ before_install: gem install bundler
6
+ script:
7
+ - bundle exec rake
8
+ - bundle exec rubocop
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
- gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- RIXML (0.0.1)
4
+ rixml (0.0.6)
5
5
  activesupport (>= 4.0.0)
6
6
  nokogiri (~> 1.5)
7
7
 
@@ -13,25 +13,39 @@ GEM
13
13
  i18n (~> 0.7)
14
14
  minitest (~> 5.1)
15
15
  tzinfo (~> 1.1)
16
+ ast (2.3.0)
16
17
  concurrent-ruby (1.0.2)
17
18
  i18n (0.7.0)
18
19
  mini_portile2 (2.1.0)
19
20
  minitest (5.9.1)
20
21
  nokogiri (1.6.8.1)
21
22
  mini_portile2 (~> 2.1.0)
23
+ parser (2.3.1.4)
24
+ ast (~> 2.2)
25
+ powerpack (0.1.1)
26
+ rainbow (2.1.0)
22
27
  rake (11.3.0)
28
+ rubocop (0.45.0)
29
+ parser (>= 2.3.1.1, < 3.0)
30
+ powerpack (~> 0.1)
31
+ rainbow (>= 1.99.1, < 3.0)
32
+ ruby-progressbar (~> 1.7)
33
+ unicode-display_width (~> 1.0, >= 1.0.1)
34
+ ruby-progressbar (1.8.1)
23
35
  thread_safe (0.3.5)
24
36
  tzinfo (1.2.2)
25
37
  thread_safe (~> 0.1)
38
+ unicode-display_width (1.1.1)
26
39
 
27
40
  PLATFORMS
28
41
  ruby
29
42
 
30
43
  DEPENDENCIES
31
- RIXML!
32
44
  bundler (~> 1.12)
33
45
  minitest (~> 5.1)
34
46
  rake (~> 11.3)
47
+ rixml!
48
+ rubocop (~> 0.45.0)
35
49
 
36
50
  BUNDLED WITH
37
- 1.13.1
51
+ 1.13.6
data/Rakefile CHANGED
@@ -1,9 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
3
4
 
4
5
  Rake::TestTask.new do |t|
5
6
  t.test_files = FileList['test/**/*_test.rb']
6
7
  end
7
- desc "Run tests"
8
+ desc 'Run tests'
8
9
 
9
- task default: :test
10
+ task default: :test
data/lib/rixml.rb CHANGED
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'nokogiri'
2
3
  require 'date'
3
4
  require 'active_support/core_ext/hash/conversions'
4
5
 
5
6
  class RIXML
6
-
7
7
  def initialize(document)
8
8
  @attrs = Hash.from_xml(document.to_s)
9
9
  end
@@ -21,6 +21,8 @@ class RIXML
21
21
  DateTime.strptime(time_str)
22
22
  end
23
23
 
24
+ # rubocop:disable Metrics/AbcSize
25
+ # rubocop:disable Metrics/MethodLength
24
26
  def authors
25
27
  org = @attrs.dig('Research', 'Product', 'Source', 'Organization') || {}
26
28
  if org.is_a? Array
@@ -41,12 +43,15 @@ class RIXML
41
43
  }
42
44
  end
43
45
  end
46
+ # rubocop:enable Metrics/AbcSize
47
+ # rubocop:enable Metrics/MethodLength
44
48
 
45
49
  def report_info
46
50
  content = @attrs.dig('Research', 'Product', 'Content')
47
51
  {
48
52
  title: content['Title'],
49
53
  abstract: content['Abstract'],
54
+ synopsis: content['Synopsis'],
50
55
  file_name: content['Resource']&.dig('Name'),
51
56
  pages: content['Resource']&.dig('Length').to_i
52
57
  }
@@ -54,24 +59,19 @@ class RIXML
54
59
 
55
60
  def context
56
61
  context = @attrs.dig('Research', 'Product', 'Context')
57
- context_info = {
58
- companies: RIXML.extract_companies_from_context(context),
59
- sectors: RIXML.extract_sectors_from_context(context)
60
- }
62
+ { companies: RIXML.extract_companies_from_context(context), sectors: RIXML.extract_sectors_from_context(context) }
61
63
  end
62
64
 
63
- def self.parse data
65
+ def self.parse(data)
64
66
  RIXML.new(Nokogiri::XML(data).root)
65
67
  end
66
68
 
67
- def self.parse_from_file filename
68
- self.parse self.read_file(filename)
69
+ def self.parse_from_file(filename)
70
+ parse read_file(filename)
69
71
  end
70
72
 
71
- private
72
-
73
- def self.read_file filename
74
- body = ''
73
+ def self.read_file(filename)
74
+ body = ''.dup
75
75
  File.open(filename, 'r') do |infile|
76
76
  while (line = infile.gets)
77
77
  body << line
@@ -80,7 +80,9 @@ class RIXML
80
80
  body
81
81
  end
82
82
 
83
- def self.extract_companies_from_context context
83
+ # rubocop:disable Metrics/AbcSize
84
+ # rubocop:disable Metrics/MethodLength
85
+ def self.extract_companies_from_context(context)
84
86
  companies = []
85
87
  list = context['IssuerDetails'].try(:[], 'Issuer')
86
88
  return [] if list.nil?
@@ -93,9 +95,10 @@ class RIXML
93
95
  end
94
96
  companies
95
97
  end
98
+ # rubocop:enable Metrics/AbcSize
99
+ # rubocop:enable Metrics/MethodLength
96
100
 
97
- def self.extract_sectors_from_context context
98
- sectors = []
101
+ def self.extract_sectors_from_context(context)
99
102
  list = context['ProductClassifications'].try(:[], 'SectorIndustry')
100
103
  return [] if list.nil?
101
104
  list = [list] unless list.is_a? Array
data/rixml.gemspec CHANGED
@@ -1,22 +1,24 @@
1
+ # frozen_string_literal: true
1
2
  Gem::Specification.new do |s|
2
3
  s.name = 'rixml'
3
- s.version = '0.0.5'
4
+ s.version = '0.0.6'
4
5
  s.date = '2016-11-01'
5
- s.summary = "RIXML Parser"
6
- s.description = "Parse RIXML files"
6
+ s.summary = 'RIXML Parser'
7
+ s.description = 'Parse RIXML files'
7
8
  s.homepage = 'https://github.com/AlphaExchange/rixml'
8
- s.authors = ["Alex Correia Santos", "Leonardo Goularte Siqueira"]
9
+ s.authors = ['Alex Correia Santos', 'Leonardo Goularte Siqueira']
9
10
  s.email = ['alex@alpha-exchange.com', 'leonardo@alpha-exchange.com']
10
11
  s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
11
12
  s.require_paths = ['lib']
12
13
  s.license = 'MIT'
13
-
14
+
14
15
  s.required_ruby_version = '>= 2.2.2'
15
-
16
+
16
17
  s.add_development_dependency 'bundler', '~> 1.12'
17
18
  s.add_development_dependency 'minitest', '~> 5.1'
18
19
  s.add_development_dependency 'rake', '~> 11.3'
19
-
20
+ s.add_development_dependency 'rubocop', '~> 0.45.0'
21
+
20
22
  s.add_runtime_dependency 'nokogiri', '~> 1.5'
21
23
  s.add_runtime_dependency 'activesupport', '>= 4.0.0'
22
24
  end
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.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Correia Santos
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '11.3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubocop
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.45.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.45.0
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: nokogiri
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +103,7 @@ executables: []
89
103
  extensions: []
90
104
  extra_rdoc_files: []
91
105
  files:
106
+ - ".rubocop.yml"
92
107
  - ".travis.yml"
93
108
  - Gemfile
94
109
  - Gemfile.lock