cotcube-helpers 0.2.2.3 → 0.2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/lib/cotcube-helpers/cache_client.rb +28 -0
- data/lib/cotcube-helpers.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e416bde4f3c3a8dbba8290c74fa4a54d8f0b5f84f61eb9af8e7bd669bab5a43
|
|
4
|
+
data.tar.gz: abb4a2842d5b11f2fcb38bbede59bd693b18117547c94d9eb11a2342d1f76665
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60f1bc2438ef256bc3d772dec73e22a12711e4088a8ffa07463976c0931e149d471f9d7ea93c6930aff3b96fe06d15537cf96319946ed0fb4cbbbdf70573295a
|
|
7
|
+
data.tar.gz: b372776b0d180c6007b0c652d1eeb056d1845ac12775a8853e6e9e9ba9de128cf411527c4912174c722d5c6c4705d4524240665e917928ab50bb9ca0a3fe53cf
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.2.
|
|
1
|
+
0.2.2.4
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
module Cotcube
|
|
5
|
+
module Helpers
|
|
6
|
+
def cached(query, timezone: Cotcube::Helpers::CHICAGO, debug: false, deflate: false)
|
|
7
|
+
# TODO: set param to enable deflate on transmission via HTTPARRTY Header
|
|
8
|
+
request_headers = {}
|
|
9
|
+
request_headers['Accept-Encoding' => 'deflate'] if deflate
|
|
10
|
+
res = JSON.parse(HTTParty.get("http://100.100.0.14:8081/#{query}").parsed_response, symbolize_names: true) rescue { error: 1, msg: "Could not parse response for query '#{query}'." }
|
|
11
|
+
unless res[:error] and res[:error].zero?
|
|
12
|
+
puts "ERROR: #{res}"
|
|
13
|
+
return false
|
|
14
|
+
end
|
|
15
|
+
#res[:valid_until] = timezone.parse(res[:valid_until])
|
|
16
|
+
#res[:modified] = timezone.parse(res[:modified_at])
|
|
17
|
+
if debug
|
|
18
|
+
puts "Warnings: #{res[:warnings]}"
|
|
19
|
+
puts "Modified: #{res[:modified]}"
|
|
20
|
+
puts "Valid_un: #{res[:valid_until]}"
|
|
21
|
+
puts "payload: #{res[:payload].to_s.size}"
|
|
22
|
+
end
|
|
23
|
+
res[:payload]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
module_function :cached
|
|
27
|
+
end
|
|
28
|
+
end
|
data/lib/cotcube-helpers.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cotcube-helpers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.2.
|
|
4
|
+
version: 0.2.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Benjamin L. Tischendorf
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-12-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -96,6 +96,7 @@ files:
|
|
|
96
96
|
- cotcube-helpers.gemspec
|
|
97
97
|
- lib/cotcube-helpers.rb
|
|
98
98
|
- lib/cotcube-helpers/array_ext.rb
|
|
99
|
+
- lib/cotcube-helpers/cache_client.rb
|
|
99
100
|
- lib/cotcube-helpers/constants.rb
|
|
100
101
|
- lib/cotcube-helpers/data_client.rb
|
|
101
102
|
- lib/cotcube-helpers/datetime_ext.rb
|