-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gem is rewrapped with Bundler instead of Jeweler. All tests are using…
… RSpec. Reorganized lib structure. Tests are fixed.
- Loading branch information
Gregory Eremin
committed
Jul 4, 2012
1 parent
2ed4c86
commit 9121e79
Showing
34 changed files
with
486 additions
and
649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,5 @@ doc | |
.yardoc | ||
.bundle | ||
pkg | ||
.DS_Store | ||
tmp | ||
Gemfile.lock | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--color |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
source "http://rubygems.org" | ||
source :rubygems | ||
gemspec | ||
|
||
gem 'simplecov', :require => false, :group => :test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
## MusicBrainz Web Service wrapper [![Travis CI](https://secure.travis-ci.org/magnolia-fan/musicbrainz.png)](http://travis-ci.org/magnolia-fan/musicbrainz) | ||
|
||
### Installation | ||
```bash | ||
gem install musicbrainz | ||
``` | ||
### Usage | ||
```ruby | ||
require 'musicbrainz' | ||
|
||
# Search for artists | ||
@suggestions = MusicBrainz::Artist.search('Jet') | ||
|
||
# Find artist by name or mbid | ||
@foo_fighters = MusicBrainz::Artist.find_by_name('Foo Fighters') | ||
@kasabian = MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033') | ||
|
||
# Use them like ActiveRecord models | ||
@empire_tracks = @kasabian.release_groups[8].releases.first.tracks | ||
|
||
# Setting a cache path enables caching of requests | ||
MusicBrainz::Tools::Cache.cache_path = "tmp/cache" | ||
|
||
# Configuring request interval | ||
MusicBrainz::Tools::Proxy.query_interval = 1.2 # seconds | ||
``` | ||
|
||
### Api | ||
|
||
MusicBrainz::Artist | ||
```ruby | ||
@artists = MusicBrainz::Artist.search(query) | ||
@artist = MusicBrainz::Artist.find_by_name(name) | ||
@artist = MusicBrainz::Artist.find(mbid) | ||
@artist.id | ||
@artist.type | ||
@artist.name | ||
@artist.country | ||
@artist.date_begin | ||
@artist.date_end | ||
@artist.release_groups | ||
``` | ||
|
||
MusicBrainz::ReleaseGroup | ||
```ruby | ||
@release_group = MusicBrainz::ReleaseGroup.find(mbid) | ||
@release_group.id | ||
@release_group.type | ||
@release_group.title | ||
@release_group.first_release_date | ||
@release_group.releases | ||
``` | ||
|
||
MusicBrainz::Release | ||
```ruby | ||
@release = MusicBrainz::Release.find(mbid) | ||
@release.id | ||
@release.title | ||
@release.status | ||
@release.date | ||
@release.country | ||
@release.tracks | ||
``` | ||
|
||
MusicBrainz::Track | ||
```ruby | ||
@track = MusicBrainz::Track.find(mbid) | ||
@track.position | ||
@track.recording_id | ||
@track.title | ||
@track.length | ||
``` | ||
|
||
### Contributing | ||
|
||
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet | ||
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it | ||
* Fork the project | ||
* Start a feature/bugfix branch | ||
* Commit and push until you are happy with your contribution | ||
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. | ||
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. | ||
|
||
### Copyright | ||
|
||
Copyright (c) 2011 Gregory Eremin. See [LICENSE](https://raw.github.com/magnolia-fan/musicbrainz/master/LICENSE) for further details. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,8 @@ | ||
# encoding: utf-8 | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
|
||
require 'rubygems' | ||
require 'bundler' | ||
begin | ||
Bundler.setup(:default, :development) | ||
rescue Bundler::BundlerError => e | ||
$stderr.puts e.message | ||
$stderr.puts "Run `bundle install` to install missing gems" | ||
exit e.status_code | ||
end | ||
require 'rake' | ||
RSpec::Core::RakeTask.new("spec") | ||
|
||
require 'jeweler' | ||
Jeweler::Tasks.new do |gem| | ||
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options | ||
gem.name = "musicbrainz" | ||
gem.homepage = "http://github.com/magnolia-fan/musicbrainz" | ||
gem.license = "MIT" | ||
gem.summary = %Q{MusicBrainz Web Service wrapper} | ||
gem.description = %Q{MusicBrainz Web Service wrapper with ActiveRecord-style models} | ||
gem.email = "[email protected]" | ||
gem.authors = ["Gregory Eremin"] | ||
# dependencies defined in Gemfile | ||
end | ||
Jeweler::RubygemsDotOrgTasks.new | ||
|
||
require 'rake/testtask' | ||
Rake::TestTask.new(:test) do |test| | ||
test.libs << 'lib' << 'test' | ||
test.pattern = 'test/**/test_*.rb' | ||
test.verbose = true | ||
end | ||
|
||
require 'rspec/core/rake_task' | ||
RSpec::Core::RakeTask.new(:spec) do |test| | ||
test.verbose = true | ||
end | ||
|
||
desc "Run Test Unit with code coverage" | ||
task :test_coverage do | ||
ENV['COVERAGE'] = 'true' | ||
Rake::Task["test"].execute | ||
end | ||
|
||
desc "Run RSpec with code coverage" | ||
task :rspec_coverage do | ||
ENV['COVERAGE'] = 'true' | ||
Rake::Task["spec"].execute | ||
end | ||
|
||
task :default => :test | ||
|
||
require 'rdoc/task' | ||
RDoc::Task.new do |rdoc| | ||
version = File.exist?('VERSION') ? File.read('VERSION') : "" | ||
|
||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = "musicbrainz #{version}" | ||
rdoc.rdoc_files.include('README*') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end | ||
task :default => :spec | ||
task :test => :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- encoding: utf-8 -*- | ||
module MusicBrainz | ||
def self.query_interval=(sec) | ||
MusicBrainz::Tools::Proxy.query_interval = sec | ||
puts "WARNING! MusicBrainz.query_interval is deprecated. Use MusicBrainz::Tools::Proxy.query_interval" | ||
end | ||
|
||
def self.cache_path=(path) | ||
MusicBrainz::Tools::Cache.cache_path = path | ||
puts "WARNING! MusicBrainz.cache_path is deprecated. Use MusicBrainz::Tools::Cache.cache_path" | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
# -*- encoding: utf-8 -*- | ||
require "open-uri" | ||
require "socket" | ||
require "nokogiri" | ||
require "cgi" | ||
|
||
require "models/music_brainz" | ||
require "models/music_brainz/base" | ||
require "models/music_brainz/artist" | ||
require "models/music_brainz/release_group" | ||
require "models/music_brainz/release" | ||
require "models/music_brainz/track" | ||
require "version" | ||
|
||
module MusicBrainz | ||
autoload :Base, "musicbrainz/base" | ||
autoload :Artist, "musicbrainz/artist" | ||
autoload :ReleaseGroup, "musicbrainz/release_group" | ||
autoload :Release, "musicbrainz/release" | ||
autoload :Track, "musicbrainz/track" | ||
|
||
module Tools | ||
autoload :Cache, "tools/cache" | ||
autoload :Proxy, "tools/proxy" | ||
end | ||
end |
Oops, something went wrong.