rack-speling 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/README.txt ADDED
@@ -0,0 +1,3 @@
1
+ Rack::Speling is a simple port of mod_speling to Rack.
2
+
3
+ Currently, only case-insensitivety is achieved.
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env rake
2
+ # vim:ft=ruby:fileencoding=utf-8
3
+
4
+ # # enable trace to get better error output
5
+ # Rake.application.options.trace = true
6
+
7
+ # # documentation tasks
8
+ # begin
9
+ # %w[ rake/rdoctask sdoc ].each { |lib| require lib }
10
+ # Rake::RDocTask.new do |rdoc|
11
+ # version = File.exist?('VERSION') ? File.read('VERSION') : ""
12
+ #
13
+ # rdoc.rdoc_dir = 'doc/rdoc'
14
+ # rdoc.title = "to_pass #{version}"
15
+ # rdoc.options << '--fmt=shtml'
16
+ # rdoc.options << '--all'
17
+ # rdoc.options << '--charset=utf-8'
18
+ # rdoc.template = 'direct'
19
+ # rdoc.rdoc_files.include('README*')
20
+ # rdoc.rdoc_files.include('LICENSE')
21
+ # rdoc.rdoc_files.include('TODO')
22
+ # rdoc.rdoc_files.include('lib/**/*.rb')
23
+ # rdoc.rdoc_files.include('data/**/*.rb')
24
+ # end
25
+ # rescue LoadError
26
+ # end
27
+
28
+ desc "run tests"
29
+ task :test do
30
+ # optional libraries
31
+ %w[ redgreen ].each do |lib|
32
+ begin
33
+ require lib
34
+ rescue LoadError
35
+ end
36
+ end
37
+
38
+ require 'test/unit'
39
+
40
+ ( ['test/helper'] + Dir['test/test_*.rb'] ).each do |file|
41
+ require File.expand_path("../#{file}", __FILE__)
42
+ end
43
+ end
44
+
45
+ task :default => :test
@@ -0,0 +1,19 @@
1
+ # vim:ft=ruby:fileencoding=utf-8
2
+
3
+ module Rack
4
+ module Speling
5
+ # remember the application as we need to call it later on
6
+ # (this is just a before-filter)
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ # downcase PATH_INFO and REQUEST_URI
12
+ def call(env)
13
+ env['PATH_INFO'] = env['PATH_INFO'].downcase
14
+ env['REQUEST_URI'] = env['REQUEST_URI'].downcase
15
+
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # vim:ft=ruby:fileencoding=utf-8
2
+
3
+ module Rack # :nodoc:
4
+ module Speling
5
+ VERSION = "0.0.1"
6
+
7
+ SUMMARY = "Simple Speling corretor in Rack"
8
+
9
+ DESCRIPTION = <<-EOD
10
+ Rack::Speling is a simple port of mod_speling to Rack.
11
+
12
+ Currently, only case-insensitivety is achieved.
13
+ EOD
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ # vim:ft=ruby:fileencoding=utf-8
2
+ require 'lib/rack-speling/version.rb'
3
+
4
+ spec = Gem::Specification.new do |s|
5
+ s.name = 'rack-speling'
6
+ s.version = Rack::Speling::VERSION
7
+
8
+ s.authors = ["Matthias Viehweger"]
9
+ s.email = ['kronn@kronn.de']
10
+ s.homepage = 'http://github.com/kronn/rack-speling'
11
+ s.rubyforge_project = '[none]' # to supress the warning
12
+
13
+ s.summary = Rack::Speling::SUMMARY
14
+ s.description = Rack::Speling::DESCRIPTION
15
+
16
+ s.platform = Gem::Platform::RUBY
17
+ s.required_rubygems_version = ">= 1.3.6"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files test`.split("\n")
21
+ # s.executables = `git ls-files bin`.split("\\n")
22
+ s.require_path = 'lib'
23
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,15 @@
1
+ # vim:ft=ruby:fileencoding=utf-8
2
+
3
+ require 'test/unit/testcase'
4
+ require 'test/unit' unless defined?(Test::Unit)
5
+
6
+ base_path = ( File.expand_path(File.dirname(__FILE__)+'/..') )
7
+ lib_path = "#{base_path}/lib"
8
+ if File.exist?(base_path + '/lib/rack-speling')
9
+ $LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
10
+ end
11
+ if File.exist?( lib_path )
12
+ $LOAD_PATH << lib_path unless $LOAD_PATH.include?(lib_path)
13
+ end
14
+
15
+ require 'rack-speling'
@@ -0,0 +1,27 @@
1
+ require File.expand_path("../helper", __FILE__)
2
+
3
+ class SpelingTest < Test::Unit::TestCase
4
+ def sut
5
+ speling = Class.new do
6
+ include Rack::Speling
7
+ end
8
+ app = lambda { |arg| return arg }
9
+
10
+ speling.new(app)
11
+ end
12
+
13
+ def env
14
+ { 'PATH_INFO' => '/somepath', 'REQUEST_URI' => '/somepath' }
15
+ end
16
+
17
+ def test_downcasing_path_info
18
+ result = sut.call( env.merge('PATH_INFO' => '/SOMEPATH') )
19
+
20
+ assert_equal env, result
21
+ end
22
+
23
+ def test_downcasing_request_uri
24
+ result = sut.call( env.merge('REQUEST_URI' => '/SOMEPATH') )
25
+ assert_equal env, result
26
+ end
27
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-speling
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Matthias Viehweger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-01 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: " Rack::Speling is a simple port of mod_speling to Rack.\n\n Currently, only case-insensitivety is achieved.\n"
23
+ email:
24
+ - kronn@kronn.de
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.txt
35
+ - Rakefile
36
+ - lib/rack-speling.rb
37
+ - lib/rack-speling/version.rb
38
+ - rack-speling.gemspec
39
+ - test/helper.rb
40
+ - test/test_rack-speling.rb
41
+ has_rdoc: true
42
+ homepage: http://github.com/kronn/rack-speling
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 23
65
+ segments:
66
+ - 1
67
+ - 3
68
+ - 6
69
+ version: 1.3.6
70
+ requirements: []
71
+
72
+ rubyforge_project: "[none]"
73
+ rubygems_version: 1.3.7
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Simple Speling corretor in Rack
77
+ test_files:
78
+ - test/helper.rb
79
+ - test/test_rack-speling.rb