garb 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/garb/profile.rb CHANGED
@@ -46,5 +46,9 @@ module Garb
46
46
  response = DataRequest.new(url).send_request
47
47
  Entry.parse(response.body).map {|entry| new(entry)}
48
48
  end
49
+
50
+ def self.first(id)
51
+ all.detect {|profile| profile.id == id || profile.web_property_id == id }
52
+ end
49
53
  end
50
54
  end
data/lib/garb/version.rb CHANGED
@@ -3,7 +3,7 @@ module Garb
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 3
6
- TINY = 1
6
+ TINY = 2
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -28,7 +28,26 @@ module Garb
28
28
 
29
29
  assert_equal profiles, Profile.all
30
30
  end
31
-
31
+
32
+ should "return the first profile for a given web property id" do
33
+ profile1 = stub(:web_property_id => '12345', :id => 'abcdef')
34
+ profile2 = stub(:web_property_id => '67890', :id => 'ghijkl')
35
+ entries = [profile1, profile2]
36
+
37
+ Garb::Profile.stubs(:all).returns(entries)
38
+
39
+ assert_equal profile1, Garb::Profile.first('12345')
40
+ end
41
+
42
+ should "return the first profile for a given table id" do
43
+ profile1 = stub(:id => '12345', :web_property_id => 'abcdef')
44
+ profile2 = stub(:id => '67890', :web_property_id => 'ghijkl')
45
+ entries = [profile1, profile2]
46
+
47
+ Garb::Profile.stubs(:all).returns(entries)
48
+
49
+ assert_equal profile2, Garb::Profile.first('67890')
50
+ end
32
51
  end
33
52
 
34
53
  context "An instance of the Profile class" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitale
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-10-27 00:00:00 -04:00
13
+ date: 2009-12-22 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency