ac 0.2.0 → 0.2.2

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ac/base.rb +15 -5
  3. data/lib/ac/version.rb +1 -1
  4. metadata +3 -8
  5. data/ac.gemspec +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 960345a74ffe3f55bdcab63d0b51fc85ec644fdf35683e6d69681d9222b51a8d
4
- data.tar.gz: e2739c2fcb68de9b8410600ca609d754468de441036cdc20b04376d0a5382a17
3
+ metadata.gz: 643c497232d37751e8f24f1e429e4da6de134fe5fb8c9ee7a553a72e96afc511
4
+ data.tar.gz: 887dab256a947fb6ec90be7e63814832d4b868f6873ff13d64944969391d4d51
5
5
  SHA512:
6
- metadata.gz: cfa8a6ad1595b35423a4dd8ec789215da4174ba566d19b1891bfd6eebfbf90f29089535614c523b036379d675f77cd9f822d15429eaac205870388c1b6cb2e9b
7
- data.tar.gz: 9bcfb7690f54a7d066b22af14cef02547fadaa11166a0d4f3a0e6490556f03628593e2e9ca764965fd447d4d68782e8a03e13273c128707be5f39195b0cb5972
6
+ metadata.gz: bda3634f53042d6d31d4cae8191b0f31f87fbd00553cb67b60e0fd806e02487b8ff26ff85d5860050c0af66b6738d55864acfa1dd0c94881eb56b2fc8f106255
7
+ data.tar.gz: 956b86c314638bc2d577716622c25c1dbebc8741603c6e3c029e21d989f93a0439ae68cba1d307997a46f89337276f9f691254d84d2dfd8c54e96b2aac1f9253
data/lib/ac/base.rb CHANGED
@@ -9,16 +9,24 @@ module Ac
9
9
  end
10
10
 
11
11
  def url path
12
- File.join(self.class::BASE_URL, path)
12
+ if path.start_with?("http://") || path.start_with?("https://")
13
+ path
14
+ else
15
+ File.join(self.class::BASE_URL, path)
16
+ end
13
17
  end
14
18
 
19
+ def authenticate! options
20
+ if access_token
21
+ options[:headers] ||= {}
22
+ options[:headers]["Authorization"] = "Bearer #{access_token}"
23
+ end
24
+ end
25
+
15
26
  %i[get post put patch delete].each do |http_verb|
16
27
  define_method :"#{http_verb}_request" do |path, options = {}|
17
28
  options[:method] = http_verb
18
- if access_token
19
- options[:headers] ||= {}
20
- options[:headers]["Authorization"] = "Bearer #{access_token}"
21
- end
29
+ authenticate!(options) unless options.delete(:skip_authentication)
22
30
  Typhoeus::Request.new url(path), options
23
31
  end
24
32
 
@@ -38,6 +46,8 @@ module Ac
38
46
  sleep(2**retries_count) # Exponential backoff
39
47
  redo
40
48
  end
49
+ elsif self.class::SAVE_RESPONSES
50
+ Database.save_request response, class_name: self.class.name
41
51
  end
42
52
 
43
53
  response
data/lib/ac/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ac
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - felipedmesquita
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-10-25 00:00:00.000000000 Z
10
+ date: 2025-03-06 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: typhoeus
@@ -24,7 +23,6 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
27
- description:
28
26
  email:
29
27
  - 16197684+felipedmesquita@users.noreply.github.com
30
28
  executables: []
@@ -35,7 +33,6 @@ files:
35
33
  - LICENSE.txt
36
34
  - README.md
37
35
  - Rakefile
38
- - ac.gemspec
39
36
  - lib/ac.rb
40
37
  - lib/ac/base.rb
41
38
  - lib/ac/database.rb
@@ -47,7 +44,6 @@ licenses:
47
44
  metadata:
48
45
  homepage_uri: https://github.com/felipedmesquita/ac
49
46
  source_code_uri: https://github.com/felipedmesquita/ac
50
- post_install_message:
51
47
  rdoc_options: []
52
48
  require_paths:
53
49
  - lib
@@ -62,8 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
58
  - !ruby/object:Gem::Version
63
59
  version: '0'
64
60
  requirements: []
65
- rubygems_version: 3.4.10
66
- signing_key:
61
+ rubygems_version: 3.6.2
67
62
  specification_version: 4
68
63
  summary: Api Client for Typhoeus
69
64
  test_files: []
data/ac.gemspec DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/ac/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "ac"
7
- spec.version = Ac::VERSION
8
- spec.authors = ["felipedmesquita"]
9
- spec.email = ["16197684+felipedmesquita@users.noreply.github.com"]
10
-
11
- spec.summary = "Api Client for Typhoeus"
12
- spec.homepage = "https://github.com/felipedmesquita/ac"
13
- spec.license = "MIT"
14
-
15
- spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = "https://github.com/felipedmesquita/ac"
17
-
18
- # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(__dir__) do
21
- `git ls-files -z`.split("\x0").reject do |f|
22
- (File.expand_path(f) == __FILE__) ||
23
- f.start_with?(*%w[bin/ mini_mock/ test/ spec/ features/ .git .circleci appveyor Gemfile])
24
- end
25
- end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
29
-
30
- # Uncomment to register a new dependency of your gem
31
- spec.add_dependency "typhoeus"
32
-
33
- # For more information and examples about making a new gem, check out our
34
- # guide at: https://bundler.io/guides/creating_gem.html
35
- end