sinatra-websocketio 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.1 2013-03-17
2
+
3
+ * read javascript file - Sinatra::WebSocketIO.javascript
4
+
1
5
  === 0.1.0 2013-03-16
2
6
 
3
7
  * support modular style application
@@ -1,28 +1,12 @@
1
1
  module Sinatra
2
2
  module WebSocketIO
3
3
 
4
- def websocketio=(options)
5
- WebSocketIO.options = options
6
- end
7
-
8
- def websocketio
9
- WebSocketIO.options
10
- end
11
-
12
4
  def self.registered(app)
13
5
  app.helpers Sinatra::WebSocketIO::Helpers
14
6
 
15
7
  app.get '/websocketio/websocketio.js' do
16
8
  content_type 'application/javascript'
17
- @js ||= (
18
- js = ''
19
- Dir.glob(File.expand_path '../js/*.js', File.dirname(__FILE__)).each do |i|
20
- File.open(i) do |f|
21
- js += f.read
22
- end
23
- end
24
- ERB.new(js).result(binding)
25
- )
9
+ @js ||= ERB.new(Sinatra::WebSocketIO.javascript).result(binding)
26
10
  end
27
11
  end
28
12
 
@@ -0,0 +1,16 @@
1
+ module Sinatra
2
+ module WebSocketIO
3
+
4
+ def self.javascript(*js_file_names)
5
+ js_file_names = ['websocketio.js', 'event_emitter.js'] if js_file_names.empty?
6
+ js = ''
7
+ js_file_names.each do |i|
8
+ File.open(File.expand_path "../js/#{i}", File.dirname(__FILE__)) do |f|
9
+ js += f.read
10
+ end
11
+ end
12
+ js
13
+ end
14
+
15
+ end
16
+ end
@@ -1,6 +1,14 @@
1
1
  module Sinatra
2
2
  module WebSocketIO
3
3
 
4
+ def websocketio=(options)
5
+ WebSocketIO.options = options
6
+ end
7
+
8
+ def websocketio
9
+ WebSocketIO.options
10
+ end
11
+
4
12
  def self.default_options
5
13
  {
6
14
  :port => [8080, lambda{|v| v.kind_of? Fixnum and v > 0 }]
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module WebSocketIO
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -8,6 +8,7 @@ require File.expand_path '../sinatra-websocketio/version', File.dirname(__FILE__
8
8
  require File.expand_path '../sinatra-websocketio/helpers', File.dirname(__FILE__)
9
9
  require File.expand_path '../sinatra-websocketio/options', File.dirname(__FILE__)
10
10
  require File.expand_path '../sinatra-websocketio/websocketio', File.dirname(__FILE__)
11
+ require File.expand_path '../sinatra-websocketio/javascript', File.dirname(__FILE__)
11
12
  require File.expand_path '../sinatra-websocketio/application', File.dirname(__FILE__)
12
13
 
13
14
  module Sinatra
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.email = ["hashimoto@shokai.org"]
10
10
  gem.description = %q{Node.js like WebSocket I/O plugin for Sinatra.}
11
11
  gem.summary = gem.description
12
- gem.homepage = "https://github.com/shokai/sinatra-websocketio"
12
+ gem.homepage = "http://shokai.github.com/sinatra-websocketio"
13
13
 
14
14
  gem.files = `git ls-files`.split($/).reject{|i| i=="Gemfile.lock" }
15
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
data/test/test_helper.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'rubygems'
2
+ require 'bundler/setup'
3
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
2
4
  require 'minitest/autorun'
3
5
  require 'em-websocketio-client'
4
6
  require File.expand_path 'app', File.dirname(__FILE__)
5
7
 
6
- $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
7
8
 
8
9
  ['SIGHUP', 'SIGINT', 'SIGKILL', 'SIGTERM'].each do |sig|
9
10
  Kernel.trap sig do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-websocketio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -159,6 +159,7 @@ files:
159
159
  - lib/sinatra-websocketio.rb
160
160
  - lib/sinatra-websocketio/application.rb
161
161
  - lib/sinatra-websocketio/helpers.rb
162
+ - lib/sinatra-websocketio/javascript.rb
162
163
  - lib/sinatra-websocketio/options.rb
163
164
  - lib/sinatra-websocketio/version.rb
164
165
  - lib/sinatra-websocketio/websocketio.rb
@@ -179,7 +180,7 @@ files:
179
180
  - test/app/main.rb
180
181
  - test/test_helper.rb
181
182
  - test/test_websocketio.rb
182
- homepage: https://github.com/shokai/sinatra-websocketio
183
+ homepage: http://shokai.github.com/sinatra-websocketio
183
184
  licenses: []
184
185
  post_install_message:
185
186
  rdoc_options: []