Sha256: 44927a558114b8427c9c7ccc918a7196312ecd10f0bf6c950a7e80fbebe4c709

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

namespace :xdr do

  # As Hayashi adds more .x files, we'll need to update this array
  # Prior to launch, we should be separating our .x files into a separate
  # repo, and should be able to improve this integration.
  HAYASHI_XDR = [
                 "src/xdr/Stellar-types.x",
                 "src/xdr/Stellar-ledger-entries.x",
                 "src/xdr/Stellar-transaction.x",
                 "src/xdr/Stellar-ledger.x",
                 "src/xdr/Stellar-overlay.x",
                 "src/xdr/Stellar-SCP.x",
                ]

  LOCAL_XDR_PATHS = HAYASHI_XDR.map{ |src| "xdr/" + File.basename(src) }

  task :update => [:download, :generate]

  task :download do
    require 'octokit'
    require 'base64'
    FileUtils.rm_rf "xdr/"
    FileUtils.mkdir_p "xdr"

    client = Octokit::Client.new(:netrc => true)

    HAYASHI_XDR.each do |src|
      local_path = "xdr/" + File.basename(src)
      encoded    = client.contents("stellar/stellar-core", path: src).content
      decoded    = Base64.decode64 encoded

      IO.write(local_path, decoded)
    end
  end

  task :generate do
    require "pathname"
    require "xdrgen"
    require 'fileutils'
    FileUtils.rm_rf "generated"

    compilation = Xdrgen::Compilation.new(
      LOCAL_XDR_PATHS,
      output_dir: "generated",
      namespace:  "auction-ruby-base-generated",
      language:   :ruby
    )
    compilation.compile
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
auction-ruby-base-0.1.3 tasks/xdr.rake
auction-ruby-base-0.1.2 tasks/xdr.rake