webflow-ruby 0.4.0 → 0.5.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
- SHA1:
3
- metadata.gz: 8c701be2da9f8559cd2f9b45398a29c1678217de
4
- data.tar.gz: 3dc52b13786c938395a34a9cc7e92d07abb36cf6
2
+ SHA256:
3
+ metadata.gz: 5da6e30284ec5f7d0405ffc811ad16673285b7e8ed5da6a58caf88827eac7c6a
4
+ data.tar.gz: bf3e9fd18fd3daa7d16dee83e5bc71d6b73acc04249d7e07dad1f71b1a4ba776
5
5
  SHA512:
6
- metadata.gz: 7accce76a13bb5ccd5ab53cb8edce6a5be4a12ef19dac34c7576e59f1e562619e03989497178c1c983718fbbae30e284220ba06f4681c63ac21be602ce367cdb
7
- data.tar.gz: bb955ccc59fd1b00c812f9cb450d92cc0bb4f9dcb7b754650d914f6411a12f8c5312e408dfdc896ac2c6abd36b8ed50633f17422689f6f6b9d555e4e77daf155
6
+ metadata.gz: 152445fe454407cb702852bbdd2735887b5bdebec6db1a1fbb669b328f3304e5439ea62c13fccbf650a2b4ff1855f6039eedf7c30b4d0f5a5333906f555540c5
7
+ data.tar.gz: 261d7ac28dd3680da3320f15fbebd1a009627a0ea6ccba321fdf2b04fa0880736818db5a9a125fcddbad0cd734c2653de99d6782bc63c2f7131536e557a72bec
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.5.0
2
+
3
+ * [FEATURE] Pagination https://github.com/penseo/webflow-ruby/pull/2 😍 @cohesiveneal
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ webflow-ruby (0.5.0)
5
+ oj
6
+ typhoeus
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.5.2)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ byebug (10.0.2)
14
+ crack (0.4.3)
15
+ safe_yaml (~> 1.0.0)
16
+ ethon (0.12.0)
17
+ ffi (>= 1.3.0)
18
+ ffi (1.10.0)
19
+ hashdiff (0.3.8)
20
+ minitest (5.11.3)
21
+ oj (3.7.7)
22
+ public_suffix (3.0.3)
23
+ rake (12.3.2)
24
+ safe_yaml (1.0.4)
25
+ typhoeus (1.3.1)
26
+ ethon (>= 0.9.0)
27
+ vcr (4.0.0)
28
+ webmock (3.5.1)
29
+ addressable (>= 2.3.6)
30
+ crack (>= 0.3.2)
31
+ hashdiff
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (> 1.13)
38
+ byebug
39
+ minitest (> 5.0)
40
+ rake (> 10.0)
41
+ vcr
42
+ webflow-ruby!
43
+ webmock
44
+
45
+ BUNDLED WITH
46
+ 2.0.1
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Webflow [![Build Status](https://travis-ci.org/phoet/webflow-ruby.svg?branch=master)](https://travis-ci.org/phoet/webflow-ruby)
1
+ # Webflow [![Build Status](https://travis-ci.org/penseo/webflow-ruby.svg?branch=master)](https://travis-ci.org/penseo/webflow-ruby)
2
2
 
3
3
  ## Installation
4
4
 
@@ -22,13 +22,14 @@ Have a look at the tests, seriously!
22
22
 
23
23
  ## Todo
24
24
 
25
+ * Use HTTPRB
25
26
  * Error handling, it's all JSON for now
26
27
  * Resource mapping, it's plain hashes for now
27
28
  * Proper docs
28
29
 
29
30
  ## Contributing
30
31
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/phoet/webflow-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/penseo/webflow-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
32
33
 
33
34
 
34
35
  ## License
@@ -48,9 +48,37 @@ module Webflow
48
48
  get("/collections/#{collection_id}")
49
49
  end
50
50
 
51
+
52
+ # https://developers.webflow.com/?javascript#get-all-items-for-a-collection
53
+ # returns json object with data to help paginate collection
54
+ #
55
+ # {
56
+ # items: your list of items returned,
57
+ # count: number of items returned,
58
+ # limit: the limit specified in the request (default: 100),
59
+ # offset: the offset specified for pagination (default: 0),
60
+ # total: total # of items in the collection
61
+ # }
62
+ #
63
+ # page starts at 1
64
+ def paginate_items(collection_id, per_page: 100, page: 1)
65
+ get("/collections/#{collection_id}/items", params: { limit: per_page, offset: per_page * (page - 1) })
66
+ end
67
+
68
+
51
69
  def items(collection_id, limit: 100)
52
- json = get("/collections/#{collection_id}/items", params: {limit: limit})
53
- json['items']
70
+ fetched_items = []
71
+ num_pages = (limit.to_f / 100.0).ceil
72
+ per_page = limit > 100 ? 100 : limit
73
+
74
+ num_pages.times do |i|
75
+ resp = paginate_items(collection_id, per_page: (limit > 100 ? 100 : limit), page: i+1)
76
+ fetched_items += resp['items']
77
+ limit -= resp['count']
78
+ break if limit <= 0 || resp['total'] <= fetched_items.length
79
+ end
80
+
81
+ fetched_items
54
82
  end
55
83
 
56
84
  def item(collection_id, item_id)
@@ -1,3 +1,3 @@
1
1
  module Webflow
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/webflow.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Webflow API bindings for Ruby}
13
13
  spec.description = spec.summary
14
- spec.homepage = "https://github.com/phoet/webflow-ruby"
14
+ spec.homepage = "https://github.com/penseo/webflow-ruby"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "typhoeus"
25
25
  spec.add_dependency "oj"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.13"
28
- spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_development_dependency "minitest", "~> 5.0"
27
+ spec.add_development_dependency "bundler", "> 1.13"
28
+ spec.add_development_dependency "rake", "> 10.0"
29
+ spec.add_development_dependency "minitest", "> 5.0"
30
30
  spec.add_development_dependency "byebug"
31
31
  spec.add_development_dependency "vcr"
32
32
  spec.add_development_dependency "webmock"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webflow-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - phoet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2019-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -42,42 +42,42 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.13'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.13'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '5.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.0'
83
83
  - !ruby/object:Gem::Dependency
@@ -131,8 +131,10 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
133
  - ".travis.yml"
134
+ - CHANGELOG.md
134
135
  - CODE_OF_CONDUCT.md
135
136
  - Gemfile
137
+ - Gemfile.lock
136
138
  - LICENSE.txt
137
139
  - README.md
138
140
  - Rakefile
@@ -143,7 +145,7 @@ files:
143
145
  - lib/webflow/ruby.rb
144
146
  - lib/webflow/version.rb
145
147
  - webflow.gemspec
146
- homepage: https://github.com/phoet/webflow-ruby
148
+ homepage: https://github.com/penseo/webflow-ruby
147
149
  licenses:
148
150
  - MIT
149
151
  metadata: {}
@@ -163,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
165
  version: '0'
164
166
  requirements: []
165
167
  rubyforge_project:
166
- rubygems_version: 2.6.8
168
+ rubygems_version: 2.7.6
167
169
  signing_key:
168
170
  specification_version: 4
169
171
  summary: Webflow API bindings for Ruby