rapgenius 1.0.5 → 1.1.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: 3dc98c505e166b321df324c14c7a90d443070452
4
- data.tar.gz: 281d8fa2c6c642a0b02cac49f4c296f95d912966
3
+ metadata.gz: b1640ae0f92fe785852dc5299ea740898c45e9ee
4
+ data.tar.gz: 87ca2d685134998e741566bf36fb84b2be5b28b2
5
5
  SHA512:
6
- metadata.gz: 4ee1fcfd58f2c942912be1100dc9794f08c32fd82874f075cacdc26911802b54acbc144dae269d9391d5bf2f35c975d63ddca80f377f8ad0bf8ed00b4069000a
7
- data.tar.gz: 208a5872b109172add3473b3832bc4759a6264c9add291d3e170d7d80b7b0c856b21bea193c57bcba5cba273b9ef8a99b9cf6dcb745c54100ff68a57a73f4994
6
+ metadata.gz: 94087dcf9563c729aa0a125e12c6ddb155c02497977c96ec6a349a8d1b7efeaa00fb565e6e0a725d5c74f5cf22b4a95bff9aade34bf7f04a1d23f1497a594d9f
7
+ data.tar.gz: 8ea1e7629947d329f0e07bb1537086fd757aa1adbfa2df7b59f91abe75cf2f0df42d1cd4ce9796b3ee6806985aa918a38607862d6324b6c583683be411c1640f
@@ -39,4 +39,8 @@ __v1.0.4__ (8th November 2014)
39
39
 
40
40
  __v1.0.5__ (12th January 2015)
41
41
 
42
- * Load descriptions as plain text, reducing code for parsing them
42
+ * Load descriptions as plain text, reducing code for parsing them
43
+
44
+ __v1.1.0__ (5th June 2015)
45
+
46
+ * Authenticate using access tokens for the official [Genius API](https://docs.genius.com)
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2014 Tim Rogers
1
+ Copyright (c) 2013-2015 Tim Rogers
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
16
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,27 +1,41 @@
1
- # rapgenius.rb
1
+ # rapgenius
2
2
 
3
- ![Rap Genius logo](http://f.cl.ly/items/303W0c1i2r100j2u3Y0y/Screen%20Shot%202013-08-17%20at%2016.01.19.png)
3
+ ![Rap Genius logo](http://assets.rapgenius.com/images/apple-touch-icon.png?1432674944)
4
4
 
5
5
  ## What does this do?
6
6
 
7
- It's a Ruby gem for accessing lyrics, artists and explanations on
8
- [Rap Genius](http://rapgenius.com).
7
+ It's a Ruby gem for accessing songs, artists and annotations on
8
+ [Genius](http://genius.com).
9
9
 
10
- In pre-1.0.0 versions, this gem used Nokogiri to scrape Rap Genius's pages,
11
- but no more. The new [Genius iOS app](http://rapgenius.com/static/app) uses
12
- a private API, which this gem makes use of.
10
+ In pre-1.0.0 versions, this gem used Nokogiri to scrape Genius' pages,
11
+ but no more thanks to the new [Genius API](https://docs.genius.com), which this
12
+ gem makes use of.
13
13
 
14
14
  ## Installation
15
15
 
16
16
  Install the gem, and you're ready to go. Simply add the following to your
17
17
  Gemfile:
18
18
 
19
- `gem "rapgenius", "~> 1.0.5"`
19
+ ```ruby
20
+ gem "rapgenius", "~> 1.1.0"
21
+ ```
20
22
 
21
23
  ## Usage
22
24
 
23
25
  __The best way to get a decent idea of the attributes available on `Song` and
24
- the other objects is by looking through the files in `lib/rapgenius`.__
26
+ the other objects is by checking out the API documentation at:
27
+ https://docs.genius.com
28
+
29
+ ### Authenticating
30
+
31
+ You can create a client and grab an access token from
32
+ http://genius.com/api-clients
33
+
34
+ From there, you can also generate a client access token and use it like so:
35
+
36
+ ``` ruby
37
+ RapGenius::Client.access_token = 'your-access-token'
38
+ ```
25
39
 
26
40
  ### Searching
27
41
 
@@ -71,7 +85,6 @@ song.description
71
85
  # => "Released in June 2013, not only did they take the beat from Soulja Boy’s OMG part 2 but they absolutely killed it."
72
86
  ```
73
87
 
74
-
75
88
  ### Lines
76
89
 
77
90
  Once you've got a song, you can then go through its "lines", which includes
@@ -151,7 +164,7 @@ If you'd like to contribute anything else, go ahead or better still, make an iss
151
164
 
152
165
  ## Copyright
153
166
 
154
- Copyright (c) 2013-2014 Tim Rogers. See LICENSE for details.
167
+ Copyright (c) 2013-2015 Tim Rogers. See LICENSE for details.
155
168
 
156
169
  ## Get in touch
157
170
 
@@ -2,12 +2,15 @@ require 'httparty'
2
2
 
3
3
  module RapGenius
4
4
  module Client
5
+ class << self
6
+ attr_accessor :access_token
7
+ end
8
+
5
9
  class HTTPClient
6
10
  include HTTParty
7
11
 
8
12
  format :json
9
13
  base_uri 'https://api.rapgenius.com'
10
- headers 'User-Agent' => "rapgenius.rb v#{RapGenius::VERSION}"
11
14
  end
12
15
 
13
16
  BASE_URL = HTTPClient.base_uri + "/".freeze
@@ -31,6 +34,9 @@ module RapGenius
31
34
  def fetch(url)
32
35
  response = HTTPClient.get(url, query: {
33
36
  text_format: "#{DOM_TEXT_FORMAT},#{PLAIN_TEXT_FORMAT}"
37
+ }, headers: {
38
+ 'Authorization' => "Bearer #{RapGenius::Client.access_token}",
39
+ 'User-Agent' => "rapgenius.rb v#{RapGenius::VERSION}"
34
40
  })
35
41
 
36
42
  if response.code != 200
@@ -1,3 +1,3 @@
1
1
  module RapGenius
2
- VERSION = "1.0.5"
3
- end
2
+ VERSION = "1.1.0"
3
+ end
@@ -9,11 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Tim Rogers"]
10
10
  s.email = ["me@timrogers.co.uk"]
11
11
  s.homepage = "https://github.com/timrogers/rapgenius"
12
- s.summary = %q{A gem for accessing lyrics and explanations on RapGenius.com}
13
- s.description = %q{Up until until now, to quote RapGenius themselves,
14
- "working at Rap Genius is the API". With this magical gem using the
15
- private API in the 'Genius' iOS app you can access the wealth of data on
16
- the internet Talmud in Ruby.}
12
+ s.summary = %q{A gem for accessing texts and explanations on Genius.com}
17
13
 
18
14
  s.add_runtime_dependency "httparty", "~>0.11.0"
19
15
  s.add_development_dependency "rspec", "~>2.14.1"
@@ -25,6 +25,21 @@ module RapGenius
25
25
  end
26
26
  end
27
27
 
28
+ describe '.access_token=' do
29
+ let(:access_token) { 'my-access-token' }
30
+
31
+ before do
32
+ RapGenius::Client.access_token = access_token
33
+ stub_request(:get, 'https://api.rapgenius.com/hello?text_format=dom,plain').
34
+ with(headers: {'Authorization' => "Bearer #{access_token}", 'User-Agent' => "rapgenius.rb v#{RapGenius::VERSION}"})
35
+ end
36
+
37
+ it 'should send the header' do
38
+ client.fetch('/hello')
39
+ assert_requested(:get, 'https://api.rapgenius.com/hello?text_format=dom,plain')
40
+ end
41
+ end
42
+
28
43
  describe "#document" do
29
44
  before { client.url = "http://foo.bar" }
30
45
 
metadata CHANGED
@@ -1,97 +1,93 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapgenius
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Rogers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.11.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.14.1
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.14.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.14.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.14.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.11.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.11.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: vcr
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.5.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.5.0
83
- description: |-
84
- Up until until now, to quote RapGenius themselves,
85
- "working at Rap Genius is the API". With this magical gem using the
86
- private API in the 'Genius' iOS app you can access the wealth of data on
87
- the internet Talmud in Ruby.
83
+ description:
88
84
  email:
89
85
  - me@timrogers.co.uk
90
86
  executables: []
91
87
  extensions: []
92
88
  extra_rdoc_files: []
93
89
  files:
94
- - .gitignore
90
+ - ".gitignore"
95
91
  - CHANGELOG.md
96
92
  - Gemfile
97
93
  - LICENSE
@@ -130,20 +126,20 @@ require_paths:
130
126
  - lib
131
127
  required_ruby_version: !ruby/object:Gem::Requirement
132
128
  requirements:
133
- - - '>='
129
+ - - ">="
134
130
  - !ruby/object:Gem::Version
135
131
  version: '0'
136
132
  required_rubygems_version: !ruby/object:Gem::Requirement
137
133
  requirements:
138
- - - '>='
134
+ - - ">="
139
135
  - !ruby/object:Gem::Version
140
136
  version: '0'
141
137
  requirements: []
142
138
  rubyforge_project:
143
- rubygems_version: 2.4.4
139
+ rubygems_version: 2.4.7
144
140
  signing_key:
145
141
  specification_version: 4
146
- summary: A gem for accessing lyrics and explanations on RapGenius.com
142
+ summary: A gem for accessing texts and explanations on Genius.com
147
143
  test_files:
148
144
  - spec/rapgenius/artist_spec.rb
149
145
  - spec/rapgenius/client_spec.rb