angular-faye-rails 0.1.0 → 0.1.0.1

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: cb287b38d22ae312046d423eeb8f3fb936c9da3c
4
- data.tar.gz: 4bfdc0982546ed710925b9be0840997d42630523
3
+ metadata.gz: 80cdfeb7cc2575b70abc2b10ef65286fc98bab38
4
+ data.tar.gz: 9902dea212e90f7fb10461624eb3df68f17c95f6
5
5
  SHA512:
6
- metadata.gz: 5f12fbf5d16e3f9f4ddb280df19ff33d714b6ab28996905e5549bebe19a81212d83bc8d994c9b6ebc8a1552848579f23f363119ab833f62939bd336da4ccdf52
7
- data.tar.gz: d34ac7496440378c0356632267f4ef52b40e8f5cc8d3ef065020e6d0b6a344480723d2a1e83775b21dc76c75817d396788499405848c8a158eaf23ef5fcd1271
6
+ metadata.gz: 720288a651bec51d04540c38b4797b993d73958cf7275228609542c157e49d9f332a1d2c23655c23d3f67f18b77598b458e0c2f46da5bddf834767bb2ffa637f
7
+ data.tar.gz: c64aa8c443ca9e37bf3f0d0f8dc7e6e9f987978f460897e6377dd90790b555d7d9a3ffe5ede014076ada2c78160c35c2341925ad65dbeeb14440801d620677e0
data/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
  Add the following to your gemfile:
6
6
 
7
7
  ```ruby
8
+ gem "faye"
9
+ gem "angular-rails"
8
10
  gem "angular-faye-rails"
9
11
  ```
10
12
 
@@ -14,42 +16,16 @@ Add the following directive to your Javascript manifest file (application.js):
14
16
  //= require angular-faye
15
17
  ```
16
18
 
17
- ## Example
18
-
19
- ### HTML
19
+ Add the following to your HTML layout
20
20
 
21
- ```html
22
- <script type="text/javascript" src="/js/angular.min.js"></script>
23
- <script type="text/javascript" src="/js/angular-faye.js"></script>
24
- <script type="text/javascript" src="http://localhost:9292/faye/client.js"></script>
25
- <script type="text/javascript" src="/js/app.js"></script>
21
+ ```erb
22
+ <%= javascript_include_tag "http://localhost:9292/faye/client.js" %>
26
23
  ```
27
24
 
28
- ### JavaScript (app.js)
29
-
30
- ```js
31
- var app = angular.module('myapp', ['faye']);
32
-
33
- app.factory('Faye', ['$faye', function($faye) {
34
- return $faye("http://localhost:9292/faye"); // set faye url in one place
35
- }]);
36
25
 
37
- this.TestCtrl = function($scope, $http, Faye) {
38
- // Publish
39
- Faye.publish("/channel-1", {msg: "hello"});
40
-
41
- // Subscribe
42
- $scope.data = [];
43
- Faye.subscribe("/channel-2", function(msg) {
44
- $scope.data.push(msg);
45
- });
46
-
47
- // Get just once (using $q - promise)
48
- $scope.data = Faye.get("/channel-3");
49
- };
50
- ```
26
+ ## Example
51
27
 
52
- ### CoffeeScript (the same as above, just in coffee)
28
+ ### CoffeeScript
53
29
 
54
30
  ```coffee
55
31
  app = angular.module('myapp', ['faye'])
@@ -0,0 +1,9 @@
1
+ require "angular-faye-rails/version"
2
+
3
+ module AngularFaye
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ # Rails -> use vendor directory.
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  module AngularFaye
2
2
  module Rails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.0.1"
4
4
  end
5
5
  end
@@ -1,23 +1,25 @@
1
- angular.module('faye', []);
1
+ # = require angular
2
2
 
3
- angular.module('faye').factory('$faye', ['$q', function($q){
4
- return function(url){
5
- var client = new Faye.Client(url);
6
- return {
7
- publish: function(channel, data){
8
- return client.publish(channel, data);
9
- },
10
- subscribe: function(channel, callback){
11
- return client.subscribe(channel, callback);
12
- },
13
- get: function(channel){
14
- var deferred = $q.defer();
15
- var sub = client.subscribe(channel, function(data){
16
- deferred.resolve(data);
17
- sub.cancel();
18
- });
19
- return deferred.promise;
20
- }
21
- };
22
- };
23
- }]);
3
+ angular.module "faye", []
4
+
5
+ angular.module("faye").factory "$faye", ["$q", "$rootScope", ($q, $rootScope) ->
6
+ (url) ->
7
+ scope = $rootScope
8
+ client = new Faye.Client(url)
9
+ publish: (channel, data) ->
10
+ client.publish channel, data
11
+
12
+ subscribe: (channel, callback) ->
13
+ client.subscribe channel, (data) ->
14
+ scope.$apply ->
15
+ callback(data)
16
+
17
+ get: (channel) ->
18
+ deferred = $q.defer()
19
+ sub = client.subscribe(channel, (data) ->
20
+ scope.$apply ->
21
+ deferred.resolve data
22
+ sub.cancel()
23
+ )
24
+ deferred.promise
25
+ ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular-faye-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tymon Tobolski
@@ -52,6 +52,7 @@ files:
52
52
  - README.md
53
53
  - Rakefile
54
54
  - angular-faye-rails.gemspec
55
+ - lib/angular-faye-rails.rb
55
56
  - lib/angular-faye-rails/version.rb
56
57
  - vendor/assets/javascripts/angular-faye.js.coffee
57
58
  homepage: http://github.com/rails-assets/angular-faye-rails