active_spy 1.4.1 → 1.4.2

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
  SHA1:
3
- metadata.gz: 53c0cd2e3ec94aba034276de4f0ba3287db6d5fe
4
- data.tar.gz: db6eda9a0b5633cd8c4f0b48042fb6e166239c1e
3
+ metadata.gz: b772783c7223609dd9f30011750e648df6cacaa4
4
+ data.tar.gz: 1a48f5c50c9e6dd0e5893d4ca0d3f12f4e903797
5
5
  SHA512:
6
- metadata.gz: cebfeee79fab26b19f8b23c70d3d358e3de53e6ec8dd48efc412fe125e33ab5966c8129e3f4fd8ccec688f6dc4852bda6354b9016a6e7759cc8814daa8bf51c2
7
- data.tar.gz: 2761cf841ee34c3915f45508a554686731135bb07d75019cf21ac7cfecb044dca3cd586e0edbc42f35ee9b18530bb95cb550698cfd7ce651d3598ca87ffc4cd9
6
+ metadata.gz: 10005804eb6e8a930ef896ab6ba1f2aa9d0a960c1a0ffe9c5a72db2a209fbfb2ad635b75dcd06842f80badba0b49c75a6a11930364403d4530a2feebd11c0183
7
+ data.tar.gz: 16fe6441aef9ba8b33bfa8e400e099bfee05ce3e27a1ae0a334081c187371ace67a4618fcf2a861e46ec875daab532ec7365ec15312818e59aa17d3d28cc919b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
data/active_spy.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: active_spy 1.4.1 ruby lib
5
+ # stub: active_spy 1.4.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "active_spy"
9
- s.version = "1.4.1"
9
+ s.version = "1.4.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Douglas Camata"]
14
- s.date = "2015-05-27"
14
+ s.date = "2015-05-29"
15
15
  s.description = " Watch for a method call in any class and run before/after callbacks.\n You can even watch your Rails models for events (like create, update,\n destroy), send these events to a event-runner instance and it redirect these\n events to other apps that are subscrived for them. This gem also provides\n classes that you can use to process the received events too.\n"
16
16
  s.email = "d.camata@gmail.com"
17
17
  s.extra_rdoc_files = [
data/lib/active_spy.rb CHANGED
@@ -31,13 +31,18 @@ module ActiveSpy
31
31
  # Class method to register the service in an event-runner instance.
32
32
  #
33
33
  def self.register_service
34
- host = ActiveSpy::Configuration.event_host
35
- port = ActiveSpy::Configuration.event_port
36
- @base_url = "#{host}:#{port}/services"
34
+ host = ActiveSpy::Configuration.event_host
35
+ port = ActiveSpy::Configuration.event_port
36
+ verify_ssl = ActiveSpy::Configuration.event_verify_ssl
37
+ @base_url = "#{host}:#{port}/services"
37
38
 
38
39
  return if self.service_registered?
39
40
  service = { service: ActiveSpy::Configuration.settings }.to_json
40
- RestClient.post(@base_url, service, content_type: :json)
41
+
42
+ params = { content_type: :json }
43
+ params[:verify_ssl] = verify_ssl if verify_ssl
44
+
45
+ RestClient.post(@base_url, service, params)
41
46
  end
42
47
 
43
48
  # @!method self.service_registered?
@@ -45,9 +50,16 @@ module ActiveSpy
45
50
  # runner instance.
46
51
  #
47
52
  def self.service_registered?
48
- name = ActiveSpy::Configuration.name
53
+ name = ActiveSpy::Configuration.name
54
+ verify_ssl = ActiveSpy::Configuration.event_verify_ssl
55
+ url = "#{@base_url}/#{name.downcase.gsub(' ', '-').strip}"
56
+
49
57
  begin
50
- RestClient.get "#{@base_url}/#{name.downcase.gsub(' ', '-').strip}"
58
+ if verify_ssl
59
+ RestClient.get url, verify_ssl: verify_ssl
60
+ else
61
+ RestClient.get url
62
+ end
51
63
  rescue RestClient::ResourceNotFound
52
64
  return false
53
65
  else
@@ -43,6 +43,16 @@ module ActiveSpy
43
43
  @event_host
44
44
  end
45
45
 
46
+ # Set the default event-tunner verify_ssl mode
47
+ #
48
+ # @param [String] host to set
49
+ #
50
+ # @return [String] the host set
51
+ def event_verify_ssl(event_verify_ssl = nil)
52
+ @event_verify_ssl = event_verify_ssl unless event_verify_ssl.nil?
53
+ @event_verify_ssl
54
+ end
55
+
46
56
  # Set if the gem is in development mode or not.
47
57
  #
48
58
  # @param [Boolean] development moded state to set
@@ -89,7 +99,7 @@ module ActiveSpy
89
99
  #
90
100
  # @return [Hash] actual event settings
91
101
  def event_settings
92
- { host: @event_host, port: @event_port }
102
+ { host: @event_host, port: @event_port, verify_ssl: @event_verify_ssl }
93
103
  end
94
104
  end
95
105
  end
@@ -81,12 +81,15 @@ module ActiveSpy
81
81
  # Sends the event request to the configured event-runner instance.
82
82
  #
83
83
  def send_event_request
84
- response = nil
85
- host = ActiveSpy::Configuration.event_host
86
- port = ActiveSpy::Configuration.event_port
84
+ response = nil
85
+ host = ActiveSpy::Configuration.event_host
86
+ port = ActiveSpy::Configuration.event_port
87
+ verify_ssl = ActiveSpy::Configuration.event_verify_ssl
88
+
89
+ params = { content_type: :json }
90
+ params[:verify_ssl] = verify_ssl if verify_ssl
87
91
  begin
88
- response = RestClient.post "#{host}:#{port}/events", @event_json,
89
- content_type: :json
92
+ response = RestClient.post "#{host}:#{port}/events", @event_json, params
90
93
  rescue => e
91
94
  ::Rails.logger.info(e.response)
92
95
  end
@@ -16,8 +16,10 @@ module ActiveSpy
16
16
  host = ActiveSpy::Configuration.event_host
17
17
  port = ActiveSpy::Configuration.event_port
18
18
  name = ActiveSpy::Configuration.name.downcase.gsub(' ', '-').strip
19
+
20
+ @verify_ssl = ActiveSpy::Configuration.event_verify_ssl
19
21
  @base_service_url = "#{host}:#{port}/services/#{name}"
20
- @hooks = []
22
+ @hooks = []
21
23
  end
22
24
 
23
25
  # Proxy all methods called in the {ActiveSpy::Hook} to
@@ -54,7 +56,13 @@ module ActiveSpy
54
56
  # Get the old hooks list for this service from the event-runner
55
57
  #
56
58
  def get_old_hooks
57
- JSON.load(RestClient.get(@base_service_url))['hooks']
59
+ request = if @verify_ssl
60
+ RestClient.get(@base_service_url, verify_ssl: @verify_ssl)
61
+ else
62
+ RestClient.get(@base_service_url)
63
+ end
64
+
65
+ JSON.load(request)['hooks']
58
66
  end
59
67
 
60
68
  # Select from old hooks those that should be deleted from event runner.
@@ -98,13 +106,20 @@ module ActiveSpy
98
106
  #
99
107
  def delete_hooks(hooks_to_delete)
100
108
  hooks_to_delete.each do |hook|
101
- RestClient.delete "#{@base_service_url}/hooks/#{hook['id']}"
109
+ if @verify_ssl
110
+ RestClient.delete "#{@base_service_url}/hooks/#{hook['id']}", verify_ssl: @verify_ssl
111
+ else
112
+ RestClient.delete "#{@base_service_url}/hooks/#{hook['id']}"
113
+ end
102
114
  end
103
115
  end
104
116
 
105
117
  # # Properly creates the +hooks_to_add+ in the event runner.
106
118
  #
107
119
  def add_hooks(hooks_to_add)
120
+ params = { content_type: :json }
121
+ params[:verify_ssl] = @verify_ssl if @verify_ssl
122
+
108
123
  hooks_to_add.each do |hook|
109
124
  hook = {
110
125
  'hook' => {
@@ -112,8 +127,7 @@ module ActiveSpy
112
127
  'post_path' => ActiveSpy::Engine.routes.url_helpers.notifications_path(hook['post_class'].downcase),
113
128
  }
114
129
  }
115
- RestClient.post "#{@base_service_url}/hooks", hook.to_json,
116
- content_type: :json
130
+ RestClient.post "#{@base_service_url}/hooks", hook.to_json, params
117
131
  end
118
132
  end
119
133
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_spy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Camata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-27 00:00:00.000000000 Z
11
+ date: 2015-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport