divining_rod 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/divining_rod.gemspec +1 -1
- data/lib/divining_rod.rb +5 -5
- data/spec/basic_spec.rb +16 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/divining_rod.gemspec
CHANGED
data/lib/divining_rod.rb
CHANGED
@@ -2,10 +2,6 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module DiviningRod
|
4
4
|
|
5
|
-
class UndefinedDefault < StandardError
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
5
|
class Profile
|
10
6
|
|
11
7
|
attr_reader :match
|
@@ -15,7 +11,7 @@ module DiviningRod
|
|
15
11
|
@match = matcher if matcher.matches?(request)
|
16
12
|
break if @match
|
17
13
|
end
|
18
|
-
|
14
|
+
nil
|
19
15
|
end
|
20
16
|
|
21
17
|
def group
|
@@ -23,6 +19,10 @@ module DiviningRod
|
|
23
19
|
end
|
24
20
|
alias_method :format, :group
|
25
21
|
|
22
|
+
def recognized?
|
23
|
+
!!@match
|
24
|
+
end
|
25
|
+
|
26
26
|
def method_missing(meth)
|
27
27
|
if meth.to_s.match(/(.+)\?$/)
|
28
28
|
tag = $1
|
data/spec/basic_spec.rb
CHANGED
@@ -32,6 +32,22 @@ describe DiviningRod do
|
|
32
32
|
profile.wap?.should be_false
|
33
33
|
end
|
34
34
|
|
35
|
+
describe "without a default definition" do
|
36
|
+
|
37
|
+
before :each do
|
38
|
+
@request = mock("rails_request", :user_agent => 'Foo Fone')
|
39
|
+
DiviningRod::Matchers.clear_definitions
|
40
|
+
DiviningRod::Matchers.define do |map|
|
41
|
+
map.ua /iPhone/, :webkit, :tags => [:iphone, :youtube, :geolocate]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not find a match" do
|
46
|
+
DiviningRod::Profile.new(@request).recognized?.should be_false
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
35
51
|
end
|
36
52
|
|
37
53
|
|