npolar-api-client-ruby 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/npolar/api/client/json_api_client.rb +16 -8
- data/lib/npolar/api/client.rb +2 -1
- data/npolar-api-client-ruby.gemspec +11 -3
- metadata +50 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmViMjQ5ZTdhNWU0YmVhNGY5MTc5YTYyZjUxNjk3M2Y3MGI2NDZlYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWY0YTE2MzcxN2NhY2I4OTAzYTE4MjY4NGE4NDI4YTgzZjUxNTA0Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmRiZDE4ZGFlYmJhY2VmYjE4OWQwMjlmMjQzZDM5OTg1YWU2MThjYWQxNmQ3
|
10
|
+
MzcyZjNhY2U2YmU4NWNhYjVmNzhlYjlhNjlhMGQ5ZWVlNmIzY2RjOGM2M2Q1
|
11
|
+
ZGY4MjE1OTk3YTUxYmRhMDA2ODIwZWNjODQ0ZGE5ZDEyYjY2OTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDlmYzNlNDg4OWE4YWNiYjA5NGJlMmM1MTBkZWFiNGZiNjcxZTQ1ZGFiZGUy
|
14
|
+
NjBjMDU3NTE2OWQxMGE2ZTBkZjg3OTQ3ZGJiNDY1YjI5OTM1YjlmNjU3ODlh
|
15
|
+
NTFjNTJiMDc4NDA1ZDZlYzQxZTI0Yzc4YmE0YTA0ZmIwMjhlNTc=
|
@@ -36,7 +36,7 @@ module Npolar::Api::Client
|
|
36
36
|
class << self
|
37
37
|
attr_accessor :key
|
38
38
|
end
|
39
|
-
attr_accessor :model, :log, :authorization, :concurrency, :slice, :param, :
|
39
|
+
attr_accessor :model, :log, :authorization, :concurrency, :slice, :param, :options
|
40
40
|
attr_reader :uri, :responses, :response, :options
|
41
41
|
|
42
42
|
extend ::Forwardable
|
@@ -80,7 +80,6 @@ module Npolar::Api::Client
|
|
80
80
|
@concurrency = 5
|
81
81
|
@slice = 1000
|
82
82
|
@param={}
|
83
|
-
@header={}
|
84
83
|
end
|
85
84
|
|
86
85
|
# All documents
|
@@ -124,10 +123,19 @@ module Npolar::Api::Client
|
|
124
123
|
|
125
124
|
# Request header Hash
|
126
125
|
def header
|
127
|
-
options[:headers]
|
128
|
-
# merge!
|
126
|
+
options[:headers]
|
129
127
|
end
|
130
128
|
alias :headers :header
|
129
|
+
|
130
|
+
def header=(header)
|
131
|
+
if header.is_a? Array
|
132
|
+
options[:headers]=header
|
133
|
+
else
|
134
|
+
options[:headers].merge! header
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
alias :headers= :header=
|
131
139
|
|
132
140
|
def http_method
|
133
141
|
@method
|
@@ -223,7 +231,7 @@ module Npolar::Api::Client
|
|
223
231
|
alias :multi_get :get_uris
|
224
232
|
|
225
233
|
# HEAD
|
226
|
-
def head(path=nil
|
234
|
+
def head(path=nil)
|
227
235
|
execute(request(path, :head, nil, param, header))
|
228
236
|
end
|
229
237
|
|
@@ -244,9 +252,9 @@ module Npolar::Api::Client
|
|
244
252
|
|
245
253
|
# POST
|
246
254
|
# @param [Array, Hash, String] body
|
247
|
-
def post(body, path=nil
|
255
|
+
def post(body, path=nil)
|
248
256
|
if header["Content-Type"] =~ /application\/(\w+[+])?json/
|
249
|
-
|
257
|
+
chunk_save(path, "POST", body, param, header)
|
250
258
|
else
|
251
259
|
execute(
|
252
260
|
request(path, :post, body, param, header)
|
@@ -255,7 +263,7 @@ module Npolar::Api::Client
|
|
255
263
|
end
|
256
264
|
|
257
265
|
# PUT
|
258
|
-
def put(body, path=nil
|
266
|
+
def put(body, path=nil)
|
259
267
|
execute(
|
260
268
|
request(path, :put, body, param, header)
|
261
269
|
)
|
data/lib/npolar/api/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "yajl/json_gem"
|
2
2
|
require "hashie"
|
3
3
|
require "typhoeus"
|
4
|
+
|
4
5
|
require "forwardable"
|
5
6
|
require "uri"
|
6
7
|
|
@@ -8,7 +9,7 @@ module Npolar
|
|
8
9
|
module Api
|
9
10
|
module Client
|
10
11
|
|
11
|
-
VERSION = "0.
|
12
|
+
VERSION = "0.3.0"
|
12
13
|
|
13
14
|
USER_AGENT = "npolar-api-client-ruby-#{VERSION}/Typhoeus-#{Typhoeus::VERSION}/libcurl-#{`curl --version`.chomp.split(" ")[1]}"
|
14
15
|
|
@@ -7,14 +7,22 @@ $:.unshift lib unless $:.include?(lib)
|
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "npolar-api-client-ruby"
|
10
|
-
s.version = "0.
|
10
|
+
s.version = "0.3.0" # Not DRY, trouble with include Npolar::Api::Client::VERSION
|
11
11
|
s.platform = Gem::Platform::RUBY
|
12
12
|
s.authors = ["Conrad Helgeland"]
|
13
13
|
s.email = ["data*npolar.no"]
|
14
14
|
s.homepage = "http://github.com/npolar/npolar-api-client-ruby"
|
15
15
|
s.summary = "Ruby client library and command line tools for https://api.npolar.no"
|
16
16
|
s.description = "Official Ruby client for the Norwegian Polar Institute's API."
|
17
|
-
|
17
|
+
|
18
|
+
#s.add_development_dependency "rspec", "~> 2.0"
|
19
|
+
#s.add_development_dependency "bundler", "~> 2.0"
|
20
|
+
|
21
|
+
s.add_runtime_dependency "hashie" #, "~> 1"
|
22
|
+
s.add_runtime_dependency "typhoeus" #, "~> 0"
|
23
|
+
s.add_runtime_dependency "yajl-ruby" #, "~> 0"
|
24
|
+
s.add_runtime_dependency "uuidtools" #, "~> 1"
|
25
|
+
|
18
26
|
s.files = Dir.glob("{lib}/**/*") + %w(README.md)
|
19
27
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
28
|
s.require_paths = ["lib"]
|
@@ -22,4 +30,4 @@ Gem::Specification.new do |s|
|
|
22
30
|
s.files = git_files # + whatever_else
|
23
31
|
s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
24
32
|
s.require_paths = ["lib"]
|
25
|
-
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: npolar-api-client-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conrad Helgeland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: hashie
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: typhoeus
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yajl-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: uuidtools
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
27
69
|
description: Official Ruby client for the Norwegian Polar Institute's API.
|
28
70
|
email:
|
29
71
|
- data*npolar.no
|