itunes_api 0.5.1 → 0.6.0

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: b326b2d7b06c7a84cff4dae101431c6fc35780c9
4
- data.tar.gz: 722fb5d4845b660b4b1476e3468e3527fae55d83
3
+ metadata.gz: 1d99e396f4049e8c7bd11bc060e06c3ff70aad41
4
+ data.tar.gz: e4447f6837f2feb4025f414d5de2d23958944830
5
5
  SHA512:
6
- metadata.gz: 939f30bf0179cd4e91000428177b0376c61100de9d0ebaef4fa5a5005ba4188f33fa07235831d799cff7973eea85c97372bd1d10cf9bbca208bc3757c6fba40e
7
- data.tar.gz: b1ce698ef182a75629c3ec09445c03478df7a537fd3ec3d08a9112c5177ffb3cae5da9e3116d73f1de146cc050f8fc63c93933d30e61bb0668830f2033b2e970
6
+ metadata.gz: 9a713e9774c704803155dcddbc1da773bd5c9c8180144cb5995e9d2d131a4a8916ab97c50b1f9e0fa6946e7d7a1710935ed057edb8c7f8c4ce59a5e06c43f733
7
+ data.tar.gz: 99dd861be1948e382b33696a7027aceb3e00d8847a3b1016c6906c34368df668b4e4eb97f94c97df675b97ffb9c0a05b8fe7fc64891f025e668c249afa23702b
data/README.md CHANGED
@@ -25,6 +25,16 @@ Or install it yourself as:
25
25
  $ gem install itunes_api
26
26
  ```
27
27
 
28
+ ## Configuration
29
+
30
+ Add an initializer to your app to set the country for the Store:
31
+ ```ruby
32
+ # config/initializers/itunes_api.rb
33
+ ItunesApi.configure do |config|
34
+ config.country_code = ENV['COUNTRY_CODE']
35
+ end
36
+ ```
37
+
28
38
  ## Usage
29
39
 
30
40
  To return all the AMG ids associated with a search term.
@@ -0,0 +1,8 @@
1
+ require 'singleton'
2
+
3
+ module ItunesApi
4
+ class Configuration
5
+ include Singleton
6
+ attr_accessor :country_code
7
+ end
8
+ end
@@ -16,6 +16,10 @@ module ItunesApi
16
16
  @artwork ||= data[:artworkUrl100]
17
17
  end
18
18
 
19
+ def collection_id
20
+ @collection_id ||= data[:collectionId]
21
+ end
22
+
19
23
  def name
20
24
  @name ||= data[:collectionName]
21
25
  end
@@ -24,6 +28,15 @@ module ItunesApi
24
28
  @released ||= Date.parse(data[:releaseDate])
25
29
  end
26
30
 
31
+ def to_hash
32
+ {
33
+ artwork: artwork,
34
+ collection_id: collection_id,
35
+ name: name,
36
+ released: released,
37
+ }
38
+ end
39
+
27
40
  private
28
41
 
29
42
  attr_reader :data
@@ -0,0 +1,4 @@
1
+ require_relative 'album'
2
+ require_relative 'artist'
3
+ require_relative 'artist_lookup'
4
+ require_relative 'artist_search'
@@ -0,0 +1,3 @@
1
+ require_relative 'base'
2
+ require_relative 'lookup'
3
+ require_relative 'search'
@@ -18,6 +18,10 @@ module ItunesApi
18
18
  Faraday.new(url: BASE_URL)
19
19
  end
20
20
 
21
+ def country_code
22
+ Configuration.instance.country_code || 'GB'
23
+ end
24
+
21
25
  def response
22
26
  connection.get(action, query)
23
27
  end
@@ -46,7 +46,7 @@ module ItunesApi
46
46
  {
47
47
  entity: 'album',
48
48
  amgArtistId: @artist_id,
49
- country: COUNTRY_CODE,
49
+ country: country_code,
50
50
  limit: LIMIT,
51
51
  sort: 'recent'
52
52
  }
@@ -29,7 +29,7 @@ module ItunesApi
29
29
  attribute: 'artistTerm',
30
30
  entity: 'album',
31
31
  term: @artist_name,
32
- country: COUNTRY_CODE,
32
+ country: country_code,
33
33
  limit: LIMIT,
34
34
  media: 'music',
35
35
  sort: 'recent'
@@ -1,3 +1,3 @@
1
1
  module ItunesApi
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
data/lib/itunes_api.rb CHANGED
@@ -1,15 +1,10 @@
1
- require 'itunes_api/requests/base'
2
- require 'itunes_api/requests/lookup'
3
- require 'itunes_api/requests/search'
4
- require 'itunes_api/music/album'
5
- require 'itunes_api/music/artist'
6
- require 'itunes_api/music/artist_lookup'
7
- require 'itunes_api/music/artist_search'
1
+ require 'itunes_api/configuration'
2
+ require 'itunes_api/requests/all'
3
+ require 'itunes_api/music/all'
8
4
 
9
5
  # Interface to the Itunes Api
10
6
  module ItunesApi
11
7
  BASE_URL = 'https://itunes.apple.com'.freeze
12
- COUNTRY_CODE = 'GB'.freeze
13
8
  LIMIT = 200
14
9
 
15
10
  def self.artist_ids(name)
@@ -23,4 +18,8 @@ module ItunesApi
23
18
  def self.artist_search(name)
24
19
  Music::ArtistSearch.artists(name)
25
20
  end
21
+
22
+ def self.configure
23
+ yield(Configuration.instance)
24
+ end
26
25
  end
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.5.1
4
+ version: 0.6.0
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: 2017-05-20 00:00:00.000000000 Z
11
+ date: 2017-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -112,10 +112,13 @@ files:
112
112
  - bin/setup
113
113
  - itunes_api.gemspec
114
114
  - lib/itunes_api.rb
115
+ - lib/itunes_api/configuration.rb
115
116
  - lib/itunes_api/music/album.rb
117
+ - lib/itunes_api/music/all.rb
116
118
  - lib/itunes_api/music/artist.rb
117
119
  - lib/itunes_api/music/artist_lookup.rb
118
120
  - lib/itunes_api/music/artist_search.rb
121
+ - lib/itunes_api/requests/all.rb
119
122
  - lib/itunes_api/requests/base.rb
120
123
  - lib/itunes_api/requests/lookup.rb
121
124
  - lib/itunes_api/requests/search.rb