nobel 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nobel/api.rb +1 -2
- data/lib/nobel/config.rb +1 -1
- data/lib/nobel/http.rb +19 -0
- data/lib/nobel/version.rb +1 -1
- data/lib/nobel.rb +1 -0
- data/spec/nobel/config_spec.rb +1 -1
- metadata +2 -1
data/lib/nobel/api.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'uri'
|
4
|
-
require 'net/http'
|
5
4
|
require 'json'
|
6
5
|
|
7
6
|
module Nobel
|
@@ -25,7 +24,7 @@ module Nobel
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def get_json(endpoint, params = {})
|
28
|
-
load_json get("#{endpoint}.json", params)
|
27
|
+
load_json get("#{endpoint}.json", params) || "{}"
|
29
28
|
end
|
30
29
|
|
31
30
|
def get(path, params = {})
|
data/lib/nobel/config.rb
CHANGED
data/lib/nobel/http.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Nobel
|
6
|
+
class HTTP
|
7
|
+
class << self
|
8
|
+
def get(uri)
|
9
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
10
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
11
|
+
response = http.request(request)
|
12
|
+
response.body if response.code == '200'
|
13
|
+
end
|
14
|
+
rescue StandardError
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/nobel/version.rb
CHANGED
data/lib/nobel.rb
CHANGED
data/spec/nobel/config_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nobel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/nobel/api.rb
|
29
29
|
- lib/nobel/config.rb
|
30
30
|
- lib/nobel/country.rb
|
31
|
+
- lib/nobel/http.rb
|
31
32
|
- lib/nobel/laureate.rb
|
32
33
|
- lib/nobel/prize.rb
|
33
34
|
- lib/nobel/version.rb
|