require 'rake'

# extconf
require "rake/extensiontask"

# Gem
require 'rubygems'
require 'rubygems/package_task'



# Gemspec

GEMSPEC = Gem::Specification.new do |s|
  s.name = "gqlite"
  s.version = "1.1.0"
  s.summary = "Ruby bindings for GQLite, a Graph Query library."
  s.description = <<-DESC
GQLite is a C++-language library, with a C interface, that implements a small, fast, self-contained, high-reliability, full-featured, Graph Query database engine. The data is stored in a Redb or sqlite database, which the fasted and most used SQL database. This enable to achieve high performance and for application to combine Graph queries with traditional SQL queries.

GQLite source code is license under the [MIT License](LICENSE) and is free to everyone to use for any purpose. 

The official repositories contains bindings/APIs for C, C++, Python, Ruby and Crystal.

The library is still in its early stage, but it is now fully functional. Development effort has now slowed down and new features are added on a by-need basis. It supports a subset of ISO GQL.
  
Example of use
--------------

```ruby
require 'gqlite'

begin
  # Create a database on the file "test.db"
  connection = GQLite::Connection.new filename: "test.db"

  # Execute a simple query to create a node and return all the nodes
  value = connection.execute_oc_query("CREATE () MATCH (n) RETURN n")

  # Print the result
  if value.nil?
    puts "Empty results"
  else
    puts "Results are \#{value.to_s}"
  end
rescue GQLite::Error => ex
  # Report any error
  puts "An error has occured: \#{ex.message}"
end

```

The documentation for the GQL query language can found in [GQL](https://gitlab.com/gqlite/GQLite/-/blob/docs/gql.md) and for the [API](https://gitlab.com/gqlite/GQLite/-/blob/docs/api.md).

DESC
  s.authors     = ["Cyrille Berger"]
  s.files       = %w[lib/gqlite.rb ext/gqlite/gqlite.h ext/gqlite/gqlite-c.h ext/gqlite/gqlite-amalgamate.cpp]
  s.homepage    = "https://gitlab.com/gqlite/gqlite"
  s.license     = "MIT"
  s.add_dependency "ffi", "~> 1.15"
  s.extensions = %w[ext/gqlite/extconf.rb]
end

# Tasks

Rake::ExtensionTask.new "gqlite" do |ext|
  ext.lib_dir = "lib/gqlite"
end

task prepare: [] do |t|
  
end

Gem::PackageTask.new(GEMSPEC) do |pkg|
  # Hack to trick GEM into following the symlinks while packaging instead of adding symlink to tarfile
  class File
    def File.lstat fn
      return File.stat fn
    end
  end
end

