Sha256: 479111b285e8ff4ba28604f9ba8bf6129ec5892f3b6dbe8f9b4b386efe049c75

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'thor'
require 'eost/bigquery'
require 'eost/folhacalculo'
require 'eost/version'

# @author Hernani Rodrigues Vaz
module Eost
  ID = `whoami`.chomp

  class Error < StandardError; end

  # CLI para carregar folhas calculo comuns no bigquery
  class CLI < Thor
    desc 'load', 'carrega dados da folha calculo no bigquery'
    option :d, banner: 'DIR', default: "/home/#{ID}/Downloads",
               desc: 'Onde procurar folhas calculo'
    option :x, banner: 'EXT', default: '.csv',
               desc: 'Extensao das folhas calculo'
    option :e, type: :boolean, default: false,
               desc: 'apaga linha igual no bigquery'
    option :m, type: :boolean, default: false,
               desc: 'apaga linhas existencia multipla no bigquery'
    # processa csv
    def load
      Dir.glob("#{options[:d]}/*#{options[:x]}").sort.each do |f|
        Bigquery.new(f, { e: options[:e], m: options[:m], i: true }).processa
      end
    end

    desc 'mostra', 'mostra dados da folha calculo'
    option :d, banner: 'DIR', default: "/home/#{ID}/Downloads",
               desc: 'Onde procurar folhas calculo'
    option :x, banner: 'EXT', default: '.csv',
               desc: 'Extensao das folhas calculo'
    # mostra csv
    def mostra
      Dir.glob("#{options[:d]}/*#{options[:x]}").sort.each do |f|
        Bigquery.new(f).processa
      end
    end

    default_task :mostra
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eost-0.1.7 lib/eost.rb
eost-0.1.6 lib/eost.rb