nashville 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/nashville/client.rb +16 -5
- data/lib/nashville/media.rb +13 -3
- data/lib/nashville/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: 62962f469eb9696132e9bf5f62c76a81c3e48615
|
4
|
+
data.tar.gz: 1b71e4cb85eb7fab659a54166d3e6dd78dcfe1ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba0ccc5643d120520ff0c678c53fbe317d13ea8cd40379b594c4b46c64e57e77b66d0c6e596b3482559871e228dbcad58fc6af3c45656e342f39e65506f65964
|
7
|
+
data.tar.gz: e77e28982943f22586dbc5cd06cc6c2b35596861ff7d6fc214227d1adeac395de74624c8e10b3bcecb863314a75ce1ba577e8ed9266cd27f66aac7fc2c26d35a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# Nashville
|
1
2
|
|
2
3
|
Nashville is a wrapper and command line interface for querying the iTunes Store API.
|
3
4
|
|
4
|
-
> Nashville is named
|
5
|
+
> Nashville is named after the [eponymous Capital of Country Music (and Tennesee)](http://en.wikipedia.org/wiki/Nashville,_Tennessee), home of [the Grand 'Ole Opry](http://en.wikipedia.org/wiki/Grand_Ole_Opry) and the [Country Music Hall of Fame and Museum](http://en.wikipedia.org/wiki/Country_Music_Hall_of_Fame_and_Museum).
|
6
|
+
|
5
7
|
> It's part of a series of world-class command-line utilities for iOS development, which includes [Cupertino](https://github.com/mattt/cupertino) (Apple Dev Center management), [Shenzhen](https://github.com/mattt/shenzhen) (Building & Distribution), [Houston](https://github.com/mattt/houston) (Push Notifications), [Venice](https://github.com/mattt/venice) (In-App Purchase Verification), and [Dubai](https://github.com/mattt/dubai) (Passbook pass generation).
|
6
8
|
|
7
9
|
## Installation
|
data/lib/nashville/client.rb
CHANGED
@@ -3,7 +3,7 @@ require 'net/https'
|
|
3
3
|
require 'uri'
|
4
4
|
|
5
5
|
module Nashville
|
6
|
-
ITUNES_SEARCH_ENDPOINT = "https://itunes.apple.com/
|
6
|
+
ITUNES_SEARCH_ENDPOINT = "https://itunes.apple.com/"
|
7
7
|
|
8
8
|
class Client
|
9
9
|
attr_accessor :search_url
|
@@ -17,9 +17,22 @@ module Nashville
|
|
17
17
|
def search(params = {})
|
18
18
|
params[:country] ||= @country
|
19
19
|
|
20
|
-
uri = URI(@search_url)
|
20
|
+
uri = URI.join(@search_url, "search")
|
21
21
|
uri.query = URI.encode_www_form(params)
|
22
22
|
|
23
|
+
json_response_from_uri(uri)["results"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def lookup(params = {})
|
27
|
+
uri = URI.join(@search_url, "lookup")
|
28
|
+
uri.query = URI.encode_www_form(params)
|
29
|
+
|
30
|
+
json_response_from_uri(uri)["results"]
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def json_response_from_uri(uri)
|
23
36
|
http = Net::HTTP.new(uri.host, uri.port)
|
24
37
|
http.use_ssl = true
|
25
38
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
@@ -28,9 +41,7 @@ module Nashville
|
|
28
41
|
request['Accept'] = "application/json"
|
29
42
|
|
30
43
|
response = http.request(request)
|
31
|
-
|
32
|
-
|
33
|
-
return json["results"]
|
44
|
+
JSON.parse(response.body) rescue nil
|
34
45
|
end
|
35
46
|
end
|
36
47
|
end
|
data/lib/nashville/media.rb
CHANGED
@@ -60,7 +60,7 @@ module Nashville
|
|
60
60
|
params[:entity] = self.entity
|
61
61
|
|
62
62
|
results = self.delegator.search(params)
|
63
|
-
results.collect{|result| self.new(result)}
|
63
|
+
results.collect{|result| self.new(result.to_h)}
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -70,8 +70,18 @@ module Nashville
|
|
70
70
|
include Media
|
71
71
|
|
72
72
|
class << self
|
73
|
-
def search(
|
74
|
-
|
73
|
+
def search(*args)
|
74
|
+
params = args.last.is_a?(Hash) ? args.pop : {}
|
75
|
+
params[:term] ||= args.shift
|
76
|
+
|
77
|
+
client.search(params).collect{|result| Hashie::Rash.new(result)}
|
78
|
+
end
|
79
|
+
|
80
|
+
def lookup(*args)
|
81
|
+
params = args.last.is_a?(Hash) ? args.pop : {}
|
82
|
+
params[:id] ||= args.shift
|
83
|
+
|
84
|
+
client.lookup(params).collect{|result| Hashie::Rash.new(result)}
|
75
85
|
end
|
76
86
|
|
77
87
|
private
|
data/lib/nashville/version.rb
CHANGED