hh 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +2 -0
- data/README.md +2 -0
- data/lib/hh.rb +2 -0
- data/lib/hh/API/specialization.rb +2 -0
- data/lib/hh/api.rb +2 -0
- data/lib/hh/client.rb +48 -11
- data/lib/hh/version.rb +1 -1
- data/spec/hh/client_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTc1ZmIzMGU0M2NiNzdkNzJiYzBkNWQ4NTI1MTFmNjBjM2IzODAxYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzgyOTBkMTJhY2QzODVkN2RiY2JlMzZhYzkzOTAwM2Q0NTE3YTE0OQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDE1ZThkNjYwZTg0Njg0MTE1YWZlOTE2MmQ2ZjVkMzQ2NWVhYmZjZDRiYjYy
|
10
|
+
Nzc3ZTg2NjZlMDA3OTczN2YxYmUwMGJhNDNkMGEyNTdjYWI0NzFjYzdlNWYw
|
11
|
+
MTgwMWRmYTU4ZTI3MGJmNGUyMzY4MTA2ZmViYzg1MDJkNDg4OGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODM1MDkzNWYwYjgzMTJkZWMwNGY4ZjZhZjFlMjE3ODlkMTM2Y2ZjMGE1M2Ix
|
14
|
+
NWMzYzliYzNiM2JiN2Y2MmZmMzY1OWU3NjdmMzMxNmI1MGIwYmIzNjE2OTA3
|
15
|
+
ZDcxNTM3NzE5YWEwNGU3ZTE3MDBkMjk2YTYzMmI3YjZiNWQ4NTg=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/hh.png)](http://badge.fury.io/rb/hh)
|
4
4
|
[![Build Status](https://travis-ci.org/ivaravko/hh.png?branch=master)](https://travis-ci.org/ivaravko/hh)
|
5
|
+
[![Dependency Status](https://gemnasium.com/ivaravko/hh.png)](https://gemnasium.com/ivaravko/hh)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/ivaravko/hh/badge.png?branch=master)](https://coveralls.io/r/ivaravko/hh)
|
5
7
|
|
6
8
|
A Ruby interface to the HeadHanter
|
7
9
|
|
data/lib/hh.rb
CHANGED
data/lib/hh/api.rb
CHANGED
data/lib/hh/client.rb
CHANGED
@@ -1,24 +1,61 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
|
1
3
|
module HH
|
2
4
|
class Client
|
3
5
|
include API
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
# @param options [Hash]
|
8
|
+
def default_middleware(options={})
|
9
|
+
Proc.new do |conn|
|
10
|
+
conn.request :multipart
|
11
|
+
conn.adapter :net_http
|
12
|
+
|
13
|
+
if ENV['DEBUG']
|
14
|
+
conn.response :logger
|
15
|
+
else
|
16
|
+
conn.response :json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
@stack = nil
|
22
|
+
|
23
|
+
# Exposes middleware builder to facilitate custom stacks
|
24
|
+
# @param options [Hash]
|
25
|
+
# @return [Faraday::Builder]
|
26
|
+
def stack(options={}, &block)
|
27
|
+
@stack ||= begin
|
28
|
+
if block_given?
|
29
|
+
Faraday::Builder.new(&block)
|
30
|
+
else
|
31
|
+
Faraday::Builder.new(&default_middleware(options))
|
32
|
+
end
|
33
|
+
end
|
9
34
|
end
|
10
35
|
|
11
|
-
|
12
|
-
|
36
|
+
# @param options [Hash]
|
37
|
+
# @return [Faraday::Connection]
|
38
|
+
def connection(options={})
|
39
|
+
conn_options = default_options(options)
|
40
|
+
puts "OPTIONS:#{conn_options.inspect}" if ENV['DEBUG']
|
41
|
+
|
42
|
+
@connection ||= Faraday.new(conn_options.merge(builder: stack(options)))
|
13
43
|
end
|
14
44
|
|
15
45
|
private
|
16
46
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
47
|
+
# @param options [Hash]
|
48
|
+
# @return [Hash]
|
49
|
+
def default_options(options={})
|
50
|
+
{
|
51
|
+
headers: {
|
52
|
+
accept: "application/json;q=0.1",
|
53
|
+
accept_charset: "utf-8",
|
54
|
+
user_agent: "Ruby gem HH version #{HH::VERSION}",
|
55
|
+
content_type: "application/json"
|
56
|
+
},
|
57
|
+
url: API_URL
|
58
|
+
}.merge(options)
|
22
59
|
end
|
23
60
|
end
|
24
61
|
end
|
data/lib/hh/version.rb
CHANGED
data/spec/hh/client_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe HH::Client do
|
4
|
-
let(:connection) {
|
4
|
+
let(:connection) { described_class.new.connection }
|
5
5
|
|
6
|
-
describe "
|
7
|
-
it "connection use
|
8
|
-
expect(connection.inspect).to include('
|
6
|
+
describe "default middleware" do
|
7
|
+
it "connection use Faraday::Request::Multipart" do
|
8
|
+
expect(connection.inspect).to include('Faraday::Request::Multipart')
|
9
9
|
end
|
10
10
|
it "response parse by ParseJson" do
|
11
11
|
expect(connection.inspect).to include('FaradayMiddleware::ParseJson')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Varavko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|