itunes_api 0.0.0 → 0.0.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.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/itunes_api.gemspec +1 -1
- data/lib/itunes_api/all.rb +2 -0
- data/lib/itunes_api/music/album.rb +40 -0
- data/lib/itunes_api/music/all.rb +1 -0
- data/lib/itunes_api/request.rb +19 -0
- data/lib/itunes_api/version.rb +1 -1
- data/lib/itunes_api.rb +4 -6
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60692f8078fec897509d930b312f27f0864d6618
|
4
|
+
data.tar.gz: 1c7e4d06b470b8e3bcd7e68da4dc869e59e65842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ace4631bd06fb8f7cd4ae8f18ab01eb35229d6fe9f86593a8401543fb4f913c2cd60a458835c195c156cb5d39b92b456e3bbd61bc188f8a4645a29c00c243ca3
|
7
|
+
data.tar.gz: f7394825a891aa37e78dff0b6b7a9eed179b3c81ab080e3296abbcd87e0c8bbd1a3a5d72dae72291d411dad31174967307d11781d4042a6dcfda45a388e403ad
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# ItunesApi
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
A simple interface for the Itunes Api.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'itunes_api'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "itunes_api"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/itunes_api.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.email = ['mariodarco78@icloud.com']
|
19
19
|
spec.summary = 'iTunes Api'
|
20
20
|
spec.description = 'An interface to the iTunes Api'
|
21
|
-
spec.homepage = 'https://
|
21
|
+
spec.homepage = 'https://github.com/mariodarco/itunes-api'
|
22
22
|
spec.license = 'MIT'
|
23
23
|
spec.bindir = 'exe'
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ItunesApi
|
2
|
+
module Music
|
3
|
+
# Use to retrieve available albums from artist's ids.
|
4
|
+
class Album
|
5
|
+
include Request
|
6
|
+
|
7
|
+
TYPE = 'Album'.freeze
|
8
|
+
|
9
|
+
def initialize(artists_id)
|
10
|
+
@artists_id = artists_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.info(artists_id)
|
14
|
+
new(artists_id).info
|
15
|
+
end
|
16
|
+
|
17
|
+
def info
|
18
|
+
@info ||= results
|
19
|
+
.find_all { |r| r['collectionType'] == TYPE }
|
20
|
+
.sort_by { |a| a['releaseDate'] }
|
21
|
+
.reverse
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def url
|
27
|
+
"#{BASE_URL}/lookup?id=#{all_artists_id}&" \
|
28
|
+
"entity=#{entity}&country=#{COUNTRY_CODE}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def all_artists_id
|
32
|
+
@artists_id.join(',')
|
33
|
+
end
|
34
|
+
|
35
|
+
def entity
|
36
|
+
TYPE.downcase
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'album'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module ItunesApi
|
5
|
+
# Allow requests to the iTunes API.
|
6
|
+
module Request
|
7
|
+
def request
|
8
|
+
@request ||= open(url).read
|
9
|
+
end
|
10
|
+
|
11
|
+
def response
|
12
|
+
JSON.parse(request)
|
13
|
+
end
|
14
|
+
|
15
|
+
def results
|
16
|
+
response.fetch('results', [])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/itunes_api/version.rb
CHANGED
data/lib/itunes_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario D’Arco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,8 +85,12 @@ files:
|
|
85
85
|
- bin/setup
|
86
86
|
- itunes_api.gemspec
|
87
87
|
- lib/itunes_api.rb
|
88
|
+
- lib/itunes_api/all.rb
|
89
|
+
- lib/itunes_api/music/album.rb
|
90
|
+
- lib/itunes_api/music/all.rb
|
91
|
+
- lib/itunes_api/request.rb
|
88
92
|
- lib/itunes_api/version.rb
|
89
|
-
homepage: https://
|
93
|
+
homepage: https://github.com/mariodarco/itunes-api
|
90
94
|
licenses:
|
91
95
|
- MIT
|
92
96
|
metadata:
|