cherrypie-rails-sdk 0.2.6 → 0.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3dbf37c31a4ee19ebc946c565c5393b116eab396744d6161002fff824073b7ef
4
- data.tar.gz: 70f0b037240d413617b3bdc2499329a1c7a61f4477401a99d06b738be943d55f
3
+ metadata.gz: 32a0755c03ac3669e78ac0fc76bc9c0651bffba375792dcea1275a14d3b33fec
4
+ data.tar.gz: 2625a3c584c468dd03468a52e15214baacf0f636ddc1c9677a2e3cecaf3ffec3
5
5
  SHA512:
6
- metadata.gz: ec05e31a58e44d9524f116fe8603c2d7919ef42ac765997885ecfbd30b49f186ddf8a737e92df4fce067fa8f286658a04d7ead87b894770770257f5b89c7eb44
7
- data.tar.gz: 6f0d5b5d489a50a599a4862eb38c09c5c12a5d0a56dd8d266a764a3fe804d248381c9dfa841948af6273c1b5ac2e7b21c59b4a2034309123d631d03c74c0023d
6
+ metadata.gz: 60c8651155c6c7657c43f1b6d94aab1c2e4c3bd05f4b5fe630cd08caa328dff2a380c0c58231430ad0ad04179932d28d64e6e1da782a3b66876f138f1b3376e9
7
+ data.tar.gz: a1fe05068eec81fe776482a0f67b332da54194461db09895c2d940adcdbc87e7455361139759a90cf288f86088c8baed658c183a62c8b9a834dc2a11ab649b0b
data/Gemfile CHANGED
@@ -8,3 +8,5 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rspec", "~> 3.0"
11
+
12
+ gem 'concurrent-ruby', require: 'concurrent'
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cherrypie-rails-sdk (0.1.0)
4
+ cherrypie-rails-sdk (0.2.6)
5
+ concurrent-ruby
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ concurrent-ruby (1.1.9)
9
11
  diff-lcs (1.4.4)
10
12
  rake (13.0.6)
11
13
  rspec (3.10.0)
@@ -27,6 +29,7 @@ PLATFORMS
27
29
 
28
30
  DEPENDENCIES
29
31
  cherrypie-rails-sdk!
32
+ concurrent-ruby
30
33
  rake (~> 13.0)
31
34
  rspec (~> 3.0)
32
35
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CherrypieRailsSdk
1
+ # CherryPie Rails SDK
2
2
 
3
3
  Cherrypie Rails SDK.
4
4
 
@@ -7,7 +7,7 @@ Cherrypie Rails SDK.
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'cherrypie-rails-sdk', '~> 0.2.4'
10
+ gem 'cherrypie-rails-sdk', '~> 0.2.6'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -42,8 +42,3 @@ module ExampleApp
42
42
  end
43
43
  end
44
44
  ```
45
-
46
-
47
- ## Contributing
48
-
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cherrypie_rails_sdk.
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  # Uncomment to register a new dependency of your gem
31
- # spec.add_dependency "example-gem", "~> 1.0"
31
+ spec.add_dependency "concurrent-ruby"
32
32
 
33
33
  # For more information and examples about making a new gem, checkout our
34
34
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,11 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "cherrypie_rails_sdk/version"
4
+ require 'concurrent'
4
5
 
5
6
  module CherrypieRailsSdk
6
7
  class Error < StandardError; end
7
8
  class Middleware
8
- def initialize(app, api_key, identity_function, api_url: "http://api.cherrypie.app")
9
+ include Concurrent::Async
10
+
11
+ def initialize(app, api_key, identity_function, api_url: "https://api.cherrypie.app")
12
+ super()
9
13
  @app = app
10
14
  @api_key = api_key
11
15
  @api_url = api_url
@@ -40,7 +44,11 @@ module CherrypieRailsSdk
40
44
  "statusCode"=> status,
41
45
  }
42
46
  end
43
-
47
+
48
+ def _send_log(http, request)
49
+ http.request(request)
50
+ end
51
+
44
52
  def _call env
45
53
  request_started_on = Time.now
46
54
  @status, @headers, @response = @app.call(env)
@@ -67,7 +75,8 @@ module CherrypieRailsSdk
67
75
 
68
76
  uri = URI("#{@api_url}/v1/logs")
69
77
  http = Net::HTTP.new(uri.host, uri.port)
70
- request = Net::HTTP::Post.new(
78
+ http.use_ssl = true
79
+ cherrypie_request = Net::HTTP::Post.new(
71
80
  uri.request_uri,
72
81
  {
73
82
  'Content-Type' => 'application/json',
@@ -75,10 +84,10 @@ module CherrypieRailsSdk
75
84
  'Accept'=>'application/json',
76
85
  }
77
86
  )
78
- request.body = payload
87
+ cherrypie_request.body = payload
79
88
  # Only log non-300 statuses.
80
89
  if !(@status >= 300 && @status <= 399)
81
- cherrypie_response = http.request(request)
90
+ cherrypie_response = self.async._send_log(http, cherrypie_request)
82
91
  end
83
92
  [@status, @headers, @response]
84
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CherrypieRailsSdk
4
- VERSION = "0.2.6"
4
+ VERSION = "0.2.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cherrypie-rails-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Macro Computer Club
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2021-08-17 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: concurrent-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: CherryPie Rails SDK
14
28
  email:
15
29
  - founders@cherrypie.app