genius-api 0.3.0

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.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
  3. data/.github/ISSUE_TEMPLATE/config.yml +5 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
  5. data/.github/PULL_REQUEST_TEMPLATE.md +23 -0
  6. data/.github/workflows/check-source-branch.yml +8 -0
  7. data/.github/workflows/ci.yml +38 -0
  8. data/.gitignore +15 -0
  9. data/.rspec +3 -0
  10. data/.rubocop.yml +20 -0
  11. data/.ruby-version +1 -0
  12. data/CHANGELOG.md +37 -0
  13. data/CODE_OF_CONDUCT.md +106 -0
  14. data/CONTRIBUTING.md +368 -0
  15. data/Gemfile +7 -0
  16. data/Gemfile.lock +174 -0
  17. data/LICENSE.txt +674 -0
  18. data/README.md +288 -0
  19. data/SECURITY.md +14 -0
  20. data/Steepfile +13 -0
  21. data/bin/console +15 -0
  22. data/bin/release +5 -0
  23. data/bin/setup +21 -0
  24. data/docscribe.yml +9 -0
  25. data/exe/genius-api +4 -0
  26. data/genius-api.gemspec +47 -0
  27. data/lib/extensions/deep_find.rb +36 -0
  28. data/lib/extensions/extensions.rb +12 -0
  29. data/lib/extensions/options_helper.rb +17 -0
  30. data/lib/extensions/token_ext.rb +12 -0
  31. data/lib/extensions/unescape.rb +13 -0
  32. data/lib/genius/api/account.rb +35 -0
  33. data/lib/genius/api/annotations.rb +90 -0
  34. data/lib/genius/api/artists.rb +82 -0
  35. data/lib/genius/api/authorization.rb +47 -0
  36. data/lib/genius/api/errors.rb +211 -0
  37. data/lib/genius/api/referents.rb +38 -0
  38. data/lib/genius/api/search.rb +26 -0
  39. data/lib/genius/api/songs.rb +84 -0
  40. data/lib/genius/api/version.rb +8 -0
  41. data/lib/genius/api/web_pages.rb +26 -0
  42. data/lib/genius/api.rb +23 -0
  43. data/rbs_collection.lock.yaml +232 -0
  44. data/rbs_collection.yaml +14 -0
  45. data/sig/lib/extensions/deep_find.rbs +30 -0
  46. data/sig/lib/extensions/options_helper.rbs +3 -0
  47. data/sig/lib/extensions/token_ext.rbs +3 -0
  48. data/sig/lib/extensions/unescape.rbs +3 -0
  49. data/sig/lib/genius/api/account.rbs +23 -0
  50. data/sig/lib/genius/api/annotations.rbs +13 -0
  51. data/sig/lib/genius/api/artists.rbs +15 -0
  52. data/sig/lib/genius/api/authorization.rbs +11 -0
  53. data/sig/lib/genius/api/errors.rbs +46 -0
  54. data/sig/lib/genius/api/referents.rbs +7 -0
  55. data/sig/lib/genius/api/search.rbs +5 -0
  56. data/sig/lib/genius/api/songs.rbs +15 -0
  57. data/sig/lib/genius/api/version.rbs +5 -0
  58. data/sig/lib/genius/api/web_pages.rbs +5 -0
  59. data/sig/lib/genius/api.rbs +9 -0
  60. metadata +313 -0
@@ -0,0 +1,232 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: ast
5
+ version: '2.4'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: bigdecimal
13
+ version: 4.1.2
14
+ source:
15
+ type: rubygems
16
+ - name: concurrent-ruby
17
+ version: '1.1'
18
+ source:
19
+ type: git
20
+ name: ruby/gem_rbs_collection
21
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
22
+ remote: https://github.com/ruby/gem_rbs_collection.git
23
+ repo_dir: gems
24
+ - name: csv
25
+ version: '3.3'
26
+ source:
27
+ type: git
28
+ name: ruby/gem_rbs_collection
29
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
30
+ remote: https://github.com/ruby/gem_rbs_collection.git
31
+ repo_dir: gems
32
+ - name: diff-lcs
33
+ version: '1.5'
34
+ source:
35
+ type: git
36
+ name: ruby/gem_rbs_collection
37
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
38
+ remote: https://github.com/ruby/gem_rbs_collection.git
39
+ repo_dir: gems
40
+ - name: ffi
41
+ version: 1.17.4
42
+ source:
43
+ type: rubygems
44
+ - name: fileutils
45
+ version: '0'
46
+ source:
47
+ type: stdlib
48
+ - name: forwardable
49
+ version: '0'
50
+ source:
51
+ type: stdlib
52
+ - name: httparty
53
+ version: '0.18'
54
+ source:
55
+ type: git
56
+ name: ruby/gem_rbs_collection
57
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
58
+ remote: https://github.com/ruby/gem_rbs_collection.git
59
+ repo_dir: gems
60
+ - name: json
61
+ version: '0'
62
+ source:
63
+ type: stdlib
64
+ - name: lint_roller
65
+ version: '1.1'
66
+ source:
67
+ type: git
68
+ name: ruby/gem_rbs_collection
69
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
70
+ remote: https://github.com/ruby/gem_rbs_collection.git
71
+ repo_dir: gems
72
+ - name: listen
73
+ version: '3.9'
74
+ source:
75
+ type: git
76
+ name: ruby/gem_rbs_collection
77
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
78
+ remote: https://github.com/ruby/gem_rbs_collection.git
79
+ repo_dir: gems
80
+ - name: logger
81
+ version: '1.7'
82
+ source:
83
+ type: git
84
+ name: ruby/gem_rbs_collection
85
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
86
+ remote: https://github.com/ruby/gem_rbs_collection.git
87
+ repo_dir: gems
88
+ - name: mini_mime
89
+ version: '0.1'
90
+ source:
91
+ type: git
92
+ name: ruby/gem_rbs_collection
93
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
94
+ remote: https://github.com/ruby/gem_rbs_collection.git
95
+ repo_dir: gems
96
+ - name: monitor
97
+ version: '0'
98
+ source:
99
+ type: stdlib
100
+ - name: multi_xml
101
+ version: 0.9.1
102
+ source:
103
+ type: rubygems
104
+ - name: net-http
105
+ version: '0'
106
+ source:
107
+ type: stdlib
108
+ - name: net-protocol
109
+ version: '0'
110
+ source:
111
+ type: stdlib
112
+ - name: nokogiri
113
+ version: '1.11'
114
+ source:
115
+ type: git
116
+ name: ruby/gem_rbs_collection
117
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
118
+ remote: https://github.com/ruby/gem_rbs_collection.git
119
+ repo_dir: gems
120
+ - name: optparse
121
+ version: '0'
122
+ source:
123
+ type: stdlib
124
+ - name: parallel
125
+ version: '1.20'
126
+ source:
127
+ type: git
128
+ name: ruby/gem_rbs_collection
129
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
130
+ remote: https://github.com/ruby/gem_rbs_collection.git
131
+ repo_dir: gems
132
+ - name: parser
133
+ version: '3.2'
134
+ source:
135
+ type: git
136
+ name: ruby/gem_rbs_collection
137
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
138
+ remote: https://github.com/ruby/gem_rbs_collection.git
139
+ repo_dir: gems
140
+ - name: prism
141
+ version: 1.9.0
142
+ source:
143
+ type: rubygems
144
+ - name: rainbow
145
+ version: '3.0'
146
+ source:
147
+ type: git
148
+ name: ruby/gem_rbs_collection
149
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
150
+ remote: https://github.com/ruby/gem_rbs_collection.git
151
+ repo_dir: gems
152
+ - name: rake
153
+ version: '13.0'
154
+ source:
155
+ type: git
156
+ name: ruby/gem_rbs_collection
157
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
158
+ remote: https://github.com/ruby/gem_rbs_collection.git
159
+ repo_dir: gems
160
+ - name: random-formatter
161
+ version: '0'
162
+ source:
163
+ type: stdlib
164
+ - name: rbs
165
+ version: 4.0.2
166
+ source:
167
+ type: rubygems
168
+ - name: rdoc
169
+ version: '0'
170
+ source:
171
+ type: stdlib
172
+ - name: regexp_parser
173
+ version: '2.8'
174
+ source:
175
+ type: git
176
+ name: ruby/gem_rbs_collection
177
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
178
+ remote: https://github.com/ruby/gem_rbs_collection.git
179
+ repo_dir: gems
180
+ - name: ripper
181
+ version: '0'
182
+ source:
183
+ type: stdlib
184
+ - name: rubocop
185
+ version: '1.57'
186
+ source:
187
+ type: git
188
+ name: ruby/gem_rbs_collection
189
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
190
+ remote: https://github.com/ruby/gem_rbs_collection.git
191
+ repo_dir: gems
192
+ - name: rubocop-ast
193
+ version: '1.46'
194
+ source:
195
+ type: git
196
+ name: ruby/gem_rbs_collection
197
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
198
+ remote: https://github.com/ruby/gem_rbs_collection.git
199
+ repo_dir: gems
200
+ - name: securerandom
201
+ version: '0'
202
+ source:
203
+ type: stdlib
204
+ - name: stringio
205
+ version: '0'
206
+ source:
207
+ type: stdlib
208
+ - name: strscan
209
+ version: '0'
210
+ source:
211
+ type: stdlib
212
+ - name: timeout
213
+ version: '0'
214
+ source:
215
+ type: stdlib
216
+ - name: tsort
217
+ version: '0'
218
+ source:
219
+ type: stdlib
220
+ - name: uri
221
+ version: '0'
222
+ source:
223
+ type: stdlib
224
+ - name: yard
225
+ version: '0.9'
226
+ source:
227
+ type: git
228
+ name: ruby/gem_rbs_collection
229
+ revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
230
+ remote: https://github.com/ruby/gem_rbs_collection.git
231
+ repo_dir: gems
232
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,14 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # A directory to install the downloaded RBSs
10
+ path: .gem_rbs_collection
11
+
12
+ gems:
13
+ - name: activesupport
14
+ ignore: true
@@ -0,0 +1,30 @@
1
+ class Hash[unchecked out K, unchecked out V]
2
+ # +Hash#deep_find+ -> value
3
+ #
4
+ # @param [Object] key A key, which value should be found
5
+ # @param [FalseClass] uniq A flag to make values unique in an array
6
+ # @return [Object] output depends on key value
7
+ # This method is an extension for Hash core class to search for a value of a key in N-nested
8
+ # hash. It provides search for multiple values if key appears more than once. For e.g.:
9
+ #
10
+ # @example
11
+ # musicians = { "Travis Scott" => { "28" => ["Highest in the Room", "Franchise"] },
12
+ # "Adele" => { "19" => ["Day Dreamer", "Best for Last"] },
13
+ # "Ed Sheeran" => { "28" => ["Shape of You", "Castle on the Hill"] } }
14
+ # musicians.deep_find("19") #=> ["Day Dreamer", "Best for Last"]
15
+ # musicians.deep_find("Adele") #=> {"19"=>["Day Dreamer", "Best for Last"]}
16
+ # musicians.deep_find("28") #=> [["Highest in the Room", "Franchise"], ["Shape of You", "Castle on the Hill"]]
17
+ #
18
+ # If values are identical, they will be returned in a single copy. You can disable this
19
+ # feature with special param +uniq+, which is +true+ by default. For e.g.:
20
+ #
21
+ # @example
22
+ # h = {"a" => "b", "c" => {"a" => "b"}}
23
+ # h.deep_find("a") #=> "b", instead ["b", "b"]
24
+ # @todo change uniq true to uniq false
25
+ def deep_find: (untyped key, ?uniq: bool) -> (nil | untyped)
26
+
27
+ private
28
+
29
+ def collect_values: (untyped key) -> Array[untyped]
30
+ end
@@ -0,0 +1,3 @@
1
+ class Object
2
+ def options_helper: (Hash[Symbol, untyped] options, Array[Symbol] arry) -> String
3
+ end
@@ -0,0 +1,3 @@
1
+ class Object
2
+ def token_ext: (String? token) -> String
3
+ end
@@ -0,0 +1,3 @@
1
+ class String
2
+ def unescape: -> String
3
+ end
@@ -0,0 +1,23 @@
1
+ module Genius
2
+ # +Genius::Account+ module provides methods to work with Genius account
3
+ module Account
4
+ # +Genius::Account.account+ -> value
5
+ #
6
+ # An alias to {Genius::Account.account me} method
7
+ #
8
+ # @param [String] token Token to access https://api.genius.com.
9
+ # @raise [TokenError] if +token+ or +Genius::Auth.token+ are invalid.
10
+ # @return [Hash]
11
+ # @return [NilClass] if TokenError exception raised.
12
+ # This method is a standard Genius API {request}[https://docs.genius.com/#search-h2] to get
13
+ # account info. Output +JSON+ is translated to Hash structure to make it easy to work with account fields.
14
+ #
15
+ # @example
16
+ # Genius::Auth.login="yuiaYqbncErCVwItjQxFspNWUZLhGpXrPbkvgbgHSEKJRAlToamzMfdOeDB"
17
+ # Genius::Account.account #=> {"meta"=>{"status"=>200}, "response"=>{"user"=>{...}}}
18
+ # @todo somehow refactor 50/52 exceptions
19
+ def self.account: (?token: String?) -> (Hash[String, untyped] | nil)
20
+
21
+ alias self.me self.account
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ module Genius
2
+ module Annotations
3
+ def self.annotations: (id: Integer, action: String?, token: String?, http_verb: String, ?options: Hash[Symbol, untyped]) -> (Hash[String, untyped] | nil)
4
+
5
+ private
6
+
7
+ def self.request: (id: Integer, action: String?, token: String?, http_verb: String, options: Hash[Symbol, untyped]) -> HTTParty::Response
8
+
9
+ def self.put_request: (id: Integer, action: String?, token: String?, options: Hash[Symbol, untyped]) -> HTTParty::Response
10
+
11
+ def self.post_payload: (?options: Hash[Symbol, untyped]) -> String
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Genius
2
+ module Artists
3
+ def self.artists: (?token: String?, ?id: Integer?) -> (Hash[String, untyped] | nil)
4
+
5
+ def self.artists_songs: (?token: String?, ?id: Integer?, ?options: Hash[Symbol, untyped]) -> (Hash[String, untyped] | nil)
6
+
7
+ private
8
+
9
+ def self.validate: (Array[String] sort_values, **untyped options) -> void
10
+
11
+ def self.validate_sort: (String? sort, Array[String] sort_values) -> void
12
+
13
+ def self.validate_page_per_page: (Integer? page_per_page) -> void
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Genius
2
+ module Auth
3
+ def self.token=: (String token) -> String
4
+
5
+ def self.authorized?: (?String token, ?method_name: String) -> bool
6
+
7
+ def self.logout!: -> nil
8
+
9
+ # alias login= token=
10
+ end
11
+ end
@@ -0,0 +1,46 @@
1
+ module Genius
2
+ module Errors
3
+ ENDPOINT: String
4
+
5
+ class GeniusExceptionSuperClass < StandardError
6
+ end
7
+
8
+ class TokenError < GeniusExceptionSuperClass
9
+ attr_reader msg: String
10
+ attr_reader exception_type: String
11
+ attr_reader method_name: String?
12
+
13
+ def initialize: (?msg: String, ?exception_type: String, ?method_name: String?) -> void
14
+ end
15
+
16
+ class LyricsNotFoundError < GeniusExceptionSuperClass
17
+ attr_reader msg: String
18
+ attr_reader exception_type: String
19
+
20
+ def initialize: (?msg: String, ?exception_type: String) -> void
21
+ end
22
+
23
+ class PageNotFound < GeniusExceptionSuperClass
24
+ attr_reader msg: String
25
+ attr_reader exception_type: String
26
+
27
+ def initialize: (?msg: String, ?exception_type: String) -> void
28
+
29
+ def self.page_not_found?: (untyped html) -> bool
30
+ end
31
+
32
+ module DynamicRescue
33
+ def self.rescue: (Module klass) -> Array[Symbol]
34
+
35
+ def self.rescue_from: (Array[Symbol] meths, Module klass, Module exception) { (untyped) -> void } -> Array[Symbol]
36
+ end
37
+
38
+ def self.validate_token: (String? token, ?method_name: String?) -> void
39
+
40
+ def self.error_handle?: (String? token, ?method_name: String?) -> bool
41
+
42
+ private
43
+
44
+ def self.check_status?: (String token) -> bool
45
+ end
46
+ end
@@ -0,0 +1,7 @@
1
+ module Genius
2
+ module Referents
3
+ ENDPOINT: String
4
+
5
+ def self.referents: (?token: String?, ?options: Hash[Symbol, untyped]) -> (Hash[String, untyped] | nil)
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Genius
2
+ module Search
3
+ def self.search: (?token: String?, ?query: String?, ?search_by: String?) -> (Hash[String, untyped] | String | nil)
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ module Genius
2
+ module Songs
3
+ def self.songs: (?token: String?, ?song_id: Integer?, ?combine: bool) -> (Hash[String, untyped] | String | nil)
4
+
5
+ private
6
+
7
+ def self.merge_lyrics: (Integer song_id, Hash[String, untyped] response) -> (Hash[String, untyped] | String)
8
+
9
+ def self.parse_preloaded_state: (untyped output_html) -> Hash[String, untyped]
10
+
11
+ public
12
+
13
+ def self.get_lyrics: (Integer song_id) -> String
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Genius
2
+ module Api
3
+ VERSION: String
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Genius
2
+ module WebPages
3
+ def self.lookup: (?token: String?, ?options: Hash[Symbol, untyped]) -> (Hash[String, untyped] | nil)
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ # Base module which contains all of other methods/classes/etc.
2
+ module Genius
3
+ # +Genius::Api+ is a base module with different constants.
4
+ module Api
5
+ # +Genius::Api::RESOURCE+ constant contains reference to
6
+ # {Genius API}[https://api.genius.com] resource.
7
+ RESOURCE: "https://api.genius.com"
8
+ end
9
+ end