swiftner 0.0.2 → 0.0.3

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: 2012383224b63c20920e314f1f475b3ceefc371b6ffb304b4bab51a8ae2cd8e5
4
- data.tar.gz: 38a3b6e70c2387d6f71992e95c45e22d003f0c4a5772e5fa3cfa18076dd21e42
3
+ metadata.gz: 0bccfb7a6a850c917d592bd4dbfaf84ed83f167443056642653e151e029c10e0
4
+ data.tar.gz: a8d9567709a73226085a560cb1ada880075067407276002eec0584e908520f47
5
5
  SHA512:
6
- metadata.gz: 3014179290cf659595aaa9d44be639e44c6be0a88ace20146dc8f0069200355aad675252604022f57e0fba793a927d1ae94e242eedc2ce099dd2a00532b56e2e
7
- data.tar.gz: ad51894f768e7bdfccc9f1079e4337b67a17f56993bd20fd228623e1c149fbe104781c7e44055915ef5f9a583228cab3e4bd3262686a1ca2dcc9b6c139b919c1
6
+ metadata.gz: 42390d0d4f6bc5b6ee40a91deaeafc27c78c17fb2c4bd5663d91338dc376c5f22dfd818759cc9a627e8e3a1c7dded5a40b411baaae93faf124daa6c3a44f3620
7
+ data.tar.gz: 89f9c9ceab9e07ad7884fadb389830b5ff2f8cc36d9eda4898c17366fc8a1433179f956f79961c7b808bd644b8d688618e06b0147567ccafaa3d5e2bf37ec690
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.0
3
3
  NewCops: enable
4
4
 
5
5
  Style/StringLiterals:
data/README.md CHANGED
@@ -25,8 +25,11 @@ This section includes syntax examples of some of the key features of the Swiftne
25
25
 
26
26
  ### Initializing the Client
27
27
  ```ruby
28
- @api_key = "swiftner_api_key"
29
- @client = Swiftner::Client.new(@api_key)
28
+ api_key = "swiftner_api_key"
29
+
30
+ Swiftner.configure do |config|
31
+ config.client = Swiftner::Client.new(api_key)
32
+ end
30
33
  ```
31
34
 
32
35
  ### Working with Video Content
@@ -10,7 +10,13 @@ module Swiftner
10
10
  new(details)
11
11
  end
12
12
 
13
- def initialize(attributes = {}, client = Base.client)
13
+ def self.client
14
+ Swiftner.configuration.client
15
+ end
16
+
17
+ def initialize(attributes = {}, client = self.class.client)
18
+ raise Swiftner::Error, "Client must be set" if client.nil?
19
+
14
20
  @id = attributes["id"]
15
21
  @details = attributes
16
22
  @client = client
@@ -7,12 +7,12 @@ module Swiftner
7
7
  # Provides methods for interacting with transcriptions.
8
8
  class Transcription < Service
9
9
  def self.find(transcription_id)
10
- response = Base.client.get("/transcription/get/#{transcription_id}")
10
+ response = client.get("/transcription/get/#{transcription_id}")
11
11
  build(response.parsed_response)
12
12
  end
13
13
 
14
14
  def self.create(attributes)
15
- response = Base.client.post(
15
+ response = client.post(
16
16
  "/transcription/create",
17
17
  body: attributes.to_json,
18
18
  headers: { "Content-Type" => "application/json" }
@@ -7,17 +7,17 @@ module Swiftner
7
7
  # to an upload.
8
8
  class Upload < Service
9
9
  def self.find_uploads
10
- response = Base.client.get("/upload/get-uploads/")
10
+ response = client.get("/upload/get-uploads/")
11
11
  response.map { |upload| build(upload) }
12
12
  end
13
13
 
14
14
  def self.find(upload_id)
15
- response = Base.client.get("/upload/get/#{upload_id}")
15
+ response = client.get("/upload/get/#{upload_id}")
16
16
  build(response.parsed_response)
17
17
  end
18
18
 
19
19
  def self.create(attributes)
20
- response = Base.client.post(
20
+ response = client.post(
21
21
  "/upload/create",
22
22
  body: attributes.to_json,
23
23
  headers: { "Content-Type" => "application/json" }
@@ -6,12 +6,12 @@ module Swiftner
6
6
  # It allows you to find and update video content.
7
7
  class VideoContent < Service
8
8
  def self.find_video_contents
9
- response = Base.client.get("/video-content/get-all/")
9
+ response = client.get("/video-content/get-all/")
10
10
  response.map { |upload| build(upload) }
11
11
  end
12
12
 
13
13
  def self.find(id)
14
- response = Base.client.get("/video-content/get/#{id}")
14
+ response = client.get("/video-content/get/#{id}")
15
15
  build(response.parsed_response)
16
16
  end
17
17
 
@@ -16,7 +16,7 @@ module Swiftner
16
16
 
17
17
  %i[get post put delete].each do |http_method|
18
18
  define_method(http_method) do |path, options = {}|
19
- response = self.class.public_send(http_method, build_path(path), options)
19
+ response = self.class.public_send(http_method, path, options)
20
20
  handle_response(response)
21
21
  end
22
22
  end
@@ -27,11 +27,6 @@ module Swiftner
27
27
 
28
28
  private
29
29
 
30
- def build_path(path)
31
- # This is temporary solution because server doesn't accept the API Key in headers for some reason.
32
- "#{path}?api_key_query=#{ENV.fetch("SWIFTNER_API_KEY", "swiftner-api-key")}"
33
- end
34
-
35
30
  def handle_response(response)
36
31
  case response.code
37
32
  when 200 then response
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Swiftner
4
+ ## `Swiftner::Configuration`
5
+ class Configuration
6
+ attr_accessor :client
7
+
8
+ def initialize
9
+ @client = nil
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Swiftner
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
data/lib/swiftner.rb CHANGED
@@ -4,7 +4,7 @@ require_relative "swiftner/API/service"
4
4
  require_relative "swiftner/API/transcription"
5
5
  require_relative "swiftner/API/upload"
6
6
  require_relative "swiftner/API/video_content"
7
- require_relative "swiftner/base"
7
+ require_relative "swiftner/configuration"
8
8
  require_relative "swiftner/client"
9
9
  require_relative "swiftner/version"
10
10
 
@@ -16,7 +16,12 @@ module Swiftner
16
16
  class NotFound < Error; end
17
17
  class InternalError < Error; end
18
18
 
19
- def self.create_client(api_key)
20
- Base.client = Client.new(api_key)
19
+ class << self
20
+ attr_accessor :configuration
21
+ end
22
+
23
+ def self.configure
24
+ self.configuration ||= Configuration.new
25
+ yield(configuration)
21
26
  end
22
27
  end
data/swiftner.gemspec ADDED
@@ -0,0 +1,40 @@
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
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Ulleberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-13 00:00:00.000000000 Z
11
+ date: 2024-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -42,9 +42,10 @@ files:
42
42
  - lib/swiftner/API/transcription.rb
43
43
  - lib/swiftner/API/upload.rb
44
44
  - lib/swiftner/API/video_content.rb
45
- - lib/swiftner/base.rb
46
45
  - lib/swiftner/client.rb
46
+ - lib/swiftner/configuration.rb
47
47
  - lib/swiftner/version.rb
48
+ - swiftner.gemspec
48
49
  homepage: https://swiftner.com
49
50
  licenses: []
50
51
  metadata:
@@ -60,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
61
  requirements:
61
62
  - - ">="
62
63
  - !ruby/object:Gem::Version
63
- version: 2.6.0
64
+ version: 3.0.0
64
65
  required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  requirements:
66
67
  - - ">="
data/lib/swiftner/base.rb DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Swiftner
4
- ## `Swiftner::Base`
5
- class Base
6
- @client = nil
7
-
8
- class << self
9
- attr_accessor :client
10
- end
11
- end
12
- end