ulule 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ulule.rb +13 -17
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aebe9db8e423042495679d2c3683d6bf47b89ffb
|
4
|
+
data.tar.gz: 543f6099a86b8eb562c37a37175ed5259862a31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 673f065a2f402815c603235369244f5cdc420ef41b0d71b57d6c0ff8fde7f84875ec35d381121736f6c5ed6a5a43fc7a995036f74da3a9b2a94d7f10838dfd35
|
7
|
+
data.tar.gz: c0de5f299bb3a79e1393320ef49ff64cca0ac4e3801ebf9c05872471e18c0e0d8995a5d8a344b755d34812526857d2d4a2b096b026422e5d311a102d4f12226e
|
data/lib/ulule.rb
CHANGED
@@ -1,37 +1,33 @@
|
|
1
|
-
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
class UluleError < Exception
|
5
|
+
end
|
5
6
|
|
7
|
+
class Ulule
|
6
8
|
attr_accessor :username
|
7
9
|
attr_accessor :apikey
|
8
10
|
|
9
11
|
def initialize(username, apikey)
|
10
|
-
@username = username
|
11
|
-
@apikey = apikey
|
12
|
+
@username, @apikey = username, apikey
|
12
13
|
end
|
13
14
|
|
14
|
-
def project
|
15
|
-
if (name = url.match(/.*\/(.*)\/$/)).nil?
|
16
|
-
return puts "Wrong url !"
|
17
|
-
end
|
15
|
+
def project url
|
16
|
+
raise UluleError, "Wrong url" if (name = url.match(/.*\/(.*)\/$/)).nil?
|
18
17
|
output = send_request name[1]
|
19
|
-
if output.empty?
|
20
|
-
|
21
|
-
end
|
22
|
-
JSON.parse(output)
|
18
|
+
raise UluleError "Wrong username/apikey or url" if output.empty?
|
19
|
+
JSON.parse output
|
23
20
|
end
|
24
21
|
|
25
22
|
private
|
26
23
|
|
27
24
|
def send_request name
|
28
|
-
uri = URI
|
29
|
-
Net::HTTP.start
|
25
|
+
uri = URI "https://api.ulule.com/v1/projects/#{name}"
|
26
|
+
Net::HTTP.start uri.host, uri.port, use_ssl: uri.scheme == 'https' do |http|
|
30
27
|
request = Net::HTTP::Get.new uri
|
31
|
-
request.add_field
|
28
|
+
request.add_field 'Authorization', "ApiKey #{@username}:#{@apikey}"
|
32
29
|
response = http.request request
|
33
30
|
response.body
|
34
31
|
end
|
35
32
|
end
|
36
|
-
|
37
33
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ulule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Puyet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: A simple gem
|
13
|
+
description: A simple gem to fetch datas projects from Ulule's API
|
14
14
|
email: sebastienpuyet@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
@@ -40,5 +40,5 @@ rubyforge_project:
|
|
40
40
|
rubygems_version: 2.2.2
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
|
-
summary: Ulule
|
43
|
+
summary: Ulule API for Rails
|
44
44
|
test_files: []
|