Class: Drum::MockService

Inherits:
Service show all
Defined in:
lib/drum/service/mock.rb

Overview

A service that provides a mock playlist for ease of manual testing.

Instance Method Summary collapse

Methods inherited from Service

#remove, #upload

Instance Method Details

#download(playlist_ref) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/drum/service/mock.rb', line 22

def download(playlist_ref)
  if playlist_ref.resource_type == :playlist
    [Playlist.new(
      id: '95d5e24cde85a09ce2ac0ae381179dabacee0202',
      name: 'Mock Playlist',
      description: 'Lots of great songs',
      author_id: '0',
      users: {
        '0' => User.new(id: '0', display_name: 'Mr. X')
      },
      artists: {
        '0' => Artist.new(id: '0', name: 'Queen'),
        '1' => Artist.new(id: '1', name: 'The Beatles')
      },
      tracks: [
        Track.new(name: 'Bohemian Rhapsody', artist_ids: ['0']),
        Track.new(name: 'Let it be', artist_ids: ['1'])
      ],
      path: [
        'Top',
        'Sub'
      ]
    )]
  else
    []
  end
end

#nameObject



10
11
12
# File 'lib/drum/service/mock.rb', line 10

def name
  'mock'
end

#parse_ref(raw_ref) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/drum/service/mock.rb', line 14

def parse_ref(raw_ref)
  if raw_ref.is_token && raw_ref.text == 'mock'
    Ref.new(self.name, :playlist, '')
  else
    nil
  end
end