sandro-tagooru 0.1.0 → 0.1.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/VERSION +1 -1
- data/lib/tagooru.rb +6 -2
- data/lib/tagooru/playlist.rb +3 -3
- data/spec/tagooru/playlist_spec.rb +2 -30
- data/spec/tagooru/track_spec.rb +38 -0
- data/tagooru.gemspec +7 -2
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/tagooru.rb
CHANGED
@@ -10,10 +10,14 @@ class Tagooru
|
|
10
10
|
|
11
11
|
include HTTParty
|
12
12
|
base_uri 'http://tagoo.ru'
|
13
|
-
default_params :for => :audio, :key => '
|
13
|
+
default_params :for => :audio, :key => '5239980d'
|
14
14
|
headers 'Referer' => 'http://tagoo.ru/en/webmaster.php?mode=json_api'
|
15
15
|
format :plain
|
16
16
|
|
17
|
+
def self.api_key=(key)
|
18
|
+
default_params :key => key
|
19
|
+
end
|
20
|
+
|
17
21
|
# override method from HTTParty to prevent cookies from overriding other
|
18
22
|
# header data (httparty 0.4.4)
|
19
23
|
def self.perform_request(http_method, path, options) #:nodoc:
|
@@ -22,7 +26,7 @@ class Tagooru
|
|
22
26
|
|
23
27
|
def self.search(query, page = 1)
|
24
28
|
response = get '/api_search.php', :query => {:search => query, :page => page, :seed => generate_seed}
|
25
|
-
data = Crack::JSON.parse(response.sub(
|
29
|
+
data = Crack::JSON.parse(response.sub(/^.*?= /, ''))
|
26
30
|
data['data'].map do |d|
|
27
31
|
Track.new d['title'], d['file_url']
|
28
32
|
end
|
data/lib/tagooru/playlist.rb
CHANGED
@@ -30,13 +30,11 @@ describe Tagooru::Playlist do
|
|
30
30
|
|
31
31
|
describe "#lines" do
|
32
32
|
before do
|
33
|
-
@
|
34
|
-
@playlist.contents.stub!(:to_a => @array)
|
33
|
+
@playlist = Tagooru::Playlist.new "INFO\r\nline1\r\nline2\r\n"
|
35
34
|
end
|
36
35
|
|
37
36
|
it "skips the first line" do
|
38
|
-
@
|
39
|
-
@playlist.send(:lines)
|
37
|
+
@playlist.send(:lines)[0].should_not =~ /INFO/
|
40
38
|
end
|
41
39
|
|
42
40
|
it "removes line separators" do
|
@@ -44,30 +42,4 @@ describe Tagooru::Playlist do
|
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
47
|
-
|
48
|
-
describe Tagooru::Track do
|
49
|
-
before do
|
50
|
-
@track = Tagooru::Track.new "Fix You", "http://google.com/?q=fixyou.mp3"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "has a name and location" do
|
54
|
-
@track.name.should == "Fix You"
|
55
|
-
@track.location.should == "http://google.com/?q=fixyou.mp3"
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "accessibility" do
|
59
|
-
it "is accessible" do
|
60
|
-
http = stub(:request_head => stub(:code => 200), :null_object => true)
|
61
|
-
Net::HTTP.stub!(:new => http)
|
62
|
-
@track.should be_accessible
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'is not accessible' do
|
66
|
-
http = stub(:null_object => true)
|
67
|
-
http.should_receive(:request_head).and_raise(SocketError)
|
68
|
-
Net::HTTP.stub!(:new => http)
|
69
|
-
@track.should_not be_accessible
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
45
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
|
2
|
+
|
3
|
+
describe Tagooru::Track do
|
4
|
+
before do
|
5
|
+
@track = Tagooru::Track.new "Fix You", "http://google.com/?q=fixyou.mp3"
|
6
|
+
end
|
7
|
+
|
8
|
+
it "has a name and location" do
|
9
|
+
@track.name.should == "Fix You"
|
10
|
+
@track.location.should == "http://google.com/?q=fixyou.mp3"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "accessibility" do
|
14
|
+
it "is accessible" do
|
15
|
+
http = stub(:request_head => stub(:code => 200), :null_object => true)
|
16
|
+
Net::HTTP.stub!(:new => http)
|
17
|
+
@track.should be_accessible
|
18
|
+
end
|
19
|
+
|
20
|
+
context "not accessible" do
|
21
|
+
before do
|
22
|
+
@http = stub(:null_object => true)
|
23
|
+
Net::HTTP.stub!(:new => @http)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "rescues SocketError" do
|
27
|
+
@http.should_receive(:request_head).and_raise(SocketError)
|
28
|
+
@track.should_not be_accessible
|
29
|
+
end
|
30
|
+
|
31
|
+
it "rescues Timeout::Error" do
|
32
|
+
timeout_error = Timeout::Error.new 'timeout'
|
33
|
+
@http.should_receive(:request_head).and_raise(timeout_error)
|
34
|
+
@track.should_not be_accessible
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/tagooru.gemspec
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
7
|
s.name = %q{tagooru}
|
5
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
6
9
|
|
7
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
11
|
s.authors = ["Sandro Turriate"]
|
9
|
-
s.date = %q{2009-08-
|
12
|
+
s.date = %q{2009-08-16}
|
10
13
|
s.email = %q{sandro.turriate@gmail.com}
|
11
14
|
s.extra_rdoc_files = [
|
12
15
|
"LICENSE",
|
@@ -28,6 +31,7 @@ Gem::Specification.new do |s|
|
|
28
31
|
"spec/spec.opts",
|
29
32
|
"spec/spec_helper.rb",
|
30
33
|
"spec/tagooru/playlist_spec.rb",
|
34
|
+
"spec/tagooru/track_spec.rb",
|
31
35
|
"spec/tagooru_spec.rb",
|
32
36
|
"tagooru.gemspec"
|
33
37
|
]
|
@@ -40,6 +44,7 @@ Gem::Specification.new do |s|
|
|
40
44
|
s.test_files = [
|
41
45
|
"spec/spec_helper.rb",
|
42
46
|
"spec/tagooru/playlist_spec.rb",
|
47
|
+
"spec/tagooru/track_spec.rb",
|
43
48
|
"spec/tagooru_spec.rb"
|
44
49
|
]
|
45
50
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandro-tagooru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sandro Turriate
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- spec/spec.opts
|
39
39
|
- spec/spec_helper.rb
|
40
40
|
- spec/tagooru/playlist_spec.rb
|
41
|
+
- spec/tagooru/track_spec.rb
|
41
42
|
- spec/tagooru_spec.rb
|
42
43
|
- tagooru.gemspec
|
43
44
|
has_rdoc: true
|
@@ -70,4 +71,5 @@ summary: Ruby wrapper for the tagoo search engine
|
|
70
71
|
test_files:
|
71
72
|
- spec/spec_helper.rb
|
72
73
|
- spec/tagooru/playlist_spec.rb
|
74
|
+
- spec/tagooru/track_spec.rb
|
73
75
|
- spec/tagooru_spec.rb
|