Skip to content
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
14 changes: 11 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 3.0
Exclude:
- lib/prometheus/api_client/version.rb
NewCops: disable
SuggestExtensions: false

AlignHash:
Layout/HashAlignment:
EnforcedHashRocketStyle: table

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma

Style/TrailingCommaInLiteral:
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma

Metrics/AbcSize:
Expand All @@ -21,6 +29,6 @@ Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'

Metrics/LineLength:
Layout/LineLength:
Exclude:
- 'spec/**/*.rb'
98 changes: 98 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-02-20 17:39:35 UTC using RuboCop version 1.45.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'prometheus-api-client.gemspec'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'examples/get_metrics.rb'
- 'examples/low_level.rb'
- 'spec/prometheus/api_client/client_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'lib/prometheus/api_client/client.rb'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
Style/Encoding:
Exclude:
- 'Rakefile'
- 'lib/prometheus.rb'
- 'lib/prometheus/api_client.rb'
- 'lib/prometheus/api_client/client.rb'
- 'prometheus-api-client.gemspec'
- 'spec/prometheus/api_client/client_spec.rb'
- 'spec/prometheus/api_client_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/ExpandPathArguments:
Exclude:
- 'prometheus-api-client.gemspec'

# Offense count: 13
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'Gemfile'
- 'Rakefile'
- 'examples/authentication_proxy.rb'
- 'examples/get_labels.rb'
- 'examples/get_metrics.rb'
- 'examples/low_level.rb'
- 'lib/prometheus.rb'
- 'lib/prometheus/api_client.rb'
- 'lib/prometheus/api_client/client.rb'
- 'prometheus-api-client.gemspec'
- 'spec/prometheus/api_client/client_spec.rb'
- 'spec/prometheus/api_client_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'prometheus-api-client.gemspec'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantCondition:
Exclude:
- 'lib/prometheus/api_client/client.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/prometheus/api_client/client.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ before_install:
- |
if [[ "$(ruby -e 'puts RUBY_VERSION')" != 1.* ]]; then gem update --system; fi
rvm:
- 2.3.3
- 2.4.0
- 2.5.3
- 2.6.0
- jruby-9.1.9.0
- 3.0.5
- 3.1.3
- 3.2.1
- jruby-9.4.1.0
11 changes: 1 addition & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@ source 'https://rubygems.org'

gemspec

def ruby_version?(constraint)
Gem::Dependency.new('', constraint).match?('', RUBY_VERSION)
end

gem 'faraday'

group :test do
gem 'coveralls'
gem 'json', '< 2.0' if ruby_version?('< 2.0')
gem 'rack', '< 2.0' if ruby_version?('< 2.2.2')
gem 'rack-test'
gem 'rake'
gem 'rspec'
gem 'rubocop', '< 0.42'
gem 'term-ansicolor', '< 1.4' if ruby_version?('< 2.0')
gem 'tins', '< 1.7' if ruby_version?('< 2.0')
gem 'rubocop'
gem 'vcr'
gem 'webmock'
end
5 changes: 4 additions & 1 deletion lib/prometheus/api_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'json'
require 'faraday'
require 'faraday/net_http'

module Prometheus
# Client is a ruby implementation for a Prometheus compatible api_client.
Expand Down Expand Up @@ -38,7 +39,9 @@ def initialize(options = {})

@client = Faraday.new(
faraday_options(options),
)
) do |f|
f.adapter :net_http
end
end

# Evaluates an instant query at a single point in time:
Expand Down
23 changes: 12 additions & 11 deletions prometheus-api-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'prometheus/api_client/version'

Gem::Specification.new do |s|
s.name = 'prometheus-api-client'
s.version = Prometheus::ApiClient::VERSION
s.summary = 'A suite of reading metrics stored on ' \
'a Prometheus server.'
s.authors = ['Yaacov Zamir']
s.email = ['[email protected]']
s.homepage = 'https://github.com/yaacov/prometheus_api_client_ruby'
s.license = 'Apache-2.0'
s.name = 'prometheus-api-client'
s.version = Prometheus::ApiClient::VERSION
s.summary = 'A suite of reading metrics stored on ' \
'a Prometheus server.'
s.authors = ['Yaacov Zamir']
s.email = ['[email protected]']
s.homepage = 'https://github.com/yaacov/prometheus_api_client_ruby'
s.license = 'Apache-2.0'
s.required_ruby_version = '>= 3.0.0'

s.files = %w(README.md) + Dir.glob('{lib/**/*}')
s.require_paths = ['lib']
s.files = %w(README.md) + Dir.glob('{lib/**/*}')
s.require_paths = ['lib']

s.add_dependency 'faraday', '>= 0.9', '< 2.0.0'
s.add_dependency 'faraday', '>= 2.0.0', '< 3.0.0'
end