sinatra-cometio 0.3.2 → 0.3.3

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.3.3 2013-03-17
2
+
3
+ * read javascript - Sinatra::CometIO.javascript
4
+
1
5
  === 0.3.2 2013-03-16
2
6
 
3
7
  * fix README
@@ -1,29 +1,13 @@
1
1
  module Sinatra
2
2
  module CometIO
3
3
 
4
- def cometio=(options)
5
- CometIO.options = options
6
- end
7
-
8
- def cometio
9
- CometIO.options
10
- end
11
-
12
4
  def self.registered(app)
13
5
  app.helpers Sinatra::Streaming
14
6
  app.helpers Sinatra::CometIO::Helpers
15
7
 
16
8
  app.get '/cometio/cometio.js' do
17
9
  content_type 'application/javascript'
18
- @js ||= (
19
- js = ''
20
- Dir.glob(File.expand_path '../js/*.js', File.dirname(__FILE__)).sort.each do |i|
21
- File.open(i) do |f|
22
- js += f.read
23
- end
24
- end
25
- ERB.new(js).result(binding)
26
- )
10
+ @js ||= ERB.new(Sinatra::CometIO.javascript).result(binding)
27
11
  end
28
12
 
29
13
  app.get '/cometio/io' do
@@ -0,0 +1,16 @@
1
+ module Sinatra
2
+ module CometIO
3
+
4
+ def self.javascript(*js_file_names)
5
+ js_file_names = ['cometio.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 CometIO
3
3
 
4
+ def cometio=(options)
5
+ CometIO.options = options
6
+ end
7
+
8
+ def cometio
9
+ CometIO.options
10
+ end
11
+
4
12
  def self.default_options
5
13
  {
6
14
  :timeout => [120, lambda{|v| v.kind_of? Fixnum and v >= 20 }]
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module CometIO
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.3'
4
4
  end
5
5
  end
@@ -7,6 +7,7 @@ require File.expand_path '../sinatra-cometio/version', File.dirname(__FILE__)
7
7
  require File.expand_path '../sinatra-cometio/helpers', File.dirname(__FILE__)
8
8
  require File.expand_path '../sinatra-cometio/options', File.dirname(__FILE__)
9
9
  require File.expand_path '../sinatra-cometio/cometio', File.dirname(__FILE__)
10
+ require File.expand_path '../sinatra-cometio/javascript', File.dirname(__FILE__)
10
11
  require File.expand_path '../sinatra-cometio/application', File.dirname(__FILE__)
11
12
 
12
13
  module Sinatra
data/sample/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GEM
13
13
  multi_json (~> 1.0)
14
14
  multi_xml (>= 0.5.2)
15
15
  json (1.7.7)
16
- multi_json (1.6.1)
16
+ multi_json (1.7.0)
17
17
  multi_xml (0.5.3)
18
18
  rack (1.5.2)
19
19
  rack-protection (1.5.0)
data/test/test_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'rubygems'
2
+ require 'bundler/setup'
2
3
  require 'minitest/autorun'
3
4
  require 'sinatra/cometio/client'
4
5
  require File.expand_path 'app', File.dirname(__FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-cometio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -142,6 +142,7 @@ files:
142
142
  - lib/sinatra-cometio/application.rb
143
143
  - lib/sinatra-cometio/cometio.rb
144
144
  - lib/sinatra-cometio/helpers.rb
145
+ - lib/sinatra-cometio/javascript.rb
145
146
  - lib/sinatra-cometio/options.rb
146
147
  - lib/sinatra-cometio/version.rb
147
148
  - lib/sinatra/cometio.rb