Skip to content

Commit

Permalink
Make up
Browse files Browse the repository at this point in the history
  • Loading branch information
dsalahutdinov committed Mar 17, 2020
1 parent e82f64b commit e518170
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 37 deletions.
16 changes: 11 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

gem "rake", "~> 12.0"
gem "rspec", "~> 3.0"
gem 'sniffer', git: 'https://github.com/dsalahutdinov/sniffer', branch: 'feature/middleware'
gem 'rake', '~> 12.0'
gem 'rspec', '~> 3.0'
gem 'rubocop'

gem 'byebug'
gem 'faraday'
gem 'faraday', require: false
gem 'sniffer',
git: 'https://github.com/dsalahutdinov/sniffer',
branch: 'feature/middleware'
11 changes: 8 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

RuboCop::RakeTask.new

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

task :default => :spec
task default: %i[rubocop spec]
7 changes: 4 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "yabeda/http"
require 'bundler/setup'
require 'yabeda/http'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand All @@ -10,5 +11,5 @@ require "yabeda/http"
# require "pry"
# Pry.start

require "irb"
require 'irb'
IRB.start(__FILE__)
10 changes: 7 additions & 3 deletions lib/yabeda/http.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
require "yabeda/http/version"
# frozen_string_literal: true

require 'yabeda/http/version'
require 'yabeda/http/sniffer'
require "yabeda"
require 'yabeda'
require 'sniffer'

require 'byebug'
module Yabeda
# Common module
module Http
Yabeda.configure do
group :http

counter :requests_total,
comment: "A counter of the total number of external HTTP requests.",
comment: 'A counter of the total number of external HTTP \
requests.',
tags: %i[host]

::Sniffer.config do |c|
Expand Down
3 changes: 3 additions & 0 deletions lib/yabeda/http/sniffer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

module Yabeda
module Http
# Middleware for sniffer gem
class Sniffer
def call(data_item)
Yabeda.http_requests_total.increment(
Expand Down
4 changes: 3 additions & 1 deletion lib/yabeda/http/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module Yabeda
module Http
VERSION = "0.1.0"
VERSION = '0.1.0'
end
end
9 changes: 6 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
require "bundler/setup"
require "yabeda/http"
# frozen_string_literal: true

require 'bundler/setup'
require 'yabeda/http'
require 'faraday'

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
config.example_status_persistence_file_path = '.rspec_status'

# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
Expand Down
24 changes: 21 additions & 3 deletions spec/yabeda/http_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
# frozen_string_literal: true

RSpec.describe Yabeda::Http do
it "has a version number" do
it 'has a version number' do
expect(Yabeda::Http::VERSION).not_to be nil
end

it "does something useful" do
expect(false).to eq(true)
context 'sdf' do
before do
Yabeda.configure!
Faraday.get 'http://sushi.com/nigiri/sake.json'
end

it do
expect(Yabeda.http_requests_total.values).to(
eq(
{
host: 'sushi.com',
method: 'GET',
port: 80,
query: '/nigiri/sake.json'
} => 1
)
)
end
end
end
36 changes: 20 additions & 16 deletions yabeda-http.gemspec
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# frozen_string_literal: true

require_relative 'lib/yabeda/http/version'

Gem::Specification.new do |spec|
spec.name = "yabeda-http"
spec.name = 'yabeda-http'
spec.version = Yabeda::Http::VERSION
spec.authors = ["Dmitry Salahutdinov"]
spec.email = ["[email protected]"]
spec.authors = ['Dmitry Salahutdinov']
spec.email = ['[email protected]']

spec.summary = %q{Monitoring of external services http/https calls}
spec.description = %q{Extends Yabeda metrics to collect external calls}
spec.homepage = "https://github.com/yabeda-rb/yabeda-http"
spec.license = "MIT"
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.summary = 'Monitoring of external services http/https calls'
spec.description = 'Extends Yabeda metrics to collect external calls'
spec.homepage = 'https://github.com/yabeda-rb/yabeda-http'
spec.license = 'MIT'
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/yabeda-rb/yabeda-http"
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/yabeda-rb/yabeda-http'

spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
end
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_runtime_dependency "yabeda"
spec.add_runtime_dependency "sniffer"
spec.add_runtime_dependency 'sniffer'
spec.add_runtime_dependency 'yabeda'
end

0 comments on commit e518170

Please sign in to comment.