ulule 0.0.3 → 0.0.4

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 +33 -31
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 302ec42636bd52092397d3e5cb80346e6a8d3dad
4
- data.tar.gz: f6997aa37a40f9e8780f95b84ed3437690315492
3
+ metadata.gz: 8ced3ecfd6958e19c23d609574c4909d37d025e5
4
+ data.tar.gz: 850f5d94dfa447e152bf9a809efde2a9a0dc265c
5
5
  SHA512:
6
- metadata.gz: 4fd4a6d8934472fad14a53a62a4e393f27c6f561c31e73bc6b2eea0d0b729495e25ada9b8162bac1769e83ccd2295c124f0215ea1154aa5845ea5900e339b9d7
7
- data.tar.gz: 60911b1663551d6283e8b9aef10667d86723b82ce5715aa8a4ff15994a894ea32c803a27e07a846f140fa0d933f23fd07fce18652b3f57cf252e2929f034ff4c
6
+ metadata.gz: e5202a89166e513cd3c5c10145f2f2c10784a5795a99ca55c40a463bad450fac5646ec8b9fd4fa93ea060b4422eb153caa68f953da2f705823ac3236c66c9ebb
7
+ data.tar.gz: 185464e68dce16592262cdf99e1ed9195cc5644317274c0b6cf3ebff1cb2ee59ad47ae01c3aa59bf257629d47ea54d407cedc81dc5e88a4871c1b7bb4b65e12e
@@ -1,35 +1,37 @@
1
- require 'json'
2
-
3
1
  class Ulule
4
2
 
5
- attr_accessor :username
6
- attr_accessor :apikey
7
-
8
- def initialize(username, apikey)
9
- @username = username
10
- @apikey = apikey
11
- end
12
-
13
- def project(url)
14
- if (name = check_url(url)).nil?
15
- return puts "Wrong url !"
16
- end
17
- command = gcommand(name[1])
18
- if (output = `#{command}`).length == 0
19
- return puts "Wrong username/apikey or url !"
20
- end
21
- JSON.parse(output)
22
- end
23
-
24
-
25
- private
26
-
27
- def gcommand name
28
- "curl -H 'Authorization: ApiKey #{@username}:#{@apikey}' https://api.ulule.com/v1/projects/#{name}"
29
- end
30
-
31
- def check_url url
32
- url.match(/.*\/(.*)\/$/)
33
- end
3
+ require 'net/http'
4
+ require 'json'
5
+
6
+ attr_accessor :username
7
+ attr_accessor :apikey
8
+
9
+ def initialize(username, apikey)
10
+ @username = username
11
+ @apikey = apikey
12
+ end
13
+
14
+ def project(url)
15
+ if (name = url.match(/.*\/(.*)\/$/)).nil?
16
+ return puts "Wrong url !"
17
+ end
18
+ output = send_request name[1]
19
+ if output.empty?
20
+ return puts "Wrong username/apikey or url !"
21
+ end
22
+ JSON.parse(output)
23
+ end
24
+
25
+ private
26
+
27
+ 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|
30
+ request = Net::HTTP::Get.new uri
31
+ request.add_field( 'Authorization', "ApiKey #{username}:#{apikey}" )
32
+ response = http.request request
33
+ response.body
34
+ end
35
+ end
34
36
 
35
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ulule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Puyet
@@ -27,17 +27,17 @@ require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  required_rubygems_version: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - '>='
35
+ - - ">="
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  requirements: []
39
39
  rubyforge_project:
40
- rubygems_version: 2.4.1
40
+ rubygems_version: 2.2.2
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: Ulule api for rails