opal-actioncable 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7b15e15c592d97bcbad3d603ad05eb6a6acbdba9
4
+ data.tar.gz: b90cdf94bdad8b28c8d76c88ea26afa00ecb6962
5
+ SHA512:
6
+ metadata.gz: 5e74c10e87f3d60e8b2567bbb1ff0345658e940997bb4ce7542d143bf2789b85f3eb057c658d44dd93d776dc69cf67cba594996b00f46f22d7b953b9c4974ba1
7
+ data.tar.gz: 9281343203e1fa512969028de28ebfbe2e3f93fcb9d66565452559431331bc15130117525b8e0272d26bb4ac429531cf9e2b7084405d7a8417008622e4b8b33d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in opal-actioncable.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Opal::Actioncable
2
+
3
+ Bring ActionCable support to Opal.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'opal-actioncable'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install opal-actioncable
20
+
21
+ ## Usage
22
+
23
+ # assets/javascript/application.rb
24
+ require 'opal-actioncable'
25
+
26
+ class TestChannel < ActionCable::Subscription
27
+ def connected
28
+ end
29
+
30
+ def disconnected
31
+ end
32
+
33
+ def received data
34
+ end
35
+ end
36
+
37
+ consumer = ActionCable.createConsumer("/cable")
38
+ consumer.subscriptions.create TestChannel
39
+
40
+ # or
41
+
42
+ ChatChannel = TestChannel
43
+ consumer.subscriptions.create ChatChannel, {channel: 'Chat', room: 'default'}
44
+
45
+ ## Development
46
+
47
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
48
+
49
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it ( https://github.com/MichaelSp/opal-actioncable/fork )
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "opal/actioncable"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ module Opal
2
+ module Actioncable
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require "opal/actioncable/version"
2
+ require 'opal'
3
+
4
+ Opal.append_path File.expand_path('../../../opal', __FILE__)
@@ -0,0 +1,21 @@
1
+ class ActionCable::Connection
2
+ include Native::Helpers
3
+
4
+ def initialize consumer
5
+ @native = `new ActionCable.Connection(#{consumer})`
6
+ %x{
7
+ Opal.defn(self.$class(), 'isOpen', #{@native}.isOpen);
8
+ Opal.defn(self.$class(), 'isState', #{@native}.isState);
9
+ Opal.defn(self.$class(), 'send', #{@native}.send);
10
+ Opal.defn(self.$class(), 'open', #{@native}.open);
11
+ Opal.defn(self.$class(), 'close', #{@native}.close);
12
+ Opal.defn(self.$class(), 'reopen', #{@native}.reopen);
13
+ Opal.defn(self.$class(), 'getState', #{@native}.getState);
14
+ }
15
+ end
16
+
17
+ def send data
18
+ `#{@native}.send(#{data})`
19
+ end
20
+
21
+ end
@@ -0,0 +1,7 @@
1
+ class ActionCable::ConnectionMonitor
2
+ include Native::Helpers
3
+
4
+ def initialize consumer
5
+ @native = `new ActionCable.ConnectionMonitor(#{consumer})`
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ class ActionCable::Consumer
2
+ include Native::Helpers
3
+ attr_reader :subscriptions, :connection, :connectionMonitor
4
+
5
+ def initialize url
6
+ @url = url
7
+ @subscriptions = ActionCable::Subscriptions.new self
8
+ @connection = ActionCable::Connection.new self
9
+ @connectionMonitor = ActionCable::ConnectionMonitor.new self
10
+ %x{
11
+ Opal.defn(self.$class(), 'send', #{self}.$send);
12
+ }
13
+ end
14
+
15
+ def send data
16
+ @connection.send data
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ class ActionCable::Subscription
2
+ include Native::Helpers
3
+
4
+ def initialize subscriptions, params
5
+ @native = `new ActionCable.Subscription(#{subscriptions}, #{params.to_n})`
6
+ %x{Opal.defn(self.$class(), 'perform', #{@native}.perform)}
7
+ end
8
+
9
+ def perform action, data
10
+ @native.perform action, data
11
+ end
12
+
13
+ end
@@ -0,0 +1,24 @@
1
+ class ActionCable::Subscriptions
2
+ include Native::Helpers
3
+
4
+ def initialize consumer
5
+ @native = `new ActionCable.Subscriptions(#{consumer})`
6
+ %x{
7
+ Opal.defn(self.$class(), 'add', #{@native}.add);
8
+ Opal.defn(self.$class(), 'notify', #{@native}.notify);
9
+ Opal.defn(self.$class(), 'notifyAll', #{@native}.notifyAll);
10
+ Opal.defn(self.$class(), 'reload', #{@native}.reload);
11
+ Opal.defn(self.$class(), 'findAll', #{@native}.findAll);
12
+ Opal.defn(self.$class(), 'sendCommand', #{@native}.sendCommand);
13
+ Opal.defn(self.$class(), 'forget', #{@native}.forget);
14
+ Opal.defn(self.$class(), 'reject', #{@native}.reject);
15
+ self.subscriptions = #{@native}.subscriptions;
16
+ self.consumer = #{@native}.consumer;
17
+ }
18
+ end
19
+
20
+ def create mixin, params={}
21
+ params[:channel] ||= channel_name || mixin.class.name
22
+ mixin.new self, params
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+
2
+ require 'opal-actioncable/connection'
3
+ require 'opal-actioncable/connection_monitor'
4
+ require 'opal-actioncable/consumer'
5
+ require 'opal-actioncable/subscription'
6
+ require 'opal-actioncable/subscriptions'
7
+
8
+
9
+ module ActionCable
10
+
11
+ class << self
12
+ def create_consumer url
13
+ @@default_consumer ||= Consumer.new create_web_socket_url(url)
14
+ end
15
+ alias createConsumer create_consumer
16
+
17
+ def get_config name
18
+ `ActionCable.getConfig(#{name})`
19
+ end
20
+ alias getConfig get_config
21
+
22
+ def create_web_socket_url url
23
+ `ActionCable.createWebSocketURL(#{url})`
24
+ end
25
+ alias createWebSocketURL create_web_socket_url
26
+
27
+ def default_consumer
28
+ @@default_consumer
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'opal/actioncable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "opal-actioncable"
8
+ spec.version = Opal::Actioncable::VERSION
9
+ spec.authors = ["Jose Añasco", "Michael Sprauer"]
10
+ spec.email = ["joseanasco1@gmail.com", "Michael@Sprauer.net"]
11
+
12
+ spec.summary = %q{ActionCable adapter for Opal}
13
+ spec.description = %q{Bring all the ActionCable goodness back to the ruby language}
14
+ spec.homepage = "https://github.com/MichaelSp/opal-actioncable"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.9"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opal-actioncable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jose Añasco
8
+ - Michael Sprauer
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.9'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.9'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ description: Bring all the ActionCable goodness back to the ruby language
43
+ email:
44
+ - joseanasco1@gmail.com
45
+ - Michael@Sprauer.net
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - ".travis.yml"
52
+ - Gemfile
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - lib/opal/actioncable.rb
58
+ - lib/opal/actioncable/version.rb
59
+ - opal-actioncable.gemspec
60
+ - opal/opal-actioncable.rb
61
+ - opal/opal-actioncable/connection.rb
62
+ - opal/opal-actioncable/connection_monitor.rb
63
+ - opal/opal-actioncable/consumer.rb
64
+ - opal/opal-actioncable/subscription.rb
65
+ - opal/opal-actioncable/subscriptions.rb
66
+ homepage: https://github.com/MichaelSp/opal-actioncable
67
+ licenses: []
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.4.5
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: ActionCable adapter for Opal
89
+ test_files: []