radiowaves 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in radiowaves.gemspec
4
+ gemspec
5
+
6
+ gem 'em-websocket'
7
+ gem 'web-socket-ruby', :require => 'web_socket'
@@ -0,0 +1,48 @@
1
+ # radiowaves
2
+
3
+ Transmitts notifications in Rails to a websocket. Born as a supporting gem for ["Rails panel" Chrome
4
+ extension](https://github.com/dejan/rails_panel).
5
+
6
+ ## Installation
7
+
8
+ Add radiowaves gem to development group in Gemfile:
9
+
10
+ group :development do
11
+ gem 'radiowaves'
12
+ end
13
+
14
+ ## Usage
15
+
16
+ Start radiowaves websocket server:
17
+
18
+ bundle exec rake radiowaves:start
19
+
20
+ Now subscribe to ws://localhost:12010 and start receiving notifications from
21
+ Rails via websocket.
22
+
23
+ ## Licence
24
+
25
+ Copyright (c) 2012 Dejan Simic
26
+
27
+ MIT License
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining
30
+ a copy of this software and associated documentation files (the
31
+ "Software"), to deal in the Software without restriction, including
32
+ without limitation the rights to use, copy, modify, merge, publish,
33
+ distribute, sublicense, and/or sell copies of the Software, and to
34
+ permit persons to whom the Software is furnished to do so, subject to
35
+ the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be
38
+ included in all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
41
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
43
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
44
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
45
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
46
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
47
+
48
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ require 'radiowaves/version'
2
+ require 'radiowaves/transmitter'
3
+ require 'radiowaves/server'
4
+
5
+ module Radiowaves
6
+ end
@@ -0,0 +1,29 @@
1
+ require 'em-websocket'
2
+
3
+ module Radiowaves
4
+ class Server < ::Rails::Railtie
5
+
6
+ rake_tasks do
7
+ load "tasks/radiowaves.tasks"
8
+ end
9
+
10
+ def self.start!(host='localhost', port=12010)
11
+ EventMachine.run {
12
+ @channel = EM::Channel.new
13
+ EventMachine::WebSocket.start(:host => host, :port => port) do |ws|
14
+ ws.onopen {
15
+ sid = @channel.subscribe { |msg| ws.send msg }
16
+ ws.onmessage { |msg|
17
+ @channel.push "#{msg}"
18
+ }
19
+ ws.onclose {
20
+ @channel.unsubscribe(sid)
21
+ }
22
+ }
23
+ end
24
+ }
25
+ end
26
+ end
27
+ end
28
+
29
+
@@ -0,0 +1,18 @@
1
+ require 'web_socket'
2
+
3
+ module Radiowaves
4
+ class Transmitter < ::Rails::Railtie
5
+
6
+ initializer "radiowaves.transmitter" do
7
+ Radiowaves::Transmitter.start!
8
+ end
9
+
10
+ def self.start!(host='localhost', port=12010)
11
+ ActiveSupport::Notifications.subscribe('process_action.action_controller') do |*args|
12
+ client = WebSocket.new("ws://#{host}:#{port}/")
13
+ client.send(ActiveSupport::Notifications::Event.new(*args).to_json)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,3 @@
1
+ module Radiowaves
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ desc 'Start radiowaves server'
2
+ namespace :radiowaves do
3
+ task :start do
4
+ puts "Starting radiowaves server..."
5
+ Radiowaves::Server.start!
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'radiowaves/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "radiowaves"
8
+ gem.version = Radiowaves::VERSION
9
+ gem.authors = ["Dejan Simic"]
10
+ gem.email = ["desimic@gmail.com"]
11
+ gem.description = %q{Transmits notifications in Rails to a websocket. Born as a supporting gem for "Rails panel" extension in Chrome.}
12
+ gem.summary = %q{Transmits notifications in Rails to a websocket. Born as a supporting gem for "Rails panel" extension in Chrome.}
13
+ gem.homepage = "https://github.com/dejan/radiowaves"
14
+
15
+ gem.add_dependency('em-websocket')
16
+ gem.add_dependency('web-socket-ruby')
17
+
18
+ gem.files = `git ls-files`.split($/)
19
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
20
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
+ gem.require_paths = ["lib"]
22
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiowaves
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dejan Simic
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: em-websocket
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: web-socket-ruby
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Transmits notifications in Rails to a websocket. Born as a supporting
47
+ gem for "Rails panel" extension in Chrome.
48
+ email:
49
+ - desimic@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - README.md
57
+ - Rakefile
58
+ - lib/radiowaves.rb
59
+ - lib/radiowaves/server.rb
60
+ - lib/radiowaves/transmitter.rb
61
+ - lib/radiowaves/version.rb
62
+ - lib/tasks/radiowaves.tasks
63
+ - radiowaves.gemspec
64
+ homepage: https://github.com/dejan/radiowaves
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.24
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Transmits notifications in Rails to a websocket. Born as a supporting gem
88
+ for "Rails panel" extension in Chrome.
89
+ test_files: []
90
+ has_rdoc: