ulule 0.0.2 → 0.0.3

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 +15 -26
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aed0b681e7c9f848f8b6cb20bd0b95dbfaea57d7
4
- data.tar.gz: 6664efb638eff95fbb894ea54d2990becbeca3de
3
+ metadata.gz: 302ec42636bd52092397d3e5cb80346e6a8d3dad
4
+ data.tar.gz: f6997aa37a40f9e8780f95b84ed3437690315492
5
5
  SHA512:
6
- metadata.gz: 2b3029ceb15b9c73c3719b03d2924529568208f97bcd030f57dbf8d5a05da8800488080007cdf4457fc144b353a6efc50daf6ba5e6509742f31ef01c0ac7ae72
7
- data.tar.gz: bc06dabaeba26f700839d08a5e28e804ebe905610519d2989ca03d509bb23ddaa5542a4be2f70fa941afa8299a08ad8aef24774dcefa964e045e77d12230c9b6
6
+ metadata.gz: 4fd4a6d8934472fad14a53a62a4e393f27c6f561c31e73bc6b2eea0d0b729495e25ada9b8162bac1769e83ccd2295c124f0215ea1154aa5845ea5900e339b9d7
7
+ data.tar.gz: 60911b1663551d6283e8b9aef10667d86723b82ce5715aa8a4ff15994a894ea32c803a27e07a846f140fa0d933f23fd07fce18652b3f57cf252e2929f034ff4c
@@ -1,46 +1,35 @@
1
1
  require 'json'
2
2
 
3
3
  class Ulule
4
+
5
+ attr_accessor :username
6
+ attr_accessor :apikey
7
+
4
8
  def initialize(username, apikey)
5
9
  @username = username
6
10
  @apikey = apikey
7
11
  end
8
12
 
9
- def get_project(url)
10
- name = check_url(url)
11
- if name.nil?
12
- return put_error("Wrong url !")
13
+ def project(url)
14
+ if (name = check_url(url)).nil?
15
+ return puts "Wrong url !"
13
16
  end
14
- command = generate_command(name)
15
- output = `#{command}`
16
- if output.length == 0
17
- return put_error("Wrong username/apikey or url !")
17
+ command = gcommand(name[1])
18
+ if (output = `#{command}`).length == 0
19
+ return puts "Wrong username/apikey or url !"
18
20
  end
19
21
  JSON.parse(output)
20
22
  end
21
23
 
22
- def generate_command name
23
- "curl -H" + '"Authorization: ApiKey '+ "#{@username}:#{@apikey}" +'" ' + "https://api.ulule.com/v1/projects/#{name}"
24
- end
25
24
 
26
- def put_error msg
27
- puts msg
28
- nil
29
- end
25
+ private
30
26
 
31
- def check_url url
32
- name = url.match(/.*\/(.*)\/$/)
33
- if name.nil?
34
- return nil
35
- end
36
- name[1]
27
+ def gcommand name
28
+ "curl -H 'Authorization: ApiKey #{@username}:#{@apikey}' https://api.ulule.com/v1/projects/#{name}"
37
29
  end
38
30
 
39
- def update_username username
40
- @username = username
31
+ def check_url url
32
+ url.match(/.*\/(.*)\/$/)
41
33
  end
42
34
 
43
- def update_apikey apikey
44
- @apikey = apikey
45
- end
46
35
  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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Puyet