simplespotify 0.0.6 → 0.1.0
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/lib/simplespotify/actions/player.rb +7 -2
- data/lib/simplespotify/models/collection.rb +10 -5
- data/lib/simplespotify/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93fa79fb7a04b8f2f805569f2140b18420d4abda
|
4
|
+
data.tar.gz: 950b0fcaa298a45e9ba3b409d4af4fcd564d4402
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe51c2e2fe9973410895657a9dc44bc621264ed2feae546f9686ff890cb4a8ca574a39146176f19df3f85c5d2bd7cf687b2263cbcf577d5cc16173dbb98b4310
|
7
|
+
data.tar.gz: 30e890843bdd6bd66455e1945f4a2072e458b9b5fd55d7509012ffaa1c4020d5e87716b7c5358730c3fe535c66828088a8f5450b96110a89e2db3a75886bbf6a
|
@@ -8,9 +8,14 @@ module SimpleSpotify
|
|
8
8
|
}
|
9
9
|
query[:after] = after if after
|
10
10
|
query[:before] = before if before
|
11
|
-
response = get "me/player/recently-played"
|
11
|
+
response = get "me/player/recently-played?limit=#{limit}"
|
12
12
|
|
13
|
-
|
13
|
+
refresh = -> url {
|
14
|
+
puts url
|
15
|
+
response = get url
|
16
|
+
return Model::Collection.of(SimpleSpotify::Model::PlayEvent, response.body, &refresh)
|
17
|
+
}
|
18
|
+
Model::Collection.of(SimpleSpotify::Model::PlayEvent, response.body, &refresh)
|
14
19
|
end
|
15
20
|
|
16
21
|
end
|
@@ -5,7 +5,7 @@ module SimpleSpotify
|
|
5
5
|
|
6
6
|
attr_accessor :total
|
7
7
|
|
8
|
-
def self.of type, collection
|
8
|
+
def self.of type, collection, &refresh
|
9
9
|
if type.is_a? Class
|
10
10
|
model = type;
|
11
11
|
prop = type.to_s.split('::').last.downcase+'s'
|
@@ -19,15 +19,16 @@ module SimpleSpotify
|
|
19
19
|
prop = collection.has_key?(prop.to_sym) ? prop.to_sym : :items
|
20
20
|
|
21
21
|
collection[prop].map! {|item| model.new(item) }
|
22
|
-
self.new(collection)
|
22
|
+
self.new(collection, prop, &refresh)
|
23
23
|
end
|
24
24
|
|
25
25
|
|
26
|
-
def initialize data, property=:items
|
26
|
+
def initialize data, property=:items, &refresh
|
27
27
|
values = data[property]
|
28
28
|
super values
|
29
29
|
@total = data[:total] || self.count
|
30
30
|
@next = data[:next]
|
31
|
+
@refresh = refresh if block_given?
|
31
32
|
end
|
32
33
|
|
33
34
|
|
@@ -43,8 +44,12 @@ module SimpleSpotify
|
|
43
44
|
|
44
45
|
def more
|
45
46
|
return [] unless more?
|
46
|
-
|
47
|
-
|
47
|
+
if @refresh
|
48
|
+
@refresh.call @next
|
49
|
+
else
|
50
|
+
req = Request.new(@next, {private: true})
|
51
|
+
SimpleSpotify.dispatch(req)
|
52
|
+
end
|
48
53
|
end
|
49
54
|
end #/class
|
50
55
|
|