assonnato 0.5 → 0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7abcf3f0a457c4680fcb2ed3c69dda5f66fd05fa
4
- data.tar.gz: 3c9e48de606c1b8a1d353d9384204e3c07ee561d
3
+ metadata.gz: 484942eb226ba61bef25c07194237ae08ba67c86
4
+ data.tar.gz: 771ca979395c5c0f66f4a365c0ad29b248eba7d5
5
5
  SHA512:
6
- metadata.gz: f49da6a555b0f92431c1783f700f7ae50c4c4c690083875e6444f5e97c71b42da766c3758f61af0e214ac3376d3b8daaeacf90f4c0f259303bea23b5de2f9f3c
7
- data.tar.gz: 5397143482762e1e163ee9e4402e273b2050c5e12fefd22bd1d7367f9f94e8a6901ef3f5f34a33fae044f08428972148830828e6dbf9c2eaf68fff03f7f5ac15
6
+ metadata.gz: 0b65a99929164a70dfd40bd53793d2b8e9246f50c4cc8d18bcb292e48f1020d840890e420dd96ce55e30ca123fc00fb7d7c899d8b34fdb1a6a8f2d53f7318107
7
+ data.tar.gz: 2e4f7bf18cf6187ab947912b2829e30008f289ca0c502df54ceda31d32164a2bcf6521e7fb53751b15591eb9eabcb3007ce426707362799a8f575ad0b5451c48
@@ -19,8 +19,21 @@ module Assonnato
19
19
  @path = path || '/api/v1'
20
20
  end
21
21
 
22
- def all!(status = :ongoing, fansub = '')
23
- parse get(@host, @path, "/shows/all/#{status}/#{fansub}")
22
+ def all!(status = :ongoing, options = {})
23
+ filters = ''.tap { |str|
24
+ if options.has_key? :fansub
25
+ str << by_fansub(options[:fansub])
26
+ elsif options.has_key? :user
27
+ if options.has_key? :role
28
+ str << by_role(options[:user], options[:role])
29
+ else
30
+ str << by_staff(options[:user])
31
+ end
32
+ end
33
+ }
34
+
35
+ puts "#{filters}/shows/all/#{status}"
36
+ parse get(@host, @path, "#{filters}/shows/all/#{status}")
24
37
  end
25
38
 
26
39
  def search!(keyword)
@@ -32,5 +45,20 @@ module Assonnato
32
45
  show.name == show_name
33
46
  }
34
47
  end
48
+
49
+ private
50
+ def by_fansub(fansub)
51
+ "/fansubs/#{URI.escape fansub}"
52
+ end
53
+
54
+ private
55
+ def by_staff(user)
56
+ "/users/#{URI.escape user}"
57
+ end
58
+
59
+ private
60
+ def by_role(user, role)
61
+ "/users/#{URI.escape user}/#{role}"
62
+ end
35
63
  end
36
64
  end
@@ -9,5 +9,5 @@
9
9
  #++
10
10
 
11
11
  module Assonnato
12
- VERSION = '0.5'
12
+ VERSION = '0.6'
13
13
  end
data/spec/show_spec.rb CHANGED
@@ -14,26 +14,33 @@ describe 'Assonnato' do
14
14
  res.first.status.should eql('ongoing')
15
15
  end
16
16
 
17
+ it 'search all the shows which name is similar to the given keyword' do
18
+ res = @show.search! 'strike'
19
+ res.should be_kind_of(Array)
20
+ res.should_not be_empty
21
+ res.first.should be_kind_of(Struct)
22
+ res.first.name.should eql('Strike the Blood')
23
+ end
24
+
17
25
  it 'returns all the ongoing shows of the given fansub' do
18
- res = @show.all! :ongoing, 'Omnivium'
26
+ res = @show.all! :ongoing, fansub: 'Omnivium'
19
27
  res.should be_kind_of(Array)
20
28
  res.should_not be_empty
21
29
  res.first.should be_kind_of(Struct)
22
30
  res.first.fansub.should eql('Omnivium')
23
31
  end
24
32
 
25
- it 'search all the shows which name is similar to the given keyword' do
26
- res = @show.search! 'Strike'
33
+ it 'returns all the ongoing shows in wich the given user has worked' do
34
+ res = @show.all! :ongoing, user: 'Roxas Shadow'
27
35
  res.should be_kind_of(Array)
28
36
  res.should_not be_empty
29
- res.first.should be_kind_of(Struct)
30
- res.first.name.should eql('Strike the Blood')
31
37
  end
32
38
 
33
- it 'doesn\'t get an unknown show' do
34
- res = @show.search! 'le_too_derp'
39
+ it 'returns all the ongoing shows in wich the given user has worked in the given role' do
40
+ res = @show.all! :ongoing, { user: 'Roxas Shadow', role: :translator }
35
41
  res.should be_kind_of(Array)
36
- res.should be_empty
42
+ res.should_not be_empty
43
+ res.first.translator.should eql('Roxas Shadow')
37
44
  end
38
45
 
39
46
  it 'returns all the informations of the given show' do
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.5'
4
+ version: '0.6'
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-06 00:00:00.000000000 Z
11
+ date: 2014-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json