Sha256: d2edd570ac961b108bbe58e9b6038c55ce113a507decb8ef636e0272278ffbfc

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

#! /usr/bin/env ruby

require 'bundler/setup'
require 'eventmachine'
require 'em-http-request'
require 'em-dextras'
require 'json'

require_relative './fetch_list_of_countries'
require_relative './parse_worldbank_document'
require_relative './fetch_indicator'
require_relative './for_gnuplot'

INCOME_SHARE_BY_TOP_10PC = 'SI.DST.10TH.10'

class Monitoring
  def end_of_chain!(value)
    EM.stop
  end

  def inform_exception!(exception, stage)
    STDERR.puts "Error: #{exception} #{exception.backtrace.join("\n") if exception.respond_to?(:backtrace)}"
  end
end

class Print
  include EMDextras::Chains::SynchronousStage
  def invoke(input)
    puts input
  end
end

EM.run do
  EMDextras::Chains.pipe('no input', Monitoring.new, [
    FetchListOfCountries.new,
    ParseWorldbankDocument.new,
    :split,
    FetchIndicator.new(INCOME_SHARE_BY_TOP_10PC),
    ParseWorldbankDocument.new,
    :split,
    ForGnuplot.new,
    Print.new
  ], debug: true)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
em-dextras-0.4.0 doc/samples/worldbank/worldbank.rb
em-dextras-0.3.0 doc/samples/worldbank/worldbank.rb