puke 0.0.1 → 0.0.2

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