Skip to content

Commit

Permalink
Gem is rewrapped with Bundler instead of Jeweler. All tests are using…
Browse files Browse the repository at this point in the history
… RSpec. Reorganized lib structure. Tests are fixed.
  • Loading branch information
Gregory Eremin committed Jul 4, 2012
1 parent 2ed4c86 commit 9121e79
Show file tree
Hide file tree
Showing 34 changed files with 486 additions and 649 deletions.
5 changes: 0 additions & 5 deletions .document

This file was deleted.

3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ doc
.yardoc
.bundle
pkg
.DS_Store
tmp
Gemfile.lock
Gemfile.lock
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
5 changes: 1 addition & 4 deletions Gemfile
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

6 changes: 4 additions & 2 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Copyright (c) 2011 magnolia-fan
Copyright (c) 2012 Gregory Eremin

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86 changes: 86 additions & 0 deletions README.md
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.
80 changes: 0 additions & 80 deletions README.rdoc

This file was deleted.

66 changes: 6 additions & 60 deletions Rakefile
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
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

12 changes: 12 additions & 0 deletions lib/deprecated.rb
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
78 changes: 0 additions & 78 deletions lib/models/music_brainz.rb

This file was deleted.

21 changes: 15 additions & 6 deletions lib/musicbrainz.rb
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
Loading

0 comments on commit 9121e79

Please sign in to comment.