falconer 0.0.2

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.
Files changed (57) hide show
  1. data/.travis.yml +2 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Gemfile +10 -0
  4. data/Gemfile.lock +108 -0
  5. data/Guardfile +11 -0
  6. data/README.md +3 -0
  7. data/Rakefile +18 -0
  8. data/falconer.gemspec +25 -0
  9. data/lib/falconer.rb +12 -0
  10. data/lib/falconer/class_methods.rb +30 -0
  11. data/lib/falconer/rack.rb +17 -0
  12. data/lib/falconer/rails.rb +28 -0
  13. data/lib/falconer/store.rb +2 -0
  14. data/lib/falconer/store/memory.rb +21 -0
  15. data/lib/falconer/version.rb +3 -0
  16. data/spec/dummy/README.rdoc +261 -0
  17. data/spec/dummy/Rakefile +7 -0
  18. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  21. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  22. data/spec/dummy/app/mailers/.gitkeep +0 -0
  23. data/spec/dummy/app/models/.gitkeep +0 -0
  24. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  25. data/spec/dummy/config.ru +4 -0
  26. data/spec/dummy/config/application.rb +56 -0
  27. data/spec/dummy/config/boot.rb +10 -0
  28. data/spec/dummy/config/database.yml +25 -0
  29. data/spec/dummy/config/environment.rb +5 -0
  30. data/spec/dummy/config/environments/development.rb +37 -0
  31. data/spec/dummy/config/environments/production.rb +67 -0
  32. data/spec/dummy/config/environments/test.rb +37 -0
  33. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  34. data/spec/dummy/config/initializers/inflections.rb +15 -0
  35. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  36. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  37. data/spec/dummy/config/initializers/session_store.rb +8 -0
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  39. data/spec/dummy/config/locales/en.yml +5 -0
  40. data/spec/dummy/config/routes.rb +58 -0
  41. data/spec/dummy/db/test.sqlite3 +0 -0
  42. data/spec/dummy/lib/assets/.gitkeep +0 -0
  43. data/spec/dummy/log/.gitkeep +0 -0
  44. data/spec/dummy/log/test.log +2 -0
  45. data/spec/dummy/public/404.html +26 -0
  46. data/spec/dummy/public/422.html +26 -0
  47. data/spec/dummy/public/500.html +25 -0
  48. data/spec/dummy/public/favicon.ico +0 -0
  49. data/spec/dummy/script/rails +6 -0
  50. data/spec/falconer/class_methods_spec.rb +67 -0
  51. data/spec/falconer/rack_spec.rb +57 -0
  52. data/spec/falconer/rails_spec.rb +37 -0
  53. data/spec/falconer/store/memory_spec.rb +50 -0
  54. data/spec/falconer_spec.rb +20 -0
  55. data/spec/spec_helper.rb +10 -0
  56. data/spec/spec_helper_rails.rb +9 -0
  57. metadata +144 -0
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+  (0.5ms) begin transaction
2
+  (0.1ms) rollback transaction
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Falconer, 'class methods' do
4
+ it 'should respond to trigger' do
5
+ Falconer.must_respond_to :trigger
6
+ end
7
+
8
+ it 'should respond to flush' do
9
+ Falconer.must_respond_to :flush
10
+ end
11
+
12
+
13
+ describe 'flush' do
14
+ describe 'with no triggered events' do
15
+ it 'should return an empty array' do
16
+ Falconer.flush.must_equal []
17
+ end
18
+ end
19
+
20
+ describe 'with a single triggered event' do
21
+ before do
22
+ Falconer.flush
23
+ Falconer.trigger 'event-one', {'some' => 'data'}
24
+ end
25
+
26
+ it 'should return an array with one event' do
27
+ Falconer.flush.size.must_equal 1
28
+ end
29
+
30
+ it 'should return the event as a size 2 tuple' do
31
+ Falconer.flush[0].size.must_equal 2
32
+ end
33
+
34
+ it 'should return an event as an array with name and data' do
35
+ Falconer.flush.must_equal [['event-one', {'some' => 'data'}]]
36
+ end
37
+
38
+
39
+ it 'should clear the data after flushed' do
40
+ Falconer.flush
41
+ Falconer.flush.must_equal []
42
+ end
43
+ end
44
+
45
+ describe 'with several triggered events' do
46
+ before do
47
+ Falconer.flush
48
+ Falconer.trigger 'event-one', {'one' => 1}
49
+ Falconer.trigger 'event-two', {'two' => 2}
50
+ Falconer.trigger 'event-three', {'three' => 3}
51
+ end
52
+
53
+
54
+ it 'should return events in first-in-first-out order' do
55
+ Falconer.flush.must_equal [
56
+ ['event-one', {'one' => 1}] ,
57
+ ['event-two', {'two' => 2}] ,
58
+ ['event-three', {'three' => 3}]
59
+ ]
60
+
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Falconer::Rack do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ Rack::Builder.new do
8
+ use Falconer::Rack
9
+ run Rack::Lobster.new
10
+ end
11
+ end
12
+
13
+ def falconer_accept_header
14
+ {"HTTP_#{Falconer::ACCEPT_HEADER.upcase.gsub '-', '_'}" => '1'}
15
+ end
16
+
17
+ def events_header
18
+ last_response.headers[Falconer::EVENTS_HEADER]
19
+ end
20
+
21
+ before do
22
+ Falconer.flush
23
+ end
24
+
25
+ describe 'falconer-request' do
26
+ it 'should return a falconer event header' do
27
+ get '/', {}, falconer_accept_header
28
+ events_header.wont_be_nil
29
+ end
30
+
31
+ it 'should return a JSON encoded array' do
32
+ Falconer.trigger 'foo', {:bar => 1}
33
+ get '/', {}, falconer_accept_header
34
+ events = JSON.parse events_header
35
+ events.size.must_equal 1
36
+ events[0].must_equal ['foo', {'bar'=> 1}]
37
+
38
+ end
39
+
40
+ end
41
+
42
+ describe 'normal request' do
43
+ it 'should return 200' do
44
+ get '/'
45
+ last_response.status.must_be :==, 200
46
+ end
47
+
48
+ it 'should not send falconer events header' do
49
+ get '/'
50
+ last_response.headers[Falconer::EVENTS_HEADER].must_be_nil
51
+ last_response.headers['content-type'].wont_be_nil
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+
@@ -0,0 +1,37 @@
1
+ require 'spec_helper_rails'
2
+ require 'falconer/rails'
3
+
4
+ describe Falconer::Rails do
5
+
6
+ describe "Middleware" do
7
+ it 'inserts Falconer::Rack after Rack::Lock' do
8
+ Rails.configuration.middleware.must_include Falconer::Rack
9
+ end
10
+ end
11
+
12
+
13
+ describe 'Controller extensions' do
14
+ before do
15
+ @controller = ApplicationController.new
16
+ end
17
+
18
+ it 'should have a falconer method' do
19
+ @controller.must_respond_to :falconer
20
+ end
21
+
22
+ it 'should return the Falconer Class for falconer' do
23
+ @controller.send(:falconer).must_equal Falconer
24
+ end
25
+
26
+ it 'should be private' do
27
+ lambda {
28
+ @controller.falconer
29
+ }.must_raise NoMethodError
30
+ end
31
+
32
+
33
+ it 'should expose falconer as helper method' do
34
+ @controller.send(:_helper_methods).must_include :falconer
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Falconer::Store::Memory do
4
+ before do
5
+ @store = Falconer::Store::Memory.new
6
+ end
7
+
8
+ describe 'empty store' do
9
+ it 'should be empty' do
10
+ @store.events.must_equal []
11
+ end
12
+ end
13
+
14
+ describe 'with one event' do
15
+ before do
16
+ @store.add_event 'name-1', 'data-1'
17
+ end
18
+
19
+ it 'should have one event' do
20
+ @store.events.must_equal [['name-1', 'data-1']]
21
+ end
22
+
23
+ it 'should clear events' do
24
+ @store.events.must_equal [['name-1', 'data-1']]
25
+ @store.clear_events
26
+ @store.events.must_equal []
27
+ end
28
+ end
29
+
30
+ describe 'with multiple events' do
31
+ before do
32
+ @events = [
33
+ ['event-1', 'data1'] ,
34
+ ['event-2', 'data2'] ,
35
+ ['event-3', 'data3']
36
+ ]
37
+
38
+ @events.each do |(event, data)|
39
+ @store.add_event event, data
40
+ end
41
+
42
+ end
43
+
44
+ it 'should have all events in order' do
45
+ @store.events.must_equal @events
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Falconer do
4
+ describe 'constants' do
5
+
6
+ it 'should define the events header' do
7
+ Falconer::EVENTS_HEADER.must_equal 'x-falconer-events'
8
+ end
9
+
10
+ it 'should define the accept events header' do
11
+ Falconer::ACCEPT_HEADER.must_equal 'x-falconer-accept-events'
12
+ end
13
+
14
+ it 'should define the accept events header env key' do
15
+ Falconer::ACCEPT_HEADER_ENV.must_equal 'HTTP_X_FALCONER_ACCEPT_EVENTS'
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,10 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+ require 'minitest/spec'
3
+ require 'minitest/wscolor'
4
+ require 'minitest/autorun'
5
+ require 'rack/lobster'
6
+ require 'rack/test'
7
+
8
+ $:.unshift(File.join(File.dirname(__FILE__), '../lib'))
9
+
10
+ require 'falconer'
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+ # Configure Rails Environment
3
+ ENV["RAILS_ENV"] = "test"
4
+
5
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
+ require "rails/test_help"
7
+
8
+ Rails.backtrace_cleaner.remove_silencers!
9
+
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: falconer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jim Hoskins
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &75091060 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.5'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *75091060
25
+ - !ruby/object:Gem::Dependency
26
+ name: rails
27
+ requirement: &75090780 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 3.2.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *75090780
36
+ - !ruby/object:Gem::Dependency
37
+ name: sqlite3
38
+ requirement: &75090590 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *75090590
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &75090300 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *75090300
58
+ description: Falconer Event Endpoint for Ruby and Rack
59
+ email: jim@jimhoskins.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - .travis.yml
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - Guardfile
69
+ - README.md
70
+ - Rakefile
71
+ - falconer.gemspec
72
+ - lib/falconer.rb
73
+ - lib/falconer/class_methods.rb
74
+ - lib/falconer/rack.rb
75
+ - lib/falconer/rails.rb
76
+ - lib/falconer/store.rb
77
+ - lib/falconer/store/memory.rb
78
+ - lib/falconer/version.rb
79
+ - spec/dummy/README.rdoc
80
+ - spec/dummy/Rakefile
81
+ - spec/dummy/app/assets/javascripts/application.js
82
+ - spec/dummy/app/assets/stylesheets/application.css
83
+ - spec/dummy/app/controllers/application_controller.rb
84
+ - spec/dummy/app/helpers/application_helper.rb
85
+ - spec/dummy/app/mailers/.gitkeep
86
+ - spec/dummy/app/models/.gitkeep
87
+ - spec/dummy/app/views/layouts/application.html.erb
88
+ - spec/dummy/config.ru
89
+ - spec/dummy/config/application.rb
90
+ - spec/dummy/config/boot.rb
91
+ - spec/dummy/config/database.yml
92
+ - spec/dummy/config/environment.rb
93
+ - spec/dummy/config/environments/development.rb
94
+ - spec/dummy/config/environments/production.rb
95
+ - spec/dummy/config/environments/test.rb
96
+ - spec/dummy/config/initializers/backtrace_silencers.rb
97
+ - spec/dummy/config/initializers/inflections.rb
98
+ - spec/dummy/config/initializers/mime_types.rb
99
+ - spec/dummy/config/initializers/secret_token.rb
100
+ - spec/dummy/config/initializers/session_store.rb
101
+ - spec/dummy/config/initializers/wrap_parameters.rb
102
+ - spec/dummy/config/locales/en.yml
103
+ - spec/dummy/config/routes.rb
104
+ - spec/dummy/db/test.sqlite3
105
+ - spec/dummy/lib/assets/.gitkeep
106
+ - spec/dummy/log/.gitkeep
107
+ - spec/dummy/log/test.log
108
+ - spec/dummy/public/404.html
109
+ - spec/dummy/public/422.html
110
+ - spec/dummy/public/500.html
111
+ - spec/dummy/public/favicon.ico
112
+ - spec/dummy/script/rails
113
+ - spec/falconer/class_methods_spec.rb
114
+ - spec/falconer/rack_spec.rb
115
+ - spec/falconer/rails_spec.rb
116
+ - spec/falconer/store/memory_spec.rb
117
+ - spec/falconer_spec.rb
118
+ - spec/spec_helper.rb
119
+ - spec/spec_helper_rails.rb
120
+ homepage: https://github.com/jimrhoskins/ruby-falconer
121
+ licenses: []
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 1.8.11
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: Falconer Server
144
+ test_files: []