ulule 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ulule.rb +13 -17
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ced3ecfd6958e19c23d609574c4909d37d025e5
4
- data.tar.gz: 850f5d94dfa447e152bf9a809efde2a9a0dc265c
3
+ metadata.gz: aebe9db8e423042495679d2c3683d6bf47b89ffb
4
+ data.tar.gz: 543f6099a86b8eb562c37a37175ed5259862a31d
5
5
  SHA512:
6
- metadata.gz: e5202a89166e513cd3c5c10145f2f2c10784a5795a99ca55c40a463bad450fac5646ec8b9fd4fa93ea060b4422eb153caa68f953da2f705823ac3236c66c9ebb
7
- data.tar.gz: 185464e68dce16592262cdf99e1ed9195cc5644317274c0b6cf3ebff1cb2ee59ad47ae01c3aa59bf257629d47ea54d407cedc81dc5e88a4871c1b7bb4b65e12e
6
+ metadata.gz: 673f065a2f402815c603235369244f5cdc420ef41b0d71b57d6c0ff8fde7f84875ec35d381121736f6c5ed6a5a43fc7a995036f74da3a9b2a94d7f10838dfd35
7
+ data.tar.gz: c0de5f299bb3a79e1393320ef49ff64cca0ac4e3801ebf9c05872471e18c0e0d8995a5d8a344b755d34812526857d2d4a2b096b026422e5d311a102d4f12226e
@@ -1,37 +1,33 @@
1
- class Ulule
1
+ require 'net/http'
2
+ require 'json'
2
3
 
3
- require 'net/http'
4
- require 'json'
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(url)
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
- return puts "Wrong username/apikey or url !"
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("https://api.ulule.com/v1/projects/#{name}")
29
- Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
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( 'Authorization', "ApiKey #{username}:#{apikey}" )
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
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: 2012-07-31 00:00:00.000000000 Z
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A simple gem for fetch datas projects from Ulule's API
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 api for rails
43
+ summary: Ulule API for Rails
44
44
  test_files: []