vimaly 1.1.1 → 1.2.0

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: 24a7563b37e94b8774a431498191ea44c158f630b84f1effda7a5dea0b4380c4
4
- data.tar.gz: 0eea178740c3bff79d23b16d6b69e7e283eebee640acef16a1d260c2c62486ef
3
+ metadata.gz: 7e67a18552b8d4a3c3bf527a2bb4fb859a15b8c59e0fded3fc7f5138df00d375
4
+ data.tar.gz: 5a1c9269b2556e45fe0eb867f4ad31f4fa73b11bd581da743ea5dc15eca2717c
5
5
  SHA512:
6
- metadata.gz: 49b0c813976c5901e34b0e3dfffa411c2cdaf465be30d05687b6bbb2fe1f558ce444bc14e0a86bee9346010407121b4bd91db1fbe00675b2e4a72e9d8a4de499
7
- data.tar.gz: 0e590b435fe14297a656c187eef8c861531715def1479f4d8c636ef6b1eecf6958028f85ec6f70f3012bbd823ad69ec5bced1b8088b3a208e4ff73e904021681
6
+ metadata.gz: 610de2b9dac4235222006ab0361a3d62f0c42ff6c6a67e5c6173ddb700ba19608a17f51e6d06c7d07bdf10b3791f3a88fe9dd98bf52a3cd6f355fb227a474142
7
+ data.tar.gz: a58e11c17157e1192383164018457b11502f6b284582432c6d04224bdbd7365f2a322847cfd7eebb8176f713a5025098276683bcee79277a9b6294d487741c4d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.0
4
+
5
+ * add support for more than 500 bins, refactored and options added [#21](https://github.com/sharesight/vimaly/pull/21)
6
+
3
7
  ## 1.1.1
4
8
 
5
9
  * add support for more than 500 bins [#20](https://github.com/sharesight/vimaly/pull/20)
data/lib/vimaly/client.rb CHANGED
@@ -84,14 +84,25 @@ module Vimaly
84
84
  end
85
85
  end
86
86
 
87
- def bins
87
+ def bins(options={})
88
88
  @bins ||= begin
89
- per_page = 500
90
- data = (0..1).inject([]) do |list, page|
91
- list += get("/bins?max-results=#{per_page}&page-token=#{page * 500}")
89
+ # 500 is the vimaly limit
90
+ bins_per_request = options[:bins_per_request] || 500
91
+ # 5000 is just a random value here; hopefully we never reach this limit
92
+ max_number_of_bins = options[:max_number_of_bins] || 5000
93
+
94
+ bins = []
95
+ current_page = 0
96
+ while bins.size < max_number_of_bins
97
+ # those request parameters are not documented, maybe this gets added at some
98
+ # point to https://vimaly.com/public/rest-help.html#Bins
99
+ chunk_of_bins = get("/bins?max-results=#{bins_per_request}&page-token=#{current_page * bins_per_request}")
100
+ current_page += 1
101
+ bins += chunk_of_bins
102
+ break if chunk_of_bins.size < bins_per_request
92
103
  end
93
- data.map do |bin_data|
94
- Bin.new(bin_data['_id'], bin_data['name'])
104
+ bins.map do |bin|
105
+ Bin.new(bin['_id'], bin['name'])
95
106
  end
96
107
  end
97
108
  end
@@ -1,3 +1,3 @@
1
1
  module Vimaly
2
- VERSION = "1.1.1".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimaly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Boettger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-01 00:00:00.000000000 Z
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday