podcast_index 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: be3811eb9cbde914e7e314e4d02e35a335fcb06250b8e22519ed0b59487d2e4b
4
- data.tar.gz: 19de21d136dbc55f8cf0adcc65a710d773baceb99398ff22182d7e67b26ebc6b
3
+ metadata.gz: 1364632f70ac0a7504a90e90c5b6bd53d978697ecba73dc85bbbcddebe92706e
4
+ data.tar.gz: d495e5fdce0ce3baedb5ada68f4876f7e906c0dbfee655dc49df0681aad45601
5
5
  SHA512:
6
- metadata.gz: 353f4074705cd1e93675d8bb8908698a57b07f321f54510d6d8e23af483736d6fd127b94aafcc67cd3d29e84e628c505aac290823e33425e30bc7c4343044cf8
7
- data.tar.gz: 03075bb9e16b26edaa2b4d865435b0bdf919fd896f7b19e0b5c3f7d204cb0093a2f35e02d1312b2e0248c2a3385dbb54cd240a504b92afd1bbae3bb8d8a22d40
6
+ metadata.gz: f3b68defbe2c3640ac0ac63317a4838590304a296dabb786c43ebeb8b3eca4eba2aa90745e5857cc0b916e22c2e025a43dd4f991b0915185261c03b33f445aeb
7
+ data.tar.gz: dbd7f74e52c4e2f5c40d1ccdfad1bfb498b28d6ce3e14b8c32cb38cd1bc014bf21083ad3db05c0167979974a5c14be8889552fbb94c7bd168b324c327fcad7cf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2023-09-22
4
+
5
+ * Add `max` parameter to search requests (thanks @lbrito1)
6
+
7
+ ## [0.2.1] - 2023-07-06
8
+
9
+ * Raise exception when `Podcast.find` returns no result ([#6](https://github.com/jasonyork/podcast-index/issues/6))
10
+
3
11
  ## [0.2.0] - 2023-04-24
4
12
 
5
13
  * BREAKING: Switching to be more consistent with ActiveRecord conventions, using `find_by` and `where` methods for all models
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- podcast_index (0.2.0)
4
+ podcast_index (0.3.0)
5
5
  activesupport (>= 6.0, < 8)
6
6
  addressable (~> 2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (7.0.3.1)
11
+ activesupport (7.0.8)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
@@ -27,13 +27,13 @@ GEM
27
27
  diff-lcs (1.5.0)
28
28
  docile (1.4.0)
29
29
  hashdiff (1.0.1)
30
- i18n (1.12.0)
30
+ i18n (1.14.1)
31
31
  concurrent-ruby (~> 1.0)
32
32
  io-console (0.6.0)
33
33
  irb (1.6.2)
34
34
  reline (>= 0.3.0)
35
35
  json (2.6.3)
36
- minitest (5.17.0)
36
+ minitest (5.20.0)
37
37
  parallel (1.22.1)
38
38
  parser (3.1.3.0)
39
39
  ast (~> 2.4.1)
@@ -86,7 +86,7 @@ GEM
86
86
  simplecov_json_formatter (~> 0.1)
87
87
  simplecov-html (0.12.3)
88
88
  simplecov_json_formatter (0.1.4)
89
- tzinfo (2.0.5)
89
+ tzinfo (2.0.6)
90
90
  concurrent-ruby (~> 1.0)
91
91
  unicode-display_width (2.3.0)
92
92
  webmock (3.14.0)
data/README.md CHANGED
@@ -56,6 +56,16 @@ podcast = PodcastIndex::Podcast.find(920666)
56
56
  podcast.title # => "Podcasting 2.0"
57
57
  ```
58
58
 
59
+ When the podcast cannot be found:
60
+
61
+ ```ruby
62
+ begin
63
+ podcast = PodcastIndex::Podcast.find("invalid")
64
+ rescue PodcastIndex::PodcastNotFound
65
+ puts "Podcast not found"
66
+ end
67
+ ```
68
+
59
69
  Find an episode by guid:
60
70
 
61
71
  ```ruby
@@ -1,29 +1,34 @@
1
+ # rubocop:disable Metrics/ParameterLists
1
2
  module PodcastIndex
2
3
  module Api
3
4
  class Search
4
5
  extend Request
5
6
 
6
7
  class << self
7
- def by_term(term:, val: nil, aponly: nil, clean: nil, fulltext: nil)
8
- response = get("/search/byterm", q: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext)
8
+ def by_term(term:, val: nil, aponly: nil, clean: nil, fulltext: nil, max: nil)
9
+ response = get("/search/byterm", q: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext,
10
+ max: max)
9
11
  JSON.parse(response.body)
10
12
  end
11
13
 
12
- def by_title(title:, val: nil, clean: nil, fulltext: nil, similar: nil)
13
- response = get("/search/bytitle", q: title, val: val, clean: clean, fulltext: fulltext, similar: similar)
14
+ def by_title(title:, val: nil, clean: nil, fulltext: nil, similar: nil, max: nil)
15
+ response = get("/search/bytitle", q: title, val: val, clean: clean, fulltext: fulltext, similar: similar,
16
+ max: max)
14
17
  JSON.parse(response.body)
15
18
  end
16
19
 
17
- def by_person(person:, fulltext: nil)
18
- response = get("/search/byperson", q: person, fulltext: fulltext)
20
+ def by_person(person:, fulltext: nil, max: nil)
21
+ response = get("/search/byperson", q: person, fulltext: fulltext, max: max)
19
22
  JSON.parse(response.body)
20
23
  end
21
24
 
22
- def music_by_term(term:, val: nil, aponly: nil, clean: nil, fulltext: nil)
23
- response = get("/search/music/byterm", q: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext)
25
+ def music_by_term(term:, val: nil, aponly: nil, clean: nil, fulltext: nil, max: nil)
26
+ response = get("/search/music/byterm", q: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext,
27
+ max: max)
24
28
  JSON.parse(response.body)
25
29
  end
26
30
  end
27
31
  end
28
32
  end
29
33
  end
34
+ # rubocop:enable Metrics/ParameterLists
@@ -66,8 +66,8 @@ module PodcastIndex
66
66
  from_response_collection(response)
67
67
  end
68
68
 
69
- def find_all_by_person(person:, fulltext: nil)
70
- response = Api::Search.by_person(person: person, fulltext: fulltext)
69
+ def find_all_by_person(person:, fulltext: nil, max: nil)
70
+ response = Api::Search.by_person(person: person, fulltext: fulltext, max: max)
71
71
  from_response_collection(response)
72
72
  end
73
73
 
@@ -10,6 +10,8 @@ module PodcastIndex
10
10
 
11
11
  def find(id)
12
12
  response = Api::Podcasts.by_feed_id(id: id)
13
+ raise PodcastIndex::PodcastNotFound, response["description"] if response["feed"].empty?
14
+
13
15
  from_response(response)
14
16
  end
15
17
 
@@ -53,8 +55,9 @@ module PodcastIndex
53
55
  from_response_collection(response)
54
56
  end
55
57
 
56
- def find_all_music_by_term(medium:, term:, val: nil, aponly: nil, clean: nil, fulltext: nil)
57
- response = Api::Search.music_by_term(term: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext)
58
+ def find_all_music_by_term(medium:, term:, val: nil, aponly: nil, clean: nil, fulltext: nil, max: nil)
59
+ response = Api::Search.music_by_term(term: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext,
60
+ max: max)
58
61
  from_response_collection(response)
59
62
  end
60
63
 
@@ -74,13 +77,13 @@ module PodcastIndex
74
77
  from_response_collection(response)
75
78
  end
76
79
 
77
- def find_all_by_term(term:, val: nil, aponly: nil, clean: nil, fulltext: nil)
78
- response = Api::Search.by_term(term: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext)
80
+ def find_all_by_term(term:, val: nil, aponly: nil, clean: nil, fulltext: nil, max: nil)
81
+ response = Api::Search.by_term(term: term, val: val, aponly: aponly, clean: clean, fulltext: fulltext, max: max)
79
82
  from_response_collection(response)
80
83
  end
81
84
 
82
- def find_all_by_title(title:, val: nil, clean: nil, fulltext: nil)
83
- response = Api::Search.by_title(title: title, val: val, clean: clean, fulltext: fulltext)
85
+ def find_all_by_title(title:, val: nil, clean: nil, fulltext: nil, max: nil)
86
+ response = Api::Search.by_title(title: title, val: val, clean: clean, fulltext: fulltext, max: max)
84
87
  from_response_collection(response)
85
88
  end
86
89
 
@@ -1,3 +1,3 @@
1
1
  module PodcastIndex
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
data/lib/podcast_index.rb CHANGED
@@ -20,6 +20,7 @@ module PodcastIndex
20
20
  config_accessor :api_key, :api_secret, :base_url
21
21
 
22
22
  class Error < StandardError; end
23
+ class PodcastNotFound < Error; end
23
24
 
24
25
  def self.configure
25
26
  self.base_url = "https://api.podcastindex.org/api/1.0".freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: podcast_index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason York
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-24 00:00:00.000000000 Z
11
+ date: 2023-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport