http_router 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ pkg
4
4
  rdoc
5
5
  Gemfile.lock
6
6
  .rvmrc
7
+ *.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile CHANGED
@@ -1,13 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gem 'rack', '>=1.0'
4
- gem 'url_mount', '>=0.2.1'
5
-
6
- group :development do
7
- gem 'rspec'
8
- gem 'rake'
9
- gem 'sinatra'
10
- gem 'rbench'
11
- gem 'code_stats'
12
- gem 'tumbler', ">= 0.0.11"
13
- end
3
+ gemspec
data/Rakefile CHANGED
@@ -1,13 +1,12 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
- require 'spec'
4
3
  require 'code_stats'
5
- require 'spec/rake/spectask'
4
+ require 'rspec/core/rake_task'
6
5
 
7
- Spec::Rake::SpecTask.new(:spec) do |t|
8
- t.spec_opts ||= []
9
- t.spec_opts << "--options" << "spec/spec.opts"
10
- t.spec_files = FileList['spec/**/*_spec.rb']
6
+ desc "Run specs"
7
+ RSpec::Core::RakeTask.new do |t|
8
+ #t.rspec_opts = %w(--options spec/spec.opts)
9
+ #t.ruby_opts = %w(-w)
11
10
  end
12
11
 
13
12
  require 'rake/rdoctask'
data/benchmarks/rec2.rb CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rbench'
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
- require 'lib/http_router'
5
+ require 'http_router'
6
6
 
7
7
  #require 'http_router'
8
8
 
@@ -34,33 +34,33 @@ simple_and_dynamic_env = Rack::MockRequest.env_for('/dynamic/anything')
34
34
  #simple_and_dynamic_env1 = Rack::MockRequest.env_for('/rails/controller/action/id')
35
35
  #simple_and_dynamic_env2 = Rack::MockRequest.env_for('/greedy/controller/action/id')
36
36
  #simple_and_dynamic_env3 = Rack::MockRequest.env_for('/greedy/hey.hello.html')
37
+ 5.times {
38
+ RBench.run(TIMES) do
37
39
 
38
- RBench.run(TIMES) do
39
-
40
- report "2 levels, static" do
41
- u.call(simple_env).first == 200 or raise
42
- end
43
-
44
- report "4 levels, static" do
45
- u.call(simple2_env).first == 200 or raise
46
- end
40
+ report "2 levels, static" do
41
+ u.call(simple_env).first == 200 or raise
42
+ end
47
43
 
48
- #report "8 levels, static" do
49
- # u.call(simple3_env).first == 200 or raise
50
- #end
44
+ report "4 levels, static" do
45
+ u.call(simple2_env).first == 200 or raise
46
+ end
51
47
 
52
- report "4 levels, 1 dynamic" do
53
- u.call(simple_and_dynamic_env).first == 200 or raise
54
- end
48
+ #report "8 levels, static" do
49
+ # u.call(simple3_env).first == 200 or raise
50
+ #end
55
51
 
56
- #report "8 levels, 3 dynamic" do
57
- # u.call(simple_and_dynamic_env1).first == 200 or raise
58
- #end
59
- #
60
- #report "4 levels, 1 greedy" do
61
- # u.call(simple_and_dynamic_env2).first == 200 or raise
62
- #end
52
+ report "4 levels, 1 dynamic" do
53
+ u.call(simple_and_dynamic_env).first == 200 or raise
54
+ end
63
55
 
64
- end
56
+ #report "8 levels, 3 dynamic" do
57
+ # u.call(simple_and_dynamic_env1).first == 200 or raise
58
+ #end
59
+ #
60
+ #report "4 levels, 1 greedy" do
61
+ # u.call(simple_and_dynamic_env2).first == 200 or raise
62
+ #end
65
63
 
64
+ end
65
+ }
66
66
  puts `ps -o rss= -p #{Process.pid}`.to_i
data/http_router.gemspec CHANGED
@@ -20,14 +20,14 @@ Gem::Specification.new do |s|
20
20
  s.rubyforge_project = 'http_router'
21
21
 
22
22
  # dependencies
23
- s.add_runtime_dependency 'rack', '>=1.0'
24
- s.add_runtime_dependency 'url_mount', '>=0.2.1'
25
- s.add_development_dependency 'rspec'
23
+ s.add_runtime_dependency 'rack', '>= 1.0.0'
24
+ s.add_runtime_dependency 'url_mount', '~> 0.2.1'
25
+ s.add_development_dependency 'rspec', '~> 2.0.0'
26
26
  s.add_development_dependency 'code_stats'
27
27
  s.add_development_dependency 'rake'
28
28
  s.add_development_dependency 'sinatra'
29
29
  s.add_development_dependency 'rbench'
30
- s.add_development_dependency 'bundler', ">= 1.0.0.rc4"
30
+ s.add_development_dependency 'bundler', "~> 1.0.0"
31
31
 
32
32
  if s.respond_to? :specification_version then
33
33
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -42,12 +42,13 @@ class HttpRouter
42
42
  # *default_value -- Maps to #default_value method.
43
43
  def with_options(options)
44
44
  if options
45
- name(options[:name]) if options[:name]
46
- matching(options[:matching]) if options[:matching]
47
- condition(options[:conditions]) if options[:conditions]
48
- default(options[:default_values]) if options[:default_values]
49
- partial(options[:partial]) if options[:partial]
50
- Array(options[:arbitrary]).each{|a| arbitrary(&a)} if options[:arbitrary]
45
+ name(options.delete(:name)) if options[:name]
46
+ matching(options.delete(:matching)) if options[:matching]
47
+ condition(options.delete(:conditions)) if options[:conditions]
48
+ default(options.delete(:default_values)) if options[:default_values]
49
+ partial(options.delete(:partial)) if options[:partial]
50
+ Array(options.delete(:arbitrary)).each{|a| arbitrary(&a)} if options[:arbitrary]
51
+ matching(options)
51
52
  end
52
53
  self
53
54
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  class HttpRouter #:nodoc
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
@@ -392,6 +392,14 @@ describe "HttpRouter#recognize" do
392
392
  response.params_as_hash[:variable].should == '123'
393
393
  end
394
394
 
395
+ it "should recognize with a regex as part of the options" do
396
+ route = @router.add('/one-:variable-time', :variable => /\d+/).to(:test)
397
+ @router.recognize(Rack::MockRequest.env_for('/one-value-time')).should be_nil
398
+ response = @router.recognize(Rack::MockRequest.env_for('/one-123-time'))
399
+ response.route.should == route
400
+ response.params_as_hash[:variable].should == '123'
401
+ end
402
+
395
403
  it "should recognize when there is an extension" do
396
404
  route = @router.add('/hey.:greed.html').to(:test)
397
405
  response = @router.recognize(Rack::MockRequest.env_for('/hey.greedyboy.html'))
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require 'rubygems'
3
2
  require 'http_router'
4
- require 'spec'
5
- require 'spec/autorun'
6
3
 
7
4
  module CallWithMockRequestMixin
8
5
  def call_with_mock_request(url = "/sample", method = "GET", params = Hash.new)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_router
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hull
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-04 00:00:00 -07:00
18
+ date: 2010-10-18 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,11 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 15
29
+ hash: 23
30
30
  segments:
31
31
  - 1
32
32
  - 0
33
- version: "1.0"
33
+ - 0
34
+ version: 1.0.0
34
35
  type: :runtime
35
36
  version_requirements: *id001
36
37
  - !ruby/object:Gem::Dependency
@@ -39,7 +40,7 @@ dependencies:
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
- - - ">="
43
+ - - ~>
43
44
  - !ruby/object:Gem::Version
44
45
  hash: 21
45
46
  segments:
@@ -55,12 +56,14 @@ dependencies:
55
56
  requirement: &id003 !ruby/object:Gem::Requirement
56
57
  none: false
57
58
  requirements:
58
- - - ">="
59
+ - - ~>
59
60
  - !ruby/object:Gem::Version
60
- hash: 3
61
+ hash: 15
61
62
  segments:
63
+ - 2
62
64
  - 0
63
- version: "0"
65
+ - 0
66
+ version: 2.0.0
64
67
  type: :development
65
68
  version_requirements: *id003
66
69
  - !ruby/object:Gem::Dependency
@@ -125,15 +128,14 @@ dependencies:
125
128
  requirement: &id008 !ruby/object:Gem::Requirement
126
129
  none: false
127
130
  requirements:
128
- - - ">="
131
+ - - ~>
129
132
  - !ruby/object:Gem::Version
130
- hash: 977940573
133
+ hash: 23
131
134
  segments:
132
135
  - 1
133
136
  - 0
134
137
  - 0
135
- - rc4
136
- version: 1.0.0.rc4
138
+ version: 1.0.0
137
139
  type: :development
138
140
  version_requirements: *id008
139
141
  description: This library allows you to recognize and build URLs in a Rack application. As well it contains an interface for use within Sinatra.
@@ -146,6 +148,7 @@ extra_rdoc_files:
146
148
  - README.rdoc
147
149
  files:
148
150
  - .gitignore
151
+ - .rspec
149
152
  - CHANGELOG
150
153
  - Gemfile
151
154
  - README.rdoc
@@ -194,7 +197,6 @@ files:
194
197
  - spec/rack/urlmap_spec.rb
195
198
  - spec/recognize_spec.rb
196
199
  - spec/sinatra/recognize_spec.rb
197
- - spec/spec.opts
198
200
  - spec/spec_helper.rb
199
201
  has_rdoc: true
200
202
  homepage: http://github.com/joshbuddy/http_router
@@ -241,5 +243,4 @@ test_files:
241
243
  - spec/rack/urlmap_spec.rb
242
244
  - spec/recognize_spec.rb
243
245
  - spec/sinatra/recognize_spec.rb
244
- - spec/spec.opts
245
246
  - spec/spec_helper.rb
data/spec/spec.opts DELETED
@@ -1,7 +0,0 @@
1
- --colour
2
- --format
3
- specdoc
4
- --loadby
5
- mtime
6
- --reverse
7
- --backtrace