puggernaut 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/public/spec.html ADDED
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
+ <html>
3
+ <head>
4
+ <link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
5
+ <script src="jquery.js"></script>
6
+ <script src="qunit.js"></script>
7
+ <script src="puggernaut.js"></script>
8
+ <script src="spec.js"></script>
9
+ </head>
10
+ <body>
11
+ <h1 id="qunit-header">Puggernaut</h1>
12
+ <h2 id="qunit-banner"></h2>
13
+ <h2 id="qunit-userAgent"></h2>
14
+ <ol id="qunit-tests"></ol>
15
+ <div id="qunit-fixture">test markup, will be hidden</div>
16
+ </body>
17
+ </html>
data/public/spec.js ADDED
@@ -0,0 +1,95 @@
1
+ $(function() {
2
+
3
+ module("Single message", {
4
+ setup: function() {
5
+ Puggernaut.watch('single', function(e, message) {
6
+ equals(message, 'single message');
7
+ Puggernaut.unwatch('single');
8
+ start();
9
+ });
10
+ }
11
+ });
12
+
13
+ test("should receive a message", function() {
14
+ stop();
15
+ $.get('/single');
16
+ });
17
+
18
+ module("Multiple messages", {
19
+ setup: function() {
20
+ var executions = 0;
21
+ Puggernaut.watch('multiple', function(e, message) {
22
+ executions += 1;
23
+ equals(message, 'multiple message ' + executions);
24
+ if (executions == 2) {
25
+ Puggernaut.unwatch('multiple');
26
+ start();
27
+ }
28
+ });
29
+ }
30
+ });
31
+
32
+ test("should receive multiple messages", function() {
33
+ stop();
34
+ $.get('/multiple');
35
+ });
36
+
37
+ module("Last message", {
38
+ setup: function() {
39
+ Puggernaut.watch('last', function(e, message) {
40
+ if (message != 'last message 2') {
41
+ equals(message, 'last message 1');
42
+ Puggernaut.disabled = true;
43
+ $.get('/last/2', function() {
44
+ Puggernaut.disabled = false;
45
+ Puggernaut.watch('last', function(e, message) {
46
+ equals(message, 'last message 2');
47
+ Puggernaut.unwatch('last');
48
+ start();
49
+ });
50
+ });
51
+ }
52
+ });
53
+ }
54
+ });
55
+
56
+ test("should pick up last message", function() {
57
+ stop();
58
+ $.get('/last/1');
59
+ });
60
+
61
+ module("Multiple channels");
62
+
63
+ test("should receive all messages", function() {
64
+ stop();
65
+
66
+ var executions = 0;
67
+ var total_runs = 0;
68
+
69
+ Puggernaut.disabled = true;
70
+
71
+ Puggernaut
72
+ .watch('single', function(e, message) {
73
+ total_runs += 1;
74
+ equals(message, 'single message');
75
+ Puggernaut.unwatch('single');
76
+ if (total_runs == 3)
77
+ start();
78
+ });
79
+
80
+ Puggernaut.disabled = false;
81
+
82
+ Puggernaut
83
+ .watch('multiple', function(e, message) {
84
+ executions += 1;
85
+ total_runs += 1;
86
+ equals(message, 'multiple message ' + executions);
87
+ if (executions == 2)
88
+ Puggernaut.unwatch('multiple');
89
+ if (total_runs == 3)
90
+ start();
91
+ });
92
+
93
+ $.get('/multiple/channels');
94
+ });
95
+ });
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ root = File.expand_path('../', __FILE__)
3
+ lib = "#{root}/lib"
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require 'puggernaut/gems'
7
+ Puggernaut::Gems.gemset ||= ENV['GEMSET'] || :default
8
+
9
+ Gem::Specification.new do |s|
10
+ Puggernaut::Gems.gemspec.hash.each do |key, value|
11
+ if key == 'name' && Puggernaut::Gems.gemset != :default
12
+ s.name = "#{value}-#{Puggernaut::Gems.gemset}"
13
+ elsif key == 'summary' && Puggernaut::Gems.gemset == :solo
14
+ s.summary = value + " (no dependencies)"
15
+ elsif !%w(dependencies development_dependencies).include?(key)
16
+ s.send "#{key}=", value
17
+ end
18
+ end
19
+
20
+ Puggernaut::Gems.dependencies.each do |g|
21
+ s.add_dependency g.to_s, Puggernaut::Gems.versions[g]
22
+ end
23
+
24
+ Puggernaut::Gems.development_dependencies.each do |g|
25
+ s.add_development_dependency g.to_s, Puggernaut::Gems.versions[g]
26
+ end
27
+
28
+ s.executables = `cd #{root} && git ls-files -- {bin}/*`.split("\n").collect { |f| File.basename(f) }
29
+ s.files = `cd #{root} && git ls-files`.split("\n")
30
+ s.require_paths = %w(lib)
31
+ s.test_files = `cd #{root} && git ls-files -- {features,test,spec}/*`.split("\n")
32
+ end
data/puggernaut.png ADDED
Binary file
@@ -0,0 +1,9 @@
1
+ name:
2
+ rake: =0.8.7
3
+ default:
4
+ mysql: =2.8.1
5
+ rspec: =1.3.1
6
+ rspec2:
7
+ mysql2: =0.2.6
8
+ rspec: =2.3.0
9
+ solo: null
@@ -0,0 +1,15 @@
1
+ name: name
2
+ version: 0.1.0
3
+ authors:
4
+ - Author
5
+ email: email@email.com
6
+ homepage: http://github.com/author/name
7
+ summary: Summary
8
+ description: Description
9
+ dependencies:
10
+ - rake
11
+ - default:
12
+ - mysql
13
+ - rspec2:
14
+ - mysql2
15
+ development_dependencies: null
@@ -0,0 +1,249 @@
1
+ require 'spec_helper'
2
+
3
+ describe Puggernaut::Gems do
4
+
5
+ before(:each) do
6
+ @old_config = Puggernaut::Gems.config
7
+
8
+ Puggernaut::Gems.config.gemspec = "#{$root}/spec/fixtures/gemspec.yml"
9
+ Puggernaut::Gems.config.gemsets = [
10
+ "#{$root}/spec/fixtures/gemsets.yml"
11
+ ]
12
+ Puggernaut::Gems.config.warn = true
13
+
14
+ Puggernaut::Gems.gemspec true
15
+ Puggernaut::Gems.gemset = nil
16
+ end
17
+
18
+ after(:each) do
19
+ Puggernaut::Gems.config = @old_config
20
+ end
21
+
22
+ describe :activate do
23
+ it "should activate gems" do
24
+ Puggernaut::Gems.stub!(:gem)
25
+ Puggernaut::Gems.should_receive(:gem).with('rspec', '=1.3.1')
26
+ Puggernaut::Gems.should_receive(:gem).with('rake', '=0.8.7')
27
+ Puggernaut::Gems.activate :rspec, 'rake'
28
+ end
29
+ end
30
+
31
+ describe :gemset= do
32
+ before(:each) do
33
+ Puggernaut::Gems.config.gemsets = [
34
+ {
35
+ :name => {
36
+ :rake => '>0.8.6',
37
+ :default => {
38
+ :externals => '=1.0.2'
39
+ }
40
+ }
41
+ },
42
+ "#{$root}/spec/fixtures/gemsets.yml"
43
+ ]
44
+ end
45
+
46
+ describe :default do
47
+ before(:each) do
48
+ Puggernaut::Gems.gemset = :default
49
+ end
50
+
51
+ it "should set @gemset" do
52
+ Puggernaut::Gems.gemset.should == :default
53
+ end
54
+
55
+ it "should set @gemsets" do
56
+ Puggernaut::Gems.gemsets.should == {
57
+ :name => {
58
+ :rake => ">0.8.6",
59
+ :default => {
60
+ :externals => '=1.0.2',
61
+ :mysql => "=2.8.1",
62
+ :rspec => "=1.3.1"
63
+ },
64
+ :rspec2 => {
65
+ :mysql2 => "=0.2.6",
66
+ :rspec => "=2.3.0"
67
+ },
68
+ :solo => nil
69
+ }
70
+ }
71
+ end
72
+
73
+ it "should set Gems.versions" do
74
+ Puggernaut::Gems.versions.should == {
75
+ :externals => "=1.0.2",
76
+ :mysql => "=2.8.1",
77
+ :rake => ">0.8.6",
78
+ :rspec => "=1.3.1"
79
+ }
80
+ end
81
+
82
+ it "should return proper values for Gems.dependencies" do
83
+ Puggernaut::Gems.dependencies.should == [ :rake, :mysql ]
84
+ Puggernaut::Gems.development_dependencies.should == []
85
+ end
86
+
87
+ it "should return proper values for Gems.gemset_names" do
88
+ Puggernaut::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
89
+ end
90
+ end
91
+
92
+ describe :rspec2 do
93
+ before(:each) do
94
+ Puggernaut::Gems.gemset = "rspec2"
95
+ end
96
+
97
+ it "should set @gemset" do
98
+ Puggernaut::Gems.gemset.should == :rspec2
99
+ end
100
+
101
+ it "should set @gemsets" do
102
+ Puggernaut::Gems.gemsets.should == {
103
+ :name => {
104
+ :rake => ">0.8.6",
105
+ :default => {
106
+ :externals => '=1.0.2',
107
+ :mysql => "=2.8.1",
108
+ :rspec => "=1.3.1"
109
+ },
110
+ :rspec2 => {
111
+ :mysql2=>"=0.2.6",
112
+ :rspec => "=2.3.0"
113
+ },
114
+ :solo => nil
115
+ }
116
+ }
117
+ end
118
+
119
+ it "should set Gems.versions" do
120
+ Puggernaut::Gems.versions.should == {
121
+ :mysql2 => "=0.2.6",
122
+ :rake => ">0.8.6",
123
+ :rspec => "=2.3.0"
124
+ }
125
+ end
126
+
127
+ it "should return proper values for Gems.dependencies" do
128
+ Puggernaut::Gems.dependencies.should == [ :rake, :mysql2 ]
129
+ Puggernaut::Gems.development_dependencies.should == []
130
+ end
131
+
132
+ it "should return proper values for Gems.gemset_names" do
133
+ Puggernaut::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
134
+ end
135
+ end
136
+
137
+ describe :solo do
138
+ before(:each) do
139
+ Puggernaut::Gems.gemset = :solo
140
+ end
141
+
142
+ it "should set @gemset" do
143
+ Puggernaut::Gems.gemset.should == :solo
144
+ end
145
+
146
+ it "should set @gemsets" do
147
+ Puggernaut::Gems.gemsets.should == {
148
+ :name => {
149
+ :rake => ">0.8.6",
150
+ :default => {
151
+ :externals => '=1.0.2',
152
+ :mysql => "=2.8.1",
153
+ :rspec => "=1.3.1"
154
+ },
155
+ :rspec2 => {
156
+ :mysql2=>"=0.2.6",
157
+ :rspec => "=2.3.0"
158
+ },
159
+ :solo => nil
160
+ }
161
+ }
162
+ end
163
+
164
+ it "should set Gems.versions" do
165
+ Puggernaut::Gems.versions.should == {:rake=>">0.8.6"}
166
+ end
167
+
168
+ it "should return proper values for Gems.dependencies" do
169
+ Puggernaut::Gems.dependencies.should == [:rake]
170
+ Puggernaut::Gems.development_dependencies.should == []
171
+ end
172
+
173
+ it "should return proper values for Gems.gemset_names" do
174
+ Puggernaut::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
175
+ end
176
+ end
177
+
178
+ describe :nil do
179
+ before(:each) do
180
+ Puggernaut::Gems.gemset = nil
181
+ end
182
+
183
+ it "should set everything to nil" do
184
+ Puggernaut::Gems.gemset.should == nil
185
+ Puggernaut::Gems.gemsets.should == nil
186
+ Puggernaut::Gems.versions.should == nil
187
+ end
188
+ end
189
+ end
190
+
191
+ describe :gemset_from_loaded_specs do
192
+ before(:each) do
193
+ Gem.stub!(:loaded_specs)
194
+ end
195
+
196
+ it "should return the correct gemset for name gem" do
197
+ Gem.should_receive(:loaded_specs).and_return({ "name" => nil })
198
+ Puggernaut::Gems.send(:gemset_from_loaded_specs).should == :default
199
+ end
200
+
201
+ it "should return the correct gemset for name-rspec gem" do
202
+ Gem.should_receive(:loaded_specs).and_return({ "name-rspec2" => nil })
203
+ Puggernaut::Gems.send(:gemset_from_loaded_specs).should == :rspec2
204
+ end
205
+ end
206
+
207
+ describe :reload_gemspec do
208
+ it "should populate @gemspec" do
209
+ Puggernaut::Gems.gemspec.hash.should == {
210
+ "name" => "name",
211
+ "version" => "0.1.0",
212
+ "authors" => ["Author"],
213
+ "email" => "email@email.com",
214
+ "homepage" => "http://github.com/author/name",
215
+ "summary" => "Summary",
216
+ "description" => "Description",
217
+ "dependencies" => [
218
+ "rake",
219
+ { "default" => [ "mysql" ] },
220
+ { "rspec2" => [ "mysql2" ] }
221
+ ],
222
+ "development_dependencies" => nil
223
+ }
224
+ end
225
+
226
+ it "should create methods from keys of @gemspec" do
227
+ Puggernaut::Gems.gemspec.name.should == "name"
228
+ Puggernaut::Gems.gemspec.version.should == "0.1.0"
229
+ Puggernaut::Gems.gemspec.authors.should == ["Author"]
230
+ Puggernaut::Gems.gemspec.email.should == "email@email.com"
231
+ Puggernaut::Gems.gemspec.homepage.should == "http://github.com/author/name"
232
+ Puggernaut::Gems.gemspec.summary.should == "Summary"
233
+ Puggernaut::Gems.gemspec.description.should == "Description"
234
+ Puggernaut::Gems.gemspec.dependencies.should == [
235
+ "rake",
236
+ { "default" => ["mysql"] },
237
+ { "rspec2" => [ "mysql2" ] }
238
+ ]
239
+ Puggernaut::Gems.gemspec.development_dependencies.should == nil
240
+ end
241
+
242
+ it "should produce a valid gemspec" do
243
+ Puggernaut::Gems.gemset = :default
244
+ gemspec = File.expand_path("../../../puggernaut.gemspec", __FILE__)
245
+ gemspec = eval(File.read(gemspec), binding, gemspec)
246
+ gemspec.validate.should == true
247
+ end
248
+ end
249
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Puggernaut do
4
+ end
@@ -0,0 +1,11 @@
1
+ require 'pp'
2
+
3
+ $root = File.expand_path('../../', __FILE__)
4
+ require "#{$root}/lib/puggernaut/gems"
5
+
6
+ Puggernaut::Gems.activate :rspec
7
+
8
+ require "#{$root}/lib/puggernaut"
9
+
10
+ Spec::Runner.configure do |config|
11
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puggernaut
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Winton Welsh
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-18 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: eventmachine
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 59
30
+ segments:
31
+ - 0
32
+ - 12
33
+ - 10
34
+ version: 0.12.10
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Simple server push implementation using eventmachine and long polling
38
+ email: mail@wintoni.us
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.md
49
+ - Rakefile
50
+ - bin/puggernaut
51
+ - config.ru
52
+ - config/gemsets.yml
53
+ - config/gemspec.yml
54
+ - lib/puggernaut.rb
55
+ - lib/puggernaut/client.rb
56
+ - lib/puggernaut/gems.rb
57
+ - lib/puggernaut/logger.rb
58
+ - lib/puggernaut/server.rb
59
+ - lib/puggernaut/server/channel.rb
60
+ - lib/puggernaut/server/http.rb
61
+ - lib/puggernaut/server/tcp.rb
62
+ - lib/puggernaut/spec_server.rb
63
+ - public/jquery.js
64
+ - public/puggernaut.js
65
+ - public/qunit.css
66
+ - public/qunit.js
67
+ - public/spec.html
68
+ - public/spec.js
69
+ - puggernaut.gemspec
70
+ - puggernaut.png
71
+ - spec/fixtures/gemsets.yml
72
+ - spec/fixtures/gemspec.yml
73
+ - spec/puggernaut/gems_spec.rb
74
+ - spec/puggernaut_spec.rb
75
+ - spec/spec_helper.rb
76
+ has_rdoc: true
77
+ homepage: http://github.com/winton/puggernaut
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options: []
82
+
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ requirements: []
104
+
105
+ rubyforge_project:
106
+ rubygems_version: 1.4.2
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Simple server push implementation using eventmachine and long polling
110
+ test_files:
111
+ - spec/fixtures/gemsets.yml
112
+ - spec/fixtures/gemspec.yml
113
+ - spec/puggernaut/gems_spec.rb
114
+ - spec/puggernaut_spec.rb
115
+ - spec/spec_helper.rb