cotcube-helpers 0.2.2.3 → 0.2.2.4

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: 54c97a5746e0e03b971b9421be0636eb2c259beb90840ff34404f8049114019b
4
- data.tar.gz: 6d565f00ed620b2458122ad686b1b6c60bb26e815f248474f746b38c10902dc6
3
+ metadata.gz: 2e416bde4f3c3a8dbba8290c74fa4a54d8f0b5f84f61eb9af8e7bd669bab5a43
4
+ data.tar.gz: abb4a2842d5b11f2fcb38bbede59bd693b18117547c94d9eb11a2342d1f76665
5
5
  SHA512:
6
- metadata.gz: f9a71ad40a61b1caf44162851d2c323c1b762501705459fbbca85d38c8a6bf66e261eb920093fa01f3ea6ddd07b48dbe7aa4f46e5010a39e0e5bb3045c9941d1
7
- data.tar.gz: a862cb81820c8459a015788d273c1cd159078f11705f2c5f8db2847e355a6e5f6cf54b4532a43efef246804a1679053ca807b76c79c580881a46e3ea09fb0f01
6
+ metadata.gz: 60f1bc2438ef256bc3d772dec73e22a12711e4088a8ffa07463976c0931e149d471f9d7ea93c6930aff3b96fe06d15537cf96319946ed0fb4cbbbdf70573295a
7
+ data.tar.gz: b372776b0d180c6007b0c652d1eeb056d1845ac12775a8853e6e9e9ba9de128cf411527c4912174c722d5c6c4705d4524240665e917928ab50bb9ca0a3fe53cf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.2.4 (December 07, 2021)
2
+ - introduced cache_client as client to readcache
3
+
1
4
  ## 0.2.2.3 (November 28, 2021)
2
5
  - data_client: fixing troublesome output in .command
3
6
 
data/Gemfile CHANGED
@@ -6,3 +6,4 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
  gem 'parallel'
8
8
  gem 'bunny'
9
+ gem 'httparty'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2.3
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
@@ -53,3 +53,4 @@ module Cotcube
53
53
  end
54
54
 
55
55
  require_relative 'cotcube-helpers/data_client'
56
+ require_relative 'cotcube-helpers/cache_client'
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.3
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-28 00:00:00.000000000 Z
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