LyricFind 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da1b66e31f48f26036d612ecf429f5eb623696bf
4
- data.tar.gz: 608c02edb5eea6ac9966023a583cd2722819df3b
3
+ metadata.gz: 3fdf2f4d062693f196d6dbbad0d79b7afdc64305
4
+ data.tar.gz: a4aa878c290fdd3daf7960fcff95422e8faf85b6
5
5
  SHA512:
6
- metadata.gz: adb4ce5659103ade5103c9af102d6844993399e8bdf78397d070b7d795681d4c4dbba69c502e51291794f73909d3ad5b86581f989eb094b02ac6816d0653c9a5
7
- data.tar.gz: 2607ed2478ab873b120a483366859e6e5dea2b8d764feba0d84cf6ea554db71f1659ee6b329780a3fe084020f86b586d76e42f18a39b43edd838caeccb134439
6
+ metadata.gz: f33aa6c38e308eee978a5576b54c70b41df4a99433c78410d8fbc6a7283b05148911db9b8dc503d8b7b7ee265dca9df17718e2126ef3fd7c17ba44e79ddad766
7
+ data.tar.gz: 90e9574edb1d97200de4db64eb04e70902988b93106d2f1cf28709586c6c86b00e10ffd3778b86aff60c1e1b9f601b9a9a996cc12aaceafbda91abcc03b8608b
data/.gitignore CHANGED
@@ -12,4 +12,6 @@ log/**
12
12
  spec/lyricfind.yml
13
13
  spec/vcr_cassettes/*
14
14
  *.gem
15
-
15
+ build/**
16
+ pkg/**
17
+ install/**
@@ -1,3 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.1
4
+ sudo: required
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in lyricfind.gemspec
4
4
  gemspec
5
+
6
+ gem 'bundler'
7
+ gem 'vcr'
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 'lyricfind'
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 lyricfind
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
@@ -12,5 +12,5 @@ task :build do
12
12
  end
13
13
 
14
14
  task :release => :build do
15
- system "gem push lyricfind-#{LYRICFIND::VERSION}"
15
+ system "gem push lyricfind-#{LyricFind::VERSION}"
16
16
  end
@@ -9,32 +9,46 @@ module LyricFind
9
9
  end
10
10
 
11
11
  def get_lyrics_by_song_name artist, song_name
12
- query_url = URI.escape "http://api.lyricfind.com/search.do?apikey=#{@search_key}&reqtype=default&searchtype=track&artist=#{artist}&track=#{song_name}"
13
- response = open(query_url).read
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
- return nil if !(check_success doc, 100)
18
- tracks = doc.xpath('//tracks')[0]['totalresults'].to_i
19
- return nil if tracks == 0
15
+ artist = URI.escape artist
16
+ song_name = URI.escape song_name
20
17
 
21
- track = doc.xpath('//tracks/track')[0]['amg']
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
- query_url = URI.escape "http://api.lyricfind.com/lyric.do?apikey=#{@display_key}&reqtype=default&trackid=amg:#{track}"
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
- response = open(query_url).read
26
- doc = Nokogiri::HTML(response)
27
- doc.encoding = 'utf-8'
28
+ track = doc.xpath('//tracks/track')[0]['amg']
28
29
 
29
- return nil if !(check_success doc, 101)
30
+ query_url = URI.escape "http://api.lyricfind.com/lyric.do?apikey=#{@display_key}&reqtype=default&trackid=amg:#{track}"
30
31
 
31
- lyrics = doc.xpath('//lyrics')
32
- lyrics[0].content
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
- response = doc.xpath('//response')
37
- response[0]['code'].to_i == code
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
@@ -1,3 +1,3 @@
1
1
  module LyricFind
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.1
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in build.gemspec
4
- gemspec
@@ -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
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -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
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -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
@@ -1,5 +0,0 @@
1
- require "build/version"
2
-
3
- module Build
4
- # Your code goes here...
5
- end
@@ -1,3 +0,0 @@
1
- module Build
2
- VERSION = "0.1.0"
3
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Build do
4
- it 'has a version number' do
5
- expect(Build::VERSION).not_to be nil
6
- end
7
-
8
- it 'does something useful' do
9
- expect(false).to eq(true)
10
- end
11
- end
@@ -1,2 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'build'
@@ -1,9 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.1
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in install.gemspec
4
- gemspec
@@ -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
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -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
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -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
@@ -1,5 +0,0 @@
1
- require "install/version"
2
-
3
- module Install
4
- # Your code goes here...
5
- end
@@ -1,3 +0,0 @@
1
- module Install
2
- VERSION = "0.1.0"
3
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Install do
4
- it 'has a version number' do
5
- expect(Install::VERSION).not_to be nil
6
- end
7
-
8
- it 'does something useful' do
9
- expect(false).to eq(true)
10
- end
11
- end
@@ -1,2 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'install'