kitman-faraday-middleware 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd3cc0372402efc8ff80b38781f433dc560d9372
4
+ data.tar.gz: b770072fafcd185b3b500f63cb6b66d3c80a5963
5
+ SHA512:
6
+ metadata.gz: eeee8585b6c7b327e13e264e3f2d236828a34529bd3975bbb8711a00fa0d5a2741f760a85350f27352290455f9fccb6001182150125e9076315bbd0cfb3ee8b0
7
+ data.tar.gz: b3a47f4fa1642a774c5fc73d6863c0bb83efa56ff9a41f0154f01d086219dcf2c13e33c27319673188b0a1f20d1bf0b58438e4a29147cf2fd9e16d4ee1c57b76
data/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_size = 2
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup markdown
2
+ lib/**/*.rb
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'activesupport', '~> 4.1'
4
+ gem 'bundler', '~> 1.6'
5
+ gem 'faraday', '~> 0.9'
6
+
7
+ group :development do
8
+ gem 'factory_girl', '~> 4.4'
9
+ gem 'jeweler', '~> 2.0'
10
+ gem 'pry', '~> 0.10', require: 'pry'
11
+ gem 'pry-byebug', '~> 1.3'
12
+ gem 'pry-stack_explorer', '~> 0.4'
13
+ gem 'pry-theme', '~> 1.1'
14
+ gem 'rspec', '~> 3.0'
15
+ gem 'shoulda-matchers', '~> 2.6', require: false
16
+ gem 'simplecov', '~> 0.9'
17
+ gem 'yard', '~> 0.8'
18
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Kitman Labs Ltd.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,9 @@
1
+ # Kitman::FaradayMiddleware
2
+
3
+ A collection of middleware for use with Faraday.
4
+
5
+ gem install kitman-faraday-middleware
6
+
7
+ ## Kitman::FaradayMiddleware::Response::WithIndifferentAccess
8
+
9
+ Converts Hashes (and arrays of Hashes) in responses into ActiveSupport HashWithIndifferentAccess.
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'jeweler'
4
+ require 'rake'
5
+ require 'rspec/core'
6
+ require 'rspec/core/rake_task'
7
+ require 'yard'
8
+
9
+ begin
10
+ Bundler.setup(:default, :development)
11
+ rescue Bundler::BundlerError => e
12
+ $stderr.puts e.message
13
+ $stderr.puts 'Run `bundle install` to install missing gems'
14
+ exit e.status_code
15
+ end
16
+
17
+ Jeweler::Tasks.new do |gem|
18
+ gem.authors = ['Alan Larkin']
19
+ gem.description = %Q{A collection of middleware for use with Faraday.}
20
+ gem.email = 'alan.larkin@gmail.com'
21
+ gem.executables = []
22
+ gem.homepage = 'https://github.com/KitmanLabs/kitman-faraday-middleware'
23
+ gem.license = 'MIT'
24
+ gem.name = 'kitman-faraday-middleware'
25
+ gem.summary = %Q{Kitman Faraday Middleware}
26
+ end
27
+
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ desc 'Code coverage detail'
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = 'true'
37
+ Rake::Task['spec'].execute
38
+ end
39
+
40
+ YARD::Rake::YardocTask.new do |yard|
41
+ yard.files = FileList['lib/**/*.rb']
42
+ end
43
+
44
+ task default: :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/bundler ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'bundler' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('bundler', 'bundler')
data/bin/byebug ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'byebug' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('byebug', 'byebug')
data/bin/coderay ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'coderay' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('coderay', 'coderay')
data/bin/htmldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/jeweler ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'jeweler' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('jeweler', 'jeweler')
data/bin/ldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'ldiff')
data/bin/nokogiri ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'nokogiri' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('nokogiri', 'nokogiri')
data/bin/pry ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'pry' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('pry', 'pry')
data/bin/rackup ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rackup' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rack', 'rackup')
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
data/bin/rdoc ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rdoc' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rdoc', 'rdoc')
data/bin/ri ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ri' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rdoc', 'ri')
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
data/bin/yard ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'yard' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('yard', 'yard')
data/bin/yardoc ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'yardoc' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('yard', 'yardoc')
data/bin/yri ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'yri' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('yard', 'yri')
@@ -0,0 +1,106 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: kitman-faraday-middleware 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "kitman-faraday-middleware"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Alan Larkin"]
14
+ s.date = "2014-10-14"
15
+ s.description = "A collection of middleware for use with Faraday."
16
+ s.email = "alan.larkin@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.markdown"
20
+ ]
21
+ s.files = [
22
+ ".editorconfig",
23
+ ".yardopts",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.markdown",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/bundler",
30
+ "bin/byebug",
31
+ "bin/coderay",
32
+ "bin/htmldiff",
33
+ "bin/jeweler",
34
+ "bin/ldiff",
35
+ "bin/nokogiri",
36
+ "bin/pry",
37
+ "bin/rackup",
38
+ "bin/rake",
39
+ "bin/rdoc",
40
+ "bin/ri",
41
+ "bin/rspec",
42
+ "bin/yard",
43
+ "bin/yardoc",
44
+ "bin/yri",
45
+ "kitman-faraday-middleware.gemspec",
46
+ "lib/kitman-faraday-middleware.rb",
47
+ "lib/kitman-faraday-middleware/response/with_indifferent_access.rb",
48
+ "spec/kitman-faraday-middleware/response/with_indifferent_access_spec.rb",
49
+ "spec/spec_helper.rb",
50
+ "spec/support/env_compatability.rb",
51
+ "spec/support/response_middleware_example_group.rb"
52
+ ]
53
+ s.homepage = "https://github.com/KitmanLabs/kitman-faraday-middleware"
54
+ s.licenses = ["MIT"]
55
+ s.rubygems_version = "2.2.2"
56
+ s.summary = "Kitman Faraday Middleware"
57
+
58
+ if s.respond_to? :specification_version then
59
+ s.specification_version = 4
60
+
61
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
62
+ s.add_runtime_dependency(%q<activesupport>, ["~> 4.1"])
63
+ s.add_runtime_dependency(%q<bundler>, ["~> 1.6"])
64
+ s.add_runtime_dependency(%q<faraday>, ["~> 0.9"])
65
+ s.add_development_dependency(%q<factory_girl>, ["~> 4.4"])
66
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
67
+ s.add_development_dependency(%q<pry>, ["~> 0.10"])
68
+ s.add_development_dependency(%q<pry-byebug>, ["~> 1.3"])
69
+ s.add_development_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
70
+ s.add_development_dependency(%q<pry-theme>, ["~> 1.1"])
71
+ s.add_development_dependency(%q<rspec>, ["~> 3.0"])
72
+ s.add_development_dependency(%q<shoulda-matchers>, ["~> 2.6"])
73
+ s.add_development_dependency(%q<simplecov>, ["~> 0.9"])
74
+ s.add_development_dependency(%q<yard>, ["~> 0.8"])
75
+ else
76
+ s.add_dependency(%q<activesupport>, ["~> 4.1"])
77
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
78
+ s.add_dependency(%q<faraday>, ["~> 0.9"])
79
+ s.add_dependency(%q<factory_girl>, ["~> 4.4"])
80
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
81
+ s.add_dependency(%q<pry>, ["~> 0.10"])
82
+ s.add_dependency(%q<pry-byebug>, ["~> 1.3"])
83
+ s.add_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
84
+ s.add_dependency(%q<pry-theme>, ["~> 1.1"])
85
+ s.add_dependency(%q<rspec>, ["~> 3.0"])
86
+ s.add_dependency(%q<shoulda-matchers>, ["~> 2.6"])
87
+ s.add_dependency(%q<simplecov>, ["~> 0.9"])
88
+ s.add_dependency(%q<yard>, ["~> 0.8"])
89
+ end
90
+ else
91
+ s.add_dependency(%q<activesupport>, ["~> 4.1"])
92
+ s.add_dependency(%q<bundler>, ["~> 1.6"])
93
+ s.add_dependency(%q<faraday>, ["~> 0.9"])
94
+ s.add_dependency(%q<factory_girl>, ["~> 4.4"])
95
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
96
+ s.add_dependency(%q<pry>, ["~> 0.10"])
97
+ s.add_dependency(%q<pry-byebug>, ["~> 1.3"])
98
+ s.add_dependency(%q<pry-stack_explorer>, ["~> 0.4"])
99
+ s.add_dependency(%q<pry-theme>, ["~> 1.1"])
100
+ s.add_dependency(%q<rspec>, ["~> 3.0"])
101
+ s.add_dependency(%q<shoulda-matchers>, ["~> 2.6"])
102
+ s.add_dependency(%q<simplecov>, ["~> 0.9"])
103
+ s.add_dependency(%q<yard>, ["~> 0.8"])
104
+ end
105
+ end
106
+
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler.setup :default, ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
3
+
4
+ require 'kitman-faraday-middleware/response/with_indifferent_access'
5
+
6
+ Faraday::Response.register_middleware with_indifferent_access: -> {
7
+ Kitman::FaradayMiddleware::Response::WithIndifferentAccess
8
+ }
@@ -0,0 +1,25 @@
1
+ require 'active_support/core_ext/hash/indifferent_access'
2
+ require 'faraday'
3
+
4
+ module Kitman
5
+ module FaradayMiddleware
6
+ module Response
7
+ class WithIndifferentAccess < ::Faraday::Response::Middleware
8
+ def initialize(app, options = {})
9
+ super(app)
10
+ end
11
+
12
+ def call(env)
13
+ @app.call(env).on_complete do |response|
14
+ json = response[:body]
15
+ if json.is_a?(Hash)
16
+ response[:body] = json.with_indifferent_access
17
+ elsif json.is_a?(Array) && json.first.is_a?(Hash)
18
+ response[:body] = json.map(&:with_indifferent_access)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ describe Kitman::FaradayMiddleware::Response::WithIndifferentAccess, type: :response do
2
+ context 'when the response is an object' do
3
+ let(:response) { { "a" => 1 } }
4
+
5
+ it 'should return a Hash with indifferent access' do
6
+ body = process(response).body
7
+ expect(body[:a]).to eq(body['a'])
8
+ end
9
+ end
10
+
11
+ context 'when the response is an array of objects' do
12
+ let(:response) { [{ "a" => 1 }, { "a" => 2 }] }
13
+
14
+ it 'should return a Hash with indifferent access' do
15
+ body = process(response).body
16
+ symbols = body.map { |hsh| hsh[:a] }
17
+ strings = body.map { |hsh| hsh['a'] }
18
+ expect(symbols).to eq(strings)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'bundler'
5
+ Bundler.require :default, :development
6
+ require 'kitman-faraday-middleware'
7
+ require 'shoulda/matchers'
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each &method(:require)
9
+
10
+ RSpec.configure do |config|
11
+ config.default_formatter = 'doc' if config.files_to_run.one?
12
+ config.expect_with :rspec do |expectations|
13
+ expectations.syntax = :expect
14
+ end
15
+ config.filter_run :focus
16
+ config.include EnvCompatibility
17
+ config.include ResponseMiddlewareExampleGroup, type: :response
18
+ config.mock_with :rspec do |mocks|
19
+ mocks.syntax = :expect
20
+ mocks.verify_partial_doubles = true
21
+ end
22
+ config.order = :random
23
+ config.profile_examples = 10
24
+ config.run_all_when_everything_filtered = true
25
+ Kernel.srand config.seed
26
+ end
27
+
28
+ module SimpleCov::Configuration
29
+ def clean_filters
30
+ @filters = []
31
+ end
32
+ end
33
+
34
+ SimpleCov.configure do
35
+ clean_filters
36
+ load_profile 'test_frameworks'
37
+ end
38
+
39
+ ENV['COVERAGE'] && SimpleCov.start do
40
+ add_filter '/spec/'
41
+ end
@@ -0,0 +1,11 @@
1
+ require 'faraday'
2
+
3
+ module EnvCompatibility
4
+ def faraday_env(env)
5
+ if defined?(Faraday::Env)
6
+ Faraday::Env.from(env)
7
+ else
8
+ env
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ require 'faraday'
2
+
3
+ module ResponseMiddlewareExampleGroup
4
+ def self.included(base)
5
+ base.let(:headers) { Hash.new }
6
+ base.let(:middleware) {
7
+ described_class.new -> (env) { Faraday::Response.new(env) }, options
8
+ }
9
+ base.let(:options) { Hash.new }
10
+ end
11
+
12
+ def process(body, content_type = nil, options = {})
13
+ env = {
14
+ body: body,
15
+ request: options,
16
+ request_headers: Faraday::Utils::Headers.new,
17
+ response_headers: Faraday::Utils::Headers.new(headers)
18
+ }
19
+ env[:response_headers]['content-type'] = content_type if content_type
20
+ yield(env) if block_given?
21
+ middleware.call(faraday_env(env))
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,257 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kitman-faraday-middleware
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alan Larkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: factory_girl
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.3'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-stack_explorer
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.4'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.4'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-theme
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: shoulda-matchers
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '2.6'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '2.6'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.9'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.9'
181
+ - !ruby/object:Gem::Dependency
182
+ name: yard
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.8'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.8'
195
+ description: A collection of middleware for use with Faraday.
196
+ email: alan.larkin@gmail.com
197
+ executables: []
198
+ extensions: []
199
+ extra_rdoc_files:
200
+ - LICENSE.txt
201
+ - README.markdown
202
+ files:
203
+ - ".editorconfig"
204
+ - ".yardopts"
205
+ - Gemfile
206
+ - LICENSE.txt
207
+ - README.markdown
208
+ - Rakefile
209
+ - VERSION
210
+ - bin/bundler
211
+ - bin/byebug
212
+ - bin/coderay
213
+ - bin/htmldiff
214
+ - bin/jeweler
215
+ - bin/ldiff
216
+ - bin/nokogiri
217
+ - bin/pry
218
+ - bin/rackup
219
+ - bin/rake
220
+ - bin/rdoc
221
+ - bin/ri
222
+ - bin/rspec
223
+ - bin/yard
224
+ - bin/yardoc
225
+ - bin/yri
226
+ - kitman-faraday-middleware.gemspec
227
+ - lib/kitman-faraday-middleware.rb
228
+ - lib/kitman-faraday-middleware/response/with_indifferent_access.rb
229
+ - spec/kitman-faraday-middleware/response/with_indifferent_access_spec.rb
230
+ - spec/spec_helper.rb
231
+ - spec/support/env_compatability.rb
232
+ - spec/support/response_middleware_example_group.rb
233
+ homepage: https://github.com/KitmanLabs/kitman-faraday-middleware
234
+ licenses:
235
+ - MIT
236
+ metadata: {}
237
+ post_install_message:
238
+ rdoc_options: []
239
+ require_paths:
240
+ - lib
241
+ required_ruby_version: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - ">="
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ required_rubygems_version: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
251
+ requirements: []
252
+ rubyforge_project:
253
+ rubygems_version: 2.2.2
254
+ signing_key:
255
+ specification_version: 4
256
+ summary: Kitman Faraday Middleware
257
+ test_files: []