roda-cj 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +13 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.rdoc +715 -0
  5. data/Rakefile +124 -0
  6. data/lib/roda/plugins/all_verbs.rb +48 -0
  7. data/lib/roda/plugins/default_headers.rb +50 -0
  8. data/lib/roda/plugins/error_handler.rb +69 -0
  9. data/lib/roda/plugins/flash.rb +108 -0
  10. data/lib/roda/plugins/h.rb +24 -0
  11. data/lib/roda/plugins/halt.rb +79 -0
  12. data/lib/roda/plugins/header_matchers.rb +57 -0
  13. data/lib/roda/plugins/hooks.rb +106 -0
  14. data/lib/roda/plugins/indifferent_params.rb +47 -0
  15. data/lib/roda/plugins/middleware.rb +88 -0
  16. data/lib/roda/plugins/multi_route.rb +77 -0
  17. data/lib/roda/plugins/not_found.rb +62 -0
  18. data/lib/roda/plugins/pass.rb +34 -0
  19. data/lib/roda/plugins/render.rb +217 -0
  20. data/lib/roda/plugins/streaming.rb +165 -0
  21. data/lib/roda/version.rb +3 -0
  22. data/lib/roda.rb +610 -0
  23. data/spec/composition_spec.rb +19 -0
  24. data/spec/env_spec.rb +11 -0
  25. data/spec/integration_spec.rb +63 -0
  26. data/spec/matchers_spec.rb +683 -0
  27. data/spec/module_spec.rb +29 -0
  28. data/spec/opts_spec.rb +42 -0
  29. data/spec/plugin/all_verbs_spec.rb +29 -0
  30. data/spec/plugin/default_headers_spec.rb +63 -0
  31. data/spec/plugin/error_handler_spec.rb +67 -0
  32. data/spec/plugin/flash_spec.rb +123 -0
  33. data/spec/plugin/h_spec.rb +13 -0
  34. data/spec/plugin/halt_spec.rb +62 -0
  35. data/spec/plugin/header_matchers_spec.rb +61 -0
  36. data/spec/plugin/hooks_spec.rb +97 -0
  37. data/spec/plugin/indifferent_params_spec.rb +13 -0
  38. data/spec/plugin/middleware_spec.rb +52 -0
  39. data/spec/plugin/multi_route_spec.rb +98 -0
  40. data/spec/plugin/not_found_spec.rb +99 -0
  41. data/spec/plugin/pass_spec.rb +23 -0
  42. data/spec/plugin/render_spec.rb +148 -0
  43. data/spec/plugin/streaming_spec.rb +52 -0
  44. data/spec/plugin_spec.rb +61 -0
  45. data/spec/redirect_spec.rb +24 -0
  46. data/spec/request_spec.rb +55 -0
  47. data/spec/response_spec.rb +131 -0
  48. data/spec/session_spec.rb +35 -0
  49. data/spec/spec_helper.rb +89 -0
  50. data/spec/version_spec.rb +8 -0
  51. metadata +136 -0
@@ -0,0 +1,35 @@
1
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
2
+
3
+ describe "session handling" do
4
+ it "should give a warning if session variable is not available" do
5
+ app do |r|
6
+ begin
7
+ session
8
+ rescue Exception => e
9
+ e.message
10
+ end
11
+ end
12
+
13
+ body.should =~ /use Rack::Session::Cookie/
14
+ end
15
+
16
+ it "should return session if available" do
17
+ app(:bare) do
18
+ use Rack::Session::Cookie, :secret=>'1'
19
+
20
+ route do |r|
21
+ r.on do
22
+ (session[1] ||= 'a') << 'b'
23
+ session[1]
24
+ end
25
+ end
26
+ end
27
+
28
+ _, h, b = req
29
+ b.join.should == 'ab'
30
+ _, h, b = req('HTTP_COOKIE'=>h['Set-Cookie'].sub("; path=/; HttpOnly", ''))
31
+ b.join.should == 'abb'
32
+ _, h, b = req('HTTP_COOKIE'=>h['Set-Cookie'].sub("; path=/; HttpOnly", ''))
33
+ b.join.should == 'abbb'
34
+ end
35
+ end
@@ -0,0 +1,89 @@
1
+ $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
2
+
3
+ require "rubygems"
4
+
5
+ if ENV['COVERAGE']
6
+ require 'coverage'
7
+ require 'simplecov'
8
+
9
+ def SimpleCov.roda_coverage(opts = {})
10
+ start do
11
+ add_filter "/spec/"
12
+ add_group('Missing'){|src| src.covered_percent < 100}
13
+ add_group('Covered'){|src| src.covered_percent == 100}
14
+ yield self if block_given?
15
+ end
16
+ end
17
+
18
+ ENV.delete('COVERAGE')
19
+ SimpleCov.roda_coverage
20
+ end
21
+
22
+ require "roda"
23
+ require "stringio"
24
+
25
+ unless defined?(RSPEC_EXAMPLE_GROUP)
26
+ if defined?(RSpec)
27
+ require 'rspec/version'
28
+ if RSpec::Version::STRING >= '2.11.0'
29
+ RSpec.configure do |config|
30
+ config.expect_with :rspec do |c|
31
+ c.syntax = :should
32
+ end
33
+ config.mock_with :rspec do |c|
34
+ c.syntax = :should
35
+ end
36
+ end
37
+ end
38
+ RSPEC_EXAMPLE_GROUP = RSpec::Core::ExampleGroup
39
+ else
40
+ RSPEC_EXAMPLE_GROUP = Spec::Example::ExampleGroup
41
+ end
42
+ end
43
+
44
+ class RSPEC_EXAMPLE_GROUP
45
+ def app(type=nil, &block)
46
+ case type
47
+ when :new
48
+ @app = _app{route(&block)}
49
+ when :bare
50
+ @app = _app(&block)
51
+ when Symbol
52
+ @app = _app do
53
+ plugin type
54
+ route(&block)
55
+ end
56
+ else
57
+ @app ||= _app{route(&block)}
58
+ end
59
+ end
60
+
61
+ def req(path='/', env={})
62
+ if path.is_a?(Hash)
63
+ env = path
64
+ else
65
+ env['PATH_INFO'] = path
66
+ end
67
+
68
+ env = {"REQUEST_METHOD" => "GET", "PATH_INFO" => "/", "SCRIPT_NAME" => ""}.merge(env)
69
+ @app.call(env)
70
+ end
71
+
72
+ def status(path='/', env={})
73
+ req(path, env)[0]
74
+ end
75
+
76
+ def header(name, path='/', env={})
77
+ req(path, env)[1][name]
78
+ end
79
+
80
+ def body(path='/', env={})
81
+ req(path, env)[2].join
82
+ end
83
+
84
+ def _app(&block)
85
+ c = Class.new(Roda)
86
+ c.class_eval(&block)
87
+ c
88
+ end
89
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path("spec_helper", File.dirname(__FILE__))
2
+
3
+ describe "Roda::RodaVersion" do
4
+ it "should be a string in x.y.z integer format" do
5
+ Roda::RodaVersion.should =~ /\A\d+\.\d+\.\d+\z/
6
+ end
7
+ end
8
+
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roda-cj
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tilt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Routing tree web framework, inspired by Sinatra and Cuba
56
+ email:
57
+ - code@jeremyevans.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - README.rdoc
63
+ - MIT-LICENSE
64
+ - CHANGELOG
65
+ - Rakefile
66
+ - lib/roda/version.rb
67
+ - lib/roda/plugins/multi_route.rb
68
+ - lib/roda/plugins/hooks.rb
69
+ - lib/roda/plugins/pass.rb
70
+ - lib/roda/plugins/h.rb
71
+ - lib/roda/plugins/render.rb
72
+ - lib/roda/plugins/middleware.rb
73
+ - lib/roda/plugins/flash.rb
74
+ - lib/roda/plugins/halt.rb
75
+ - lib/roda/plugins/header_matchers.rb
76
+ - lib/roda/plugins/error_handler.rb
77
+ - lib/roda/plugins/indifferent_params.rb
78
+ - lib/roda/plugins/streaming.rb
79
+ - lib/roda/plugins/all_verbs.rb
80
+ - lib/roda/plugins/not_found.rb
81
+ - lib/roda/plugins/default_headers.rb
82
+ - lib/roda.rb
83
+ - spec/response_spec.rb
84
+ - spec/integration_spec.rb
85
+ - spec/module_spec.rb
86
+ - spec/env_spec.rb
87
+ - spec/opts_spec.rb
88
+ - spec/redirect_spec.rb
89
+ - spec/composition_spec.rb
90
+ - spec/matchers_spec.rb
91
+ - spec/spec_helper.rb
92
+ - spec/request_spec.rb
93
+ - spec/version_spec.rb
94
+ - spec/plugin_spec.rb
95
+ - spec/session_spec.rb
96
+ - spec/plugin/indifferent_params_spec.rb
97
+ - spec/plugin/error_handler_spec.rb
98
+ - spec/plugin/all_verbs_spec.rb
99
+ - spec/plugin/render_spec.rb
100
+ - spec/plugin/multi_route_spec.rb
101
+ - spec/plugin/default_headers_spec.rb
102
+ - spec/plugin/hooks_spec.rb
103
+ - spec/plugin/streaming_spec.rb
104
+ - spec/plugin/flash_spec.rb
105
+ - spec/plugin/pass_spec.rb
106
+ - spec/plugin/not_found_spec.rb
107
+ - spec/plugin/middleware_spec.rb
108
+ - spec/plugin/h_spec.rb
109
+ - spec/plugin/halt_spec.rb
110
+ - spec/plugin/header_matchers_spec.rb
111
+ homepage: https://github.com/jeremyevans/roda
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.0.14
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Routing tree web framework
135
+ test_files: []
136
+ has_rdoc: