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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 949b5541a2079ded96976f17bc88b556556295c4
4
- data.tar.gz: 64013ae8a2b6cbcdd431da95f7be5188da523ce2
3
+ metadata.gz: 7abcf3f0a457c4680fcb2ed3c69dda5f66fd05fa
4
+ data.tar.gz: 3c9e48de606c1b8a1d353d9384204e3c07ee561d
5
5
  SHA512:
6
- metadata.gz: 246e86ddaae95129d7c9bda0cc01f5840ed23ab5b53966b3c46a648fb2ee0914b32cfd8312d261a13c592a6c7e3d2ad2e4cf97b97ab54f55646864161ae1a1a4
7
- data.tar.gz: 3760d6d198657daa5186fe4dbda5680e3b50702e4ad2c816217bde0c21efac24ff3a714ed3eb7c56a8beca3f70b323060b1f8e8a92f9e3b1bef4199eef25ac9e
6
+ metadata.gz: f49da6a555b0f92431c1783f700f7ae50c4c4c690083875e6444f5e97c71b42da766c3758f61af0e214ac3376d3b8daaeacf90f4c0f259303bea23b5de2f9f3c
7
+ data.tar.gz: 5397143482762e1e163ee9e4402e273b2050c5e12fefd22bd1d7367f9f94e8a6901ef3f5f34a33fae044f08428972148830828e6dbf9c2eaf68fff03f7f5ac15
@@ -10,13 +10,13 @@
10
10
 
11
11
  module Assonnato
12
12
  module Request
13
- def get(host, path)
14
- uri = URI.join(host, '/api/', path[1..-1])
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.join(host, '/api/', path[1..-1])
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, "/shows/get/#{URI.escape show}/episodes/all")
14
+ parse get(@host, @path, "/episodes/#{URI.escape show}")
15
15
  end
16
16
 
17
17
  def search!(keyword)
18
- raise NotImplementedError, 'you can search only the shows'
18
+ raise NotImplementedError, 'you cannot search episodes'
19
19
  end
20
20
 
21
21
  def get!(show, episode)
@@ -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, '/shows/all')
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!(show)
30
- parse get(@host, "/shows/get/#{URI.escape show}")
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
@@ -9,5 +9,5 @@
9
9
  #++
10
10
 
11
11
  module Assonnato
12
- VERSION = '0.4.2'
12
+ VERSION = '0.5'
13
13
  end
data/spec/episode_spec.rb CHANGED
@@ -16,7 +16,7 @@ describe 'Assonnato' do
16
16
 
17
17
  it 'can\'t search episodes' do
18
18
  expect {
19
- @episode.search!('Strikederp')
19
+ @episode.search!('le_too_derp')
20
20
  }.to raise_error(NotImplementedError)
21
21
  end
22
22
 
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.name.length.should > 5
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! 'Strikederp'
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.2
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-04 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json