dor-workflow-client 3.4.2 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -2
- data/README.md +2 -0
- data/lib/dor/workflow/client.rb +5 -1
- data/lib/dor/workflow/client/version.rb +1 -1
- data/lib/dor/workflow/client/workflow_template.rb +30 -0
- data/spec/spec_helper.rb +3 -3
- data/spec/workflow/client/workflow_template_spec.rb +20 -0
- data/spec/workflow/client_spec.rb +15 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 282db0ca244d39fff241a2a30face5c69f101762aba3355a078da50eccae6e49
|
4
|
+
data.tar.gz: 34342d7f0f0808aec6ce8bf59de2fde85f9154c656940da008928404b74e0224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fb6baead7b56ee334ad8c100e541fb45fdef6d0053b98b440ceb2982801fced53280c7a15718d7c5d0983f89adf452f5ba2daa8c7c81b4718cbac1ff4274a3b
|
7
|
+
data.tar.gz: 7515e44eac0411fac130ca5661237161ce8ee60def8c8384ba4fc7ef35d72013455ed8f77ff54b770df72afe6099cef20eaa55a14791c35bd8b13d17c7d35899
|
data/.travis.yml
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
email: false
|
2
|
+
cache: bundler
|
4
3
|
|
5
4
|
rvm:
|
6
5
|
- 2.5.3
|
@@ -9,3 +8,14 @@ env:
|
|
9
8
|
- "RAILS_VERSION=4.2.11.1"
|
10
9
|
- "RAILS_VERSION=5.2.3"
|
11
10
|
- "RAILS_VERSION=6.0.0"
|
11
|
+
|
12
|
+
before_script:
|
13
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
14
|
+
- chmod +x ./cc-test-reporter
|
15
|
+
- ./cc-test-reporter before-build
|
16
|
+
|
17
|
+
after_script:
|
18
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
19
|
+
|
20
|
+
notifications:
|
21
|
+
email: false
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/sul-dlss/dor-workflow-client.svg?branch=master)](https://travis-ci.org/sul-dlss/dor-workflow-client)
|
2
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/fba77ff479c468f8510f/test_coverage)](https://codeclimate.com/github/sul-dlss/dor-services-client/test_coverage)
|
3
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/fba77ff479c468f8510f/maintainability)](https://codeclimate.com/github/sul-dlss/dor-services-client/maintainability)
|
2
4
|
[![Gem Version](https://badge.fury.io/rb/dor-workflow-client.svg)](https://badge.fury.io/rb/dor-workflow-client)
|
3
5
|
|
4
6
|
# dor-workflow-client gem
|
data/lib/dor/workflow/client.rb
CHANGED
@@ -22,7 +22,7 @@ module Dor
|
|
22
22
|
# Create and update workflows
|
23
23
|
class Client
|
24
24
|
# From Workflow Service's admin/Process.java
|
25
|
-
VALID_STATUS = %w[waiting completed error queued skipped
|
25
|
+
VALID_STATUS = %w[waiting completed error queued skipped].freeze
|
26
26
|
|
27
27
|
attr_accessor :requestor
|
28
28
|
|
@@ -66,6 +66,10 @@ module Dor
|
|
66
66
|
@version_routes ||= VersionRoutes.new(requestor: requestor)
|
67
67
|
end
|
68
68
|
|
69
|
+
def workflow_template(name)
|
70
|
+
WorkflowTemplate.new(requestor: requestor).retrieve(name)
|
71
|
+
end
|
72
|
+
|
69
73
|
private
|
70
74
|
|
71
75
|
# Among other things, a distinct method helps tests mock default logger
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dor
|
4
|
+
module Workflow
|
5
|
+
class Client
|
6
|
+
# Makes requests relating to a workflow template
|
7
|
+
class WorkflowTemplate
|
8
|
+
def initialize(requestor:)
|
9
|
+
@requestor = requestor
|
10
|
+
end
|
11
|
+
|
12
|
+
# Retrieves a representation of the workflow template
|
13
|
+
#
|
14
|
+
# @param [String] workflow_name The name of the workflow you want to retrieve
|
15
|
+
# @return [Hash] a representation of the workflow template
|
16
|
+
# @example:
|
17
|
+
# retrieve('assemblyWF') => '{"processes":[{"name":"start-assembly"},{"name":"content-metadata-create"},...]}'
|
18
|
+
#
|
19
|
+
def retrieve(workflow_name)
|
20
|
+
body = requestor.request "workflow_templates/#{workflow_name}"
|
21
|
+
JSON.parse(body)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :requestor
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
|
6
3
|
require 'simplecov'
|
7
4
|
SimpleCov.start do
|
8
5
|
add_filter 'spec'
|
9
6
|
end
|
10
7
|
|
8
|
+
lib = File.expand_path('lib', __dir__)
|
9
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
10
|
+
|
11
11
|
require 'byebug'
|
12
12
|
require 'dor/workflow/client'
|
13
13
|
require 'webmock/rspec'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Dor::Workflow::Client::WorkflowTemplate do
|
6
|
+
let(:data) { '{"processes":[{"name":"start-assembly"},{"name":"content-metadata-create"}]}' }
|
7
|
+
let(:mock_requestor) { instance_double(Dor::Workflow::Client::Requestor, request: data) }
|
8
|
+
|
9
|
+
let(:routes) { described_class.new(requestor: mock_requestor) }
|
10
|
+
|
11
|
+
describe '#retrieve' do
|
12
|
+
subject(:workflow_template) { routes.retrieve('accessionWF') }
|
13
|
+
|
14
|
+
it 'returns a workflow' do
|
15
|
+
expect(workflow_template['processes']).to eq [{ 'name' => 'start-assembly' },
|
16
|
+
{ 'name' => 'content-metadata-create' }]
|
17
|
+
expect(mock_requestor).to have_received(:request).with('workflow_templates/accessionWF')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -185,6 +185,21 @@ RSpec.describe Dor::Workflow::Client do
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
+
describe '#workflow_template' do
|
189
|
+
subject(:workflow_template) { client.workflow_template('etdSubmitWF') }
|
190
|
+
|
191
|
+
let(:workflow_template_client) { instance_double Dor::Workflow::Client::WorkflowTemplate, retrieve: 'data' }
|
192
|
+
|
193
|
+
before do
|
194
|
+
allow(Dor::Workflow::Client::WorkflowTemplate).to receive(:new).and_return(workflow_template_client)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'delegates to the client' do
|
198
|
+
expect(workflow_template).to eq 'data'
|
199
|
+
expect(workflow_template_client).to have_received(:retrieve).with('etdSubmitWF')
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
188
203
|
describe '#workflow_status' do
|
189
204
|
let(:repo) { @repo }
|
190
205
|
let(:druid) { @druid }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willy Mene
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/dor/workflow/client/version.rb
|
218
218
|
- lib/dor/workflow/client/version_routes.rb
|
219
219
|
- lib/dor/workflow/client/workflow_routes.rb
|
220
|
+
- lib/dor/workflow/client/workflow_template.rb
|
220
221
|
- lib/dor/workflow/response/process.rb
|
221
222
|
- lib/dor/workflow/response/update.rb
|
222
223
|
- lib/dor/workflow/response/workflow.rb
|
@@ -229,6 +230,7 @@ files:
|
|
229
230
|
- spec/workflow/client/lifecycle_routes_spec.rb
|
230
231
|
- spec/workflow/client/requestor_spec.rb
|
231
232
|
- spec/workflow/client/workflow_routes_spec.rb
|
233
|
+
- spec/workflow/client/workflow_template_spec.rb
|
232
234
|
- spec/workflow/client_spec.rb
|
233
235
|
homepage: https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow
|
234
236
|
licenses: []
|
@@ -248,8 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
250
|
- !ruby/object:Gem::Version
|
249
251
|
version: '0'
|
250
252
|
requirements: []
|
251
|
-
|
252
|
-
rubygems_version: 2.7.8
|
253
|
+
rubygems_version: 3.0.3
|
253
254
|
signing_key:
|
254
255
|
specification_version: 4
|
255
256
|
summary: Provides convenience methods to work with the DOR Workflow Service
|
@@ -261,4 +262,5 @@ test_files:
|
|
261
262
|
- spec/workflow/client/lifecycle_routes_spec.rb
|
262
263
|
- spec/workflow/client/requestor_spec.rb
|
263
264
|
- spec/workflow/client/workflow_routes_spec.rb
|
265
|
+
- spec/workflow/client/workflow_template_spec.rb
|
264
266
|
- spec/workflow/client_spec.rb
|