Vladimir Ulianitsky 9adbd76c77
Add Ruby gem (#2022)
* Init gem

* WIP

* WIP

* WIP: Gemify

* WIP

* Try ffi_gen

* Revert "Try ffi_gen"

This reverts commit a54e56b35a1bdc079dbe122aff47d79038d4e52f.

* Vibecode 1

* Vibecode 2

* rework progressbar

* Some ref + test_captcha

* Return deleted by Claude

* Draft precompiled packaging

* Review and refactor C bindings

* ref OwnedString

* Rename methods and add notes

* rubocop

* Fix progressbar, add examples

* Ref spec

* Ref spec - final

* Final ver

* Add srt, other fixes

* Move to ruby dir

---------

Co-authored-by: Nickolay V. Shmyrev <nshmyrev@gmail.com>
2026-02-22 11:51:10 +03:00

51 lines
1.8 KiB
Ruby

# frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rubygems/package_task"
RSpec::Core::RakeTask.new(:spec)
require "rubocop/rake_task"
require "fileutils"
RuboCop::RakeTask.new
# TODO: modify 'build' task somehow to include pre-compiled binary
# (or add this logic into gemspec)
spec = Gem::Specification.load("vosk.gemspec")
# Tweak spec when building pre-compiled gem:
# (see example in https://github.com/oxidize-rb/actions/blob/main/cross-gem/action.yml and https://github.com/oxidize-rb/rb-sys/blob/main/gem/lib/rb_sys/extensiontask.rb)
# See also https://github.com/rake-compiler/rake-compiler/blob/master/lib/rake/extensiontask.rb and https://github.com/rake-compiler/rake-compiler-dock
# def cross_compile?
# # TODO: impl
# false
# end
# TODO: maybe it should be a separate task that extends Gem::PackageTask
# if cross_compile?
# # Can't use 'file' task bc we don't know file names exactly
# task :libs do
# # TODO
# # vosk_source = os.getenv("VOSK_SOURCE", os.path.abspath(os.path.join(os.path.dirname(__file__),
# # "..")))
# FileUtils.cp Dir[File.join(vosk_source, "src/lib*.*")], "lib/vosk"
# # TODO: check it works properly (spec is modified after `gem` task is already created)
# # Matches package_data = {'vosk': ['*.so', '*.dll', '*.dyld']},
# spec.files += Dir["lib/vosk/*.{so,dll,dyld}"]
# end
# task gem: :libs
# # TODO: figure out platform
# # system = os.environ.get('VOSK_SYSTEM', platform.system())
# # architecture = os.environ.get('VOSK_ARCHITECTURE', platform.architecture()[0])
# # machine = os.environ.get('VOSK_MACHINE', platform.machine())
# spec.platform = Gem::Platform.new(platf)
# end
# add your default gem packing task
# Run with `rake build`
Gem::PackageTask.new(spec)
task default: %i[spec rubocop]