Skip to content

Commit

Permalink
Add rspec and create Lago module
Browse files Browse the repository at this point in the history
  • Loading branch information
nudded committed Oct 15, 2024
1 parent 6e110e5 commit 787fcaf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions expression-ruby/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

require 'rb_sys/extensiontask'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

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

GEMSPEC = Gem::Specification.load('lago-expression.gemspec')

Expand Down
8 changes: 5 additions & 3 deletions expression-ruby/ext/lago_expression/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ fn evaluate(

#[magnus::init]
fn init(ruby: &Ruby) -> Result<(), Error> {
let class = ruby.define_class("ExpressionParser", ruby.class_object())?;
let module = ruby.define_module("Lago")?;

let class = module.define_class("ExpressionParser", ruby.class_object())?;
class.define_singleton_method("parse", function!(parse, 1))?;

let class = ruby.define_class("Expression", ruby.class_object())?;
let class = module.define_class("Expression", ruby.class_object())?;
class.define_method("evaluate", method!(evaluate, 1))?;

let class = ruby.define_class("Event", ruby.class_object())?;
let class = module.define_class("Event", ruby.class_object())?;
class.define_singleton_method("new", function!(EventWrapper::new, 3))?;

Ok(())
Expand Down
1 change: 1 addition & 0 deletions expression-ruby/lago-expression.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'libclang', '~> 14'
spec.add_development_dependency 'rake-compiler', '~> 1.2'
spec.add_development_dependency 'rb_sys', '~> 0.9'
spec.add_development_dependency 'rspec', '~> 3'
end

0 comments on commit 787fcaf

Please sign in to comment.