endless 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@endless --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in endless.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,25 @@
1
+ Endless
2
+ =======
3
+ A tiny webapp for generating an endless stream of data in an HTTP response.
4
+
5
+
6
+ Installation
7
+ ============
8
+
9
+ gem install endless
10
+
11
+
12
+ Usage
13
+ =====
14
+
15
+ rake server[5678]
16
+
17
+ curl -s http://localhost:5678/endless | head -c 100
18
+
19
+ Caveats
20
+ =======
21
+
22
+ Pre-alpha software. Useful for testing purposes only.
23
+
24
+ Currently, I think the server just keeps streaming a response even after the
25
+ client disconnects, until you kill the server. Pull requests welcome!
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'bundler/setup'
4
+ Bundler.require(:default)
5
+
6
+ Dir['tasks/*.rake'].sort.each { |task| load task }
7
+
8
+ # Add rake tasks from selected gems
9
+ gem_names = []
10
+ gem_names.each do |gem_name|
11
+ Dir[File.join(Gem.searcher.find(gem_name).full_gem_path, '**', '*.rake')].each{|rake_file| load rake_file }
12
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "endless/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "endless"
7
+ s.version = Endless::VERSION
8
+ s.authors = ["Chris Johnson"]
9
+ s.email = ["chris@kindkid.com"]
10
+ s.homepage = "https://github.com/kindkid/endless"
11
+ s.summary = "A tiny webapp for generating an endless stream of data in an HTTP response."
12
+ s.description = s.summary
13
+
14
+ s.rubyforge_project = "endless"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency 'async_sinatra', '~> 1.0.0'
22
+ s.add_runtime_dependency 'thin', '~> 1.3.1'
23
+ s.add_development_dependency "rspec", "~> 2.9.0"
24
+ s.add_development_dependency "simplecov", "~> 0.6.1"
25
+ s.add_development_dependency("rb-fsevent", "~> 0.9.0") if RUBY_PLATFORM =~ /darwin/i
26
+ s.add_development_dependency "guard", "~> 1.0.1"
27
+ s.add_development_dependency "guard-bundler", "~> 0.1.3"
28
+ s.add_development_dependency "guard-rspec", "~> 0.6.0"
29
+ end
@@ -0,0 +1,14 @@
1
+ require "endless/version"
2
+
3
+ tried_with_rubygems = false
4
+ begin
5
+ require 'sinatra/async'
6
+ require 'thin'
7
+ rescue => e
8
+ raise if tried_with_rubygems
9
+ tried_with_rubygems = true
10
+ require 'rubygems'
11
+ retry
12
+ end
13
+
14
+ require 'endless/app'
@@ -0,0 +1,37 @@
1
+ module Endless
2
+ class App < Sinatra::Base
3
+ register Sinatra::Async
4
+
5
+ class DataStream
6
+ include EventMachine::Deferrable
7
+
8
+ def stream(data)
9
+ @block.call(data)
10
+ end
11
+
12
+ def each(&block)
13
+ @block = block
14
+ end
15
+ end
16
+
17
+ def randomLetters(length)
18
+ s = []
19
+ length.times do
20
+ s << 97+rand(26)
21
+ end
22
+ s.pack('c' * s.size)
23
+ end
24
+
25
+ aget '/endless' do
26
+ out = DataStream.new
27
+ body(out)
28
+ EM.next_tick do
29
+ timer = EM.add_periodic_timer(0.001) do
30
+ s = randomLetters(8191)
31
+ s << "\n"
32
+ out.stream(s)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module Endless
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ desc "Open development console"
2
+ task :console do
3
+ puts "Loading development console..."
4
+ system "irb -r #{File.join('.', 'lib', 'endless')}"
5
+ end
@@ -0,0 +1,4 @@
1
+ desc "Load the environment"
2
+ task :environment do
3
+ require File.expand_path('../../lib/endless', __FILE__)
4
+ end
@@ -0,0 +1,4 @@
1
+ desc "Run the server"
2
+ task :server, [:port] => :environment do |t, args|
3
+ Endless::App.run! :port => (args[:port] || 5678)
4
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: endless
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Johnson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: async_sinatra
16
+ requirement: &70264000444880 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70264000444880
25
+ - !ruby/object:Gem::Dependency
26
+ name: thin
27
+ requirement: &70264000444220 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70264000444220
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70264000442480 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.9.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70264000442480
47
+ - !ruby/object:Gem::Dependency
48
+ name: simplecov
49
+ requirement: &70264000441180 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.1
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70264000441180
58
+ - !ruby/object:Gem::Dependency
59
+ name: rb-fsevent
60
+ requirement: &70264000439660 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.9.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70264000439660
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: &70264000438640 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.0.1
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70264000438640
80
+ - !ruby/object:Gem::Dependency
81
+ name: guard-bundler
82
+ requirement: &70264000437440 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 0.1.3
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70264000437440
91
+ - !ruby/object:Gem::Dependency
92
+ name: guard-rspec
93
+ requirement: &70264000436540 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.6.0
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70264000436540
102
+ description: A tiny webapp for generating an endless stream of data in an HTTP response.
103
+ email:
104
+ - chris@kindkid.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - .gitignore
110
+ - .rvmrc
111
+ - Gemfile
112
+ - README
113
+ - Rakefile
114
+ - endless.gemspec
115
+ - lib/endless.rb
116
+ - lib/endless/app.rb
117
+ - lib/endless/version.rb
118
+ - tasks/console.rake
119
+ - tasks/environment.rake
120
+ - tasks/server.rake
121
+ homepage: https://github.com/kindkid/endless
122
+ licenses: []
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
134
+ - 0
135
+ hash: -1761712717339384040
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ segments:
143
+ - 0
144
+ hash: -1761712717339384040
145
+ requirements: []
146
+ rubyforge_project: endless
147
+ rubygems_version: 1.8.10
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: A tiny webapp for generating an endless stream of data in an HTTP response.
151
+ test_files: []