Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Move httpclient dependency into another gem #21

Open
wants to merge 2 commits into
base: main
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pkg
.bundle
Gemfile.lock
bin/
.idea
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'https://rubygems.org'
gemspec
gemspec name: 'sekken'
gemspec name: 'sekken-httpclient'

# profiling
#gem 'method_profiler', require: false
Expand Down
9 changes: 7 additions & 2 deletions lib/sekken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require 'sekken/errors'
require 'sekken/wsdl'
require 'sekken/operation'
require 'sekken/httpclient'

class Sekken

Expand All @@ -17,7 +16,13 @@ class Sekken

# Public: Returns the HTTP adapter to use.
def self.http_adapter
@http_adapter ||= HTTPClient
@http_adapter ||= begin
require 'sekken/http_adapter/httpclient'
HTTPClient
rescue LoadError
warn 'No http adapter set (see Sekken.http_adapter=) and default adapter (install gem sekken-httpclient) not found.'
raise
end
end

# Public: Sets the HTTP adapter to use.
Expand Down
29 changes: 29 additions & 0 deletions lib/sekken/abstract_http_adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Sekken
class AbstractHttpAdapter
# @api 1.0
# @abstract

# Public: Executes an HTTP GET request to a given url.
#
# Returns the raw HTTP response body as a String.
#
# @param [String, URI] url
# @param [Hash<String, String>] headers
# @return [String] the raw body of the response
def get(url, headers = {})
fail NotImplementedError
end

# Public: Executes an HTTP POST request to a given url with headers and body.
#
# Returns the raw HTTP response body as a String.
#
# @param [String, URI] url
# @param [Hash<String, String>] headers
# @param [String] body
# @return [String] the raw body of the response
def post(url, headers, body)
fail NotImplementedError
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'sekken/abstract_http_adapter'
require 'httpclient'

class Sekken
class HTTPClient

class HTTPClient < AbstractHttpAdapter
def initialize
@client = ::HTTPClient.new
end
Expand Down
26 changes: 26 additions & 0 deletions sekken-httpclient.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- encoding : utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$:.unshift lib unless $:.include? lib

require 'sekken/version'

Gem::Specification.new do |s|
s.name = 'sekken-httpclient'
s.version = Sekken::VERSION
s.authors = ['Daniel Harrington', 'Tim Jarratt']
s.email = '[email protected]'
s.homepage = 'http://savonrb.com'
s.summary = 'HTTPClient adapter for Sekken'
s.description = 'Sekken is an experimental SOAP client for the Ruby community. This is the standard HTTP adapter.'
s.required_ruby_version = '>= 1.9.3'

s.rubyforge_project = s.name
s.license = 'MIT'

s.add_dependency 'httpclient', '~> 2.3'
s.add_dependency 'sekken', "~> #{Sekken::VERSION}"

s.files = Dir['lib/sekken/http_adapter/httpclient*']

s.require_path = 'lib'
end
7 changes: 4 additions & 3 deletions sekken.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ Gem::Specification.new do |s|

ignores = File.readlines('.gitignore').grep(/\S+/).map(&:chomp)
dotfiles = %w[.gitignore .travis.yml .yardopts]
http_adapters = Dir['lib/sekken/http_adapter/*']

all_files_without_ignores = Dir['**/*'].reject { |f|
File.directory?(f) || ignores.any? { |i| File.fnmatch(i, f) }
unexcluded_files = Dir['**/*'].reject { |f|
File.directory?(f) || ignores.any? { |i| File.fnmatch(i, f) } || http_adapters.any? { |i| File.fnmatch(i, f) }
}

s.files = (all_files_without_ignores + dotfiles).sort
s.files = (unexcluded_files + dotfiles).sort

s.require_path = 'lib'
end
1 change: 1 addition & 0 deletions spec/sekken/httpclient_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'sekken/http_adapter/httpclient'

describe Sekken::HTTPClient do

Expand Down