webflow-ruby 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: e225d3153cb6f386e6d53d594688dc5697adbb6f
4
- data.tar.gz: 95936bf278be750cee5b7be77115602f2e81bed2
3
+ metadata.gz: d81f96d9c3c1fb868731f75e2d018280de13d85e
4
+ data.tar.gz: d424e2465fa6a905a3b418595591798a22fc229d
5
5
  SHA512:
6
- metadata.gz: 44ab5fbc6a9d6b93c6b4ce6888e91fd167a4849218254650b27d8a8ed3612d4f04c73dbf032b5099ded1ef7e7e59b773a786c46ec356d0582380ddb5f3d1d2a3
7
- data.tar.gz: 3841dbbfaccc10ec328d22c18c36520e66a350bd2319baffee99eb0c95ebb236ba670a188fd3584f8462a3d0ae1bb6a0287a96b0152bdb2a958c5d7f77974db6
6
+ metadata.gz: a698b14be7efc40420829673334874e2a55ec5d4e969981daa86cef29add8956fa85906b8321b61d755be4564489ee6a66ed0cfced95edfc6e4a8e480fd232e9
7
+ data.tar.gz: 83394b6bb177bfc61d6800df8edc9f14d5ca9e7d6f2f1043af711aa6018beed58317da8ca60aa1964686cac6f308f73eef6f3b3d26cf42161a27d9d7cee6f15a
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Webflow [![Build Status](https://travis-ci.org/phoet/webflow-ruby.svg?branch=master)](https://travis-ci.org/phoet/webflow-ruby)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/webflow`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -22,7 +18,7 @@ Or install it yourself as:
22
18
 
23
19
  ## Usage
24
20
 
25
- TODO: Write usage instructions here
21
+ Have a look at the tests!
26
22
 
27
23
  ## Development
28
24
 
@@ -32,7 +28,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
28
 
33
29
  ## Contributing
34
30
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/webflow. 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.
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.
36
32
 
37
33
 
38
34
  ## License
@@ -26,19 +26,15 @@ module Webflow
26
26
  get("/sites/#{site_id}/domains")
27
27
  end
28
28
 
29
- def publish(site_id)
30
- names = domains.map { |domain| domain['name'] }
31
- post("/sites/#{site_id}/publish", domains: names)
29
+ def publish(site_id, domain_names: nil)
30
+ domain_names ||= domains(site_id).map { |domain| domain['name'] }
31
+ post("/sites/#{site_id}/publish", domains: domain_names)
32
32
  end
33
33
 
34
34
  def collections(site_id)
35
35
  get("/sites/#{site_id}/collections")
36
36
  end
37
37
 
38
- def collection_by(key, value)
39
- collections.find { |c| c[key.to_s] == value }
40
- end
41
-
42
38
  def items(collection_id, limit: 100)
43
39
  json = get("/collections/#{collection_id}/items", params: {limit: limit})
44
40
  json['items']
@@ -49,6 +45,7 @@ module Webflow
49
45
  end
50
46
 
51
47
  def update_item(collection_id, item, data)
48
+ # FIXME: (PS) looks like the API does not have partial updates...
52
49
  base = item.reject {|key, _| ['_id', 'published-by', 'published-on', 'created-on', 'created-by', 'updated-by', 'updated-on', '_cid'].include?(key) }
53
50
  put("/collections/#{collection_id}/items/#{item['_id']}", fields: base.merge(data))
54
51
  end
@@ -60,30 +57,23 @@ module Webflow
60
57
  private
61
58
 
62
59
  def get(path, params: nil)
63
- url = File.join(HOST, path)
64
- response = http(url, method: :get, headers: headers, params: params)
65
- Oj.load(response)
60
+ http(path, method: :get, headers: headers, params: params)
66
61
  end
67
62
 
68
63
  def post(path, data)
69
- url = File.join(HOST, path)
70
- response = http(url, method: :post, headers: headers, body: data)
71
- Oj.load(response)
64
+ http(path, method: :post, headers: headers, body: data)
72
65
  end
73
66
 
74
67
  def put(path, data)
75
- url = File.join(HOST, path)
76
- response = http(url, method: :put, headers: headers, body: data)
77
- Oj.load(response)
68
+ http(path, method: :put, headers: headers, body: data)
78
69
  end
79
70
 
80
71
  def delete(path)
81
- url = File.join(HOST, path)
82
- response = http(url, method: :delete, headers: headers)
83
- Oj.load(response)
72
+ http(path, method: :delete, headers: headers)
84
73
  end
85
74
 
86
- def http(url, method: :get, params: nil, headers: nil, body: nil)
75
+ def http(path, method: :get, params: nil, headers: nil, body: nil)
76
+ url = File.join(HOST, path)
87
77
  request = Typhoeus::Request.new(
88
78
  url,
89
79
  method: method,
@@ -91,7 +81,8 @@ module Webflow
91
81
  headers: headers,
92
82
  body: (Oj.dump(body) if body),
93
83
  )
94
- request.run.body
84
+ body = request.run.body
85
+ Oj.load(body)
95
86
  end
96
87
 
97
88
  def headers
@@ -1,3 +1,3 @@
1
1
  module Webflow
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webflow-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - phoet