sequencescape-client-api 0.4.2 → 0.6.0.pre.rc1

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +39 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +16 -10
  5. data/.rubocop_todo.yml +58 -18
  6. data/README.markdown +11 -7
  7. data/lib/sequencescape-api/connection_factory.rb +5 -5
  8. data/lib/sequencescape-api/connection_factory/actions.rb +6 -6
  9. data/lib/sequencescape-api/finder_methods.rb +1 -3
  10. data/lib/sequencescape-api/rails.rb +5 -9
  11. data/lib/sequencescape-api/version.rb +1 -1
  12. data/lib/sequencescape/barcode_printer.rb +1 -1
  13. data/lib/sequencescape/order.rb +2 -1
  14. data/sequencescape-api.gemspec +15 -3
  15. data/spec/sequencescape-api/contracts/create-invalid-resource.txt +1 -1
  16. data/spec/sequencescape-api/contracts/create-model-c-has-many-inline-nested.txt +1 -1
  17. data/spec/sequencescape-api/contracts/create-model-c-has-many-inline.txt +1 -1
  18. data/spec/sequencescape-api/contracts/create-model-c-has-many.txt +1 -1
  19. data/spec/sequencescape-api/contracts/create-model-c.txt +1 -1
  20. data/spec/sequencescape-api/contracts/create-via-has-many.txt +1 -1
  21. data/spec/sequencescape-api/contracts/retrieve-belongs-to-association.txt +1 -1
  22. data/spec/sequencescape-api/contracts/retrieve-model.txt +1 -2
  23. data/spec/sequencescape-api/contracts/retrieve-results-page-1.txt +1 -1
  24. data/spec/sequencescape-api/contracts/retrieve-results-page-2.txt +1 -1
  25. data/spec/sequencescape-api/contracts/retrieve-results-page-3.txt +1 -1
  26. data/spec/sequencescape-api/contracts/retrieve-root-with-an-authorised-client.txt +1 -2
  27. data/spec/sequencescape-api/contracts/retrieve-root-with-an-unauthorised-client.txt +1 -2
  28. data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-a-list.txt +1 -2
  29. data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-b-list.txt +1 -2
  30. data/spec/sequencescape-api/contracts/retrieve-unauthorised-model-c-list.txt +1 -2
  31. data/spec/sequencescape-api/contracts/update-invalid-resource.txt +1 -1
  32. data/spec/sequencescape-api/contracts/update-model-c.txt +1 -1
  33. data/spec/sequencescape-api/root_spec.rb +3 -3
  34. data/spec/support/contract_helper.rb +3 -3
  35. metadata +40 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8200a9305df5e01306b595a1086ed82943d9d8cfaf9bfd47b2f9d64a0626124d
4
- data.tar.gz: f22421d0c8977570652c2edcc5a6f80b8f3673deb9a9c41c7da0a1722a8d0afc
3
+ metadata.gz: 44f010fb9ed69aae5a2db7f07ae354c9c122ad86fb5d96c0a731cd0db7a7188e
4
+ data.tar.gz: 3d4ddf33e18bcceb7c04634b2c7c753a47ab91ad3ae8280b75c9f7e47f5497e5
5
5
  SHA512:
6
- metadata.gz: af4a326cfdc0808f3ccd64c383d0752b4f9b9807567bb4b3e5efb6926163615d37f97758fb834a69b87733cc6872a4275b8ab06b3199ac5215148192dbc41c45
7
- data.tar.gz: 4ea91648609483222f4eb4abe0f66951294e1957779e16b004726d8b3d12b56cf1ccba7c75dfef078e9b4e6fd492cc6c228c130e378c73a095ce953d7837bf1c
6
+ metadata.gz: 3ac41fe200d33af7324ccd449f35c755b036adc44f101c3a60729d515de2882a948d511771755c20b85e20908b9661f6a7b9469c7b90fdf2b98c3ce7ce47b78e
7
+ data.tar.gz: 96d7dbd068dfbf42cc9425330c146f1d6a24abf7c5da19306b8d3ebaace8f0e3ca933f2037826f6a335390a0bcf05e8e598ca7993e0b49fcb597d6c006ed372c
@@ -0,0 +1,39 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby: ["2.5", "2.6", "2.7", "3.0"]
13
+ name: Ruby Test ${{ matrix.ruby }}
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache:
22
+ true # Runs bundle install and caches gems. See the ruby_test.yml
23
+ # example if you need more control over bundler.
24
+ - name: Run tests
25
+ run: bundle exec rspec
26
+ lint:
27
+ runs-on: ubuntu-latest
28
+
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - name: Set up Ruby
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: 3.0
35
+ bundler-cache:
36
+ true # Runs bundle install and caches gems. See the ruby_test.yml
37
+ # example if you need more control over bundler.
38
+ - name: Run lint
39
+ run: bundle exec rubocop
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  tags
6
6
  .DS_Store
7
7
  lib/.DS_Store
8
+ .talismanrc
data/.rubocop.yml CHANGED
@@ -22,23 +22,29 @@ Naming/FileName:
22
22
  - 'lib/sequencescape-api.rb'
23
23
 
24
24
  # Pending Cops
25
- Layout/EmptyLinesAroundAttributeAccessor:
25
+ Lint/DuplicateBranch: # (new in 1.3)
26
26
  Enabled: true
27
- Layout/SpaceAroundMethodCallOperator:
27
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
28
28
  Enabled: true
29
- Lint/DeprecatedOpenSSLConstant:
29
+ Lint/EmptyBlock: # (new in 1.1)
30
30
  Enabled: true
31
- Lint/RaiseException:
31
+ Lint/EmptyClass: # (new in 1.3)
32
32
  Enabled: true
33
- Lint/StructNewOverride:
33
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
34
34
  Enabled: true
35
- Style/ExponentialNotation:
35
+ Lint/ToEnumArguments: # (new in 1.1)
36
36
  Enabled: true
37
- Style/HashEachMethods:
37
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
38
38
  Enabled: true
39
- Style/HashTransformKeys:
39
+ Style/ArgumentsForwarding: # (new in 1.1)
40
40
  Enabled: true
41
- Style/HashTransformValues:
41
+ Style/CollectionCompact: # (new in 1.2)
42
42
  Enabled: true
43
- Style/SlicingWithRange:
43
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
44
+ Enabled: true
45
+ Style/NegatedIfElseCondition: # (new in 1.2)
46
+ Enabled: true
47
+ Style/NilLambda: # (new in 1.3)
48
+ Enabled: true
49
+ Style/SwapValues: # (new in 1.1)
44
50
  Enabled: true
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,29 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --exclude-limit 15000`
3
- # on 2020-05-28 09:58:56 +0100 using RuboCop version 0.84.0.
3
+ # on 2020-11-20 12:14:23 UTC using RuboCop version 1.3.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 4
10
+ Lint/DuplicateBranch:
11
+ Exclude:
12
+ - 'lib/sequencescape-api/associations/belongs_to.rb'
13
+ - 'lib/sequencescape-api/connection_factory/actions.rb'
14
+
15
+ # Offense count: 3
16
+ Lint/MissingSuper:
17
+ Exclude:
18
+ - 'lib/sequencescape-api/associations/belongs_to.rb'
19
+ - 'lib/sequencescape-api/resource_model_proxy.rb'
20
+ - 'lib/sequencescape/search.rb'
21
+
22
+ # Offense count: 1
23
+ Lint/MixedRegexpCaptureTypes:
24
+ Exclude:
25
+ - 'spec/support/contract_helper.rb'
26
+
9
27
  # Offense count: 2
10
28
  Lint/ShadowingOuterLocalVariable:
11
29
  Exclude:
@@ -28,28 +46,34 @@ Lint/Void:
28
46
  Exclude:
29
47
  - 'spec/sequencescape-api/associations_spec.rb'
30
48
 
31
- # Offense count: 10
49
+ # Offense count: 7
32
50
  # Configuration parameters: IgnoredMethods.
33
51
  Metrics/AbcSize:
34
- Max: 25
52
+ Max: 26
35
53
 
36
54
  # Offense count: 8
37
- # Configuration parameters: CountComments, ExcludedMethods.
55
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
38
56
  # ExcludedMethods: refine
39
57
  Metrics/BlockLength:
40
58
  Max: 65
41
59
 
42
60
  # Offense count: 1
43
- # Configuration parameters: CountComments.
61
+ # Configuration parameters: IgnoredMethods.
62
+ Metrics/CyclomaticComplexity:
63
+ Max: 8
64
+
65
+ # Offense count: 1
66
+ # Configuration parameters: CountComments, CountAsOne.
44
67
  Metrics/ModuleLength:
45
68
  Max: 120
46
69
 
47
- # Offense count: 1
70
+ # Offense count: 2
48
71
  # Configuration parameters: IgnoredMethods.
49
72
  Metrics/PerceivedComplexity:
50
- Max: 9
73
+ Max: 10
51
74
 
52
75
  # Offense count: 1
76
+ # Cop supports --auto-correct.
53
77
  Naming/BinaryOperatorParameterName:
54
78
  Exclude:
55
79
  - 'lib/sequencescape-api/resource/instance_methods.rb'
@@ -71,18 +95,23 @@ Naming/PredicateName:
71
95
  - 'lib/sequencescape-api/resource/attributes.rb'
72
96
  - 'lib/sequencescape-api/resource_model_proxy.rb'
73
97
 
74
- # Offense count: 1
75
- # Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
76
- # SupportedStyles: inline, group
77
- Style/AccessModifierDeclarations:
78
- Exclude:
79
- - 'lib/sequencescape-api/resource/attributes.rb'
80
-
81
98
  # Offense count: 1
82
99
  Style/BeginBlock:
83
100
  Exclude:
84
101
  - 'lib/sequencescape-api/connection_factory/actions.rb'
85
102
 
103
+ # Offense count: 11
104
+ Style/DocumentDynamicEvalDefinition:
105
+ Exclude:
106
+ - 'lib/sequencescape-api/actions.rb'
107
+ - 'lib/sequencescape-api/associations.rb'
108
+ - 'lib/sequencescape-api/composition.rb'
109
+ - 'lib/sequencescape-api/finder_methods.rb'
110
+ - 'lib/sequencescape-api/resource/attributes.rb'
111
+ - 'lib/sequencescape/batch.rb'
112
+ - 'lib/sequencescape/behaviour/state_driven.rb'
113
+ - 'lib/sequencescape/search.rb'
114
+
86
115
  # Offense count: 138
87
116
  Style/Documentation:
88
117
  Exclude:
@@ -214,6 +243,12 @@ Style/EvalWithLocation:
214
243
  - 'lib/sequencescape/behaviour/state_driven.rb'
215
244
  - 'lib/sequencescape/search.rb'
216
245
 
246
+ # Offense count: 1
247
+ # Cop supports --auto-correct.
248
+ Style/ExplicitBlockArgument:
249
+ Exclude:
250
+ - 'spec/support/contract_helper.rb'
251
+
217
252
  # Offense count: 104
218
253
  # Cop supports --auto-correct.
219
254
  # Configuration parameters: EnforcedStyle.
@@ -326,13 +361,18 @@ Style/FrozenStringLiteralComment:
326
361
  - 'sequencescape-api.gemspec'
327
362
 
328
363
  # Offense count: 2
329
- Style/MethodMissingSuper:
364
+ Style/MissingRespondToMissing:
330
365
  Exclude:
331
366
  - 'lib/sequencescape-api/associations/belongs_to.rb'
332
- - 'lib/sequencescape-api/resource_model_proxy.rb'
367
+ - 'lib/sequencescape-api/core.rb'
333
368
 
334
- # Offense count: 2
335
- Style/MissingRespondToMissing:
369
+ # Offense count: 6
370
+ # Configuration parameters: AllowedMethods.
371
+ # AllowedMethods: respond_to_missing?
372
+ Style/OptionalBooleanParameter:
336
373
  Exclude:
337
374
  - 'lib/sequencescape-api/associations/belongs_to.rb'
338
375
  - 'lib/sequencescape-api/core.rb'
376
+ - 'lib/sequencescape-api/finder_methods.rb'
377
+ - 'lib/sequencescape-api/resource/instance_methods.rb'
378
+ - 'lib/sequencescape-api/resource/modifications.rb'
data/README.markdown CHANGED
@@ -1,23 +1,25 @@
1
- Sequencescape Client API
2
- ========================
1
+ # Sequencescape Client API
3
2
 
4
3
  This is the Ruby client library for the Sequencescape API.
5
4
  Documentation can be found [on the wiki](https://github.com/sanger/sequencescape-client-api/wiki).
6
5
 
7
- Version Guides
8
- --------------
6
+ ## Version Guides
9
7
 
10
8
  - 0.2.x Supports older versions of Rails.
11
9
  - 0.3.x Supports Rails 3.2.x to 5.1.x
12
10
  - 0.4.x Supports Rails 5.0 and up
11
+ - 0.5.x Supports Rails 5.0 and up, drops yajl in favour of multi-json
12
+ - 0.6.x Removes usage of WTSISignOn cookie. Replaces with user specific api key,
13
+ can be provided to Sequencescape::Api.new as user_api_key: or via
14
+ `api_connection_options` in the controller.
13
15
 
14
- - master currently corresponds to 0.4.x
16
+ - master currently corresponds to 0.6.x
15
17
 
16
18
  Rails 6 appears to be supported judging by Specs, but haven't used it in anger
17
19
  yet.
18
20
 
19
- Making a release
20
- ----------------
21
+ ## Making a release
22
+
21
23
  1. Update the version number in `lib/sequencescape-api/version.rb`
22
24
  2. For pre-releases the version number should be in the format:
23
25
  major.minor.point-rcx
@@ -25,6 +27,8 @@ Making a release
25
27
  major.minor.point
26
28
  4. Ensure everything is committed, and for non-pre-releases, make sure you are
27
29
  merged to master.
30
+
28
31
  ```
29
32
  rake release
30
33
  ``
34
+ ```
@@ -7,8 +7,8 @@ class Sequencescape::Api::ConnectionFactory
7
7
 
8
8
  def self.create(options)
9
9
  required_options = []
10
- required_options.push(:cookie) if options[:authorisation].blank?
11
- required_options.push(:url) if default_url.blank?
10
+ required_options.push(:user_api_key) if options[:authorisation].blank?
11
+ required_options.push(:url) if default_url.blank?
12
12
 
13
13
  required_options.push(allow_blank: false)
14
14
  options.required!(*required_options) do |missing|
@@ -19,12 +19,12 @@ class Sequencescape::Api::ConnectionFactory
19
19
  new(options)
20
20
  end
21
21
 
22
- attr_reader :url, :cookie, :read_timeout
23
- private :url, :cookie, :read_timeout
22
+ attr_reader :url, :user_api_key, :read_timeout
23
+ private :url, :user_api_key, :read_timeout
24
24
 
25
25
  def initialize(options)
26
26
  @url = options[:url]
27
- @cookie = options[:cookie]
27
+ @user_api_key = options[:user_api_key]
28
28
  @authorisation = options[:authorisation]
29
29
  @read_timeout = options[:read_timeout] || 120
30
30
  end
@@ -1,5 +1,5 @@
1
1
  require 'net/http'
2
- require 'yajl'
2
+ require 'multi_json'
3
3
 
4
4
  # PINCHED FROM https://gist.github.com/736721
5
5
  BEGIN {
@@ -48,7 +48,7 @@ module Sequencescape::Api::ConnectionFactory::Actions
48
48
  end
49
49
 
50
50
  # rubocop:todo Metrics/MethodLength
51
- def create(url, body, handler) # rubocop:todo Metrics/CyclomaticComplexity
51
+ def create(url, body, handler)
52
52
  perform(:post, url, jsonify(body, action: :create)) do |response|
53
53
  case response
54
54
  when Net::HTTPCreated then handler.success(parse_json_from(response))
@@ -64,7 +64,7 @@ module Sequencescape::Api::ConnectionFactory::Actions
64
64
  # rubocop:enable Metrics/MethodLength
65
65
 
66
66
  # rubocop:todo Metrics/MethodLength
67
- def create_from_file(url, file, filename, content_type, handler) # rubocop:todo Metrics/CyclomaticComplexity
67
+ def create_from_file(url, file, filename, content_type, handler)
68
68
  perform_for_file(:post, url, file, filename, content_type) do |response|
69
69
  case response
70
70
  when Net::HTTPCreated then handler.success(parse_json_from(response))
@@ -113,7 +113,7 @@ module Sequencescape::Api::ConnectionFactory::Actions
113
113
  unless body.nil?
114
114
  request.content_type = 'application/json'
115
115
  # request.body = body.to_json
116
- request.body = Yajl::Encoder.encode(body)
116
+ request.body = MultiJson.dump(body)
117
117
  end
118
118
  yield(connection.request(request))
119
119
  end
@@ -146,12 +146,12 @@ module Sequencescape::Api::ConnectionFactory::Actions
146
146
  def parse_json_from(response)
147
147
  raise ServerError, 'server returned non-JSON content' unless response.content_type == 'application/json'
148
148
 
149
- Yajl::Parser.parse(StringIO.new(response.body))
149
+ MultiJson.load(StringIO.new(response.body))
150
150
  end
151
151
  private :parse_json_from
152
152
 
153
153
  def headers
154
- { 'Accept' => 'application/json', 'Cookie' => "WTSISignOn=#{cookie}" }.tap do |standard|
154
+ { 'Accept' => 'application/json', 'Cookie' => "api_key=#{user_api_key}" }.tap do |standard|
155
155
  standard.merge!('X-Sequencescape-Client-ID' => @authorisation) unless @authorisation.blank?
156
156
  end
157
157
  end
@@ -82,11 +82,9 @@ end
82
82
  class Sequencescape::Api::PageOfResults
83
83
  include Enumerable
84
84
 
85
- attr_reader :api, :actions
85
+ attr_reader :api, :actions, :size
86
86
  private :api, :actions
87
87
 
88
- attr_reader :size
89
-
90
88
  def initialize(api, json, &block)
91
89
  @api = api
92
90
  @ctor = block
@@ -1,7 +1,6 @@
1
1
  module Sequencescape::Api::Rails
2
2
  # Including this module into your Rails ApplicationController adds a before filter that will
3
- # provide a user (based on the WTSISignOn cookie) specific Sequencescape::Api instance to
4
- # use, accessible through `api`.
3
+ # provide a Sequencescape::Api instance to use, accessible through `api`.
5
4
  module ApplicationController
6
5
  def self.included(base) # rubocop:todo Metrics/MethodLength
7
6
  base.class_eval do
@@ -20,32 +19,29 @@ module Sequencescape::Api::Rails
20
19
  end
21
20
  end
22
21
 
22
+ private
23
+
23
24
  def api_class
24
25
  ::Sequencescape::Api
25
26
  end
26
- private :api_class
27
27
 
28
28
  def configure_api
29
- @api = api_class.new({ cookie: cookies['WTSISignOn'] }.merge(api_connection_options))
29
+ @api = api_class.new(api_connection_options)
30
30
  end
31
- private :configure_api
32
31
 
33
32
  def api_connection_options
34
- {}
33
+ raise Sequencescape::Api::Error, "api_connection_options not implemented for #{self.class}"
35
34
  end
36
- private :api_connection_options
37
35
 
38
36
  def sequencescape_api_error_handler(exception)
39
37
  Rails.logger.error "#{exception}, #{exception.backtrace}"
40
38
  raise StandardError, "There is an issue with the API connection to Sequencescape (#{exception.message})"
41
39
  end
42
- private :sequencescape_api_error_handler
43
40
 
44
41
  def sequencescape_api_unauthenticated_handler(exception)
45
42
  Rails.logger.error "#{exception}, #{exception.backtrace}"
46
43
  raise StandardError, 'You are not authenticated; please visit the WTSI login page'
47
44
  end
48
- private :sequencescape_api_unauthenticated_handler
49
45
  end
50
46
 
51
47
  # Including this module into your Rails model indicates that the model is associated with
@@ -1,5 +1,5 @@
1
1
  module Sequencescape
2
2
  class Api
3
- VERSION = '0.4.2'.freeze
3
+ VERSION = '0.6.0-rc1'.freeze
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require 'sequencescape-api/resource'
2
2
 
3
3
  class Sequencescape::BarcodePrinter < Sequencescape::Api::Resource
4
- attribute_reader :name, :active
4
+ attribute_reader :name, :active, :print_service
5
5
 
6
6
  attribute_group :service do
7
7
  attribute_reader :url
@@ -9,5 +9,6 @@ class Sequencescape::Order < ::Sequencescape::Api::Resource
9
9
  # It does, but we don't care for now.
10
10
  # has_many :request_types
11
11
 
12
- attr_accessor :request_options
12
+ attribute_accessor :request_options
13
+ attribute_writer :autodetect_studies_projects
13
14
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = ''
11
11
  s.summary = 'Gem for the client side of the Sequencescape API'
12
12
  s.description = 'Provides all of the necessary code for interacting with the Sequencescape API'
13
+ s.required_ruby_version = '> 2.4'
13
14
 
14
15
  s.rubyforge_project = 'sequencescape-client-api'
15
16
 
@@ -18,16 +19,27 @@ Gem::Specification.new do |s|
18
19
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
20
  s.require_paths = ['lib']
20
21
 
22
+ s.post_install_message = <<~POST_INSTALL
23
+ sequencescape-client-api has dropped 'yajl-ruby' in favour of 'multi_json',
24
+ https://rubygems.org/gems/multi_json. This will automatically pick the
25
+ fastest json encoder in your Gemfile, falling back to the default encoder.
26
+
27
+ For best performance you are strongly encouraged to add a custom json
28
+ encoder to your project. eg. bundle install oj.
29
+ POST_INSTALL
30
+
21
31
  s.add_dependency('activemodel', '>= 5.0.0')
22
- s.add_dependency('activesupport', '>= 5.0.0')
32
+ s.add_dependency('activesupport', '>= 5.0.0', '< 6.1.0')
23
33
  s.add_dependency('i18n')
24
- s.add_dependency('yajl-ruby', '>= 1.4.1')
34
+ s.add_dependency('multi_json')
25
35
 
26
36
  s.add_development_dependency('pry')
27
37
  s.add_development_dependency('rake')
28
38
  s.add_development_dependency('redcarpet')
29
39
  s.add_development_dependency('rspec', '~> 2.11.0')
30
- s.add_development_dependency('rubocop', '~> 0.84.0')
40
+ s.add_development_dependency('rubocop', '~> 1.3.1')
31
41
  s.add_development_dependency('webmock')
32
42
  s.add_development_dependency('yard')
43
+ # Add a json encoder for development
44
+ s.add_development_dependency('oj')
33
45
  end
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /model_c/create HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  POST /UUID/model_bs HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_b": {
@@ -1,3 +1,3 @@
1
1
  GET /BELONGS_TO_UUID HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /UUID HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,3 +1,3 @@
1
1
  GET /pages/1 HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,3 +1,3 @@
1
1
  GET /pages/2 HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,3 +1,3 @@
1
1
  GET /pages/3 HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,5 +1,4 @@
1
1
  GET / HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
3
+ Cookie: api_key=single-sign-on-cookie
4
4
  X-Sequencescape-Client-Id: authorised!
5
-
@@ -1,4 +1,3 @@
1
1
  GET / HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /model_a HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /model_b HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,4 +1,3 @@
1
1
  GET /model_c HTTP/1.1
2
2
  Accept: application/json
3
- Cookie: WTSISignOn=single-sign-on-cookie
4
-
3
+ Cookie: api_key=single-sign-on-cookie
@@ -1,7 +1,7 @@
1
1
  PUT /UUID HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -1,7 +1,7 @@
1
1
  PUT /UUID HTTP/1.1
2
2
  Accept: application/json
3
3
  Content-Type: application/json
4
- Cookie: WTSISignOn=single-sign-on-cookie
4
+ Cookie: api_key=single-sign-on-cookie
5
5
 
6
6
  {
7
7
  "model_c": {
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe 'Handling authentication issues' do
6
6
  stub_request_from('retrieve-root-with-an-unauthorised-client') { response('client-fails-authentication') }
7
7
 
8
- subject { Sequencescape::Api.new(url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie') }
8
+ subject { Sequencescape::Api.new(url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie') }
9
9
 
10
10
  it 'raises an exception' do
11
11
  -> { subject }.should raise_error(Sequencescape::Api::UnauthenticatedError)
@@ -17,7 +17,7 @@ describe 'Retrieving the root URL' do
17
17
  is_working_as_an_unauthorised_client
18
18
 
19
19
  context 'with no namespace' do
20
- subject { Sequencescape::Api.new(url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie') }
20
+ subject { Sequencescape::Api.new(url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie') }
21
21
 
22
22
  Unauthorised::MODELS_THROUGH_API.each do |model|
23
23
  it "provides the #{model} through the API instance" do
@@ -25,7 +25,7 @@ describe 'Retrieving the root URL' do
25
25
  end
26
26
 
27
27
  it "errors because Sequencescape::#{model.to_s.classify} is not defined" do
28
- # Note: Using a regex as > Ruby 2.3 'DidYouMean' changes the error message slightly.
28
+ # NOTE: Using a regex as > Ruby 2.3 'DidYouMean' changes the error message slightly.
29
29
  lambda {
30
30
  subject.send(model.to_sym)
31
31
  }.should raise_error(NameError,
@@ -35,7 +35,7 @@ module ContractHelper
35
35
  @url = "http://localhost:3000#{match[:path]}"
36
36
  @conditions = {}
37
37
  @conditions[:headers] = Hash[*match[:headers].split(/\r?\n/).map { |l| l.split(':') }.flatten.map(&:strip)]
38
- @conditions[:body] = Yajl::Encoder.encode(Yajl::Parser.parse(match[:body])) unless match[:body].blank?
38
+ @conditions[:body] = MultiJson.dump(MultiJson.load(match[:body])) unless match[:body].blank?
39
39
  end
40
40
  end
41
41
 
@@ -96,7 +96,7 @@ module ContractHelper
96
96
  end
97
97
  let(:api) do
98
98
  Sequencescape::Api.new(
99
- url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie',
99
+ url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie',
100
100
  namespace: Unauthorised
101
101
  )
102
102
  end
@@ -107,7 +107,7 @@ module ContractHelper
107
107
 
108
108
  let(:api) do
109
109
  Sequencescape::Api.new(
110
- url: 'http://localhost:3000/', cookie: 'single-sign-on-cookie',
110
+ url: 'http://localhost:3000/', user_api_key: 'single-sign-on-cookie',
111
111
  authorisation: 'authorised!', namespace: Authenticated
112
112
  )
113
113
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequencescape-client-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.6.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Denner
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-09-24 00:00:00.000000000 Z
13
+ date: 2021-07-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
@@ -33,6 +33,9 @@ dependencies:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: 5.0.0
36
+ - - "<"
37
+ - !ruby/object:Gem::Version
38
+ version: 6.1.0
36
39
  type: :runtime
37
40
  prerelease: false
38
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -40,6 +43,9 @@ dependencies:
40
43
  - - ">="
41
44
  - !ruby/object:Gem::Version
42
45
  version: 5.0.0
46
+ - - "<"
47
+ - !ruby/object:Gem::Version
48
+ version: 6.1.0
43
49
  - !ruby/object:Gem::Dependency
44
50
  name: i18n
45
51
  requirement: !ruby/object:Gem::Requirement
@@ -55,19 +61,19 @@ dependencies:
55
61
  - !ruby/object:Gem::Version
56
62
  version: '0'
57
63
  - !ruby/object:Gem::Dependency
58
- name: yajl-ruby
64
+ name: multi_json
59
65
  requirement: !ruby/object:Gem::Requirement
60
66
  requirements:
61
67
  - - ">="
62
68
  - !ruby/object:Gem::Version
63
- version: 1.4.1
69
+ version: '0'
64
70
  type: :runtime
65
71
  prerelease: false
66
72
  version_requirements: !ruby/object:Gem::Requirement
67
73
  requirements:
68
74
  - - ">="
69
75
  - !ruby/object:Gem::Version
70
- version: 1.4.1
76
+ version: '0'
71
77
  - !ruby/object:Gem::Dependency
72
78
  name: pry
73
79
  requirement: !ruby/object:Gem::Requirement
@@ -130,14 +136,14 @@ dependencies:
130
136
  requirements:
131
137
  - - "~>"
132
138
  - !ruby/object:Gem::Version
133
- version: 0.84.0
139
+ version: 1.3.1
134
140
  type: :development
135
141
  prerelease: false
136
142
  version_requirements: !ruby/object:Gem::Requirement
137
143
  requirements:
138
144
  - - "~>"
139
145
  - !ruby/object:Gem::Version
140
- version: 0.84.0
146
+ version: 1.3.1
141
147
  - !ruby/object:Gem::Dependency
142
148
  name: webmock
143
149
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +172,20 @@ dependencies:
166
172
  - - ">="
167
173
  - !ruby/object:Gem::Version
168
174
  version: '0'
175
+ - !ruby/object:Gem::Dependency
176
+ name: oj
177
+ requirement: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
169
189
  description: Provides all of the necessary code for interacting with the Sequencescape
170
190
  API
171
191
  email:
@@ -176,6 +196,7 @@ executables: []
176
196
  extensions: []
177
197
  extra_rdoc_files: []
178
198
  files:
199
+ - ".github/workflows/ruby.yml"
179
200
  - ".gitignore"
180
201
  - ".rspec"
181
202
  - ".rubocop.yml"
@@ -493,23 +514,28 @@ files:
493
514
  homepage: ''
494
515
  licenses: []
495
516
  metadata: {}
496
- post_install_message:
517
+ post_install_message: |
518
+ sequencescape-client-api has dropped 'yajl-ruby' in favour of 'multi_json',
519
+ https://rubygems.org/gems/multi_json. This will automatically pick the
520
+ fastest json encoder in your Gemfile, falling back to the default encoder.
521
+
522
+ For best performance you are strongly encouraged to add a custom json
523
+ encoder to your project. eg. bundle install oj.
497
524
  rdoc_options: []
498
525
  require_paths:
499
526
  - lib
500
527
  required_ruby_version: !ruby/object:Gem::Requirement
501
528
  requirements:
502
- - - ">="
529
+ - - ">"
503
530
  - !ruby/object:Gem::Version
504
- version: '0'
531
+ version: '2.4'
505
532
  required_rubygems_version: !ruby/object:Gem::Requirement
506
533
  requirements:
507
- - - ">="
534
+ - - ">"
508
535
  - !ruby/object:Gem::Version
509
- version: '0'
536
+ version: 1.3.1
510
537
  requirements: []
511
- rubyforge_project: sequencescape-client-api
512
- rubygems_version: 2.7.6.2
538
+ rubygems_version: 3.1.4
513
539
  signing_key:
514
540
  specification_version: 4
515
541
  summary: Gem for the client side of the Sequencescape API