procore 0.8.5 → 0.8.6

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: 6fff662a5f654e6726d9ce407f3110faef18d837bf00e1a5705ac761c568ffeb
4
- data.tar.gz: a0618cce9e35ea519ffc819077d413a5c4f0e3a3b8d6035d6aaf57a678f6d3a6
3
+ metadata.gz: 6545e8ea432e0c10b0a3cd0e1257e96b57bf18f44c6d3ecfd3fa5805212290db
4
+ data.tar.gz: c93910a023d455bcc2731f8f74a1ebe3631851c0b711cf4effff9f1fe84b4503
5
5
  SHA512:
6
- metadata.gz: cc8d4a97f3b5bafade47075b1225069cf0bee01b4296e957984ea8d1e2991b4eecbc3eedcb01a24450d9e62019a182377dc1173598501df63d8729ad664b3802
7
- data.tar.gz: e16fd89928908356c5dc902dc8ed558b33dff38229f578e13b9a8ecef68fe1e1f7c8970fb633cf62fb27780195233f01ab17a64d105e4140b367deafaed8fa46
6
+ metadata.gz: 6376d8a7cc0a0a494594ce185e77630b885da38bbd14614219f069e3eaccd7f0f7cc202f007ef58129db49910bd518523e285830fbd3d6c379d920fdeceef6f9
7
+ data.tar.gz: e258551108c844d80137919ce861233db506ba97d72598f93da3c2e7818425188857a42be0ef2b3d28dde99e95eb304f5d11b179b2f470c45dfde37574e7b742
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.8.6 (May 10, 2018)
4
+
5
+ * Dalli Store
6
+
7
+ *Patrick Koperwas*
8
+
9
+ * Fix Requestable paths to prevent double slash in URI
10
+
11
+ *Megan O'Neill*
12
+
3
13
  ## 0.8.5 (May 9, 2018)
4
14
  * Rescue Errno::ECONNREFUSED errors and RestClient::ServerBrokeConnection
5
15
 
data/README.md CHANGED
@@ -14,6 +14,7 @@
14
14
  - [Stores](#stores)
15
15
  - [Session Store](#session-store)
16
16
  - [Redis Store](#redis-store)
17
+ - [Dalli Store](#dalli-store)
17
18
  - [ActiveRecord Store](#activerecord-store)
18
19
  - [File Store](#file-store)
19
20
  - [Memory Store](#memory-store)
@@ -331,6 +332,20 @@ The key will usually be the id of the current user.
331
332
  store = Procore::Auth::Stores::Redis.new(redis: Redis.new, key: current_user.id)
332
333
  ```
333
334
 
335
+ ### Dalli Store
336
+
337
+ Options: `dalli`: Instance of Dalli
338
+ Options: `key`: Unique identifier to an access token
339
+
340
+ For applications which want to store access tokens in memcached using Dalli.
341
+ There's two required options, `dalli` which is an instance of a Dalli client,
342
+ and `key` which is a unique key which will be used to save / retrieve an access
343
+ token. The key will usually be the id of the current user.
344
+
345
+ ```ruby
346
+ store = Procore::Auth::Stores::Dalli.new(dalli: Dalli.new, key: current_user.id)
347
+ ```
348
+
334
349
  ### ActiveRecord Store
335
350
 
336
351
  Options: `object`: Instance of an ActiveRecord model.
data/lib/procore.rb CHANGED
@@ -7,6 +7,7 @@ require "json"
7
7
  require "procore/auth/access_token_credentials"
8
8
  require "procore/auth/client_credentials"
9
9
  require "procore/auth/stores/active_record"
10
+ require "procore/auth/stores/dalli"
10
11
  require "procore/auth/stores/file"
11
12
  require "procore/auth/stores/memory"
12
13
  require "procore/auth/stores/redis"
@@ -0,0 +1,38 @@
1
+ module Procore
2
+ module Auth
3
+ module Stores
4
+ class Dalli
5
+ attr_reader :key, :dalli
6
+ def initialize(key:, dalli:)
7
+ @key = key
8
+ @dalli = dalli
9
+ end
10
+
11
+ def save(token)
12
+ dalli.set(dalli_key, token.to_json)
13
+ end
14
+
15
+ def fetch
16
+ return unless dalli.get(dalli_key)
17
+
18
+ token = JSON.parse(dalli.get(dalli_key))
19
+ Procore::Auth::Token.new(
20
+ access_token: token["access_token"],
21
+ refresh_token: token["refresh_token"],
22
+ expires_at: token["expires_at"],
23
+ )
24
+ end
25
+
26
+ def delete
27
+ dalli.delete(dalli_key)
28
+ end
29
+
30
+ private
31
+
32
+ def dalli_key
33
+ "procore-dalli-#{key}"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -27,9 +27,11 @@ module Procore
27
27
  #
28
28
  # @return [Response]
29
29
  def get(path, query: {}, options: {})
30
+ full_path = full_path(path)
31
+
30
32
  Util.log_info(
31
33
  "API Request Initiated",
32
- path: "#{base_api_path}/#{path}",
34
+ path: full_path,
33
35
  method: "GET",
34
36
  query: query.to_s,
35
37
  )
@@ -37,7 +39,7 @@ module Procore
37
39
  with_response_handling do
38
40
  RestClient::Request.execute(
39
41
  method: :get,
40
- url: "#{base_api_path}/#{path}",
42
+ url: full_path,
41
43
  headers: headers(options).merge(params: query),
42
44
  timeout: Procore.configuration.timeout,
43
45
  )
@@ -58,9 +60,11 @@ module Procore
58
60
  #
59
61
  # @return [Response]
60
62
  def post(path, body: {}, options: {})
63
+ full_path = full_path(path)
64
+
61
65
  Util.log_info(
62
66
  "API Request Initiated",
63
- path: "#{base_api_path}/#{path}",
67
+ path: full_path,
64
68
  method: "POST",
65
69
  body: body.to_s,
66
70
  )
@@ -68,7 +72,7 @@ module Procore
68
72
  with_response_handling(request_body: body) do
69
73
  RestClient::Request.execute(
70
74
  method: :post,
71
- url: "#{base_api_path}/#{path}",
75
+ url: full_path,
72
76
  payload: payload(body),
73
77
  headers: headers(options),
74
78
  timeout: Procore.configuration.timeout,
@@ -86,9 +90,11 @@ module Procore
86
90
  #
87
91
  # @return [Response]
88
92
  def put(path, body: {}, options: {})
93
+ full_path = full_path(path)
94
+
89
95
  Util.log_info(
90
96
  "API Request Initiated",
91
- path: "#{base_api_path}/#{path}",
97
+ path: full_path,
92
98
  method: "PUT",
93
99
  body: body.to_s,
94
100
  )
@@ -96,7 +102,7 @@ module Procore
96
102
  with_response_handling(request_body: body) do
97
103
  RestClient::Request.execute(
98
104
  method: :put,
99
- url: "#{base_api_path}/#{path}",
105
+ url: full_path,
100
106
  payload: payload(body),
101
107
  headers: headers(options),
102
108
  timeout: Procore.configuration.timeout,
@@ -118,9 +124,11 @@ module Procore
118
124
  #
119
125
  # @return [Response]
120
126
  def patch(path, body: {}, options: {})
127
+ full_path = full_path(path)
128
+
121
129
  Util.log_info(
122
130
  "API Request Initiated",
123
- path: "#{base_api_path}/#{path}",
131
+ path: full_path,
124
132
  method: "PATCH",
125
133
  body: body.to_s,
126
134
  )
@@ -128,7 +136,7 @@ module Procore
128
136
  with_response_handling(request_body: body) do
129
137
  RestClient::Request.execute(
130
138
  method: :patch,
131
- url: "#{base_api_path}/#{path}",
139
+ url: full_path,
132
140
  payload: payload(body),
133
141
  headers: headers(options),
134
142
  timeout: Procore.configuration.timeout,
@@ -145,9 +153,11 @@ module Procore
145
153
  #
146
154
  # @return [Response]
147
155
  def delete(path, query: {}, options: {})
156
+ full_path = full_path(path)
157
+
148
158
  Util.log_info(
149
159
  "API Request Initiated",
150
- path: "#{base_api_path}/#{path}",
160
+ path: full_path,
151
161
  method: "DELETE",
152
162
  headers: headers(options),
153
163
  query: query.to_s,
@@ -156,7 +166,7 @@ module Procore
156
166
  with_response_handling do
157
167
  RestClient::Request.execute(
158
168
  method: :delete,
159
- url: "#{base_api_path}/#{path}",
169
+ url: full_path,
160
170
  headers: headers.merge(params: query),
161
171
  timeout: Procore.configuration.timeout,
162
172
  )
@@ -285,5 +295,9 @@ module Procore
285
295
  def multipart?(body)
286
296
  RestClient::Payload::has_file?(body)
287
297
  end
298
+
299
+ def full_path(path)
300
+ File.join(base_api_path, path).to_s
301
+ end
288
302
  end
289
303
  end
@@ -1,3 +1,3 @@
1
1
  module Procore
2
- VERSION = "0.8.5".freeze
2
+ VERSION = "0.8.6".freeze
3
3
  end
data/procore.gemspec CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "actionpack"
26
26
  spec.add_development_dependency "activerecord"
27
27
  spec.add_development_dependency "bundler"
28
+ spec.add_development_dependency "dalli"
28
29
  spec.add_development_dependency "fakefs"
29
30
  spec.add_development_dependency "minitest"
30
31
  spec.add_development_dependency "pry"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Procore Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-09 00:00:00.000000000 Z
11
+ date: 2018-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dalli
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: fakefs
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -227,6 +241,7 @@ files:
227
241
  - lib/procore/auth/access_token_credentials.rb
228
242
  - lib/procore/auth/client_credentials.rb
229
243
  - lib/procore/auth/stores/active_record.rb
244
+ - lib/procore/auth/stores/dalli.rb
230
245
  - lib/procore/auth/stores/file.rb
231
246
  - lib/procore/auth/stores/memory.rb
232
247
  - lib/procore/auth/stores/redis.rb