windy 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/windy.rb +15 -3
- metadata +42 -9
data/lib/windy.rb
CHANGED
@@ -1,13 +1,24 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday_middleware'
|
2
2
|
require 'multi_json'
|
3
3
|
|
4
4
|
module Windy
|
5
|
-
VERSION = '0.1.
|
5
|
+
VERSION = '0.1.2'
|
6
6
|
|
7
7
|
class << self
|
8
8
|
attr_accessor :app_token, :debug
|
9
9
|
end
|
10
10
|
|
11
|
+
module Response
|
12
|
+
class RaiseClientError < Faraday::Response::Middleware
|
13
|
+
def on_complete(env)
|
14
|
+
case env[:status].to_i
|
15
|
+
when 403
|
16
|
+
raise env[:response_headers][:x_error_message]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
11
22
|
class SocrataAppTokenMiddleware < Faraday::Middleware
|
12
23
|
def call(env)
|
13
24
|
raise "You must specify an app token" if !Windy.app_token
|
@@ -26,6 +37,7 @@ module Windy
|
|
26
37
|
def initialize
|
27
38
|
@connection = Faraday.new(:url => self.class.root) do |builder|
|
28
39
|
builder.use SocrataAppTokenMiddleware
|
40
|
+
builder.use Windy::Response::RaiseClientError
|
29
41
|
builder.request :json
|
30
42
|
|
31
43
|
# Enable logger output with Windy.debug = true
|
@@ -50,7 +62,7 @@ module Windy
|
|
50
62
|
def json
|
51
63
|
# For some reason ruby 1.9.x seems to be trying to parse the
|
52
64
|
# API JSON output as ASCII instead of UTF-8
|
53
|
-
body.force_encoding("UTF-8") unless body.nil?
|
65
|
+
body.force_encoding("UTF-8") unless body.nil? || !body.respond_to?(:force_encoding)
|
54
66
|
@json ||= MultiJson.decode(body)
|
55
67
|
end
|
56
68
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,22 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
-
requirement: &
|
16
|
+
name: faraday_middleware
|
17
|
+
requirement: &70299043698520 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '0.
|
22
|
+
version: '0.8'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70299043698520
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: multi_json
|
28
|
-
requirement: &
|
28
|
+
requirement: &70299043697700 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,7 +33,40 @@ dependencies:
|
|
33
33
|
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70299043697700
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
requirement: &70299043695820 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '2.6'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *70299043695820
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: simplecov
|
50
|
+
requirement: &70299043694820 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.4'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *70299043694820
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: webmock
|
61
|
+
requirement: &70299043694020 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.7'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *70299043694020
|
37
70
|
description: Windy is a Ruby module that allows you to easily interact with the City
|
38
71
|
of Chicago's Data Portal.
|
39
72
|
email:
|
@@ -65,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
98
|
version: '0'
|
66
99
|
requirements: []
|
67
100
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.8.
|
101
|
+
rubygems_version: 1.8.11
|
69
102
|
signing_key:
|
70
103
|
specification_version: 3
|
71
104
|
summary: Ruby interface to the City of Chicago's Data Portal API
|