zoid 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/bin/publish +6 -0
- data/lib/zoid/resources.rb +25 -0
- data/lib/zoid/response.rb +7 -1
- data/lib/zoid/version.rb +1 -1
- data/lib/zoid.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a63e1d2b203aebccc51708817528c0f332f88e8
|
4
|
+
data.tar.gz: bc57753b13514dd77383783a84a36e82ee5f54cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32ba5dc4e79e1fbc9475cdeb5b1631547a44887576a2f497a6faa36e75d97027f2ca0d9ca5d384159a4f49077ef6e8b8510145632da3fbc5b7740513c157dba3
|
7
|
+
data.tar.gz: f22aaad282448e01dc3118c3773782921f2898aa314630880ba472bcd3ab5a4bdc029b3c13e7c6fbdf93d3a02e632db25187b3281d0b49672a4b7bd8ee94fbd9
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
![zoid](http://pre12.deviantart.net/81ba/th/pre/f/2013/022/e/1/why_not_zoidberg___by_claustrophobias-d5sbjw8.png)
|
4
4
|
|
5
|
+
[![Build Status](https://semaphoreci.com/api/v1/projects/3b10a258-56ac-4e32-8a02-01710a2b817c/468022/badge.svg)](https://semaphoreci.com/shiroyasha/zoid)
|
6
|
+
|
5
7
|
## Usage
|
6
8
|
|
7
9
|
Start by creating an agent for the API endpoint
|
data/bin/publish
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Zoid
|
2
|
+
class Resources
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
def initialize(resources)
|
6
|
+
@resources = resources
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_by(criteria)
|
10
|
+
key = criteria.keys.first
|
11
|
+
value = criteria[key]
|
12
|
+
|
13
|
+
@resources.find { |resource| resource.public_send(key) == value }
|
14
|
+
end
|
15
|
+
|
16
|
+
def each(&block)
|
17
|
+
@resources.each(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](index)
|
21
|
+
@resources[index]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/zoid/response.rb
CHANGED
@@ -10,12 +10,18 @@ module Zoid
|
|
10
10
|
|
11
11
|
def process(value)
|
12
12
|
case value
|
13
|
-
when Array then value
|
13
|
+
when Array then process_array(value)
|
14
14
|
when Hash then process_hash(value)
|
15
15
|
else value
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def process_array(array)
|
20
|
+
processed_array = array.map { |el| process(el) }
|
21
|
+
|
22
|
+
Zoid::Resources.new(processed_array)
|
23
|
+
end
|
24
|
+
|
19
25
|
def process_hash(hash)
|
20
26
|
processed_hash = hash.map do |key, value|
|
21
27
|
[key.to_s, process(value)]
|
data/lib/zoid/version.rb
CHANGED
data/lib/zoid.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Sarcevic
|
@@ -149,11 +149,13 @@ files:
|
|
149
149
|
- README.md
|
150
150
|
- Rakefile
|
151
151
|
- bin/console
|
152
|
+
- bin/publish
|
152
153
|
- bin/setup
|
153
154
|
- fixtures/vcr_cassettes/github/public_repo.yml
|
154
155
|
- lib/zoid.rb
|
155
156
|
- lib/zoid/agent.rb
|
156
157
|
- lib/zoid/resource.rb
|
158
|
+
- lib/zoid/resources.rb
|
157
159
|
- lib/zoid/response.rb
|
158
160
|
- lib/zoid/version.rb
|
159
161
|
- zoid.gemspec
|