ariadna 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,9 +15,12 @@ module Ariadna
15
15
  @profiles ||= create_profiles
16
16
  end
17
17
 
18
- def self.find(id)
19
- @profile_id = id
20
- all.first
18
+ def self.find(params)
19
+ return [] if params.empty?
20
+ all.each do |profile|
21
+ return profile if get_a_match(params, profile)
22
+ end
23
+ []
21
24
  end
22
25
 
23
26
  def results
@@ -42,6 +45,16 @@ module Ariadna
42
45
  end
43
46
  end
44
47
 
48
+ def self.get_a_match(params, profile)
49
+ if params[:id]
50
+ return true if profile.id.to_i == params[:id].to_i
51
+ end
52
+ if params[:name]
53
+ return true if profile.name.downcase.include? params[:name].downcase
54
+ end
55
+ return false
56
+ end
57
+
45
58
  def self.get_url
46
59
  url = @owner.childLink["href"]
47
60
  if @profile_id
@@ -1,3 +1,3 @@
1
1
  module Ariadna
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -3,7 +3,7 @@ profile:
3
3
  kind: 'analytics#profile'
4
4
  selfLink: 'selfLink'
5
5
  accountId: 111
6
- webPropertyId: 909090
6
+ webPropertyId: "UA-909090-1"
7
7
  internalWebPropertyId: 4321432
8
8
  name: 'profile_name'
9
9
  currency: 'EUR'
@@ -67,10 +67,20 @@ describe "Profile" do
67
67
  end
68
68
  end
69
69
 
70
- context "can find a profile by id" do
71
- it "should return the requested profile" do
72
- profile = @property.profiles.find(423423)
73
- profile.class.should == Ariadna::Profile
70
+ context "can find a profile by id or name" do
71
+ it "should return an empty array if can not find anything" do
72
+ profile = @property.profiles.find({})
73
+ profile.size.should == 0
74
+ end
75
+
76
+ it "should return the requested account filtered by name" do
77
+ profile = @property.profiles.find(:name => "profile")
78
+ profile.id.should == 123456
79
+ end
80
+
81
+ it "should return the requested account filtered by id" do
82
+ profile = @property.profiles.find(:id => 123456)
83
+ profile.name.should == 'profile_name'
74
84
  end
75
85
  end
76
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ariadna
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: