redirect 0.0.4 → 0.1.0

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/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.1.0 / 2009-02-22
2
+
3
+ * 1 major enhancement
4
+
5
+ * Works properly with rackup now
6
+
1
7
  === 0.0.4 / 2009-02-21
2
8
 
3
9
  * 1 minor bug fix
data/Manifest.txt CHANGED
@@ -3,6 +3,7 @@ Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
5
  example.rb
6
+ example.ru
6
7
  lib/redirect.rb
7
8
  spec/helper.rb
8
9
  spec/rack_spec.rb
data/README.txt CHANGED
@@ -16,7 +16,7 @@ Create a file and pass an array to the redirect method:
16
16
  ['^/some_regexp', '/all']
17
17
 
18
18
  The catch_url can be a regular expression.
19
- You can overwrite the default 301 http code in the options.
19
+ You can overwrite the http code (defaults is 301) in the options and pass a name for the sitemap.
20
20
 
21
21
  The default redirect code can be changed:
22
22
 
data/Rakefile CHANGED
@@ -10,9 +10,9 @@ if defined? Hoe
10
10
  p.remote_rdoc_dir = '' # Release to root
11
11
  end
12
12
  end
13
- #
13
+
14
14
  # require 'metric_fu'
15
15
  #
16
16
  # MetricFu::Configuration.run do |config|
17
- # config.coverage = { :test_files => ['test/**/test_*.rb'] }
17
+ # config.coverage = { :test_files => ['spec/**/*_spec.rb'] }
18
18
  # end
data/example.ru ADDED
@@ -0,0 +1,7 @@
1
+ require 'lib/redirect'
2
+
3
+ Redirect.autorun = false
4
+
5
+ require 'example.rb'
6
+
7
+ run Redirect.app
data/lib/redirect.rb CHANGED
@@ -5,7 +5,32 @@ require 'rack/request'
5
5
  require 'rack/response'
6
6
 
7
7
  module Redirect
8
- VERSION = '0.0.4'
8
+ VERSION = '0.1.0'
9
+
10
+ def self.default_code= default_code
11
+ @default_code = default_code
12
+ end
13
+
14
+ def self.default_code
15
+ @default_code ||= 301
16
+ end
17
+
18
+ def self.autorun= autorun
19
+ @autorun = autorun
20
+ end
21
+
22
+ def self.autorun
23
+ @autorun = true unless @autorun == false
24
+ @autorun
25
+ end
26
+
27
+ def self.app= app
28
+ @app = app
29
+ end
30
+
31
+ def self.app
32
+ @app
33
+ end
9
34
 
10
35
  class Data
11
36
  attr_reader :catch_url, :redirect_url, :code, :name
@@ -16,24 +41,18 @@ module Redirect
16
41
  @name = options[:name]
17
42
  end
18
43
  end
19
-
20
- def self.default_code= default_code
21
- @default_code = default_code
22
- end
23
-
24
- def self.default_code
25
- @default_code ||= 301
26
- end
27
44
 
28
45
  end
29
46
 
30
47
  def redirect(*redirects)
31
48
 
32
- app = Rack::Redirect.new(*redirects)
33
- Rack::Handler::WEBrick.run \
34
- Rack::ShowExceptions.new(Rack::Lint.new(app)),
35
- :Port => 3000
36
- run app
49
+ Redirect.app = Rack::Redirect.new(*redirects)
50
+ if Redirect.autorun
51
+ Rack::Handler::WEBrick.run \
52
+ Rack::ShowExceptions.new(Rack::Lint.new(Redirect.app)),
53
+ :Port => 3000
54
+ run Redirect.app
55
+ end
37
56
  end
38
57
 
39
58
  module Rack
data/spec/rack_spec.rb CHANGED
@@ -103,6 +103,8 @@ end
103
103
  describe "Redirect" do
104
104
  after do
105
105
  Redirect.default_code = 301
106
+ Redirect.app = nil
107
+ Redirect.autorun = true
106
108
  end
107
109
 
108
110
  it "Should be able to configure the default http code" do
@@ -113,4 +115,16 @@ describe "Redirect" do
113
115
  data.code.should == 307
114
116
  end
115
117
 
118
+ it "Should be able to set app" do
119
+ Redirect.app.should == nil
120
+ Redirect.app = 'a'
121
+ Redirect.app.should == 'a'
122
+ end
123
+
124
+ it "Should be able to set autorun" do
125
+ Redirect.autorun.should == true
126
+ Redirect.autorun = false
127
+ Redirect.autorun.should == false
128
+ end
129
+
116
130
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petrik de Heus
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-21 00:00:00 +01:00
12
+ date: 2009-02-22 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,6 +39,7 @@ files:
39
39
  - README.txt
40
40
  - Rakefile
41
41
  - example.rb
42
+ - example.ru
42
43
  - lib/redirect.rb
43
44
  - spec/helper.rb
44
45
  - spec/rack_spec.rb