nodevent 3.1.9 → 3.2.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.
data/Gemfile CHANGED
@@ -5,4 +5,3 @@ source 'https://rubygems.org'
5
5
  gem 'rspec'
6
6
  gem 'rails'
7
7
  gem 'redis'
8
- gem 'httparty'
data/Gemfile.lock CHANGED
@@ -1,102 +1,98 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- actionmailer (3.2.6)
5
- actionpack (= 3.2.6)
4
+ actionmailer (3.2.12)
5
+ actionpack (= 3.2.12)
6
6
  mail (~> 2.4.4)
7
- actionpack (3.2.6)
8
- activemodel (= 3.2.6)
9
- activesupport (= 3.2.6)
7
+ actionpack (3.2.12)
8
+ activemodel (= 3.2.12)
9
+ activesupport (= 3.2.12)
10
10
  builder (~> 3.0.0)
11
11
  erubis (~> 2.7.0)
12
- journey (~> 1.0.1)
13
- rack (~> 1.4.0)
12
+ journey (~> 1.0.4)
13
+ rack (~> 1.4.5)
14
14
  rack-cache (~> 1.2)
15
15
  rack-test (~> 0.6.1)
16
- sprockets (~> 2.1.3)
17
- activemodel (3.2.6)
18
- activesupport (= 3.2.6)
16
+ sprockets (~> 2.2.1)
17
+ activemodel (3.2.12)
18
+ activesupport (= 3.2.12)
19
19
  builder (~> 3.0.0)
20
- activerecord (3.2.6)
21
- activemodel (= 3.2.6)
22
- activesupport (= 3.2.6)
20
+ activerecord (3.2.12)
21
+ activemodel (= 3.2.12)
22
+ activesupport (= 3.2.12)
23
23
  arel (~> 3.0.2)
24
24
  tzinfo (~> 0.3.29)
25
- activeresource (3.2.6)
26
- activemodel (= 3.2.6)
27
- activesupport (= 3.2.6)
28
- activesupport (3.2.6)
25
+ activeresource (3.2.12)
26
+ activemodel (= 3.2.12)
27
+ activesupport (= 3.2.12)
28
+ activesupport (3.2.12)
29
29
  i18n (~> 0.6)
30
30
  multi_json (~> 1.0)
31
31
  arel (3.0.2)
32
- builder (3.0.0)
32
+ builder (3.0.4)
33
33
  diff-lcs (1.1.3)
34
34
  erubis (2.7.0)
35
35
  hike (1.2.1)
36
- httparty (0.9.0)
37
- multi_json (~> 1.0)
38
- multi_xml
39
- i18n (0.6.0)
36
+ i18n (0.6.1)
40
37
  journey (1.0.4)
41
- json (1.7.5)
38
+ json (1.7.7)
42
39
  mail (2.4.4)
43
40
  i18n (>= 0.4.0)
44
41
  mime-types (~> 1.16)
45
42
  treetop (~> 1.4.8)
46
- mime-types (1.19)
47
- multi_json (1.0.4)
48
- multi_xml (0.5.1)
43
+ mime-types (1.21)
44
+ multi_json (1.6.0)
49
45
  polyglot (0.3.3)
50
- rack (1.4.1)
46
+ rack (1.4.5)
51
47
  rack-cache (1.2)
52
48
  rack (>= 0.4)
53
- rack-ssl (1.3.2)
49
+ rack-ssl (1.3.3)
54
50
  rack
55
- rack-test (0.6.1)
51
+ rack-test (0.6.2)
56
52
  rack (>= 1.0)
57
- rails (3.2.6)
58
- actionmailer (= 3.2.6)
59
- actionpack (= 3.2.6)
60
- activerecord (= 3.2.6)
61
- activeresource (= 3.2.6)
62
- activesupport (= 3.2.6)
53
+ rails (3.2.12)
54
+ actionmailer (= 3.2.12)
55
+ actionpack (= 3.2.12)
56
+ activerecord (= 3.2.12)
57
+ activeresource (= 3.2.12)
58
+ activesupport (= 3.2.12)
63
59
  bundler (~> 1.0)
64
- railties (= 3.2.6)
65
- railties (3.2.6)
66
- actionpack (= 3.2.6)
67
- activesupport (= 3.2.6)
60
+ railties (= 3.2.12)
61
+ railties (3.2.12)
62
+ actionpack (= 3.2.12)
63
+ activesupport (= 3.2.12)
68
64
  rack-ssl (~> 1.3.2)
69
65
  rake (>= 0.8.7)
70
66
  rdoc (~> 3.4)
71
67
  thor (>= 0.14.6, < 2.0)
72
- rake (0.9.2.2)
73
- rdoc (3.12)
68
+ rake (10.0.3)
69
+ rdoc (3.12.1)
74
70
  json (~> 1.4)
75
- redis (3.0.1)
76
- rspec (2.11.0)
77
- rspec-core (~> 2.11.0)
78
- rspec-expectations (~> 2.11.0)
79
- rspec-mocks (~> 2.11.0)
80
- rspec-core (2.11.1)
81
- rspec-expectations (2.11.2)
71
+ redis (3.0.2)
72
+ rspec (2.12.0)
73
+ rspec-core (~> 2.12.0)
74
+ rspec-expectations (~> 2.12.0)
75
+ rspec-mocks (~> 2.12.0)
76
+ rspec-core (2.12.2)
77
+ rspec-expectations (2.12.1)
82
78
  diff-lcs (~> 1.1.3)
83
- rspec-mocks (2.11.1)
84
- sprockets (2.1.3)
79
+ rspec-mocks (2.12.2)
80
+ sprockets (2.2.2)
85
81
  hike (~> 1.2)
82
+ multi_json (~> 1.0)
86
83
  rack (~> 1.0)
87
84
  tilt (~> 1.1, != 1.3.0)
88
- thor (0.15.4)
85
+ thor (0.17.0)
89
86
  tilt (1.3.3)
90
- treetop (1.4.10)
87
+ treetop (1.4.12)
91
88
  polyglot
92
89
  polyglot (>= 0.3.1)
93
- tzinfo (0.3.33)
90
+ tzinfo (0.3.35)
94
91
 
95
92
  PLATFORMS
96
93
  ruby
97
94
 
98
95
  DEPENDENCIES
99
- httparty
100
96
  rails
101
97
  redis
102
98
  rspec
data/lib/nodevent.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'digest/sha2'
2
2
  require 'json'
3
3
  require 'redis'
4
- require 'nodevent/net_publisher'
5
4
 
6
5
  module NoDevent
6
+ HOUR = 60 * 60
7
7
 
8
8
  def self.included(base)
9
9
  raise "No longer supported, Please include NoDevent::Base instead"
@@ -37,6 +37,9 @@ module NoDevent
37
37
  Emitter.room_key(self.room, expires)
38
38
  end
39
39
 
40
+ def room_json(expires_after=HOUR)
41
+ {room: room, key: room_key(Time.now + expires_after)}
42
+ end
40
43
 
41
44
  def nodevent_create
42
45
  NoDevent::Emitter.emit(self.class.name, 'create', self)
@@ -50,14 +53,15 @@ module NoDevent
50
53
 
51
54
 
52
55
  module Helper
53
- def javascript_include_nodevent
56
+ def nodevent_url
54
57
  host = NoDevent::Emitter.config['host']
55
58
  namespace = NoDevent::Emitter.config['namespace']
56
59
  namespace = '/' + namespace unless namespace[0] == '/'
57
-
58
-
59
- "<script src='#{host}/api#{namespace}' type='text/javascript'></script>".html_safe
60
- end
60
+ "#{host}/api#{namespace}"
61
+ end
62
+ def javascript_include_nodevent
63
+ "<script src='#{nodevent_url}' type='text/javascript'></script>".html_safe
64
+ end
61
65
  end
62
66
  ActionView::Base.send :include, Helper if defined?(ActionView::Base)
63
67
 
@@ -72,11 +76,6 @@ module NoDevent
72
76
 
73
77
  @@publisher = Redis.new(:host => r_config["host"], :port => r_config["port"], :db => r_config["db"])
74
78
  end
75
- if @@config.keys.include?("spigot.io")
76
- @@publisher = NoDevent::NetPublisher.new(obj)
77
- config["namespace"] = @@publisher.namespace
78
- config["secret"] = @@publisher.secret
79
- end
80
79
  end
81
80
 
82
81
  def config
@@ -1,3 +1,3 @@
1
1
  module Nodevent
2
- VERSION = "3.1.9"
2
+ VERSION = "3.2.0"
3
3
  end
data/nodevent.gemspec CHANGED
@@ -16,5 +16,4 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Nodevent::VERSION
17
17
 
18
18
  gem.add_dependency('redis', '>= 2.0.0')
19
- gem.add_dependency('httparty', '>= 0.9.0')
20
19
  end
data/spec/base_spec.rb CHANGED
@@ -45,21 +45,6 @@ describe NoDevent do
45
45
  it { should == $redis}
46
46
 
47
47
  end
48
-
49
- describe "with an api_key" do
50
- before do
51
- NoDevent::Emitter.config = {
52
- "host" => "http://thehost",
53
- "namespace" => "/nodevent",
54
- "secret" => "asdf",
55
- "spigot.io" => {
56
- "api_key"=> "bar",
57
- }
58
- }
59
- end
60
- it { should be_an_instance_of(NoDevent::NetPublisher)}
61
- it { should_not == $redis}
62
- end
63
48
  end
64
49
  describe ".config=" do
65
50
  describe "the class" do
@@ -128,6 +113,16 @@ describe NoDevent do
128
113
  end
129
114
  let(:instance) {ModelMock.new( 'theparam') }
130
115
 
116
+ describe "#room_json" do
117
+ before { Time.stub(:now => Time.new(2011, 1, 10))}
118
+ subject {instance.room_json(2 * NoDevent::HOUR)}
119
+ it "should have both the room name and the key" do
120
+ subject.keys.should =~ [:room, :key]
121
+ subject[:key].should == instance.room_key(Time.now + 2*NoDevent::HOUR)
122
+ subject[:room].should == instance.room
123
+ end
124
+ end
125
+
131
126
  it { instance.room.should == "ModelMock_theparam" }
132
127
  it "should emit to the right room" do
133
128
  NoDevent::Emitter.publisher.should_receive(:publish).with("/nodevent",
@@ -216,5 +211,5 @@ describe NoDevent do
216
211
  end
217
212
  end
218
213
  end
219
- end
214
+ end
220
215
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nodevent
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.9
4
+ version: 3.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 Z
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 2.0.0
30
- - !ruby/object:Gem::Dependency
31
- name: httparty
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 0.9.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.9.0
46
30
  description: Write a gem description
47
31
  email:
48
32
  - cconstan@gmail.com
@@ -59,12 +43,10 @@ files:
59
43
  - README.md
60
44
  - Rakefile
61
45
  - lib/nodevent.rb
62
- - lib/nodevent/net_publisher.rb
63
46
  - lib/nodevent/version.rb
64
47
  - nodevent.gemspec
65
48
  - spec/base_spec.rb
66
49
  - spec/emitter_spec.rb
67
- - spec/net_publisher_spec.rb
68
50
  - spec/spec_helper.rb
69
51
  homepage: https://github.com/cconstantine/NoDevent-gem
70
52
  licenses: []
@@ -86,12 +68,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
68
  version: '0'
87
69
  requirements: []
88
70
  rubyforge_project:
89
- rubygems_version: 1.8.21
71
+ rubygems_version: 1.8.24
90
72
  signing_key:
91
73
  specification_version: 3
92
74
  summary: Write a gem summary
93
75
  test_files:
94
76
  - spec/base_spec.rb
95
77
  - spec/emitter_spec.rb
96
- - spec/net_publisher_spec.rb
97
78
  - spec/spec_helper.rb
@@ -1,59 +0,0 @@
1
- require 'httparty'
2
-
3
- module NoDevent
4
- class NetPublisher
5
- include HTTParty
6
-
7
- # HTTParty settings
8
- headers 'ContentType' => 'application/json' ,'Accept' => 'application/json'
9
-
10
- format :json
11
- default_timeout 5
12
-
13
- HOSTNAME="spigot.io"
14
-
15
- attr_accessor :namespace
16
- attr_accessor :secret
17
- attr_accessor :api_key
18
-
19
- def initialize(opts)
20
- self.api_key = opts["spigot.io"]["api_key"]
21
- self.namespace = opts["namespace"]
22
- self.secret = opts["secret"]
23
-
24
- unless self.namespace
25
- body = generate_namespace.body
26
- resp = JSON.parse body
27
- self.namespace = "/" + resp["id"]
28
- self.secret = resp["secret"]
29
- end
30
- end
31
-
32
- def publish(where, message)
33
- message = JSON.parse(message)
34
- req = {
35
- :body => {
36
- :api_key => api_key,
37
- :event => message["event"],
38
- :room => message["room"],
39
- :message => message["message"]
40
- }
41
- }
42
- self.class.post("http://#{HOSTNAME}/namespaces#{where}/emit",req)
43
-
44
- end
45
-
46
- def generate_namespace
47
- require "socket"
48
- hostname = Socket.gethostname
49
- suffix = " (#{Rails.env})" if defined?(Rails)
50
- req = {
51
- :body => {
52
- :api_key => api_key,
53
- :namespace => {"name" => "#{hostname}#{suffix}"}
54
- }
55
- }
56
- self.class.post("http://#{HOSTNAME}/namespaces",req)
57
- end
58
- end
59
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ::NoDevent::NetPublisher do
4
- let(:net_publisher) {NoDevent::NetPublisher.new(params)}
5
- subject { net_publisher }
6
-
7
- pending "a running service" do
8
- context "without a namespace" do
9
- let(:params) do
10
- {
11
- "spigot.io" => {"api_key" => "f2343b5d54557ee368a37a5d77ccd0c6"}
12
- }
13
- end
14
- it "does something" do
15
- subject.namespace.should be_present
16
- end
17
- context "#publish" do
18
- subject {net_publisher.publish(net_publisher.namespace, {:room => "the_room", :event => "the_event", :message => "the_message"}.to_json)}
19
- it {should be_success}
20
- end
21
- end
22
- end
23
- end