sfrest 0.0.16 → 0.0.17

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
  SHA256:
3
- metadata.gz: fc74108bd6ad403fcf6bfa7125dad70952c7c4ecf7b136bd606e2f699d54970a
4
- data.tar.gz: a875b7a8864b004b5c38bfc368b63c75b51a7f921bde919817dc57365819604f
3
+ metadata.gz: 94bd205352e9ec9465614828f2a5bb1b602217568ca5135b4c30223f0f16ec63
4
+ data.tar.gz: 9fdbde3ff4ba1b1811625b2eb48a3aa22c1f54e652747dc6ab6adf2fb3875348
5
5
  SHA512:
6
- metadata.gz: a62fd336bf56a3ca2bf888b062c9a640412c3ed55775f9a8336ec514e2a2d6e560ec6f1540f8faa01c18c601dddf0bb130a7f3faa68eeff1512579d348c3fce0
7
- data.tar.gz: 9679eb844a8c32d97b78cec5e87ddd01b23e013b965178186407a519fc2a7e25176c5e0b6a70383559b7340b654a8bf059e60373e606fa0e80624ef3db9bfbe5
6
+ metadata.gz: ce166dabdbc263441fc183a38f5b85700c0775a2b69249b2587c42950c441a6bf701814b786ebb1f307412dce7b9b357aaeda7b060c89bfea9259a0650bf2646
7
+ data.tar.gz: 7f98365d4da5f5121040b63fc6db432e3f67b2b368e365fef6f477c76de811fc5c8f6ba985fbe38e38acb660268b5b5833868c26d258534e050177078d57168e
data/lib/sfrest/task.rb CHANGED
@@ -60,14 +60,22 @@ module SFRest
60
60
  false
61
61
  end
62
62
 
63
+ # Get the status of a wip task by id.
64
+ # @param [Integer] task_id
65
+ # @return [Hash{"wip_task" => {"id" => Integer, "status" => Integer}, "time" => timestamp}]
66
+ def task_status(task_id)
67
+ current_path = "/api/v1/wip/task/#{task_id}/status"
68
+ res = @conn.get(current_path)
69
+ raise InvalidDataError, "No wip task returned for task id #{task_id}" if res['wip_task'].nil?
70
+ raise InvalidDataError, "No task status returned for task id #{task_id}" if res['wip_task']['status'].nil?
71
+ res['wip_task']['status']
72
+ end
73
+
63
74
  # Returns true only if WIP reports the status as running
64
75
  # @param [Integer] task_id
65
76
  # @return [Boolean]
66
77
  def task_running?(task_id)
67
- task_path = "/api/v1/wip/task/#{task_id}/status"
68
-
69
- res = @conn.get task_path
70
- status = res['wip_task']['status']
78
+ status = task_status task_id
71
79
  status_running?(status)
72
80
  end
73
81
 
@@ -75,10 +83,7 @@ module SFRest
75
83
  # @param [Integer] task_id
76
84
  # @return [Boolean]
77
85
  def task_completed?(task_id)
78
- task_path = "/api/v1/wip/task/#{task_id}/status"
79
-
80
- res = @conn.get task_path
81
- status = res['wip_task']['status']
86
+ status = task_status task_id
82
87
  status_completed?(status)
83
88
  end
84
89
 
@@ -87,10 +92,7 @@ module SFRest
87
92
  # @param [Integer] task_id
88
93
  # @return [Boolean]
89
94
  def task_done?(task_id)
90
- task_path = "/api/v1/wip/task/#{task_id}/status"
91
-
92
- res = @conn.get task_path
93
- status = res['wip_task']['status']
95
+ status = task_status task_id
94
96
  status_done?(status)
95
97
  end
96
98
 
@@ -98,10 +100,7 @@ module SFRest
98
100
  # @param [Integer] task_id
99
101
  # @return [Boolean]
100
102
  def task_killed?(task_id)
101
- task_path = "/api/v1/wip/task/#{task_id}/status"
102
-
103
- res = @conn.get task_path
104
- status = res['wip_task']['status']
103
+ status = task_status task_id
105
104
  status_killed?(status)
106
105
  end
107
106
 
@@ -109,10 +108,7 @@ module SFRest
109
108
  # @param [Integer] task_id
110
109
  # @return [Boolean]
111
110
  def task_errored?(task_id)
112
- task_path = "/api/v1/wip/task/#{task_id}/status"
113
-
114
- res = @conn.get task_path
115
- status = res['wip_task']['status']
111
+ status = task_status task_id
116
112
  status_error?(status)
117
113
  end
118
114
 
@@ -1,4 +1,4 @@
1
1
  module SFRest
2
2
  # Just tracks the version of sfrest.
3
- VERSION = '0.0.16'.freeze
3
+ VERSION = '0.0.17'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - ACSF Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-20 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon