ariadna 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ariadna/profile.rb +16 -3
- data/lib/ariadna/version.rb +1 -1
- data/spec/fixtures/profiles.yml +1 -1
- data/spec/lib/ariadna/profile_spec.rb +14 -4
- metadata +1 -1
data/lib/ariadna/profile.rb
CHANGED
@@ -15,9 +15,12 @@ module Ariadna
|
|
15
15
|
@profiles ||= create_profiles
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.find(
|
19
|
-
|
20
|
-
all.
|
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
|
data/lib/ariadna/version.rb
CHANGED
data/spec/fixtures/profiles.yml
CHANGED
@@ -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
|
72
|
-
profile = @property.profiles.find(
|
73
|
-
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
|