faraday_json 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 797f339a60927cd80ecb7e6b6a61d992402e21cc
4
- data.tar.gz: 181e9fbcff6c9a45754dd287bb54d71d09b695fb
3
+ metadata.gz: c77a32170d967ebaa3950cda3adda8697a1408e1
4
+ data.tar.gz: 229a0bd27bc9a29873ecc20e80e24d67835cdaa2
5
5
  SHA512:
6
- metadata.gz: dd2b02b134d0cc13fcca62b60669c62a5d9e5596337b1c06f0dc31d2a73ef7e9603e3a886467aa4995bfa336ff20b0f150b5bfe9c61fe28c7e56a17da6bd2118
7
- data.tar.gz: 1d42a2368bc4d7525a000e32ffffda78a88332aadc771d1406d8cd4c61fc68a1ac0964a1e1c8782c119ff44e22215fdb11d569c7b59d54a9f8371ea4033316f5
6
+ metadata.gz: 8a1d60bda56f2465d32d22a8be678b691b11e8401f7d7deb791da725efb5fa1938667eaf2bd5348ee28c3abc9b1ddd4d66689dcdb44e577484189f464fd35566
7
+ data.tar.gz: 22b9691239581d61629c4a263960f4f24370d9ad2fadc4b059b17a7812a8a47429ca1fe9ef67c8fac7bd61eb2218158533d1d6730171b0b7c49fe9c74ee2a059
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Introduction
2
2
  This is a character encoding-aware JSON middleware for Faraday.
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/faraday_json.svg)](http://badge.fury.io/rb/faraday_json)
4
5
  [![Build Status](https://travis-ci.org/spriteCloud/faraday_json.svg)](https://travis-ci.org/spriteCloud/faraday_json)
5
6
 
6
7
  The default JSON middleware from lostisland/faraday_middleware is not character
@@ -28,3 +29,38 @@ This middleware fixes these issues rather brute-force by:
28
29
  When no charset is provided, all bets are off. The correct default would be to
29
30
  assume US-ASCII, but that may break some code. This middleware lets you override
30
31
  this default.
32
+
33
+ ## Installation
34
+
35
+ Add this line to your application's Gemfile:
36
+
37
+ gem 'faraday_json'
38
+
39
+ And then execute:
40
+
41
+ $ bundle
42
+
43
+ Or install it yourself as:
44
+
45
+ $ gem install faraday_json
46
+
47
+ ## Usage
48
+
49
+ ```ruby
50
+ require 'faraday'
51
+ require 'faraday_middleware' # optional
52
+ require 'faraday_json' # replaces JSON handling from previous require
53
+
54
+ client = Faraday.new('http://some_url') do |conn|
55
+ conn.request :json
56
+ conn.response :json
57
+
58
+ conn.adapter Faraday.default_adapter
59
+ end
60
+
61
+ client.post '/', :a => "röck döts"
62
+ ```
63
+
64
+ 1. `faraday_middleware` is not required for JSON handling.
65
+ 1. Require `faraday_json` *after* `faraday_middleware` to override the behaviour
66
+ from `faraday_middleware`.
@@ -60,7 +60,7 @@ module FaradayJSON
60
60
 
61
61
  # We'll add a content length, because otherwise we're relying on every
62
62
  # component down the line properly interpreting UTF-8 - that can fail.
63
- env[:request_headers][CONTENT_LENGTH] ||= env[:body].bytesize
63
+ env[:request_headers][CONTENT_LENGTH] ||= env[:body].bytesize.to_s
64
64
 
65
65
  # Always base the encoding we're sending in the content type header on
66
66
  # the string encoding.
@@ -6,5 +6,5 @@
6
6
  # All rights reserved.
7
7
  #
8
8
  module FaradayJSON
9
- VERSION = "0.1.0"
9
+ VERSION = "0.1.1"
10
10
  end
data/lib/faraday_json.rb CHANGED
@@ -9,6 +9,7 @@
9
9
  require 'faraday'
10
10
 
11
11
  module FaradayJSON
12
+ autoload :EncodeJson, 'faraday_json/encode_json'
12
13
  autoload :ParseJson, 'faraday_json/parse_json'
13
14
 
14
15
  if Faraday::Middleware.respond_to? :register_middleware
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Finkhaeuser