faraday_collection_json 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,18 @@
1
+ # Faraday Collection JSON
2
+
3
+ This Faraday middleware parses collection+json responses using the
4
+ collection-json gem.
5
+
6
+ ```ruby
7
+ service = Faraday.new do |builder|
8
+ builder.response :collection_json, :content_type => /collection\+json$/
9
+ builder.adapter :net_http
10
+ end
11
+
12
+ collection = service.get('http://www.service.org/').body
13
+ collection.href # => 'http://www.service.org/'
14
+ collection.links.first.tap do |link|
15
+ link.rel # => 'feed'
16
+ link.href # => 'http://www.service.org/feed.rss'
17
+ end
18
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "faraday_collection_json/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "faraday_collection_json"
7
+ s.version = FaradayCollectionJSON::VERSION
8
+ s.authors = ["Sebastian Edwards"]
9
+ s.email = ["sebastian@uprise.co.nz"]
10
+ s.homepage = ""
11
+ s.summary = %q{Collection+JSON parsing middleware for faraday.}
12
+ s.description = s.summary
13
+
14
+ s.rubyforge_project = "faraday_collection_json"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency "faraday_middleware"
20
+ s.add_dependency "collection-json"
21
+ end
@@ -0,0 +1,9 @@
1
+ require "faraday_collection_json/version"
2
+ require "faraday_collection_json/parse_collection_json"
3
+
4
+ module FaradayCollectionJSON
5
+ if Faraday.respond_to? :register_middleware
6
+ Faraday.register_middleware :response,
7
+ :collection_json => lambda { ParseCollectionJSON }
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'faraday_middleware/response_middleware'
2
+
3
+ module FaradayCollectionJSON
4
+ class ParseCollectionJSON < FaradayMiddleware::ResponseMiddleware
5
+ dependency 'collection-json'
6
+
7
+ define_parser { |body|
8
+ ::CollectionJSON.parse(body)
9
+ }
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module FaradayCollectionJSON
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: faraday_collection_json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sebastian Edwards
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday_middleware
16
+ requirement: &70207708646220 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70207708646220
25
+ - !ruby/object:Gem::Dependency
26
+ name: collection-json
27
+ requirement: &70207708645580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70207708645580
36
+ description: Collection+JSON parsing middleware for faraday.
37
+ email:
38
+ - sebastian@uprise.co.nz
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - README.md
46
+ - Rakefile
47
+ - faraday_collection_json.gemspec
48
+ - lib/faraday_collection_json.rb
49
+ - lib/faraday_collection_json/parse_collection_json.rb
50
+ - lib/faraday_collection_json/version.rb
51
+ homepage: ''
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project: faraday_collection_json
71
+ rubygems_version: 1.8.15
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Collection+JSON parsing middleware for faraday.
75
+ test_files: []