mustard_client 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 977e409a5245edb0fab0ad0c6fb1b52421a32d5e
4
- data.tar.gz: 1a547e24dcef5a51f3870d920beda5c56ecc7f6f
3
+ metadata.gz: da9e2f0b5a5eb14e43cccd34866597e6a7fcaf1b
4
+ data.tar.gz: 38fb305fb5556ed576e8a547712e0980ffdd6982
5
5
  SHA512:
6
- metadata.gz: dded20e8563662832d339d4a960ede73cd082197e03be1142fbeaf07ac8cba21168dbfd9e32d0ec4e26b6cd4ac8332f031c99e95c15cf1de5057517e8009e7ab
7
- data.tar.gz: f7e9c5bc98df73d1ffc5233a2483af5ca5b2dba923b5dc1f92b29915dcb2a0201a7fc10601003e3903a7e3fa0fab644509ab2b1e73297968ef1e458370525079
6
+ metadata.gz: b3f5d09be3eff571c499572423b92b8dd1701b28635a78d8e9f8416544b050881bab701486277d5390ecf61de0b5584f4fa3dc572f7b56cedd92b12e375a9c2c
7
+ data.tar.gz: 4387af0338611e86ca7dd880196eafe65358cef6786869a12b197f22452e87f67196417a879d633070d98139e849a15c5d1e1709110b1e9ab933f287bed0ed2e
data/lib/MustardClient.rb CHANGED
@@ -1,44 +1,73 @@
1
1
  require "MustardClient/version"
2
2
  require 'rest-client'
3
+ require 'MustardClient/users'
4
+ require 'MustardClient/authenticate'
5
+ require 'MustardClient/projects'
6
+ require 'MustardClient/testcases'
7
+ require 'MustardClient/teams'
8
+ require 'MustardClient/environments'
9
+ require 'MustardClient/results'
10
+ require 'MustardClient/executions'
11
+ require 'json'
3
12
 
4
13
  module MustardClient
5
14
 
6
- class MustardClient
15
+ class Mustard
7
16
 
8
17
  attr_accessor :mustard_url, :user_token
9
18
 
10
19
  @user_token
11
20
  @mustard_url
12
21
 
13
- def initialize
14
- @mustard_url = 'localhost:8081'
22
+ def initialize(url= 'localhost:8081', token=nil)
23
+ @mustard_url = url
24
+ @user_token = token
15
25
  end
16
26
 
17
27
  def set_user_token token
18
28
  @user_token = token
19
29
  end
20
30
 
21
- def execute(command)
22
-
23
- raise Exception if command[:method].nil? || command[:route].nil?
31
+ def set_mustard_url url
32
+ @mustard_url = url
33
+ end
24
34
 
25
- #Suppress errors that return a response
26
- begin
27
- if command[:method] == :get
28
- r = RestClient.get command[:route], command[:headers]
29
- elsif command[:method] == :post
30
- r = RestClient.post command[:route], command[:params], command[:headers]
31
- elsif command[:method] == :put
32
- r = RestClient.put command[:route], command[:params], command[:headers]
33
- elsif command[:method] == :delete
34
- r = RestClient.delete command[:route], command[:headers]
35
- end
36
- rescue RestClient::ExceptionWithResponse => e
37
- r =e.response
35
+ def authenticate(username, password)
36
+ a = AuthenticateClient.new(@mustard_url, @user_token)
37
+ r = a.authenticate(username, password)
38
+ unless r['error']
39
+ @user_token = r['token']
38
40
  end
39
41
 
40
- JSON.parse(r)
41
- #end
42
+ return r
43
+ end
44
+
45
+ def users
46
+ UsersClient.new(@mustard_url, @user_token)
47
+ end
48
+
49
+ def projects
50
+ ProjectsClient.new(@mustard_url, @user_token)
51
+ end
52
+
53
+ def testcases
54
+ TestcaseClient.new(@mustard_url, @user_token)
55
+ end
56
+
57
+ def teams
58
+ TeamsClient.new(@mustard_url, @user_token)
59
+ end
60
+
61
+ def envirnments
62
+ EnvironmentsClient.new(@mustard_url, @user_token)
63
+ end
64
+
65
+ def results
66
+ ResultsClient.new(@mustard_url, @user_token)
67
+ end
68
+
69
+ def executions
70
+ ExecutionsClient.new(@mustard_url, @user_token)
42
71
  end
43
72
 
44
73
 
@@ -46,13 +75,3 @@ module MustardClient
46
75
 
47
76
 
48
77
  end
49
-
50
- require 'MustardClient/users'
51
- require 'MustardClient/authenticate'
52
- require 'MustardClient/projects'
53
- require 'MustardClient/testcases'
54
- require 'MustardClient/teams'
55
- require 'MustardClient/environments'
56
- require 'MustardClient/results'
57
- require 'MustardClient/executions'
58
- require 'json'
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Authenticate < MustardClient
3
+ class AuthenticateClient < Client
3
4
 
4
5
  def authenticate(username, password)
5
6
 
@@ -0,0 +1,33 @@
1
+ module MustardClient
2
+ class Client
3
+
4
+ def initialize(url= nil, token=nil)
5
+ @mustard_url = url
6
+ @user_token = token
7
+ end
8
+
9
+ def execute(command)
10
+
11
+ raise Exception if command[:method].nil? || command[:route].nil?
12
+
13
+ #Suppress errors that return a response
14
+ begin
15
+ if command[:method] == :get
16
+ r = RestClient.get command[:route], command[:headers]
17
+ elsif command[:method] == :post
18
+ r = RestClient.post command[:route], command[:params], command[:headers]
19
+ elsif command[:method] == :put
20
+ r = RestClient.put command[:route], command[:params], command[:headers]
21
+ elsif command[:method] == :delete
22
+ r = RestClient.delete command[:route], command[:headers]
23
+ end
24
+ rescue RestClient::ExceptionWithResponse => e
25
+ r =e.response
26
+ end
27
+
28
+ JSON.parse(r)
29
+
30
+ end
31
+
32
+ end
33
+ end
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Environments < MustardClient
3
+ class EnvironmentsClient < Client
3
4
 
4
5
  def find environment_id
5
6
 
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Executions < MustardClient
3
+ class ExecutionsClient < Client
3
4
 
4
5
  def find execution_id
5
6
 
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Projects < MustardClient
3
+ class ProjectsClient < Client
3
4
 
4
5
  def all
5
6
 
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Results < MustardClient
3
+ class ResultsClient < Client
3
4
 
4
5
  def find result_id
5
6
 
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Teams < MustardClient
3
+ class TeamsClient < Client
3
4
 
4
5
  def all
5
6
 
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Testcases < MustardClient
3
+ class TestcasesClient < Client
3
4
 
4
5
  def find testcase_id
5
6
 
@@ -1,5 +1,6 @@
1
+ require 'MustardClient/client'
1
2
  module MustardClient
2
- class Users < MustardClient
3
+ class UsersClient < Client
3
4
 
4
5
  def all
5
6
 
@@ -1,3 +1,3 @@
1
1
  module MustardClient
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustard_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Watson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-23 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -51,6 +51,7 @@ files:
51
51
  - bin/setup
52
52
  - lib/MustardClient.rb
53
53
  - lib/MustardClient/authenticate.rb
54
+ - lib/MustardClient/client.rb
54
55
  - lib/MustardClient/environments.rb
55
56
  - lib/MustardClient/executions.rb
56
57
  - lib/MustardClient/projects.rb