Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 104 lines (86 sloc) 2.579 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'rubygems'
require 'yard'
require 'rspec/core/rake_task'

task :default => :spec
task :specs => :spec

namespace :gem do
  desc "Build the sparql-#{File.read('VERSION').chomp}.gem file"
  task :build do
    sh "gem build sparql.gemspec && mv sparql-#{File.read('VERSION').chomp}.gem pkg/"
  end

  desc "Release the sparql-#{File.read('VERSION').chomp}.gem file"
  task :release do
    sh "gem push pkg/sparql-#{File.read('VERSION').chomp}.gem"
  end
end

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

desc "Run specs through RCov"
RSpec::Core::RakeTask.new("spec:rcov") do |spec|
  spec.rcov = true
  spec.rcov_opts = %q[--exclude "spec"]
end

namespace :spec do
  desc "Generate test caches"
  task :prepare do
    $:.unshift(File.join(File.dirname(__FILE__), 'spec'))
    require 'dawg_helper'
    require 'fileutils'
    
    Dir.glob("spec/dawg/*.yml") { |yml| FileUtils.rm_rf(yml)}

    puts "load 1.0 tests"
    SPARQL::Spec.sparql1_0_tests(true)
    puts "load 1.0 syntax tests"
    SPARQL::Spec.sparql1_0_syntax_tests(true)
    puts "load 1.1 tests"
    SPARQL::Spec.sparql1_1_tests(true)
  end
end

namespace :doc do
  YARD::Rake::YardocTask.new

  desc "Generate HTML report specs"
  RSpec::Core::RakeTask.new("spec") do |spec|
    spec.rspec_opts = ["--format", "html", "-o", "doc/spec.html"]
  end
end

desc 'Create versions of ebnf files in etc'
task :etc => %w{etc/sparql11.sxp etc/sparql11.ll1.sxp}

desc 'Build first, follow and branch tables'
task :meta => "lib/sparql/grammar/meta.rb"

file "lib/sparql/grammar/meta.rb" => "etc/sparql11.bnf" do |t|
  sh %{
ebnf --ll1 QueryUnit --format rb \
--mod-name SPARQL::Grammar::Meta \
--output lib/sparql/grammar/meta.rb \
etc/sparql11.bnf
}
end

file "etc/sparql11.ll1.sxp" => "etc/sparql11.bnf" do |t|
  sh %{
ebnf --ll1 QueryUnit --format sxp \
--output etc/sparql11.ll1.sxp \
etc/sparql11.bnf
}
end

file "etc/sparql11.sxp" => "etc/sparql11.bnf" do |t|
  sh %{
ebnf --bnf --format sxp \
--output etc/sparql11.sxp \
etc/sparql11.bnf
}
end

sse_files = Dir.glob("./spec/dawg/**/*.rq").map do |f|
  f.sub(".rq", ".sse")
end
desc "Build SSE versions of test '.rq' files using Jena ARQ"
task :sse => sse_files

# Rule to create SSE files
rule ".sse" => %w{.rq} do |t|
  puts "build #{t.name}"
  sse = `qparse --print op --file #{t.source} 2> /dev/null` rescue nil
  if $? == 0
    File.open(t.name, "w") {|f| f.write(sse)}
  else
    puts "skipped #{t.source}"
  end
end
Something went wrong with that request. Please try again.