rack-path_prefixer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +15 -0
- data/Readme.md +23 -0
- data/VERSION +1 -0
- data/lib/rack/path_prefixer.rb +24 -0
- data/rack-path_prefixer.gemspec +37 -0
- metadata +66 -0
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
project_name = 'rack-path_prefixer'
|
4
|
+
Jeweler::Tasks.new do |gem|
|
5
|
+
gem.name = project_name
|
6
|
+
gem.summary = "Prefix any path in your app with something."
|
7
|
+
gem.email = "grosser.michael@gmail.com"
|
8
|
+
gem.homepage = "http://github.com/grosser/#{project_name}"
|
9
|
+
gem.authors = ["Michael Grosser"]
|
10
|
+
end
|
11
|
+
|
12
|
+
Jeweler::GemcutterTasks.new
|
13
|
+
rescue LoadError
|
14
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
15
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Prefix any path in your app with something.
|
2
|
+
|
3
|
+
- Converts any incoming path from /foo/xxx to /xxx
|
4
|
+
- Converts links in body from /xxx to /foo/xxx
|
5
|
+
|
6
|
+
As Rails plugin: ` rails plugin install git://github.com/grosser/parallel_tests.git `
|
7
|
+
As Gem: ` sudo gem install rack-path_prefixer `
|
8
|
+
|
9
|
+
config.middleware.use('Rack::PathPrefixer', :prefix => 'foo')
|
10
|
+
|
11
|
+
The replace links in body part is just a gsub, so it wont cover all cases.
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
Author
|
16
|
+
======
|
17
|
+
###Contributors
|
18
|
+
|
19
|
+
- [Mark Rambow](http://github.com/markrambow)
|
20
|
+
|
21
|
+
[Michael Grosser](http://pragmatig.wordpress.com)
|
22
|
+
grosser.michael@gmail.com
|
23
|
+
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Rack
|
2
|
+
# Adds some meta info like host name to response header
|
3
|
+
class PathPrefixer
|
4
|
+
VERSION = File.read( File.join(File.dirname(__FILE__),'..','..','VERSION') ).strip
|
5
|
+
|
6
|
+
def initialize(app, options={})
|
7
|
+
@app = app
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env, options={})
|
12
|
+
env['PATH_INFO'].sub!(%r{^/#{@options[:prefix]}}, '')
|
13
|
+
status, header, @response = @app.call(env)
|
14
|
+
[status, header, self]
|
15
|
+
end
|
16
|
+
|
17
|
+
def each
|
18
|
+
@response.each do |body|
|
19
|
+
body = body.gsub(%{href="/},%{href="/#{@options[:prefix]}/}) if body
|
20
|
+
yield body
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rack-path_prefixer}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Michael Grosser"]
|
12
|
+
s.date = %q{2010-05-14}
|
13
|
+
s.email = %q{grosser.michael@gmail.com}
|
14
|
+
s.files = [
|
15
|
+
"Rakefile",
|
16
|
+
"Readme.md",
|
17
|
+
"VERSION",
|
18
|
+
"lib/rack/path_prefixer.rb",
|
19
|
+
"rack-path_prefixer.gemspec"
|
20
|
+
]
|
21
|
+
s.homepage = %q{http://github.com/grosser/rack-path_prefixer}
|
22
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
s.rubygems_version = %q{1.3.6}
|
25
|
+
s.summary = %q{Prefix any path in your app with something.}
|
26
|
+
|
27
|
+
if s.respond_to? :specification_version then
|
28
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
29
|
+
s.specification_version = 3
|
30
|
+
|
31
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
32
|
+
else
|
33
|
+
end
|
34
|
+
else
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack-path_prefixer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Michael Grosser
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-14 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: grosser.michael@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- Rakefile
|
31
|
+
- Readme.md
|
32
|
+
- VERSION
|
33
|
+
- lib/rack/path_prefixer.rb
|
34
|
+
- rack-path_prefixer.gemspec
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/grosser/rack-path_prefixer
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options:
|
41
|
+
- --charset=UTF-8
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
version: "0"
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.3.6
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Prefix any path in your app with something.
|
65
|
+
test_files: []
|
66
|
+
|