Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ruby bindings for add_policy to return package name #240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bindings/ruby/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ gemspec

# These gems are required for local development and testing,
# but won't be included in the published gem
gem "minitest", "~> 5.16"
gem "rake", "~> 13.0"
gem "minitest", "~> 5.22"
gem "rake", "~> 13.2"
gem "rake-compiler"
gem "rake-compiler-dock"
gem "rubocop", "~> 1.62", require: false
gem "rubocop", "~> 1.63", require: false
gem "rubocop-minitest", require: false
gem "rubocop-rake", require: false
24 changes: 12 additions & 12 deletions bindings/ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ PATH
remote: .
specs:
regorusrb (0.1.0)
rb_sys (~> 0.9.91)
rb_sys (~> 0.9.97)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.7.2)
language_server-protocol (3.17.0.3)
minitest (5.22.3)
minitest (5.23.0)
parallel (1.24.0)
parser (3.3.0.5)
parser (3.3.1.0)
ast (~> 2.4.1)
racc
racc (1.7.3)
rainbow (3.1.1)
rake (13.2.1)
rake-compiler (1.2.7)
rake
rake-compiler-dock (1.4.0)
rb_sys (0.9.91)
regexp_parser (2.9.0)
rake-compiler-dock (1.5.0)
rb_sys (0.9.97)
regexp_parser (2.9.2)
rexml (3.2.8)
strscan (>= 3.0.9)
rubocop (1.63.0)
rubocop (1.63.5)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -36,8 +36,8 @@ GEM
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-minitest (0.35.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
Expand All @@ -52,12 +52,12 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
minitest (~> 5.16)
rake (~> 13.0)
minitest (~> 5.22)
rake (~> 13.2)
rake-compiler
rake-compiler-dock
regorusrb!
rubocop (~> 1.62)
rubocop (~> 1.63)
rubocop-minitest
rubocop-rake

Expand Down
4 changes: 2 additions & 2 deletions bindings/ruby/ext/regorusrb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ impl Engine {
}
}

fn add_policy(&self, path: String, rego: String) -> Result<(), Error> {
fn add_policy(&self, path: String, rego: String) -> Result<String, Error> {
self.engine
.borrow_mut()
.add_policy(path, rego)
.map_err(|e| Error::new(runtime_error(), format!("Failed to add policy: {}", e)))
}

fn add_policy_from_file(&self, path: String) -> Result<(), Error> {
fn add_policy_from_file(&self, path: String) -> Result<String, Error> {
self.engine
.borrow_mut()
.add_policy_from_file(path)
Expand Down
2 changes: 1 addition & 1 deletion bindings/ruby/regorusrb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.extensions = ["ext/regorusrb/extconf.rb"]
spec.add_dependency "rb_sys", "~> 0.9.91"
spec.add_dependency "rb_sys", "~> 0.9.97"
end
3 changes: 2 additions & 1 deletion bindings/ruby/test/test_regorus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def test_engine_creation
end

def test_policy_addition
assert_silent { @engine.add_policy("example.rego", example_policy) }
# returns the package name from the REGO, not the filename
assert_equal "data.regorus_test", @engine.add_policy("example.rego", example_policy)
end

def test_object_creation_with_new
Expand Down
Loading