swiftner 0.0.4 → 0.0.5

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: df81ce74f315ba2773be31747e089c77e955415362d0de93c6f0ac5e2d844086
4
- data.tar.gz: 91ef8ff69dc8e7d8aa987d0296a45a04c02e3dc35c7466dbc2b872bf8345d43e
3
+ metadata.gz: fcaad19a345368e1cd1c8660d53bcab7a8f5152c59221e335bf9c8057f17fbd1
4
+ data.tar.gz: d1b40c55191e99e2326aac0850bc342f0eadde486f69c772a0fc828d9ad2c3e0
5
5
  SHA512:
6
- metadata.gz: a530d61cdf3023d1c9df3881ce151e346b15480f5b7ff067d69801cfc07597047d7b5985cc991e72b93a8ed7a6e33408687dbc324bc5ccc0ce4f316a1d915434
7
- data.tar.gz: 244fd82157219579145a47d20f21734b77923b5ad88b0dd725f85ea37c371f588dd510b48cf8fc259c0d2ed0be89d9e8f1dd3d3a848bf746b6dff11669eb1f4a
6
+ metadata.gz: e847384adbdb29330517d383c310085b8fc34b3e47f9b4fddcba6d12c08dca276128eaa65e1fabc9d7149adeeeee5ac4ddf80ff9f5770a86862a190b3d37b2a3
7
+ data.tar.gz: b74036ad768d3faa6c90d5564ef246153a01736785174cc2393410cb65559de4dbe41b35718313b85b27e50bcc81a3713c1f0f436cdf7f9730a9b3e8f1ac8726
@@ -30,11 +30,11 @@ module Swiftner
30
30
  def handle_response(response)
31
31
  case response.code
32
32
  when 200 then response
33
- when 401 then raise Unauthorized
34
- when 403 then raise Forbidden
35
- when 404 then raise NotFound
36
- when 500 then raise InternalError
37
- else raise Error, "Unknown error occurred"
33
+ when 401 then raise Unauthorized.from_response(response)
34
+ when 403 then raise Forbidden.from_response(response)
35
+ when 404 then raise NotFound.from_response(response)
36
+ when 500 then raise InternalError.from_response(response)
37
+ else raise Error.new("Unknown error occurred", response: response)
38
38
  end
39
39
  end
40
40
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Swiftner
4
+ # Encapsulates all errors that can be raised by the Swiftner API
5
+ class Error < StandardError
6
+ attr_reader :response
7
+
8
+ def self.from_response(response)
9
+ return new(response["detail"], response: response) if response.key?("detail")
10
+
11
+ new(response.to_s, response: response)
12
+ end
13
+
14
+ def initialize(message, response: nil)
15
+ @response = response
16
+ super(message)
17
+ end
18
+ end
19
+
20
+ class Forbidden < Error; end
21
+ class Unauthorized < Error; end
22
+ class NotFound < Error; end
23
+ class InternalError < Error; end
24
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Swiftner
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
data/lib/swiftner.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "swiftner/error"
3
4
  require_relative "swiftner/API/service"
4
5
  require_relative "swiftner/API/space"
5
6
  require_relative "swiftner/API/transcription"
@@ -12,12 +13,6 @@ require_relative "swiftner/version"
12
13
 
13
14
  ### Swiftner
14
15
  module Swiftner
15
- class Error < StandardError; end
16
- class Forbidden < Error; end
17
- class Unauthorized < Error; end
18
- class NotFound < Error; end
19
- class InternalError < Error; end
20
-
21
16
  class << self
22
17
  attr_accessor :configuration
23
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiftner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Ulleberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-04 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -46,8 +46,8 @@ files:
46
46
  - lib/swiftner/API/video_content.rb
47
47
  - lib/swiftner/client.rb
48
48
  - lib/swiftner/configuration.rb
49
+ - lib/swiftner/error.rb
49
50
  - lib/swiftner/version.rb
50
- - swiftner.gemspec
51
51
  homepage: https://swiftner.com
52
52
  licenses: []
53
53
  metadata:
@@ -55,7 +55,7 @@ metadata:
55
55
  source_code_uri: https://github.com/swiftner/swiftner_ruby
56
56
  changelog_uri: https://github.com/swiftner/swiftner_ruby/blob/main/CHANGELOG.md
57
57
  rubygems_mfa_required: 'true'
58
- post_install_message:
58
+ post_install_message:
59
59
  rdoc_options: []
60
60
  require_paths:
61
61
  - lib
@@ -70,8 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.5.3
74
- signing_key:
73
+ rubygems_version: 3.5.5
74
+ signing_key:
75
75
  specification_version: 4
76
76
  summary: API wrapper for Swiftner's AI transcription service.
77
77
  test_files: []
data/swiftner.gemspec DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/swiftner/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "swiftner"
7
- spec.version = Swiftner::VERSION
8
- spec.authors = ["Martin Ulleberg"]
9
- spec.email = ["martin.ulleberg@gmail.com"]
10
-
11
- spec.summary = "API wrapper for Swiftner's AI transcription service."
12
- spec.description = "This gem provides an easy-to-use interface for Swiftner's API, allowing seamless integration of\
13
- AI-driven transcription services into your Ruby applications."
14
- spec.homepage = "https://swiftner.com"
15
- spec.required_ruby_version = ">= 3.0.0"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/swiftner/swiftner_ruby"
19
- spec.metadata["changelog_uri"] = "https://github.com/swiftner/swiftner_ruby/blob/main/CHANGELOG.md"
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(__dir__) do
24
- `git ls-files -z`.split("\x0").reject do |f|
25
- (File.expand_path(f) == __FILE__) ||
26
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
27
- end
28
- end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- spec.add_dependency "httparty", "~> 0.21"
34
- # Uncomment to register a new dependency of your gem
35
- # spec.add_dependency "example-gem", "~> 1.0"
36
-
37
- # For more information and examples about making a new gem, check out our
38
- # guide at: https://bundler.io/guides/creating_gem.html
39
- spec.metadata["rubygems_mfa_required"] = "true"
40
- end