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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78a8b8d4dca24858ec3a2f4b731622f40fafbe7b
4
- data.tar.gz: 2ac2958de0e04adf0a7822584fd6d29a2cc47583
3
+ metadata.gz: 9a63e1d2b203aebccc51708817528c0f332f88e8
4
+ data.tar.gz: bc57753b13514dd77383783a84a36e82ee5f54cb
5
5
  SHA512:
6
- metadata.gz: 049fca773682604d4c454b5e8e38f7c6abafa5d4af75018911a39162b9e267f15f7245770fcb0d209e977d0c905a1e65cee235740a3e3fb6134439cec989bdc1
7
- data.tar.gz: 40f2d5efad678f35e5465dad77202b0f14cda7d47c104e7aa2aa1590a8644c6cd71523fed81f318e9ee83d8eb4ed307223b59f2505e0cf27ac8bab4e5ad4c622
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,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "zoid"
5
+
6
+ system("gem build zoid.gemspec && gem push zoid-#{Zoid::VERSION}.gem; rm -f zoid-#{Zoid::VERSION}.gem")
@@ -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.map { |el| process(el) }
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
@@ -1,3 +1,3 @@
1
1
  module Zoid
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/zoid.rb CHANGED
@@ -4,4 +4,5 @@ module Zoid
4
4
  require "zoid/agent"
5
5
  require "zoid/response"
6
6
  require "zoid/resource"
7
+ require "zoid/resources"
7
8
  end
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.2
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