assonnato 0.4.2 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assonnato/request.rb +4 -4
- data/lib/assonnato/type/episode.rb +2 -2
- data/lib/assonnato/type/show.rb +10 -7
- data/lib/assonnato/version.rb +1 -1
- data/spec/episode_spec.rb +1 -1
- data/spec/show_spec.rb +12 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7abcf3f0a457c4680fcb2ed3c69dda5f66fd05fa
|
4
|
+
data.tar.gz: 3c9e48de606c1b8a1d353d9384204e3c07ee561d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f49da6a555b0f92431c1783f700f7ae50c4c4c690083875e6444f5e97c71b42da766c3758f61af0e214ac3376d3b8daaeacf90f4c0f259303bea23b5de2f9f3c
|
7
|
+
data.tar.gz: 5397143482762e1e163ee9e4402e273b2050c5e12fefd22bd1d7367f9f94e8a6901ef3f5f34a33fae044f08428972148830828e6dbf9c2eaf68fff03f7f5ac15
|
data/lib/assonnato/request.rb
CHANGED
@@ -10,13 +10,13 @@
|
|
10
10
|
|
11
11
|
module Assonnato
|
12
12
|
module Request
|
13
|
-
def get(host, path)
|
14
|
-
uri = URI.
|
13
|
+
def get(host, base_path, path)
|
14
|
+
uri = URI.parse "#{host}#{base_path}#{path}"
|
15
15
|
request :get, uri
|
16
16
|
end
|
17
17
|
|
18
|
-
def post(host, path, params = {})
|
19
|
-
uri = URI.
|
18
|
+
def post(host, base_path, path, params = {})
|
19
|
+
uri = URI.parse "#{host}#{base_path}#{path}"
|
20
20
|
request :post, uri, params
|
21
21
|
end
|
22
22
|
|
@@ -11,11 +11,11 @@
|
|
11
11
|
module Assonnato
|
12
12
|
class Episode < Show
|
13
13
|
def all!(show)
|
14
|
-
parse get(@host, "/
|
14
|
+
parse get(@host, @path, "/episodes/#{URI.escape show}")
|
15
15
|
end
|
16
16
|
|
17
17
|
def search!(keyword)
|
18
|
-
raise NotImplementedError, 'you
|
18
|
+
raise NotImplementedError, 'you cannot search episodes'
|
19
19
|
end
|
20
20
|
|
21
21
|
def get!(show, episode)
|
data/lib/assonnato/type/show.rb
CHANGED
@@ -10,24 +10,27 @@
|
|
10
10
|
|
11
11
|
module Assonnato
|
12
12
|
class Show
|
13
|
-
attr_accessor :host
|
13
|
+
attr_accessor :host, :path
|
14
14
|
include Request
|
15
15
|
include Parser
|
16
16
|
|
17
|
-
def initialize(host)
|
17
|
+
def initialize(host, path = nil)
|
18
18
|
@host = host
|
19
|
+
@path = path || '/api/v1'
|
19
20
|
end
|
20
21
|
|
21
|
-
def all!
|
22
|
-
parse get(@host,
|
22
|
+
def all!(status = :ongoing, fansub = '')
|
23
|
+
parse get(@host, @path, "/shows/all/#{status}/#{fansub}")
|
23
24
|
end
|
24
25
|
|
25
26
|
def search!(keyword)
|
26
|
-
parse get(@host, "/shows/search/#{URI.escape keyword}")
|
27
|
+
parse get(@host, @path, "/shows/search/#{URI.escape keyword}")
|
27
28
|
end
|
28
29
|
|
29
|
-
def get!(
|
30
|
-
|
30
|
+
def get!(show_name)
|
31
|
+
search!(show_name).select { |show|
|
32
|
+
show.name == show_name
|
33
|
+
}
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
data/lib/assonnato/version.rb
CHANGED
data/spec/episode_spec.rb
CHANGED
data/spec/show_spec.rb
CHANGED
@@ -6,12 +6,20 @@ describe 'Assonnato' do
|
|
6
6
|
@show = Assonnato::Show.new 'http://pigro.omnivium.it:4567'
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'returns all the shows' do
|
10
|
-
res = @show.all!
|
9
|
+
it 'returns all the ongoing shows' do
|
10
|
+
res = @show.all! :ongoing
|
11
11
|
res.should be_kind_of(Array)
|
12
12
|
res.should_not be_empty
|
13
13
|
res.first.should be_kind_of(Struct)
|
14
|
-
res.first.
|
14
|
+
res.first.status.should eql('ongoing')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns all the ongoing shows of the given fansub' do
|
18
|
+
res = @show.all! :ongoing, 'Omnivium'
|
19
|
+
res.should be_kind_of(Array)
|
20
|
+
res.should_not be_empty
|
21
|
+
res.first.should be_kind_of(Struct)
|
22
|
+
res.first.fansub.should eql('Omnivium')
|
15
23
|
end
|
16
24
|
|
17
25
|
it 'search all the shows which name is similar to the given keyword' do
|
@@ -23,7 +31,7 @@ describe 'Assonnato' do
|
|
23
31
|
end
|
24
32
|
|
25
33
|
it 'doesn\'t get an unknown show' do
|
26
|
-
res = @show.search! '
|
34
|
+
res = @show.search! 'le_too_derp'
|
27
35
|
res.should be_kind_of(Array)
|
28
36
|
res.should be_empty
|
29
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assonnato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|