bearcat 1.5.17 → 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: 59e70293b595a084b1363c9c48ffb7793d014423631a90e6d6b60d3d01713345
4
- data.tar.gz: f7c2b6d41a19705775b612ae46c1aa5f721292333bac11837b2e0eb335268514
3
+ metadata.gz: 349200e5b396d03d325a41b8005a62d3dd9f84011bffd24f7a0cdc7a27938d23
4
+ data.tar.gz: b9a4ffe170514f6d1c65d296ebacc7098fcfd85502be6621941edc91e5dde69f
5
5
  SHA512:
6
- metadata.gz: 756f383a0ab2e6dbfff9ea9edca26d0535ad6827889b2cc9bfa80bcd54176e193364cc3edfc1f457fc605ed9ce6c549b548e08bd9ea07d5904efac17b9a7c2ba
7
- data.tar.gz: b5fa413a40f6593c414879f2ccf3354b8a2aa0dd8cf54b5ef035ecace5fd15a15049f4dc0a136729e2c516932037912d355d8bc75482ab66dd1f42eec2e50eb1
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
@@ -1,3 +1,3 @@
1
1
  module Bearcat
2
- VERSION = '1.5.17' 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.17
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-25 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