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

Add Ruby 3.3 support #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 0 additions & 17 deletions .github/dependabot.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
if: github.repository_owner == 'voxpupuli'
steps:
- uses: actions/checkout@v4
- name: Install Ruby 3.0
- name: Install Ruby 3.3
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
ruby-version: '3.3'
bundler: 'none'
env:
BUNDLE_WITHOUT: release:development:rubocop
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
ruby-version: '3.3'
bundler-cache: true
- name: Run rake rubocop
run: bundle exec rake rubocop
Expand All @@ -33,6 +33,7 @@ jobs:
- ruby: "3.1"
coverage: "yes"
- ruby: "3.2"
- ruby: "3.3"
env:
COVERAGE: ${{ matrix.coverage }}
name: Ruby ${{ matrix.ruby }}
Expand Down
7 changes: 5 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
---
inherit_from: .rubocop_todo.yml

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

inherit_from: .rubocop_todo.yml
inherit_gem:
voxpupuli-rubocop: rubocop.yml

Naming/FileName:
Exclude:
- "*.gemspec"
10 changes: 8 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# frozen_string_literal: true

source ENV['GEM_SOURCE'] || 'https://rubygems.org'

Check failure on line 1 in Gemfile

View workflow job for this annotation

GitHub Actions / rubocop

Style/FrozenStringLiteralComment: Missing frozen string literal comment.

gemspec

Expand All @@ -13,3 +11,11 @@
gem 'codecov', require: false
gem 'simplecov-console', require: false
end

group :development do
gem 'rake', '~> 13.0', '>= 13.0.6'
gem 'rspec', '~> 3.12'
gem 'rspec-collection_matchers', '~> 1.2'
gem 'rspec-its', '~> 1.3'
gem 'voxpupuli-rubocop', '~> 2.0'
end
2 changes: 0 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# frozen_string_literal: true

require 'rspec/core/rake_task'

Check failure on line 1 in Rakefile

View workflow job for this annotation

GitHub Actions / rubocop

Style/FrozenStringLiteralComment: Missing frozen string literal comment.

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

Expand Down
77 changes: 22 additions & 55 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,62 +1,29 @@
require 'puppet-lint'
require 'jgrep'

PuppetLint::Plugins.load_spec_helper

class PuppetDB::Client
def puppetdb_to_jgrep(query)
if query[0] == :and || query[0] == :or
"(#{puppetdb_to_jgrep(query[1])} #{query[0]} #{puppetdb_to_jgrep(query[2])})"
else
"#{[query[1]].flatten.join('.')}#{query[0]}#{query[2]}"
end
end

def process_pql_kv(q)
k, v = q.split(/\s*=\s*/)
".#{k}=#{v}"
end
# frozen_string_literal: true

def pql_to_jgrep(query)
endpoint_cols = query.split('{').first
endpoint = endpoint_cols.split(/[\s\[]/).first
query.sub!(/^#{Regexp.quote(endpoint_cols)}\{\s*/, '')
query.sub!(/(group\s+by\s+(type|title))/, '')
query.sub!(/\s*}\s*/, '')
query.sub!(/(and\s+)?nodes\s*\{\s*deactivated\s+is\s+null\s*\}/, '')
begin
require 'simplecov'
require 'simplecov-console'
require 'codecov'
rescue LoadError
else
SimpleCov.start do
track_files 'lib/**/*.rb'

return endpoint, '' if query == ''
add_filter '/spec'

query.gsub!('parameters.', 'parameter.')
query.sub!(/\s*=\s*/, '=')
enable_coverage :branch

jgrep_query_and_parts = []
query.split(/\s+and\s+/).each do |q|
newq = ''
if q.start_with?('(')
newq << '('
newq << q.split(/\s+or\s+/).map do |qq|
process_pql_kv(qq.sub(/^\(/, '').sub(/\)$/, ''))
end.join(' or ')
newq << ')'
else
newq << process_pql_kv(q)
end
jgrep_query_and_parts << newq
end
jgrep_query = jgrep_query_and_parts.join(' and ')
jgrep_query.rstrip!

[endpoint, jgrep_query]
# do not track vendored files
add_filter '/vendor'
add_filter '/.vendor'
end

def request(endpoint, query, _opts = {})
if endpoint == ''
endpoint, query = pql_to_jgrep(query)
else
query = puppetdb_to_jgrep(query)
end
ret = JGrep.jgrep(File.read("spec/fixtures/#{endpoint}.json"), query)
PuppetDB::Response.new(ret, ret.size)
end
SimpleCov.formatters = [
SimpleCov::Formatter::Console,
SimpleCov::Formatter::Codecov,
]
end

require 'puppet-lint'

PuppetLint::Plugins.load_spec_helper
Loading