LyricFind 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.travis.yml +1 -0
- data/Gemfile +3 -0
- data/README.md +12 -4
- data/Rakefile +1 -1
- data/lib/lyricfind/get_lyrics_by_song_name.rb +31 -17
- data/lib/lyricfind/version.rb +1 -1
- metadata +1 -27
- data/build/.gitignore +0 -9
- data/build/.rspec +0 -2
- data/build/.travis.yml +0 -3
- data/build/Gemfile +0 -4
- data/build/README.md +0 -39
- data/build/Rakefile +0 -1
- data/build/bin/console +0 -14
- data/build/bin/setup +0 -7
- data/build/build.gemspec +0 -27
- data/build/lib/build.rb +0 -5
- data/build/lib/build/version.rb +0 -3
- data/build/spec/build_spec.rb +0 -11
- data/build/spec/spec_helper.rb +0 -2
- data/install/.gitignore +0 -9
- data/install/.rspec +0 -2
- data/install/.travis.yml +0 -3
- data/install/Gemfile +0 -4
- data/install/README.md +0 -39
- data/install/Rakefile +0 -1
- data/install/bin/console +0 -14
- data/install/bin/setup +0 -7
- data/install/install.gemspec +0 -27
- data/install/lib/install.rb +0 -5
- data/install/lib/install/version.rb +0 -3
- data/install/spec/install_spec.rb +0 -11
- data/install/spec/spec_helper.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fdf2f4d062693f196d6dbbad0d79b7afdc64305
|
4
|
+
data.tar.gz: a4aa878c290fdd3daf7960fcff95422e8faf85b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f33aa6c38e308eee978a5576b54c70b41df4a99433c78410d8fbc6a7283b05148911db9b8dc503d8b7b7ee265dca9df17718e2126ef3fd7c17ba44e79ddad766
|
7
|
+
data.tar.gz: 90e9574edb1d97200de4db64eb04e70902988b93106d2f1cf28709586c6c86b00e10ffd3778b86aff60c1e1b9f601b9a9a996cc12aaceafbda91abcc03b8608b
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# LyricFind
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/LyricFind.svg)](http://badge.fury.io/rb/LyricFind)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/LyricFind.svg)](http://badge.fury.io/rb/LyricFind) | [![Code Climate](https://codeclimate.com/github/ihassin/lyricfind/badges/gpa.svg)](https://codeclimate.com/github/ihassin/lyricfind) | [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://opensource.org/licenses/MIT) | [![Issues](http://img.shields.io/github/issues/ihassin/lyricfind.svg?style=flat-square)](http://github.com/ihassin/lyricfind/issues) | [![Releases](http://img.shields.io/github/release/ihassin/lyricfind.svg?style=flat-square)](http://github.com/ihassin/lyricfind/releases) | [![Dependencies](http://img.shields.io/gemnasium/ihassin/lyricfind.svg?style=flat-square)](https://gemnasium.com/ihassin/lyricfind)
|
4
4
|
|
5
5
|
This gem allows your application to access LyricFind's API services
|
6
6
|
|
@@ -9,7 +9,7 @@ This gem allows your application to access LyricFind's API services
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem '
|
12
|
+
gem 'LyricFind'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -18,7 +18,7 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install
|
21
|
+
$ gem install LyricFind
|
22
22
|
|
23
23
|
## Running tests
|
24
24
|
|
@@ -32,7 +32,15 @@ rake
|
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
|
-
For usage examples, please see [here](https://github.com/ihassin/lyricfind/blob/master/spec/lyricfind_spec.rb)
|
35
|
+
For usage examples from tests, please see [here](https://github.com/ihassin/lyricfind/blob/master/spec/lyricfind_spec.rb)
|
36
|
+
|
37
|
+
Simple example:
|
38
|
+
```ruby
|
39
|
+
require 'LyricFind'
|
40
|
+
|
41
|
+
lf = LyricFind::API.new 'search-key', 'display-key'
|
42
|
+
puts lf.get_lyrics_by_song_name 'u2', 'one'
|
43
|
+
```
|
36
44
|
|
37
45
|
## Contributing
|
38
46
|
|
data/Rakefile
CHANGED
@@ -9,32 +9,46 @@ module LyricFind
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def get_lyrics_by_song_name artist, song_name
|
12
|
-
|
13
|
-
|
14
|
-
doc = Nokogiri::HTML(response)
|
15
|
-
doc.encoding = 'utf-8'
|
12
|
+
return nil if artist.nil? or artist.length == 0
|
13
|
+
return nil if song_name.nil? or song_name.length == 0
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
return nil if tracks == 0
|
15
|
+
artist = URI.escape artist
|
16
|
+
song_name = URI.escape song_name
|
20
17
|
|
21
|
-
|
18
|
+
begin
|
19
|
+
query_url = URI.escape "http://api.lyricfind.com/search.do?apikey=#{@search_key}&reqtype=default&searchtype=track&artist=#{artist}&track=#{song_name}"
|
20
|
+
response = open(query_url).read
|
21
|
+
doc = Nokogiri::HTML(response)
|
22
|
+
doc.encoding = 'utf-8'
|
22
23
|
|
23
|
-
|
24
|
+
return nil if !(check_success doc, 100)
|
25
|
+
tracks = doc.xpath('//tracks')[0]['totalresults'].to_i
|
26
|
+
return nil if tracks == 0
|
24
27
|
|
25
|
-
|
26
|
-
doc = Nokogiri::HTML(response)
|
27
|
-
doc.encoding = 'utf-8'
|
28
|
+
track = doc.xpath('//tracks/track')[0]['amg']
|
28
29
|
|
29
|
-
|
30
|
+
query_url = URI.escape "http://api.lyricfind.com/lyric.do?apikey=#{@display_key}&reqtype=default&trackid=amg:#{track}"
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
response = open(query_url).read
|
33
|
+
doc = Nokogiri::HTML(response)
|
34
|
+
doc.encoding = 'utf-8'
|
35
|
+
|
36
|
+
return nil if !(check_success doc, 101)
|
37
|
+
|
38
|
+
lyrics = doc.xpath('//lyrics')
|
39
|
+
lyrics[0].content
|
40
|
+
rescue
|
41
|
+
nil
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
def check_success doc, code
|
36
|
-
|
37
|
-
|
46
|
+
begin
|
47
|
+
response = doc.xpath('//response')
|
48
|
+
response[0]['code'].to_i == code
|
49
|
+
rescue
|
50
|
+
false
|
51
|
+
end
|
38
52
|
end
|
39
53
|
|
40
54
|
end
|
data/lib/lyricfind/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: LyricFind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Itamar Hassin
|
@@ -125,32 +125,6 @@ files:
|
|
125
125
|
- Rakefile
|
126
126
|
- bin/console
|
127
127
|
- bin/setup
|
128
|
-
- build/.gitignore
|
129
|
-
- build/.rspec
|
130
|
-
- build/.travis.yml
|
131
|
-
- build/Gemfile
|
132
|
-
- build/README.md
|
133
|
-
- build/Rakefile
|
134
|
-
- build/bin/console
|
135
|
-
- build/bin/setup
|
136
|
-
- build/build.gemspec
|
137
|
-
- build/lib/build.rb
|
138
|
-
- build/lib/build/version.rb
|
139
|
-
- build/spec/build_spec.rb
|
140
|
-
- build/spec/spec_helper.rb
|
141
|
-
- install/.gitignore
|
142
|
-
- install/.rspec
|
143
|
-
- install/.travis.yml
|
144
|
-
- install/Gemfile
|
145
|
-
- install/README.md
|
146
|
-
- install/Rakefile
|
147
|
-
- install/bin/console
|
148
|
-
- install/bin/setup
|
149
|
-
- install/install.gemspec
|
150
|
-
- install/lib/install.rb
|
151
|
-
- install/lib/install/version.rb
|
152
|
-
- install/spec/install_spec.rb
|
153
|
-
- install/spec/spec_helper.rb
|
154
128
|
- lib/lyricfind.rb
|
155
129
|
- lib/lyricfind/get_lyrics_by_song_name.rb
|
156
130
|
- lib/lyricfind/version.rb
|
data/build/.gitignore
DELETED
data/build/.rspec
DELETED
data/build/.travis.yml
DELETED
data/build/Gemfile
DELETED
data/build/README.md
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# Build
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/build`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'build'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install build
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
1. Fork it ( https://github.com/[my-github-username]/build/fork )
|
36
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
-
5. Create a new Pull Request
|
data/build/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/build/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "build"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/build/bin/setup
DELETED
data/build/build.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'build/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "build"
|
8
|
-
spec.version = Build::VERSION
|
9
|
-
spec.authors = ["Itamar Hassin"]
|
10
|
-
spec.email = ["ihassin@mac.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
|
13
|
-
spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
-
spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = "exe"
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
if spec.respond_to?(:metadata)
|
22
|
-
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
23
|
-
end
|
24
|
-
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.9"
|
26
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
-
end
|
data/build/lib/build.rb
DELETED
data/build/lib/build/version.rb
DELETED
data/build/spec/build_spec.rb
DELETED
data/build/spec/spec_helper.rb
DELETED
data/install/.gitignore
DELETED
data/install/.rspec
DELETED
data/install/.travis.yml
DELETED
data/install/Gemfile
DELETED
data/install/README.md
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# Install
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/install`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'install'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install install
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
1. Fork it ( https://github.com/[my-github-username]/install/fork )
|
36
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
-
5. Create a new Pull Request
|
data/install/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/install/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "install"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/install/bin/setup
DELETED
data/install/install.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'install/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "install"
|
8
|
-
spec.version = Install::VERSION
|
9
|
-
spec.authors = ["Itamar Hassin"]
|
10
|
-
spec.email = ["ihassin@mac.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
|
13
|
-
spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
-
spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = "exe"
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
if spec.respond_to?(:metadata)
|
22
|
-
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
23
|
-
end
|
24
|
-
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.9"
|
26
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
-
end
|
data/install/lib/install.rb
DELETED
data/install/spec/spec_helper.rb
DELETED