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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65bdcc757a28ad998b1ebb23fcddc84d97953d38
4
- data.tar.gz: ebcbb2664e78721c41ceaf8cca7e39150fc5f94b
3
+ metadata.gz: 62962f469eb9696132e9bf5f62c76a81c3e48615
4
+ data.tar.gz: 1b71e4cb85eb7fab659a54166d3e6dd78dcfe1ae
5
5
  SHA512:
6
- metadata.gz: 674f00c3f0d4e0c73ba53022d6a7dc42abbfe6084e910ae17eb703c41449ebebc5c4034a07d794acb0a9cba4d07553331bc2e33875fc7dc1e7bf1742106d76fa
7
- data.tar.gz: dccaab5326c12d41e89650db1e7f4c6cbb6a701c8d4e1c02e7f020e073a233603fd67f5dacee8d96d16bda015c78fa2f57fd542a83b08bd5f2aacb2a414b4689
6
+ metadata.gz: ba0ccc5643d120520ff0c678c53fbe317d13ea8cd40379b594c4b46c64e57e77b66d0c6e596b3482559871e228dbcad58fc6af3c45656e342f39e65506f65964
7
+ data.tar.gz: e77e28982943f22586dbc5cd06cc6c2b35596861ff7d6fc214227d1adeac395de74624c8e10b3bcecb863314a75ce1ba577e8ed9266cd27f66aac7fc2c26d35a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nashville (0.0.1)
4
+ nashville (0.0.2)
5
5
  commander (~> 4.1)
6
6
  json
7
7
  rash
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 for the [famed home of the entertainment industry](http://en.wikipedia.org/wiki/Nashville), in [Los Angeles, California](http://en.wikipedia.org/wiki/Los_Angeles).
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
@@ -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/search"
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
- json = JSON.parse(response.body)
32
-
33
- return json["results"]
44
+ JSON.parse(response.body) rescue nil
34
45
  end
35
46
  end
36
47
  end
@@ -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(params = {})
74
- client.search(params)
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
@@ -1,3 +1,3 @@
1
1
  module Nashville
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nashville
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattt Thompson