angie-core-api 0.2.5 → 0.3.0

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: 3f280c23183ad4da841e6900a5e2cf8f4aea56e03dea076e39cb1d6da6bf85f2
4
- data.tar.gz: 9ab9e5a42fdc73a7c1f7e8f28fa82e239f8d9e3c45682a0f147c8708fc3d44d7
3
+ metadata.gz: b8907a7f9ed3714adf317d1137a43d8d8948f47bc0d695024b3f4499a8fad3e1
4
+ data.tar.gz: 6bb9fe7dd4c5bb0607d05b58c83a07a721ab6b97ec402866b7b9d2031879345d
5
5
  SHA512:
6
- metadata.gz: 8db08c7421e1fe319b483620568e6c90e2dab26255c8c6c4f2c832e6f17eca429163f4684c5a3ef50f98249bdc0c71bdffd1399d36e7749571210080b77e4811
7
- data.tar.gz: 5be04e012ac0bda8b3d535aac32c531fd14f66906721b4cc2a2aebc741a1f3d93434db660ac644b20d331b1829e56cd1fd13f3d02cb1f64fccecd5af4dac40d9
6
+ metadata.gz: 5b141de4ea307c0e21a47b5c33ce9aed6b8d3ac85f3b754b586d4af9c21ae759a84814dc22f3997965f2c2236f142b5269434f34245377ae5f86e310f361e07f
7
+ data.tar.gz: 04a8e1b6d2216a69826d34bc74154d082ce88369583f0639db15c70a753fc6db81cfe779c3e64cfd079f9267d8d2af23cfd561e2ba03da25abef83321fedde3a
@@ -6,6 +6,7 @@ module AngieCoreApi
6
6
  autoload :Notification, "angie-core-api/notification"
7
7
  autoload :Weather, "angie-core-api/weather"
8
8
  autoload :DeliveryMethod, "angie-core-api/delivery_method"
9
+ autoload :Message, "angie-core-api/message"
9
10
 
10
11
  def self.configuration
11
12
  @configuration ||= Configuration.new
@@ -1,10 +1,9 @@
1
- require "active_support"
2
-
3
1
  module AngieCoreApi
4
2
  class Configuration
5
3
  include ActiveSupport::Configurable
6
4
 
7
5
  config_accessor(:url)
8
6
  config_accessor(:token)
7
+ config_accessor(:activemq)
9
8
  end
10
9
  end
@@ -0,0 +1,6 @@
1
+ module AngieCoreApi
2
+ module Message
3
+ autoload :Client, "angie-core-api/message/client"
4
+ autoload :Queue, "angie-core-api/message/queue"
5
+ end
6
+ end
@@ -0,0 +1,28 @@
1
+ require "stomp"
2
+
3
+ module AngieCoreApi
4
+ module Message
5
+ class Client
6
+ include Concurrent::Async
7
+
8
+ def initialize
9
+ config = HashWithIndifferentAccess.new(AngieCoreApi.configuration.activemq)
10
+ @client = Stomp::Client.new(config)
11
+ end
12
+
13
+ def publish(queue, data)
14
+ @client.publish(queue, data.to_json)
15
+ @client.close
16
+ end
17
+
18
+ def subscribe(queue)
19
+ @client.subscribe(queue) do |msg|
20
+ yield JSON.parse(msg.body)
21
+ rescue StandardError => e
22
+ # Rollbar.error(e)
23
+ Rails.logger.error e
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module AngieCoreApi
2
+ module Message
3
+ class Queue
4
+ def self.classes
5
+ Dir["app/queues/*.rb"].
6
+ map { |file| File.basename(file, ".rb") }.
7
+ select { |type| type != "application_queue" }.
8
+ map(&:camelize).
9
+ map(&:constantize)
10
+ end
11
+
12
+ def self.queue
13
+ path = name.underscore.sub("_queue", "")
14
+ "/queue/#{path}"
15
+ end
16
+
17
+ def self.publish(message)
18
+ Client.new.async.publish(queue, message)
19
+ end
20
+
21
+ def self.subscribe
22
+ Client.new.async.subscribe(queue) do |message|
23
+ self.new.receive(message)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angie-core-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angie Hospitality
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httparty
14
+ name: actioncable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.18.1
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.18.1
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: actionmailer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: actionmailer
42
+ name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '6.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.18.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.18.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: stomp
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
55
83
  description: Angie CoreAPI Ruby gem
56
84
  email:
57
85
  - rubygems@angie.ai
@@ -65,6 +93,9 @@ files:
65
93
  - lib/angie-core-api/delivery_method.rb
66
94
  - lib/angie-core-api/flight.rb
67
95
  - lib/angie-core-api/map.rb
96
+ - lib/angie-core-api/message.rb
97
+ - lib/angie-core-api/message/client.rb
98
+ - lib/angie-core-api/message/queue.rb
68
99
  - lib/angie-core-api/notification.rb
69
100
  - lib/angie-core-api/railtie.rb
70
101
  - lib/angie-core-api/weather.rb