rack-useragent-filter 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -6,7 +6,7 @@ Rack Middleware for filtering by user agent
6
6
 
7
7
  Let's say you don't support IE6 and want to prevent IE6 users from accessing to your Rails app. You're in luck. Just add this to your <tt>config/environment.rb</tt>:
8
8
 
9
- config.gem "bebanjo-rack-useragent", :lib => "rack/user_agent", :source => "http://gems.github.com"
9
+ config.gem "rack-useragent-filter", :lib => "rack/user_agent"
10
10
 
11
11
  config.middleware.use "Rack::UserAgent::Filter", [
12
12
  {:browser => "Internet Explorer", :version => "7.0"}
@@ -18,7 +18,7 @@ And, of course, install the gem:
18
18
 
19
19
  Done! From now on users with IE version lower than 7.0 will get a nice error message saying that their browsers need to be updated... Ok, ok, not so nice message, you can personalize it by putting an <tt>upgrade.html</tt> file inside the <tt>/public</tt> directory of your application.
20
20
 
21
- <em>- Cool!, what about something more dynamic... like ERB?</em>
21
+ <em>- Cool!, what about something more dynamic... like ERB or HAML?</em>
22
22
 
23
23
  Granted! You'll have to add to the config which template to use. In <tt>environment.rb</tt>:
24
24
 
data/Rakefile CHANGED
@@ -17,12 +17,13 @@ begin
17
17
  require 'jeweler'
18
18
  Jeweler::Tasks.new do |gemspec|
19
19
  gemspec.name = "rack-useragent-filter"
20
- gemspec.authors = ["Sergio Gil", "Luismi Cavallé", "Tomasz Mazur"]
21
- gemspec.email = ["ballsbreaking@bebanjo.com", "defkode@gmail.com"]
22
- gemspec.homepage = "http://github.com/defkode/rack-useragent"
20
+ gemspec.authors = ["Sergio Gil", "Luismi Cavallé"]
21
+ gemspec.email = "ballsbreaking@bebanjo.com"
22
+ gemspec.homepage = "http://github.com/bebanjo/rack-useragent"
23
23
  gemspec.summary = "Rack Middleware for filtering by user agent"
24
24
  gemspec.add_dependency('rack', '>= 0.9.1')
25
- gemspec.add_dependency('useragent', '>=0.1.4')
25
+ gemspec.add_dependency('useragent', '>= 0.1.5')
26
+ gemspec.add_dependency('tilt', '>= 1.0.0')
26
27
  end
27
28
  rescue LoadError
28
29
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -1,5 +1,6 @@
1
1
  require 'user_agent'
2
2
  require 'erb'
3
+ require 'tilt'
3
4
  require 'ostruct'
4
5
 
5
6
  module Rack::UserAgent
@@ -35,7 +36,7 @@ module Rack::UserAgent
35
36
  def render_page(browser)
36
37
  if @template && File.exists?(@template)
37
38
  @browser = browser # for the template
38
- ERB.new(File.read(@template)).result(binding)
39
+ Tilt.new(@template).render(self)
39
40
  else
40
41
  "Sorry, your browser is not supported. Please upgrade"
41
42
  end
@@ -0,0 +1 @@
1
+ = "Hello, #{@browser.browser} #{@browser.version}!"
@@ -54,6 +54,24 @@ class UserAgentFilterTest < Test::Unit::TestCase
54
54
 
55
55
  end
56
56
 
57
+ context "custom page (haml)" do
58
+ setup do
59
+ def app
60
+ Rack::Builder.new do
61
+ use Rack::UserAgent::Filter, [{:browser => "Internet Explorer", :version => "7.0"}], :template => File.dirname(__FILE__) + "/fixtures/upgrade.haml"
62
+ run SampleApp.new
63
+ end
64
+ end
65
+ end
66
+
67
+ should "work" do
68
+ header "User-Agent", @outdated_browser
69
+ get '/'
70
+ assert_equal "Hello, Internet Explorer 6.0!\n", last_response.body
71
+ end
72
+
73
+ end
74
+
57
75
  context "cookie" do
58
76
 
59
77
  setup do
metadata CHANGED
@@ -1,23 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-useragent-filter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sergio Gil
14
14
  - "Luismi Cavall\xC3\xA9"
15
- - Tomasz Mazur
16
15
  autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2010-06-01 00:00:00 +02:00
19
+ date: 2010-07-20 00:00:00 +02:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
@@ -44,18 +43,32 @@ dependencies:
44
43
  requirements:
45
44
  - - ">="
46
45
  - !ruby/object:Gem::Version
47
- hash: 19
46
+ hash: 17
48
47
  segments:
49
48
  - 0
50
49
  - 1
51
- - 4
52
- version: 0.1.4
50
+ - 5
51
+ version: 0.1.5
53
52
  type: :runtime
54
53
  version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: tilt
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 23
63
+ segments:
64
+ - 1
65
+ - 0
66
+ - 0
67
+ version: 1.0.0
68
+ type: :runtime
69
+ version_requirements: *id003
55
70
  description:
56
- email:
57
- - ballsbreaking@bebanjo.com
58
- - defkode@gmail.com
71
+ email: ballsbreaking@bebanjo.com
59
72
  executables: []
60
73
 
61
74
  extensions: []
@@ -70,10 +83,11 @@ files:
70
83
  - lib/rack/user_agent.rb
71
84
  - lib/rack/user_agent/filter.rb
72
85
  - test/fixtures/upgrade.erb
86
+ - test/fixtures/upgrade.haml
73
87
  - test/test_helper.rb
74
88
  - test/user_agent_filter_test.rb
75
89
  has_rdoc: true
76
- homepage: http://github.com/defkode/rack-useragent
90
+ homepage: http://github.com/bebanjo/rack-useragent
77
91
  licenses: []
78
92
 
79
93
  post_install_message: