scorpio 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d6cc227b5ff884c520333ce9f3fd11f864dd8c58d1978a593195d98a63d61a1
4
- data.tar.gz: e514788a47ac0ff2be11ae8fa926b5a5534156aa60e82c9afc71bfb842c419e5
3
+ metadata.gz: fb674493cc2557d4679ac5eb54e8734251cddd9005410ad6f5a2c5f1db662380
4
+ data.tar.gz: 1bd8308607be18331a71be7cd74627b0138aad7b6d575c887ec4f9d05d263e5c
5
5
  SHA512:
6
- metadata.gz: 1035f4e7181d230cfc455cdfa2ce71f62d511b859134fae21661261e5793f0b09e03f16c4ce588f27ff9abb2d882013a1b677ea476c41f9b0e425abdb850a63e
7
- data.tar.gz: 411ed1f50c74cc73f053146ece609452bf84a250d93a1874a33df0c0dc20088df06ee4446e8070be8d75dfad397b8437370794dc20f26763460fefda86490747
6
+ metadata.gz: e81ef200e242f7cc3a616e628bf3eaa68029effbeb0c25c7f76d2e0760e7493b2d57a3b04be492c2f674b51453c2d92a015099dbc6ed9d82a3bc478e27bd6630
7
+ data.tar.gz: 17f680366d8e6c8ef67d8755a643fdaea7ad9b4fbb4e6d86b3d603df92628fc450353b26f11a86d27b2317d0609bd36f743be22b56c7547630c2b815928f27fb
@@ -1,3 +1,6 @@
1
+ # v0.3.1
2
+ - miscellaneous minor fixes and improvements
3
+
1
4
  # v0.3.0
2
5
  - OpenAPI v3 support
3
6
  - classes Request/Response, OpenAPI::Operation, OpenAPI::Document handle a request. ResourceBase relies on these.
@@ -3,7 +3,8 @@
3
3
  require 'pathname'
4
4
  require 'json'
5
5
  require 'yaml'
6
- Pathname.glob('documents/**/*').select { |p| p.file? && !['.yml', '.yaml'].include?(p.extname) }.each do |file|
6
+
7
+ Pathname.glob(Pathname.new(__FILE__).dirname.join('../documents/**/*')).select { |p| p.file? && !['.yml', '.yaml'].include?(p.extname) }.each do |file|
7
8
  begin
8
9
  json_contents = JSON.parse(file.read)
9
10
  yaml = YAML.dump(json_contents, line_width: -1)
@@ -1,6 +1,8 @@
1
1
  require "scorpio/version"
2
2
  require "jsi"
3
3
  require "ur"
4
+ require "addressable"
5
+ require "faraday"
4
6
  require "pathname"
5
7
  require "pp"
6
8
 
@@ -19,7 +21,7 @@ module Scorpio
19
21
  proc { |v| define_singleton_method(:error_classes_by_status) { v } }.call({})
20
22
  class Error < StandardError; end
21
23
  class HTTPError < Error
22
- define_singleton_method(:status) do |status = nil|
24
+ def self.status(status = nil)
23
25
  if status
24
26
  @status = status
25
27
  Scorpio.error_classes_by_status[status] = self
@@ -192,11 +192,13 @@ module Scorpio
192
192
  JSI.class_for_schema(request_schema(media_type: media_type))
193
193
  end
194
194
 
195
- def faraday_connection(yield_ur)
195
+ def faraday_connection(yield_ur = nil)
196
196
  Faraday.new do |faraday_connection|
197
197
  faraday_builder.call(faraday_connection)
198
- ::Ur::Faraday # autoload trigger
199
- faraday_connection.response(:yield_ur, ur_class: Scorpio::Ur, logger: self.logger, &yield_ur)
198
+ if yield_ur
199
+ ::Ur::Faraday # autoload trigger
200
+ faraday_connection.response(:yield_ur, ur_class: Scorpio::Ur, logger: self.logger, &yield_ur)
201
+ end
200
202
  faraday_connection.adapter(*faraday_adapter)
201
203
  end
202
204
  end
@@ -1,6 +1,3 @@
1
- require 'addressable/template'
2
- require 'faraday'
3
-
4
1
  module Scorpio
5
2
  # see also Faraday::Env::MethodsWithBodies
6
3
  METHODS_WITH_BODIES = %w(post put patch options)
@@ -150,8 +147,10 @@ module Scorpio
150
147
  rescue NameError
151
148
  end
152
149
  define_singleton_method(:tag_name) { tag_name }
153
- define_singleton_method(:tag_name=) do |_|
154
- raise(ArgumentError, "tag_name may not be overridden. it is been set to #{tag_name.inspect}")
150
+ define_singleton_method(:tag_name=) do |tag_name|
151
+ unless tag_name == self.tag_name
152
+ raise(ArgumentError, "tag_name may not be overridden (to #{tag_name.inspect}). it is been set to #{self.tag_name.inspect}")
153
+ end
155
154
  end
156
155
  update_dynamic_methods
157
156
  end
@@ -2,15 +2,6 @@ module Scorpio
2
2
  class Ur < ::Ur
3
3
  attr_accessor :scorpio_request
4
4
 
5
- def class_for_schema(schema)
6
- jsi_class_for_schema = super
7
- if jsi_class_for_schema == ::Ur::Response
8
- Scorpio::Response
9
- else
10
- jsi_class_for_schema
11
- end
12
- end
13
-
14
5
  def raise_on_http_error
15
6
  error_class = Scorpio.error_classes_by_status[response.status]
16
7
  error_class ||= if (400..499).include?(response.status)
@@ -21,7 +12,7 @@ module Scorpio
21
12
  HTTPError
22
13
  end
23
14
  if error_class
24
- message = "Error calling operation #{scorpio_request.operation.operationId} on #{self}:\n" + response.body
15
+ message = "Error calling operation #{scorpio_request.operation.operationId}:\n" + response.body
25
16
  raise(error_class.new(message).tap do |e|
26
17
  e.ur = self
27
18
  e.response_object = response.body_object
@@ -29,5 +20,15 @@ module Scorpio
29
20
  end
30
21
  nil
31
22
  end
23
+
24
+ private
25
+ def class_for_schema(schema)
26
+ jsi_class_for_schema = super
27
+ if jsi_class_for_schema == ::Ur::Response
28
+ Scorpio::Response
29
+ else
30
+ jsi_class_for_schema
31
+ end
32
+ end
32
33
  end
33
34
  end
@@ -1,3 +1,3 @@
1
1
  module Scorpio
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "rack-test"
34
34
  spec.add_development_dependency "api_hammer"
35
35
  spec.add_development_dependency "activerecord"
36
- spec.add_development_dependency "sqlite3"
36
+ spec.add_development_dependency "sqlite3", "~> 1.3.6" # loosen this in accordance with active_record/connection_adapters/sqlite3_adapter.rb
37
37
  spec.add_development_dependency "database_cleaner"
38
38
  spec.add_development_dependency "simplecov"
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scorpio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2019-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsi
@@ -196,16 +196,16 @@ dependencies:
196
196
  name: sqlite3
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">="
199
+ - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '0'
201
+ version: 1.3.6
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">="
206
+ - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '0'
208
+ version: 1.3.6
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: database_cleaner
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -287,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
287
  version: '0'
288
288
  requirements: []
289
289
  rubyforge_project:
290
- rubygems_version: 2.7.7
290
+ rubygems_version: 2.7.8
291
291
  signing_key:
292
292
  specification_version: 4
293
293
  summary: Scorpio REST client