bearcat 1.5.16 → 1.5.19

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: 324dde5c220114f2d0063c41f60f3ef41a6089b7897b2928a9dae39a059bfd6e
4
- data.tar.gz: bee480f7c40c3203af87c5fc7e228023688b86731936b5f8dfba3c92811493c7
3
+ metadata.gz: 349200e5b396d03d325a41b8005a62d3dd9f84011bffd24f7a0cdc7a27938d23
4
+ data.tar.gz: b9a4ffe170514f6d1c65d296ebacc7098fcfd85502be6621941edc91e5dde69f
5
5
  SHA512:
6
- metadata.gz: c291702f4ae7f572b629aab42fdc89fe5a2f43a0477c2ea80cff472fa92215b00e4f2d25820a82822b89a820cbe96c1a96e68772e33ce24fb5275f113a2ea575
7
- data.tar.gz: 7fe6d25e2c7b5812983f67adb6ffbaa00f9c2567426dbf3c5fae95c55c4521fc835f686a4e484dd8700769d7cf3eec0c8e697b881773b182c911c8ef0e5bd44b
6
+ metadata.gz: 6da4c3b3c8cc79ae6ef026dd964360af049ab19c6cb6f9b4000a58b6c91cef80a0f9982482f63aa49317eace561a932e555f0508c73625e142003145a1da0dfc
7
+ data.tar.gz: f7d9050559136046b95ea62aff119048842b92adfb000e1c043f4ee3b9607bbd4cfc232e6e06bc3c1fc6032cd0946f40b79c9692c1fa354cb5a0f6aa6482a53e
@@ -45,8 +45,12 @@ module Bearcat
45
45
  raw_response.env[:method]
46
46
  end
47
47
 
48
- def [](i)
49
- @members[i]
48
+ def [](key)
49
+ if key.is_a?(Numeric)
50
+ @members[key]
51
+ else
52
+ @raw_response.body[key]
53
+ end
50
54
  end
51
55
 
52
56
  def last
@@ -127,8 +131,8 @@ module Bearcat
127
131
  end
128
132
  end
129
133
 
130
- def get_page(url, params = {})
131
- params['per_page'] = @page_count unless params.key?('per_page') || !@page_count
134
+ def get_page(url, params = {}, page_size_param: 'per_page')
135
+ params[page_size_param] = @page_count unless params.key?(page_size_param) || !@page_count
132
136
 
133
137
  parsed_url = URI.parse(url)
134
138
  p = parse_url_params(parsed_url)
@@ -202,11 +206,19 @@ module Bearcat
202
206
  end
203
207
 
204
208
  def process_body(response)
205
- if response.body.is_a?(Array)
206
- self.class.make_indifferent(response.body)
207
- elsif response.body.is_a?(Hash) && @array_key
208
- self.class.make_indifferent(response.body[@array_key])
209
+ data = response.body
210
+ if @array_key.is_a?(Proc)
211
+ data = @array_key.call(data, response)
212
+ elsif @array_key.present?
213
+ ak = @array_key
214
+ ak = ak.split('.') if ak.is_a?(String)
215
+ ak = Array(ak)
216
+ data = data.dig(*ak)
209
217
  end
218
+
219
+ raise "Response could not be mapped to items" unless data.is_a?(Array)
220
+
221
+ self.class.make_indifferent(data)
210
222
  end
211
223
  end
212
224
  end
@@ -93,7 +93,7 @@ module Bearcat
93
93
  val = val.id if val.respond_to?(:id)
94
94
  val = val['id'].presence || val[:id].presence || val if val.is_a?(Hash)
95
95
  val = val.to_s if val.present?
96
- val = URI.encode_uri_component(val) if val.is_a?(String)
96
+ val = URI.encode_www_form_component(val) if val.is_a?(String)
97
97
  val
98
98
  end
99
99
  end
@@ -1,3 +1,3 @@
1
1
  module Bearcat
2
- VERSION = '1.5.16' unless defined?(Bearcat::VERSION)
2
+ VERSION = '1.5.19' unless defined?(Bearcat::VERSION)
3
3
  end
data/lib/bearcat.rb CHANGED
@@ -4,8 +4,9 @@ require 'bearcat/client'
4
4
  module Bearcat
5
5
  class << self
6
6
  require 'logger'
7
+ attr_accessor :master_rate_limit
7
8
  attr_writer :rate_limit_min, :rate_limits, :max_sleep_seconds,
8
- :min_sleep_seconds, :logger, :master_rate_limit, :rate_limiter
9
+ :min_sleep_seconds, :logger, :rate_limiter
9
10
 
10
11
  def configure
11
12
  yield self if block_given?
@@ -27,11 +28,6 @@ module Bearcat
27
28
  @max_sleep_seconds ||= 60
28
29
  end
29
30
 
30
- # @deprecated
31
- def master_rate_limit
32
- @master_rate_limit ||= false
33
- end
34
-
35
31
  def logger
36
32
  return @logger if defined? @logger
37
33
  @logger = Logger.new(STDOUT)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bearcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.16
4
+ version: 1.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure CustomDev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-19 00:00:00.000000000 Z
11
+ date: 2024-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake