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 CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/divining_rod.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{divining_rod}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Percival"]
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
- raise UndefinedDefault, "Please define a default group for DiviningRod" unless @match
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: divining_rod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Percival