Sha256: 1a3fba000763c0149f9022bd3787b630264a08833f84de2f21d6bdb8b82f953c

Contents?: true

Size: 696 Bytes

Versions: 10

Compression:

Stored size: 696 Bytes

Contents

require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task default: :spec

desc "Download latest e-invoice donation unit list and convert it to JSON"
task :update_donation_unit do
  require "json"
  require "faraday"
  # From https://data.gov.tw/dataset/31868
  data = Faraday.get("https://www.einvoice.nat.gov.tw/home/DownLoad?fileName=1516074903969_0.csv",
                     nil, { "accept-encoding": "none" }).body.force_encoding("big5")
  orgs = data.encode("utf-8").split("\n")[1..-1].map do |line|
    line.split(",").values_at(2, 1)
  end.sort_by(&:first)

  File.write "lib/einvoice/donation_unit_list.json", JSON.pretty_generate(Hash[orgs])
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
einvoice-1.2.22 Rakefile
einvoice-1.2.21 Rakefile
einvoice-1.2.20 Rakefile
einvoice-1.2.19 Rakefile
einvoice-1.2.18 Rakefile
einvoice-1.2.17 Rakefile
einvoice-1.2.16 Rakefile
einvoice-1.2.15 Rakefile
einvoice-1.2.14 Rakefile
einvoice-1.2.13 Rakefile