puke 0.0.1
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.
- data/library/puke/piece.rb +31 -0
- data/library/puke.rb +19 -0
- data/library/tinysong.rb +18 -0
- metadata +68 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Puke
|
4
|
+
class Piece
|
5
|
+
def self.attribute name, value;
|
6
|
+
define_method name do
|
7
|
+
@attributes["#{value}"]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
attribute :id, :SongID
|
12
|
+
attribute :title, :SongName
|
13
|
+
attribute :artist, :ArtistName
|
14
|
+
attribute :album, :AlbumName
|
15
|
+
|
16
|
+
def initialize attributes
|
17
|
+
@attributes = attributes
|
18
|
+
end
|
19
|
+
|
20
|
+
def token; @attributes["Url"][/\w+$/] end
|
21
|
+
|
22
|
+
def url
|
23
|
+
name = self.title.gsub(/[^\s\w]/, '').gsub ' ', '+'
|
24
|
+
%{http://tinysong.com/#{token}}
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s
|
28
|
+
%{#<#{self.class.name}:#{id} @name=#{name.inspect} @artist=#{artist.inspect} @album=#{album.inspect}>}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/library/puke.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'tinysong'
|
4
|
+
require 'net/http'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Puke
|
8
|
+
Version = 0, 0, 1
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def search query
|
13
|
+
Tinysong.search(query).tap do |result|
|
14
|
+
result.each { |song| yield song } if block_given?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def client; @client ||= Client.new end
|
19
|
+
end
|
data/library/tinysong.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'net/http'
|
5
|
+
require 'puke/piece'
|
6
|
+
|
7
|
+
module Tinysong
|
8
|
+
Version = 0, 0, 1
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def search query
|
13
|
+
Net::HTTP.get(URI "http://tinysong.com/s/#{URI.escape query}?format=json").tap do |response|
|
14
|
+
return JSON.parse(response).map &Puke::Piece.method(:new)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puke
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Mikkel Kroman
|
13
|
+
autorequire:
|
14
|
+
bindir: executables
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-22 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: mk@maero.dk
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- library/puke.rb
|
31
|
+
- library/puke/piece.rb
|
32
|
+
- library/tinysong.rb
|
33
|
+
has_rdoc: true
|
34
|
+
homepage:
|
35
|
+
licenses: []
|
36
|
+
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
|
40
|
+
require_paths:
|
41
|
+
- library
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 9
|
50
|
+
- 1
|
51
|
+
version: 1.9.1
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.3.7
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Puke is a minimal grooveshark library for ruby, using the Tinysong.com api instead of grooveshark.com
|
67
|
+
test_files: []
|
68
|
+
|