active_spy 1.0.0.rc

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4cd2e2fa1963b0d3b0245286259ecada944cbf39
4
+ data.tar.gz: 4b0265ce9d275414da3ae3e43da3661a5f22dfc0
5
+ SHA512:
6
+ metadata.gz: 7ee7527b4f6057a9b45a3edd0587c3fcbbc33b94f0fba7cae2ac6c4b8c3b606cf277a40b5a7d13455bb02c47f293a455599ea1c5db5a3006a658aad49e0674c5
7
+ data.tar.gz: e533299e79224fb191e0464c19290204596adc873054654cbb834f8de3f1d494354276ac30ccb5bdecb0df949bcd044781273fe4715323b42d9e60107cebca35
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source 'http://rubygems.org'
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem 'activesupport', '~> 4.1.2'
6
+ gem 'rest-client', '1.6.7'
7
+ gem 'hashie'
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem 'activerecord', '~> 4.1.2'
13
+ gem 'rails', '~> 4.1.2'
14
+ gem 'rubocop', '~> 0.24.0'
15
+ gem 'pry', '~> 0.10.0'
16
+ gem 'rspec', '~> 3.0.0'
17
+ gem 'yard', '0.8.7.4'
18
+ gem 'rdoc', '~> 4.1.1'
19
+ gem 'bundler', '~> 1.6.3'
20
+ gem 'jeweler', '~> 2.0.1'
21
+ gem 'simplecov'
22
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,177 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (4.1.2)
5
+ actionpack (= 4.1.2)
6
+ actionview (= 4.1.2)
7
+ mail (~> 2.5.4)
8
+ actionpack (4.1.2)
9
+ actionview (= 4.1.2)
10
+ activesupport (= 4.1.2)
11
+ rack (~> 1.5.2)
12
+ rack-test (~> 0.6.2)
13
+ actionview (4.1.2)
14
+ activesupport (= 4.1.2)
15
+ builder (~> 3.1)
16
+ erubis (~> 2.7.0)
17
+ activemodel (4.1.2)
18
+ activesupport (= 4.1.2)
19
+ builder (~> 3.1)
20
+ activerecord (4.1.2)
21
+ activemodel (= 4.1.2)
22
+ activesupport (= 4.1.2)
23
+ arel (~> 5.0.0)
24
+ activesupport (4.1.2)
25
+ i18n (~> 0.6, >= 0.6.9)
26
+ json (~> 1.7, >= 1.7.7)
27
+ minitest (~> 5.1)
28
+ thread_safe (~> 0.1)
29
+ tzinfo (~> 1.1)
30
+ addressable (2.3.6)
31
+ arel (5.0.1.20140414130214)
32
+ ast (2.0.0)
33
+ builder (3.2.2)
34
+ coderay (1.1.0)
35
+ descendants_tracker (0.0.4)
36
+ thread_safe (~> 0.3, >= 0.3.1)
37
+ diff-lcs (1.2.5)
38
+ docile (1.1.5)
39
+ erubis (2.7.0)
40
+ faraday (0.9.0)
41
+ multipart-post (>= 1.2, < 3)
42
+ git (1.2.7)
43
+ github_api (0.11.3)
44
+ addressable (~> 2.3)
45
+ descendants_tracker (~> 0.0.1)
46
+ faraday (~> 0.8, < 0.10)
47
+ hashie (>= 1.2)
48
+ multi_json (>= 1.7.5, < 2.0)
49
+ nokogiri (~> 1.6.0)
50
+ oauth2
51
+ hashie (3.1.0)
52
+ highline (1.6.21)
53
+ hike (1.2.3)
54
+ i18n (0.6.9)
55
+ jeweler (2.0.1)
56
+ builder
57
+ bundler (>= 1.0)
58
+ git (>= 1.2.5)
59
+ github_api
60
+ highline (>= 1.6.15)
61
+ nokogiri (>= 1.5.10)
62
+ rake
63
+ rdoc
64
+ json (1.8.1)
65
+ jwt (1.0.0)
66
+ mail (2.5.4)
67
+ mime-types (~> 1.16)
68
+ treetop (~> 1.4.8)
69
+ method_source (0.8.2)
70
+ mime-types (1.25.1)
71
+ mini_portile (0.6.0)
72
+ minitest (5.3.5)
73
+ multi_json (1.10.1)
74
+ multi_xml (0.5.5)
75
+ multipart-post (2.0.0)
76
+ nokogiri (1.6.2.1)
77
+ mini_portile (= 0.6.0)
78
+ oauth2 (0.9.4)
79
+ faraday (>= 0.8, < 0.10)
80
+ jwt (~> 1.0)
81
+ multi_json (~> 1.3)
82
+ multi_xml (~> 0.5)
83
+ rack (~> 1.2)
84
+ parser (2.2.0.pre.2)
85
+ ast (>= 1.1, < 3.0)
86
+ slop (~> 3.4, >= 3.4.5)
87
+ polyglot (0.3.5)
88
+ powerpack (0.0.9)
89
+ pry (0.10.0)
90
+ coderay (~> 1.1.0)
91
+ method_source (~> 0.8.1)
92
+ slop (~> 3.4)
93
+ rack (1.5.2)
94
+ rack-test (0.6.2)
95
+ rack (>= 1.0)
96
+ rails (4.1.2)
97
+ actionmailer (= 4.1.2)
98
+ actionpack (= 4.1.2)
99
+ actionview (= 4.1.2)
100
+ activemodel (= 4.1.2)
101
+ activerecord (= 4.1.2)
102
+ activesupport (= 4.1.2)
103
+ bundler (>= 1.3.0, < 2.0)
104
+ railties (= 4.1.2)
105
+ sprockets-rails (~> 2.0)
106
+ railties (4.1.2)
107
+ actionpack (= 4.1.2)
108
+ activesupport (= 4.1.2)
109
+ rake (>= 0.8.7)
110
+ thor (>= 0.18.1, < 2.0)
111
+ rainbow (2.0.0)
112
+ rake (10.3.2)
113
+ rdoc (4.1.1)
114
+ json (~> 1.4)
115
+ rest-client (1.6.7)
116
+ mime-types (>= 1.16)
117
+ rspec (3.0.0)
118
+ rspec-core (~> 3.0.0)
119
+ rspec-expectations (~> 3.0.0)
120
+ rspec-mocks (~> 3.0.0)
121
+ rspec-core (3.0.2)
122
+ rspec-support (~> 3.0.0)
123
+ rspec-expectations (3.0.2)
124
+ diff-lcs (>= 1.2.0, < 2.0)
125
+ rspec-support (~> 3.0.0)
126
+ rspec-mocks (3.0.2)
127
+ rspec-support (~> 3.0.0)
128
+ rspec-support (3.0.2)
129
+ rubocop (0.24.0)
130
+ json (>= 1.7.7, < 2)
131
+ parser (>= 2.2.0.pre.2, < 3.0)
132
+ powerpack (~> 0.0.6)
133
+ rainbow (>= 1.99.1, < 3.0)
134
+ ruby-progressbar (~> 1.4)
135
+ ruby-progressbar (1.5.1)
136
+ simplecov (0.8.2)
137
+ docile (~> 1.1.0)
138
+ multi_json
139
+ simplecov-html (~> 0.8.0)
140
+ simplecov-html (0.8.0)
141
+ slop (3.5.0)
142
+ sprockets (2.12.1)
143
+ hike (~> 1.2)
144
+ multi_json (~> 1.0)
145
+ rack (~> 1.0)
146
+ tilt (~> 1.1, != 1.3.0)
147
+ sprockets-rails (2.1.3)
148
+ actionpack (>= 3.0)
149
+ activesupport (>= 3.0)
150
+ sprockets (~> 2.8)
151
+ thor (0.19.1)
152
+ thread_safe (0.3.4)
153
+ tilt (1.4.1)
154
+ treetop (1.4.15)
155
+ polyglot
156
+ polyglot (>= 0.3.1)
157
+ tzinfo (1.2.1)
158
+ thread_safe (~> 0.1)
159
+ yard (0.8.7.4)
160
+
161
+ PLATFORMS
162
+ ruby
163
+
164
+ DEPENDENCIES
165
+ activerecord (~> 4.1.2)
166
+ activesupport (~> 4.1.2)
167
+ bundler (~> 1.6.3)
168
+ hashie
169
+ jeweler (~> 2.0.1)
170
+ pry (~> 0.10.0)
171
+ rails (~> 4.1.2)
172
+ rdoc (~> 4.1.1)
173
+ rest-client (= 1.6.7)
174
+ rspec (~> 3.0.0)
175
+ rubocop (~> 0.24.0)
176
+ simplecov
177
+ yard (= 0.8.7.4)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Douglas Camata
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # active_spy
2
+
3
+ Watch for a method call in any class and run before/after callbacks.
4
+ You can even watch your Rails models for events (like create, update,
5
+ destroy), send these events to a event-runner instance and it redirect these
6
+ events to other apps that are subscrived for them. This gem also provides
7
+ classes that you can use to process the received events too.
8
+
9
+ ## Examples
10
+
11
+ ### Pure Ruby
12
+
13
+ ```ruby
14
+ require 'active_spy'
15
+
16
+ class Chair
17
+ include ActiveSpy::Spy
18
+
19
+ watch_method :break!
20
+
21
+ def initialize
22
+ @broken = false
23
+ end
24
+
25
+ def break!
26
+ @broken = true
27
+ puts 'Crack!!!'
28
+ end
29
+ end
30
+
31
+ class ChairEvents < ActiveSpy::Base
32
+
33
+ def before_break!
34
+ puts 'OMG! You are going to break the chair!'
35
+ end
36
+
37
+ def after_break!
38
+ puts 'You broke that chair, man.'
39
+ end
40
+ end
41
+
42
+ ActiveSpy::SpyList.activate
43
+ Chair.new.break!
44
+ ```
45
+
46
+ ### Rails app
47
+
48
+ First of all, run the install generator: `rails g active_spy:install`.
49
+ This command will generate `config/initializers/active_spy.rb` and
50
+ `config/active_spy.yml`. You must edit the YAML file to use your own app
51
+ parameters.
52
+
53
+ Then, create a `ProductEvent` class at `RAILS_ROOT/app/events`
54
+
55
+ ```ruby
56
+ class ProductEvents < ActiveSpy::Rails::Base
57
+ end
58
+ ```
59
+
60
+ Declare ActiveSpy's `model_realm`, `model_actor`, and `watch_model_changes`
61
+ methods in the model that is being watched:
62
+
63
+ ```ruby
64
+
65
+ class User < ActiveRecord::Base
66
+ belong_to :project
67
+ belongs_to :project_group
68
+
69
+ model_realm { :project }
70
+ model_actor :get_actor
71
+ watch_model_changes
72
+
73
+ def get_actor
74
+ self
75
+ end
76
+
77
+ # ActiveSpy's payload_for method override
78
+ #
79
+ # def payload_for(method)
80
+ # { user: attributes }
81
+ # end
82
+
83
+ # ActiveSpy's realm method override
84
+ #
85
+ # def realm
86
+ # return project_group if project_group.admin == self
87
+ # project
88
+ # end
89
+ end
90
+ ```
91
+
92
+ You may override `payload_for(method)`, `realm` and `actor` for more complex
93
+ use cases.
94
+
95
+ Now, when you can create, update or delete instances of User, a request will be
96
+ sent to the `event_host` and `event_port` defined in the configuration YAML file.
97
+ The body will be filled with a hash like this, as json:
98
+
99
+ ```
100
+ {
101
+ type: 'User', # object's class name
102
+ actor: user.actor, # object's actor (who made that action)
103
+ realm: user.realm, # object's realm
104
+ action: action # the action executed in the object
105
+ payload: {
106
+ user: user.attributes, # a hash with the user attributes inside the 'user'
107
+ # key
108
+ }
109
+ }
110
+ ```
111
+
112
+ Just to remember, you can override `#realm`, `#actor` and `#payload_for(method)`
113
+ to suit your own needs.
114
+
115
+ #### Handling the request received by the event runner
116
+
117
+ To handle the request received by the event-runner, you will need to mount
118
+ the `ActiveSpy::Engine` in your `routes.rb` file:
119
+
120
+ ```ruby
121
+ Rails.application.routes.draw do
122
+ mount ActiveSpy::Engine => 'active_spy', as: :active_spy
123
+ end
124
+ ```
125
+
126
+ Then, you need to create a listener class, inheriting from
127
+ `ActiveSpy::Rails::Listener` and named using the watched model's name
128
+ plus the `Listener` postfix, like this:
129
+
130
+ ```ruby
131
+ class UserListener < ActiveSpy::Rails::Listener
132
+ end
133
+ ```
134
+
135
+ The default behavior will automatically try to sync the model that was sent
136
+ with the app own database. If you need a different behavior, you can override
137
+ the `create`, `update` and `delete` methods to match your needs:
138
+
139
+ ```ruby
140
+ class UserListener < ActiveSpy::Rails::Listener
141
+
142
+ def create(object_type, payload, actor, realm)
143
+ end
144
+
145
+ def update(object_type, payload, actor, realm)
146
+ end
147
+
148
+ def destroy(object_type, payload, actor, realm)
149
+ end
150
+ end
151
+ ```
152
+
153
+ ## Contributing to active_spy
154
+
155
+ * Check out the latest master to make sure the feature hasn't been implemented
156
+ or the bug hasn't been fixed yet.
157
+ * Check out the issue tracker to make sure someone already hasn't requested it
158
+ and/or contributed it.
159
+ * Fork the project.
160
+ * Start a feature/bugfix branch.
161
+ * Commit and push until you are happy with your contribution.
162
+ * Make sure to add tests for it. This is important so I don't break it in a
163
+ future version unintentionally.
164
+ * Please try not to mess with the Rakefile, version, or history. If you want to
165
+ have your own version, or is otherwise necessary, that is fine, but please
166
+ isolate to its own commit so I can cherry-pick around it.
167
+
168
+ ## Copyright
169
+
170
+ Copyright (c) 2014 Douglas Camata. See LICENSE.txt for
171
+ further details.
172
+
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see
17
+ # http://guides.rubygems.org/specification-reference/ for more options
18
+ gem.name = 'active_spy'
19
+ gem.homepage = 'http://github.com/edools/active_spy'
20
+ gem.license = 'MIT'
21
+ gem.summary = <<-SUMMARY
22
+ Watch for a method call in any class and run before/after callbacks.
23
+ Has good integration with Rails.
24
+ SUMMARY
25
+ gem.description = <<-DESC
26
+ Watch for a method call in any class and run before/after callbacks.
27
+ You can even watch your Rails models for events (like create, update,
28
+ destroy), send these events to a event-runner instance and it redirect these
29
+ events to other apps that are subscrived for them. This gem also provides
30
+ classes that you can use to process the received events too.
31
+ DESC
32
+ gem.email = 'd.camata@gmail.com'
33
+ gem.authors = ['Douglas Camata']
34
+ gem.files = Dir['lib/**/*'] + Dir['app/**/*.rb'] + Dir['config/**/*.rb'] +
35
+ Dir['.document'] + Dir['README.md'] + Dir['LICENSE.txt'] + Dir['VERSION'] +
36
+ Dir['Rakefile'] + Dir['active_spy.gemspec'] + Dir['Gemfile*']
37
+ # dependencies defined in Gemfile
38
+ end
39
+ Jeweler::RubygemsDotOrgTasks.new
40
+
41
+ require 'rspec/core'
42
+ require 'rspec/core/rake_task'
43
+ RSpec::Core::RakeTask.new(:spec) do |spec|
44
+ spec.pattern = FileList['spec/active_spy/**/*_spec.rb']
45
+ end
46
+
47
+ desc 'Code coverage detail'
48
+ task :simplecov do
49
+ ENV['COVERAGE'] = 'true'
50
+ Rake::Task['spec'].execute
51
+ end
52
+
53
+ task default: :spec
54
+
55
+ require 'yard'
56
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0.rc
@@ -0,0 +1,101 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: active_spy 1.0.0.rc ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "active_spy"
9
+ s.version = "1.0.0.rc"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Douglas Camata"]
14
+ s.date = "2014-07-10"
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
+ s.email = "d.camata@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "active_spy.gemspec",
30
+ "app/controllers/active_event/notifications_controller.rb",
31
+ "config/initializers/active_event_configuration_loader.rb",
32
+ "config/routes.rb",
33
+ "lib/active_spy.rb",
34
+ "lib/active_spy/base.rb",
35
+ "lib/active_spy/configuration.rb",
36
+ "lib/active_spy/rails/base.rb",
37
+ "lib/active_spy/rails/engine.rb",
38
+ "lib/active_spy/rails/hook_list.rb",
39
+ "lib/active_spy/rails/listener.rb",
40
+ "lib/active_spy/rails/railtie.rb",
41
+ "lib/active_spy/rails/spy.rb",
42
+ "lib/active_spy/spy/spy.rb",
43
+ "lib/active_spy/spy/spy_list.rb",
44
+ "lib/rails/generators/active_event/install/install_generator.rb",
45
+ "lib/rails/generators/active_event/install/templates/active_event.yml",
46
+ "lib/rails/generators/active_event/install/templates/initializer.rb"
47
+ ]
48
+ s.homepage = "http://github.com/edools/active_spy"
49
+ s.licenses = ["MIT"]
50
+ s.rubygems_version = "2.2.2"
51
+ s.summary = "Watch for a method call in any class and run before/after callbacks. Has good integration with Rails."
52
+
53
+ if s.respond_to? :specification_version then
54
+ s.specification_version = 4
55
+
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_runtime_dependency(%q<activesupport>, ["~> 4.1.2"])
58
+ s.add_runtime_dependency(%q<rest-client>, ["= 1.6.7"])
59
+ s.add_runtime_dependency(%q<hashie>, [">= 0"])
60
+ s.add_development_dependency(%q<activerecord>, ["~> 4.1.2"])
61
+ s.add_development_dependency(%q<rails>, ["~> 4.1.2"])
62
+ s.add_development_dependency(%q<rubocop>, ["~> 0.24.0"])
63
+ s.add_development_dependency(%q<pry>, ["~> 0.10.0"])
64
+ s.add_development_dependency(%q<rspec>, ["~> 3.0.0"])
65
+ s.add_development_dependency(%q<yard>, ["= 0.8.7.4"])
66
+ s.add_development_dependency(%q<rdoc>, ["~> 4.1.1"])
67
+ s.add_development_dependency(%q<bundler>, ["~> 1.6.3"])
68
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
69
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
70
+ else
71
+ s.add_dependency(%q<activesupport>, ["~> 4.1.2"])
72
+ s.add_dependency(%q<rest-client>, ["= 1.6.7"])
73
+ s.add_dependency(%q<hashie>, [">= 0"])
74
+ s.add_dependency(%q<activerecord>, ["~> 4.1.2"])
75
+ s.add_dependency(%q<rails>, ["~> 4.1.2"])
76
+ s.add_dependency(%q<rubocop>, ["~> 0.24.0"])
77
+ s.add_dependency(%q<pry>, ["~> 0.10.0"])
78
+ s.add_dependency(%q<rspec>, ["~> 3.0.0"])
79
+ s.add_dependency(%q<yard>, ["= 0.8.7.4"])
80
+ s.add_dependency(%q<rdoc>, ["~> 4.1.1"])
81
+ s.add_dependency(%q<bundler>, ["~> 1.6.3"])
82
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
83
+ s.add_dependency(%q<simplecov>, [">= 0"])
84
+ end
85
+ else
86
+ s.add_dependency(%q<activesupport>, ["~> 4.1.2"])
87
+ s.add_dependency(%q<rest-client>, ["= 1.6.7"])
88
+ s.add_dependency(%q<hashie>, [">= 0"])
89
+ s.add_dependency(%q<activerecord>, ["~> 4.1.2"])
90
+ s.add_dependency(%q<rails>, ["~> 4.1.2"])
91
+ s.add_dependency(%q<rubocop>, ["~> 0.24.0"])
92
+ s.add_dependency(%q<pry>, ["~> 0.10.0"])
93
+ s.add_dependency(%q<rspec>, ["~> 3.0.0"])
94
+ s.add_dependency(%q<yard>, ["= 0.8.7.4"])
95
+ s.add_dependency(%q<rdoc>, ["~> 4.1.1"])
96
+ s.add_dependency(%q<bundler>, ["~> 1.6.3"])
97
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
98
+ s.add_dependency(%q<simplecov>, [">= 0"])
99
+ end
100
+ end
101
+
@@ -0,0 +1,6 @@
1
+ module ActiveSpy
2
+ class NotificationsController < ActionController::Base
3
+ def handle
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ require 'hashie'
2
+
3
+ yml_path = Rails.root.join('config', 'active_spy.yml')
4
+ all_settings = YAML.load_file(yml_path)
5
+ env_settings = Hashie::Mash.new(all_settings[Rails.env])
6
+
7
+ ActiveSpy.configure do |config|
8
+ config.name env_settings['name']
9
+ config.host env_settings['host']
10
+ config.port env_settings['port'].to_s
11
+
12
+ config.event_host env_settings['event_host']
13
+ config.event_port env_settings['event_port'].to_s
14
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ ActiveSpy::Engine.routes.draw do
2
+ post '/notifications/:class' => 'notifications#handle', as: :notifications
3
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveSpy
2
+ # Default template for callbacks handlers.
3
+ #
4
+ class Base
5
+ def initialize(object)
6
+ @object = object
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,71 @@
1
+ module ActiveSpy
2
+ # Defines a class to hold the configuration used to send events.
3
+ #
4
+ class Configuration
5
+ class << self
6
+ # Set the application host
7
+ #
8
+ # @param [String] host to set
9
+ #
10
+ # @return [String] the host set
11
+ def host(host = nil)
12
+ @host = host unless host.nil?
13
+ @host
14
+ end
15
+
16
+ # Set the application port
17
+ #
18
+ # @param [String] port to set
19
+ #
20
+ # @return [String] the port set
21
+ def port(port = nil)
22
+ @port = port unless port.nil?
23
+ @port
24
+ end
25
+
26
+ # Set the application name
27
+ #
28
+ # @param [String] name to set
29
+ #
30
+ # @return [String] the name set
31
+ def name(name = nil)
32
+ @name = name unless name.nil?
33
+ @name
34
+ end
35
+
36
+ # Set the default event-runner host
37
+ #
38
+ # @param [String] host to set
39
+ #
40
+ # @return [String] the host set
41
+ def event_host(host = nil)
42
+ @event_host = host unless host.nil?
43
+ @event_host
44
+ end
45
+
46
+ # Set the default event-runner port
47
+ #
48
+ # @param [String] port to set
49
+ #
50
+ # @return [String] the port set
51
+ def event_port(port = nil)
52
+ @event_port = port unless port.nil?
53
+ @event_port
54
+ end
55
+
56
+ # See how are the settings
57
+ #
58
+ # @return [Hash] actual settings
59
+ def settings
60
+ { name: @name, hostname: @host, port: @port }
61
+ end
62
+
63
+ # See how are the event settings
64
+ #
65
+ # @return [Hash] actual event settings
66
+ def event_settings
67
+ { host: @event_host, port: @event_port }
68
+ end
69
+ end
70
+ end
71
+ end