nodevent 2.0.1 → 3.0.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/.rspec +2 -0
- data/.rvmrc +48 -0
- data/Gemfile +3 -0
- data/lib/nodevent/version.rb +1 -1
- data/lib/nodevent.rb +15 -9
- data/spec/nodevent_spec.rb +40 -0
- data/spec/spec_helper.rb +27 -0
- metadata +39 -53
- data/test.rb +0 -6
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p194@nodevent"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.14.5 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/Gemfile
CHANGED
data/lib/nodevent/version.rb
CHANGED
data/lib/nodevent.rb
CHANGED
@@ -27,7 +27,7 @@ module NoDevent
|
|
27
27
|
"<script src='#{Emitter.config[:host]}/api/#{namespace}' type='text/javascript'></script>".html_safe
|
28
28
|
end
|
29
29
|
end
|
30
|
-
ActionView::Base.send :include, Helper
|
30
|
+
ActionView::Base.send :include, Helper if defined?(ActionView::Base)
|
31
31
|
|
32
32
|
module Emitter
|
33
33
|
@@config = nil
|
@@ -37,10 +37,10 @@ module NoDevent
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def config
|
40
|
-
@@config
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
@@config ||= Hash.new({
|
41
|
+
:host => "http://localhost:8080",
|
42
|
+
:namespace => "nodevent"
|
43
|
+
})
|
44
44
|
@@config
|
45
45
|
end
|
46
46
|
|
@@ -52,10 +52,16 @@ module NoDevent
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def room(obj)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
obj = "#{obj.class}_#{obj.to_param}" if (defined?(ActiveRecord::Base) &&
|
56
|
+
obj.is_a?(ActiveRecord::Base))
|
57
|
+
obj
|
58
|
+
end
|
59
|
+
|
60
|
+
def room_key(obj, expires)
|
61
|
+
r = room(obj)
|
62
|
+
ts = (expires.to_f*1000).to_i
|
63
|
+
|
64
|
+
(Digest::SHA2.new << obj.to_s << ts.to_s<< @@config[:secret]).to_s
|
59
65
|
end
|
60
66
|
end
|
61
67
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
class Base;end
|
5
|
+
end
|
6
|
+
|
7
|
+
describe NoDevent do
|
8
|
+
|
9
|
+
describe "::Emitter" do
|
10
|
+
|
11
|
+
describe "#config" do
|
12
|
+
it "has a default config" do
|
13
|
+
NoDevent::Emitter.config[:host].should be_present
|
14
|
+
NoDevent::Emitter.config[:namespace].should be_present
|
15
|
+
end
|
16
|
+
|
17
|
+
it "lets you override the config" do
|
18
|
+
NoDevent::Emitter.config = {:host => "foo", :namespace => "other"}
|
19
|
+
|
20
|
+
NoDevent::Emitter.config[:host].should == "foo"
|
21
|
+
NoDevent::Emitter.config[:namespace].should == "other"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
describe "#room" do
|
25
|
+
it "gives a room name" do
|
26
|
+
NoDevent::Emitter.room('foo').should == 'foo'
|
27
|
+
end
|
28
|
+
it "converts an active record object into a string" do
|
29
|
+
class SomeClass < ActiveRecord::Base
|
30
|
+
def to_param
|
31
|
+
"some_param"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
NoDevent::Emitter.room(SomeClass.new).should == "SomeClass_some_param"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler/setup'
|
8
|
+
|
9
|
+
if defined?(Bundler)
|
10
|
+
# If you precompile assets before deploying to production, use this line
|
11
|
+
Bundler.require(:default)
|
12
|
+
# If you want your assets lazily compiled in production, use this line
|
13
|
+
# Bundler.require(:default, :assets, Rails.env)
|
14
|
+
end
|
15
|
+
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
config.filter_run :focus
|
21
|
+
|
22
|
+
# Run specs in random order to surface order dependencies. If you find an
|
23
|
+
# order dependency and want to debug it, you can fix the order by providing
|
24
|
+
# the seed, which is printed after each run.
|
25
|
+
# --seed 1234
|
26
|
+
config.order = 'random'
|
27
|
+
end
|
metadata
CHANGED
@@ -1,49 +1,42 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: nodevent
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 2.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Chris Constantine
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: redis
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 15
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 0
|
32
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 2.0.0
|
34
22
|
type: :runtime
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0
|
36
30
|
description: Write a gem description
|
37
|
-
email:
|
31
|
+
email:
|
38
32
|
- cconstan@gmail.com.com
|
39
33
|
executables: []
|
40
|
-
|
41
34
|
extensions: []
|
42
|
-
|
43
35
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
files:
|
36
|
+
files:
|
46
37
|
- .gitignore
|
38
|
+
- .rspec
|
39
|
+
- .rvmrc
|
47
40
|
- Gemfile
|
48
41
|
- LICENSE
|
49
42
|
- README.md
|
@@ -51,39 +44,32 @@ files:
|
|
51
44
|
- lib/nodevent.rb
|
52
45
|
- lib/nodevent/version.rb
|
53
46
|
- nodevent.gemspec
|
54
|
-
-
|
47
|
+
- spec/nodevent_spec.rb
|
48
|
+
- spec/spec_helper.rb
|
55
49
|
homepage: https://github.com/cconstantine/NoDevent
|
56
50
|
licenses: []
|
57
|
-
|
58
51
|
post_install_message:
|
59
52
|
rdoc_options: []
|
60
|
-
|
61
|
-
require_paths:
|
53
|
+
require_paths:
|
62
54
|
- lib
|
63
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
56
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
|
70
|
-
- 0
|
71
|
-
version: "0"
|
72
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
62
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
version: "0"
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
81
67
|
requirements: []
|
82
|
-
|
83
68
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.
|
69
|
+
rubygems_version: 1.8.24
|
85
70
|
signing_key:
|
86
71
|
specification_version: 3
|
87
72
|
summary: Write a gem summary
|
88
|
-
test_files:
|
89
|
-
|
73
|
+
test_files:
|
74
|
+
- spec/nodevent_spec.rb
|
75
|
+
- spec/spec_helper.rb
|