Sha256: 20f730917038787f2e32be31f816012e6d1ed4b70a0ee1b5738dad82aad5e0a2

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :default => :spec

begin
  require 'yard'
  YARD::Rake::YardocTask.new
rescue LoadError
  task :yard do
    abort 'YARD is not available. In order to run yard, you must: gem install yard'
  end
end

namespace :popolo do
  desc 'Update Popolo schemas'
  task :schemas do
    require 'base64'
    require 'json'

    require 'octokit'

    Octokit.contents('popolo-project/popolo-spec', path: 'schemas', ref: 'gh-pages').each do |file|
      response = Octokit.contents('popolo-project/popolo-spec', path: file.path, ref: 'gh-pages')
      if response.encoding == 'base64'
        content = JSON.load(Base64.decode64(response.content))
      else
        raise "Can't handle #{response.encoding} encoding"
      end
      content['id'] = content['id'].sub('http://www.popoloproject.com/schemas/', '')
      File.open(File.expand_path(File.join('schemas', 'popolo', file.name), __dir__), 'w') do |f|
        f.write(JSON.dump(content))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pupa-0.2.4 Rakefile