ivt_mellon_reader 0.4.1
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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Guardfile +77 -0
- data/README.md +61 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ivt_mellon_reader.gemspec +42 -0
- data/lib/ivt_mellon_reader/client.rb +118 -0
- data/lib/ivt_mellon_reader/transaction.rb +65 -0
- data/lib/ivt_mellon_reader/version.rb +3 -0
- data/lib/ivt_mellon_reader.rb +3 -0
- data/lib/mellon_client.rb +3 -0
- data/lib/mellon_client_address.rb +3 -0
- data/lib/mellon_client_phone.rb +3 -0
- data/lib/mellon_transaction.rb +3 -0
- metadata +188 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 23786e6071fa5b047ffbd9e49a504135e7e2271d
         | 
| 4 | 
            +
              data.tar.gz: b209d8b3b5e5435e8fbc6fdf263dc1a9b6d90953
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: ef99b99ce50aa859be09989f27f54329b7ca54d1e3533b0d46d69cef3a8758d20ab247460e8a64affe89e96f6dca690ce3f24b3c24e7c4f240fc502ae477e1c6
         | 
| 7 | 
            +
              data.tar.gz: e6dbf844a0094490a834c20494cd139357115ab455db33700a55294e3cb6ef89cd5fe73a6724a18b93253165a0facb447ebd58a4d18a936cfe2469e77b87b13a
         | 
    
        data/.DS_Store
    ADDED
    
    | Binary file | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Guardfile
    ADDED
    
    | @@ -0,0 +1,77 @@ | |
| 1 | 
            +
            # A sample Guardfile
         | 
| 2 | 
            +
            # More info at https://github.com/guard/guard#readme
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            ## Uncomment and set this to only include directories you want to watch
         | 
| 5 | 
            +
            # directories %w(app lib config test spec feature)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## Uncomment to clear the screen before every task
         | 
| 8 | 
            +
            # clearing :on
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ## Guard internally checks for changes in the Guardfile and exits.
         | 
| 11 | 
            +
            ## If you want Guard to automatically start up again, run guard in a
         | 
| 12 | 
            +
            ## shell loop, e.g.:
         | 
| 13 | 
            +
            ##
         | 
| 14 | 
            +
            ##  $ while bundle exec guard; do echo "Restarting Guard..."; done
         | 
| 15 | 
            +
            ##
         | 
| 16 | 
            +
            ## Note: if you are using the `directories` clause above and you are not
         | 
| 17 | 
            +
            ## watching the project directory ('.'), the you will want to move the Guardfile
         | 
| 18 | 
            +
            ## to a watched dir and symlink it back, e.g.
         | 
| 19 | 
            +
            #
         | 
| 20 | 
            +
            #  $ mkdir config
         | 
| 21 | 
            +
            #  $ mv Guardfile config/
         | 
| 22 | 
            +
            #  $ ln -s config/Guardfile .
         | 
| 23 | 
            +
            #
         | 
| 24 | 
            +
            # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            # Note: The cmd option is now required due to the increasing number of ways
         | 
| 27 | 
            +
            #       rspec may be run, below are examples of the most common uses.
         | 
| 28 | 
            +
            #  * bundler: 'bundle exec rspec'
         | 
| 29 | 
            +
            #  * bundler binstubs: 'bin/rspec'
         | 
| 30 | 
            +
            #  * spring: 'bin/rspec' (This will use spring if running and you have
         | 
| 31 | 
            +
            #                          installed the spring binstubs per the docs)
         | 
| 32 | 
            +
            #  * zeus: 'zeus rspec' (requires the server to be started separately)
         | 
| 33 | 
            +
            #  * 'just' rspec: 'rspec'
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            guard :rspec, cmd: "bundle exec rspec" do
         | 
| 36 | 
            +
              require "guard/rspec/dsl"
         | 
| 37 | 
            +
              dsl = Guard::RSpec::Dsl.new(self)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              # Feel free to open issues for suggestions and improvements
         | 
| 40 | 
            +
             | 
| 41 | 
            +
              # RSpec files
         | 
| 42 | 
            +
              rspec = dsl.rspec
         | 
| 43 | 
            +
              watch(rspec.spec_helper) { rspec.spec_dir }
         | 
| 44 | 
            +
              watch(rspec.spec_support) { rspec.spec_dir }
         | 
| 45 | 
            +
              watch(rspec.spec_files)
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              # Ruby files
         | 
| 48 | 
            +
              ruby = dsl.ruby
         | 
| 49 | 
            +
              dsl.watch_spec_files_for(ruby.lib_files)
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              # Rails files
         | 
| 52 | 
            +
              rails = dsl.rails(view_extensions: %w(erb haml slim))
         | 
| 53 | 
            +
              dsl.watch_spec_files_for(rails.app_files)
         | 
| 54 | 
            +
              dsl.watch_spec_files_for(rails.views)
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              watch(rails.controllers) do |m|
         | 
| 57 | 
            +
                [
         | 
| 58 | 
            +
                  rspec.spec.("routing/#{m[1]}_routing"),
         | 
| 59 | 
            +
                  rspec.spec.("controllers/#{m[1]}_controller"),
         | 
| 60 | 
            +
                  rspec.spec.("acceptance/#{m[1]}")
         | 
| 61 | 
            +
                ]
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              # Rails config changes
         | 
| 65 | 
            +
              watch(rails.spec_helper)     { rspec.spec_dir }
         | 
| 66 | 
            +
              watch(rails.routes)          { "#{rspec.spec_dir}/routing" }
         | 
| 67 | 
            +
              watch(rails.app_controller)  { "#{rspec.spec_dir}/controllers" }
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              # Capybara features specs
         | 
| 70 | 
            +
              watch(rails.view_dirs)     { |m| rspec.spec.("features/#{m[1]}") }
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              # Turnip features and steps
         | 
| 73 | 
            +
              watch(%r{^spec/acceptance/(.+)\.feature$})
         | 
| 74 | 
            +
              watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
         | 
| 75 | 
            +
                Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
         | 
| 76 | 
            +
              end
         | 
| 77 | 
            +
            end
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            # IvtMellonReader
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem to read BNY Mellon files.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ```ruby
         | 
| 10 | 
            +
            gem 'ivt_mellon_reader'
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            And then execute:
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                $ bundle
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            Or install it yourself as:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                $ gem install ivt_mellon_reader
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ## Usage
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ```ruby
         | 
| 24 | 
            +
                response = IvtMellonReader::Position.new.read("your_file_path")
         | 
| 25 | 
            +
                response.first.client_id --> "String"
         | 
| 26 | 
            +
                response.first.order_id --> "String"
         | 
| 27 | 
            +
                response.first.client_name --> "String"
         | 
| 28 | 
            +
                response.first.fund_name --> "String"
         | 
| 29 | 
            +
                response.first.operation_type --> "String"
         | 
| 30 | 
            +
                response.first.value --> "Float"
         | 
| 31 | 
            +
                response.first.request_date --> "Date"
         | 
| 32 | 
            +
                response.first.quote_date --> "Date"
         | 
| 33 | 
            +
                response.first.distributor_name --> "String"
         | 
| 34 | 
            +
            ```
         | 
| 35 | 
            +
             | 
| 36 | 
            +
             | 
| 37 | 
            +
             gem push --key gemstash_key --host http://server2.investtools.com.br:9292/private pkg/ivt_mellon_reader-0.4.0.gem
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ## Development
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            ## Contributing
         | 
| 46 | 
            +
             | 
| 47 | 
            +
             | 
| 48 | 
            +
                - Você deve adicionar a chave do gemstash no seu arquivo ~/.gem/credentials. 
         | 
| 49 | 
            +
                 A chave pode ser encontrada no lastpass usando o nome gemstash 
         | 
| 50 | 
            +
                 Você deve dar um nome a essa chave, por exemplo: gemstash_key. O arquivo ficaria assim:
         | 
| 51 | 
            +
             
         | 
| 52 | 
            +
                    ---
         | 
| 53 | 
            +
                    :gemstash_key:[chave]
         | 
| 54 | 
            +
                  
         | 
| 55 | 
            +
                  O nome usado na chave é o mesmo que deve ser usado na hora do push
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                - Fazer as alterações necessárias criando uma nova versão
         | 
| 58 | 
            +
                - Fazer o push para origin
         | 
| 59 | 
            +
                - Fazer o push para server2.investtools.com.br da seguinte forma:
         | 
| 60 | 
            +
                
         | 
| 61 | 
            +
                    gem push --key gemstash_key --host http://server2.investtools.com.br:9292/private pkg/ivt_mellon_reader-0.4.0.gem
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "bundler/setup"
         | 
| 4 | 
            +
            require "ivt_mellon_reader"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # You can add fixtures and/or initialization code here to make experimenting
         | 
| 7 | 
            +
            # with your gem easier. You can also use a different console, if you like.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         | 
| 10 | 
            +
            # require "pry"
         | 
| 11 | 
            +
            # Pry.start
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "irb"
         | 
| 14 | 
            +
            IRB.start
         | 
    
        data/bin/setup
    ADDED
    
    
| @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'ivt_mellon_reader/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "ivt_mellon_reader"
         | 
| 8 | 
            +
              spec.version       = IvtMellonReader::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Lucas Pérez'"]
         | 
| 10 | 
            +
              spec.email         = ["lucascperez@gmail.com"]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.summary       = %q{Gem to read all mellon files}
         | 
| 13 | 
            +
              spec.description   = %q{Gem to read all mellon files}
         | 
| 14 | 
            +
              spec.homepage      = "https://github.com/investtools/ivt_mellon_reader"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
         | 
| 17 | 
            +
              # to allow pushing to a single host or delete this section to allow pushing to any host.
         | 
| 18 | 
            +
              # if spec.respond_to?(:metadata)
         | 
| 19 | 
            +
              #   spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
         | 
| 20 | 
            +
              # else
         | 
| 21 | 
            +
              #   raise "RubyGems 2.0 or newer is required to protect against " \
         | 
| 22 | 
            +
              #     "public gem pushes."
         | 
| 23 | 
            +
              # end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject do |f|
         | 
| 26 | 
            +
                f.match(%r{^(test|spec|features)/})
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
              spec.bindir        = "exe"
         | 
| 29 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 30 | 
            +
              spec.require_paths = ["lib"]
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              spec.add_development_dependency "bundler", "~> 1.13"
         | 
| 33 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 34 | 
            +
              spec.add_development_dependency "rspec", "~> 3.0"
         | 
| 35 | 
            +
              spec.add_development_dependency "guard-rspec"
         | 
| 36 | 
            +
              spec.add_development_dependency "terminal-notifier-guard"
         | 
| 37 | 
            +
              spec.add_dependency "roo"
         | 
| 38 | 
            +
              spec.add_dependency "roo-xls"
         | 
| 39 | 
            +
              spec.add_dependency "ox"
         | 
| 40 | 
            +
              spec.add_dependency "saxerator"
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            end
         | 
| @@ -0,0 +1,118 @@ | |
| 1 | 
            +
            require 'ox'
         | 
| 2 | 
            +
            require 'mellon_client'
         | 
| 3 | 
            +
            require 'mellon_client_address'
         | 
| 4 | 
            +
            require 'mellon_client_phone'
         | 
| 5 | 
            +
            require 'saxerator'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module IvtMellonReader
         | 
| 8 | 
            +
              class Client
         | 
| 9 | 
            +
                def read(file, &block)
         | 
| 10 | 
            +
                  @parser = Saxerator.parser(File.new(file)) do |config|
         | 
| 11 | 
            +
                    config.adapter = :ox
         | 
| 12 | 
            +
                    config.symbolize_keys!
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  @clients = [@parser.for_tag(:Titularidade)].map(&:entries)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  @clients.each do |client|
         | 
| 18 | 
            +
                    client.each do |c|
         | 
| 19 | 
            +
                      @client = c
         | 
| 20 | 
            +
                      block.call(MellonClient.new(id, name, identification_document, gender, emails, phones, addresses, occupation, profession, birth_date, type, nav_range))
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                    
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def id
         | 
| 27 | 
            +
                  @client[:Titular][:idPessoa].gsub("\r", "").gsub("\n","").strip
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def name
         | 
| 31 | 
            +
                  @client[:Titular][:nome].gsub("\r", "").gsub("\n","").strip
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                def identification_document
         | 
| 35 | 
            +
                  if @client[:Titular].has_key? :CPF
         | 
| 36 | 
            +
                    return @client[:Titular][:CPF].gsub("\r", "").gsub("\n","").strip
         | 
| 37 | 
            +
                  elsif @client[:Titular].has_key? :cnpjFundo
         | 
| 38 | 
            +
                    return @client[:Titular][:cnpjFundo].gsub("\r", "").gsub("\n","").strip
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                def gender
         | 
| 43 | 
            +
                  @client[:Titular][:sexo].to_s if @client[:Titular].has_key? :sexo
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                def type
         | 
| 47 | 
            +
                  if @client[:Titular].has_key? :cnpjFundo
         | 
| 48 | 
            +
                    return "fundo"
         | 
| 49 | 
            +
                  else
         | 
| 50 | 
            +
                    @client[:Titular][:tipoPessoa].gsub("\r","").gsub("\n","").strip
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                def emails
         | 
| 55 | 
            +
                  emails = []
         | 
| 56 | 
            +
                  if !@client[:Titular][:Emails].empty?
         | 
| 57 | 
            +
                    if @client[:Titular][:Emails][:email].respond_to? :each
         | 
| 58 | 
            +
                      @client[:Titular][:Emails][:email].each do |email|
         | 
| 59 | 
            +
                        emails << email.to_s
         | 
| 60 | 
            +
                      end
         | 
| 61 | 
            +
                    else
         | 
| 62 | 
            +
                      emails << @client[:Titular][:Emails][:email].to_s
         | 
| 63 | 
            +
                    end
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
                  emails
         | 
| 66 | 
            +
                end 
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                def occupation
         | 
| 69 | 
            +
                  @client[:Titular][:ocupacao].to_s if @client[:Titular].has_key? :ocupacao
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                def profession
         | 
| 73 | 
            +
                  @client[:Titular][:profissao].to_s if @client[:Titular].has_key? :profissao
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                def phones
         | 
| 77 | 
            +
                  phones = []
         | 
| 78 | 
            +
                  if !@client[:Titular][:Telefones].empty?
         | 
| 79 | 
            +
                    if @client[:Titular][:Telefones][:Telefone].class == Saxerator::Builder::HashElement
         | 
| 80 | 
            +
                      phones << MellonClientPhone.new(@client[:Titular][:Telefones][:Telefone][:ddi].to_s, @client[:Titular][:Telefones][:Telefone][:ddd].to_s, @client[:Titular][:Telefones][:Telefone][:numero].to_s, @client[:Titular][:Telefones][:Telefone][:tipoTelefone].to_s)
         | 
| 81 | 
            +
                    else
         | 
| 82 | 
            +
                      @client[:Titular][:Telefones][:Telefone].each do |phone|
         | 
| 83 | 
            +
                        phones << MellonClientPhone.new(phone[:ddi].to_s, phone[:ddd].to_s, phone[:numero].to_s, phone[:tipoTelefone].to_s)
         | 
| 84 | 
            +
                      end
         | 
| 85 | 
            +
                    end
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
                  phones
         | 
| 88 | 
            +
                end	
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                def addresses
         | 
| 91 | 
            +
                  addresses = []
         | 
| 92 | 
            +
                  if !@client[:Titular][:Enderecos].empty?
         | 
| 93 | 
            +
                    if @client[:Titular][:Enderecos][:endereco].class == Saxerator::Builder::HashElement
         | 
| 94 | 
            +
                      addresses << MellonClientAddress.new(@client[:Titular][:Enderecos][:endereco][:tipoEndereco].to_s, @client[:Titular][:Enderecos][:endereco][:logradouro].to_s, @client[:Titular][:Enderecos][:endereco][:numero].to_s, @client[:Titular][:Enderecos][:endereco][:complemento].to_s, @client[:Titular][:Enderecos][:endereco][:bairro].to_s, @client[:Titular][:Enderecos][:endereco][:cidade].to_s, @client[:Titular][:Enderecos][:endereco][:pais].to_s, @client[:Titular][:Enderecos][:endereco][:uf].to_s, @client[:Titular][:Enderecos][:endereco][:cep].to_s)
         | 
| 95 | 
            +
                    else
         | 
| 96 | 
            +
                      @client[:Titular][:Enderecos][:endereco].each do |address|
         | 
| 97 | 
            +
                        addresses << MellonClientAddress.new(address[:tipoEndereco].to_s, address[:logradouro].to_s, address[:numero].to_s, address[:complemento].to_s, address[:bairro].to_s, address[:cidade].to_s, address[:pais].to_s, address[:uf].to_s, address[:cep].to_s)
         | 
| 98 | 
            +
                      end
         | 
| 99 | 
            +
                    end
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
                  addresses
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                def birth_date
         | 
| 105 | 
            +
                  if @client[:Titular].has_key? :dataNascimento
         | 
| 106 | 
            +
                    Date.parse(@client[:Titular][:dataNascimento])
         | 
| 107 | 
            +
                  end
         | 
| 108 | 
            +
                end
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                def nav_range
         | 
| 111 | 
            +
                  if !@client[:faixaPatrimonial].empty?
         | 
| 112 | 
            +
                    return @client[:faixaPatrimonial].gsub("\r", "").gsub("\n","").strip
         | 
| 113 | 
            +
                  else
         | 
| 114 | 
            +
                    return nil
         | 
| 115 | 
            +
                  end
         | 
| 116 | 
            +
                end
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
            end
         | 
| @@ -0,0 +1,65 @@ | |
| 1 | 
            +
            require 'roo'
         | 
| 2 | 
            +
            require 'mellon_transaction'
         | 
| 3 | 
            +
            module IvtMellonReader
         | 
| 4 | 
            +
            	class Transaction
         | 
| 5 | 
            +
            		def read(file)
         | 
| 6 | 
            +
            			response = []
         | 
| 7 | 
            +
            			@csv = Roo::CSV.new(file, csv_options: {col_sep: "\t", encoding: Encoding::ISO_8859_1})
         | 
| 8 | 
            +
            			rows = @csv.parse({headers: true}).drop(1)
         | 
| 9 | 
            +
            			rows.each do |row|
         | 
| 10 | 
            +
            				response << MellonTransaction.new(client_id(row), order_id(row), client_name(row), fund_name(row), operation_type(row), value(row), request_date(row), quote_date(row), distributor_name(row), fund_id(row), penalty(row))
         | 
| 11 | 
            +
            			end
         | 
| 12 | 
            +
            			response
         | 
| 13 | 
            +
            		end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            		protected 
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            		def client_id(row)
         | 
| 18 | 
            +
            			row["CD_COTISTA"]
         | 
| 19 | 
            +
            		end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            		def order_id(row)
         | 
| 22 | 
            +
            			row["NU_ORDEM"]
         | 
| 23 | 
            +
            		end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            		def client_name(row)
         | 
| 26 | 
            +
            			row["NM_CLIENTE"]
         | 
| 27 | 
            +
            		end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            		def fund_name(row)
         | 
| 30 | 
            +
            			row["NM_FUNDO"]
         | 
| 31 | 
            +
            		end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            		def operation_type(row)
         | 
| 34 | 
            +
            			row["DS_OPERACAO"]
         | 
| 35 | 
            +
            		end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            		def quote_date(row)
         | 
| 38 | 
            +
            			Date.parse(row["DT_COTIZACAO"])
         | 
| 39 | 
            +
            		end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            		def request_date(row)
         | 
| 42 | 
            +
            			Date.parse(row["DT_ENTRADA"])
         | 
| 43 | 
            +
            		end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            		def value(row)
         | 
| 46 | 
            +
            			row["VL_VALOR"].to_f
         | 
| 47 | 
            +
            		end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            		def distributor_name(row)
         | 
| 50 | 
            +
            			row["NM_DISTRIBUIDOR"]
         | 
| 51 | 
            +
            		end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            		def fund_id(row)
         | 
| 54 | 
            +
            			row['CD_FUNDO']
         | 
| 55 | 
            +
            		end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            		def penalty(row)
         | 
| 58 | 
            +
            			if row['PENALTY'] == "N" 
         | 
| 59 | 
            +
            				return false
         | 
| 60 | 
            +
            			else
         | 
| 61 | 
            +
            				return true
         | 
| 62 | 
            +
            			end
         | 
| 63 | 
            +
            		end
         | 
| 64 | 
            +
            	end
         | 
| 65 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,188 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: ivt_mellon_reader
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.4.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Lucas Pérez'
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2017-04-04 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.13'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.13'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '10.0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '10.0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '3.0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '3.0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: guard-rspec
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ">="
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: terminal-notifier-guard
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ">="
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ">="
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: roo
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ">="
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: '0'
         | 
| 90 | 
            +
              type: :runtime
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ">="
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '0'
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: roo-xls
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ">="
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
              type: :runtime
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: ox
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ">="
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ">="
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: saxerator
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - ">="
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '0'
         | 
| 132 | 
            +
              type: :runtime
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - ">="
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '0'
         | 
| 139 | 
            +
            description: Gem to read all mellon files
         | 
| 140 | 
            +
            email:
         | 
| 141 | 
            +
            - lucascperez@gmail.com
         | 
| 142 | 
            +
            executables: []
         | 
| 143 | 
            +
            extensions: []
         | 
| 144 | 
            +
            extra_rdoc_files: []
         | 
| 145 | 
            +
            files:
         | 
| 146 | 
            +
            - ".DS_Store"
         | 
| 147 | 
            +
            - ".gitignore"
         | 
| 148 | 
            +
            - ".rspec"
         | 
| 149 | 
            +
            - ".travis.yml"
         | 
| 150 | 
            +
            - Gemfile
         | 
| 151 | 
            +
            - Guardfile
         | 
| 152 | 
            +
            - README.md
         | 
| 153 | 
            +
            - Rakefile
         | 
| 154 | 
            +
            - bin/console
         | 
| 155 | 
            +
            - bin/setup
         | 
| 156 | 
            +
            - ivt_mellon_reader.gemspec
         | 
| 157 | 
            +
            - lib/ivt_mellon_reader.rb
         | 
| 158 | 
            +
            - lib/ivt_mellon_reader/client.rb
         | 
| 159 | 
            +
            - lib/ivt_mellon_reader/transaction.rb
         | 
| 160 | 
            +
            - lib/ivt_mellon_reader/version.rb
         | 
| 161 | 
            +
            - lib/mellon_client.rb
         | 
| 162 | 
            +
            - lib/mellon_client_address.rb
         | 
| 163 | 
            +
            - lib/mellon_client_phone.rb
         | 
| 164 | 
            +
            - lib/mellon_transaction.rb
         | 
| 165 | 
            +
            homepage: https://github.com/investtools/ivt_mellon_reader
         | 
| 166 | 
            +
            licenses: []
         | 
| 167 | 
            +
            metadata: {}
         | 
| 168 | 
            +
            post_install_message: 
         | 
| 169 | 
            +
            rdoc_options: []
         | 
| 170 | 
            +
            require_paths:
         | 
| 171 | 
            +
            - lib
         | 
| 172 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 173 | 
            +
              requirements:
         | 
| 174 | 
            +
              - - ">="
         | 
| 175 | 
            +
                - !ruby/object:Gem::Version
         | 
| 176 | 
            +
                  version: '0'
         | 
| 177 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 178 | 
            +
              requirements:
         | 
| 179 | 
            +
              - - ">="
         | 
| 180 | 
            +
                - !ruby/object:Gem::Version
         | 
| 181 | 
            +
                  version: '0'
         | 
| 182 | 
            +
            requirements: []
         | 
| 183 | 
            +
            rubyforge_project: 
         | 
| 184 | 
            +
            rubygems_version: 2.6.10
         | 
| 185 | 
            +
            signing_key: 
         | 
| 186 | 
            +
            specification_version: 4
         | 
| 187 | 
            +
            summary: Gem to read all mellon files
         | 
| 188 | 
            +
            test_files: []
         |