braque 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/braque/collection.rb +3 -1
- data/lib/braque/version.rb +1 -1
- data/spec/braque/collection_spec.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17ebac669aabbc1f0001fa83b60e11d6e7071012
|
|
4
|
+
data.tar.gz: 58e44df33fae3b9f83dea7387b166cac0ca23391
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc9e535ae1f76e08dd8f94594489f5b1a74b2b0324ac0194db87ace0d6fd5f192a7765b635fd475f57f129446057c0114c1422162309016f22d5eb1acf90c110
|
|
7
|
+
data.tar.gz: e9f71ec7e1fe8f288905fae0ee136fb12f670e3680bee73c15bd7fe322a21025ef98557506216d975d2f2ec0957b0184f44566529cdcb7d0a89342bb155969fd
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Braque aims to provide a simple and familiar interface for setting up clients to
|
|
|
4
4
|
|
|
5
5
|
Braque is an early-stage and exploratory project.
|
|
6
6
|
|
|
7
|
-
[
|
|
7
|
+
[](https://semaphoreci.com/dylanfareed/braque)
|
|
8
8
|
|
|
9
9
|
### Model setup
|
|
10
10
|
|
data/lib/braque/collection.rb
CHANGED
|
@@ -3,15 +3,17 @@ module Braque
|
|
|
3
3
|
class LinkedArray < Array
|
|
4
4
|
attr_reader :next_link
|
|
5
5
|
attr_reader :previous_link
|
|
6
|
+
attr_reader :total_count
|
|
6
7
|
|
|
7
8
|
def initialize(response = [], klass)
|
|
8
9
|
next_link = response._links.try(:next)
|
|
9
10
|
previous_link = response._links.try(:prev)
|
|
11
|
+
total_count = response.try(:total_count)
|
|
10
12
|
retrieved_items = []
|
|
11
13
|
response.each do |item|
|
|
12
14
|
retrieved_items << klass.new(item)
|
|
13
15
|
end
|
|
14
|
-
@retrieved_items, @next_link, @previous_link = retrieved_items, next_link, previous_link
|
|
16
|
+
@retrieved_items, @next_link, @previous_link, @total_count = retrieved_items, next_link, previous_link, total_count
|
|
15
17
|
super retrieved_items
|
|
16
18
|
end
|
|
17
19
|
end
|
data/lib/braque/version.rb
CHANGED
|
@@ -20,8 +20,10 @@ RSpec.describe Braque::Collection do
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
class ResponseCollection < Array
|
|
23
|
+
attr_reader :total_count
|
|
23
24
|
attr_reader :_links
|
|
24
25
|
def initialize(array = [], next_str, previous_str)
|
|
26
|
+
@total_count = 3
|
|
25
27
|
@_links = ResponseLinks.new next_str, previous_str
|
|
26
28
|
super array
|
|
27
29
|
end
|
|
@@ -38,6 +40,9 @@ RSpec.describe Braque::Collection do
|
|
|
38
40
|
it 'returns an array of the correct number of items' do
|
|
39
41
|
expect(@linked_array.count).to eq 2
|
|
40
42
|
end
|
|
43
|
+
it 'returns the correct total_count' do
|
|
44
|
+
expect(@linked_array.total_count).to eq 3
|
|
45
|
+
end
|
|
41
46
|
it 'returns an array of new items based on the calling class' do
|
|
42
47
|
expect(@linked_array.first.id).to eq 1
|
|
43
48
|
expect(@linked_array.first.title).to eq @array.first[:title]
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: braque
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dylan Fareed
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: hyperclient
|
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
96
|
version: '0'
|
|
97
97
|
requirements: []
|
|
98
98
|
rubyforge_project:
|
|
99
|
-
rubygems_version: 2.
|
|
99
|
+
rubygems_version: 2.4.3
|
|
100
100
|
signing_key:
|
|
101
101
|
specification_version: 4
|
|
102
102
|
summary: Braque provides a simple interface for interacting with Hypermedia API services
|