plex-ruby 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/Rakefile +9 -0
- data/lib/plex-ruby/episode.rb +8 -0
- data/lib/plex-ruby/library.rb +8 -0
- data/lib/plex-ruby/media.rb +8 -0
- data/lib/plex-ruby/part.rb +9 -1
- data/lib/plex-ruby/season.rb +8 -0
- data/lib/plex-ruby/section.rb +9 -1
- data/lib/plex-ruby/show.rb +8 -0
- data/lib/plex-ruby/stream.rb +8 -0
- data/lib/plex-ruby/tags.rb +16 -0
- data/lib/plex-ruby/version.rb +1 -1
- data/lib/plex-ruby/video.rb +11 -2
- data/plex-ruby.gemspec +1 -1
- data/test/test_client.rb +0 -0
- data/test/test_episode.rb +32 -0
- data/test/test_helper.rb +166 -0
- data/test/test_library.rb +21 -0
- data/test/test_media.rb +19 -0
- data/test/test_movie.rb +32 -0
- data/test/test_part.rb +19 -0
- data/test/test_plex.rb +11 -0
- data/test/test_season.rb +24 -0
- data/test/test_section.rb +13 -0
- data/test/test_server.rb +24 -0
- data/test/test_show.rb +24 -0
- data/test/test_stream.rb +16 -0
- data/test/test_video.rb +36 -0
- metadata +29 -3
data/CHANGELOG.md
CHANGED
@@ -19,3 +19,13 @@
|
|
19
19
|
|
20
20
|
* Now allows for multiple servers
|
21
21
|
* Fix a misspelling of 'library' that broke the gem (Sorry!)
|
22
|
+
|
23
|
+
## 0.3.1
|
24
|
+
|
25
|
+
* Fix `gem install plex-ruby`, require `open-uri` as a runtime dependecy
|
26
|
+
wasn't a good idea
|
27
|
+
|
28
|
+
## 1.0.0
|
29
|
+
|
30
|
+
* Added a test suite that can be run with `rake`
|
31
|
+
* I feel this a production ready, will continue to add features
|
data/Rakefile
CHANGED
data/lib/plex-ruby/episode.rb
CHANGED
data/lib/plex-ruby/library.rb
CHANGED
data/lib/plex-ruby/media.rb
CHANGED
data/lib/plex-ruby/part.rb
CHANGED
@@ -12,7 +12,15 @@ module Plex
|
|
12
12
|
@file = node.attr('file')
|
13
13
|
@size = node.attr('size')
|
14
14
|
|
15
|
-
@streams = node.search('Stream').map { |m| Stream.new(m) }
|
15
|
+
@streams = node.search('Stream').map { |m| Plex::Stream.new(m) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def ==(other)
|
19
|
+
if other.is_a? Plex::Part
|
20
|
+
id == other.id
|
21
|
+
else
|
22
|
+
super
|
23
|
+
end
|
16
24
|
end
|
17
25
|
|
18
26
|
end
|
data/lib/plex-ruby/season.rb
CHANGED
data/lib/plex-ruby/section.rb
CHANGED
@@ -3,7 +3,7 @@ module Plex
|
|
3
3
|
|
4
4
|
GROUPS = %w(all unwatched newest recentlyAdded recentlyViewed onDeck)
|
5
5
|
|
6
|
-
attr_reader :library, :refreshing, :type, :title, :art, :agent, :scanner,
|
6
|
+
attr_reader :library, :refreshing, :key, :type, :title, :art, :agent, :scanner,
|
7
7
|
:language, :updated_at
|
8
8
|
|
9
9
|
# @param [Library] library this Section belongs to
|
@@ -53,5 +53,13 @@ module Plex
|
|
53
53
|
library.url
|
54
54
|
end
|
55
55
|
|
56
|
+
def ==(other)
|
57
|
+
if other.is_a? Plex::Section
|
58
|
+
key == other.key
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
56
64
|
end
|
57
65
|
end
|
data/lib/plex-ruby/show.rb
CHANGED
data/lib/plex-ruby/stream.rb
CHANGED
data/lib/plex-ruby/tags.rb
CHANGED
@@ -10,6 +10,14 @@ module Plex
|
|
10
10
|
@tag = node.attr('tag')
|
11
11
|
end
|
12
12
|
|
13
|
+
def ==(other)
|
14
|
+
if other.is_a? #{type}
|
15
|
+
id == other.id
|
16
|
+
else
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
13
21
|
end
|
14
22
|
end
|
15
23
|
CLASS
|
@@ -26,5 +34,13 @@ module Plex
|
|
26
34
|
@role = node.attr('role')
|
27
35
|
end
|
28
36
|
|
37
|
+
def ==(other)
|
38
|
+
if other.is_a? Role
|
39
|
+
id == other.id
|
40
|
+
else
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
29
45
|
end
|
30
46
|
end
|
data/lib/plex-ruby/version.rb
CHANGED
data/lib/plex-ruby/video.rb
CHANGED
@@ -18,14 +18,14 @@ module Plex
|
|
18
18
|
@content_rating = node.attr('contentRating')
|
19
19
|
@summary = node.attr('summary')
|
20
20
|
@rating = node.attr('rating')
|
21
|
-
@
|
21
|
+
@view_count = node.attr('viewCount')
|
22
22
|
@year = node.attr('year')
|
23
23
|
@tagline = node.attr('tagline')
|
24
24
|
@thumb = node.attr('thumb')
|
25
25
|
@art = node.attr('art')
|
26
26
|
@duration = node.attr('duration')
|
27
27
|
@originally_available_at = node.attr('originallyAvailableAt')
|
28
|
-
@
|
28
|
+
@updated_at = node.attr('updatedAt')
|
29
29
|
|
30
30
|
@media = Plex::Media.new(node.search('Media').first)
|
31
31
|
@genres = node.search('Genre').map { |m| Plex::Genre.new(m) }
|
@@ -34,5 +34,14 @@ module Plex
|
|
34
34
|
@roles = node.search('Role').map { |m| Plex::Role.new(m) }
|
35
35
|
end
|
36
36
|
|
37
|
+
|
38
|
+
def ==(other)
|
39
|
+
if other.is_a? Video
|
40
|
+
key == other.key
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
37
46
|
end
|
38
47
|
end
|
data/plex-ruby.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Eric Koslow"]
|
10
10
|
s.email = ["ekoslow@gmail.com"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "https://github.com/ekosz/Plex-Ruby"
|
12
12
|
s.summary = %q{Plex APIs in easy ruby code}
|
13
13
|
s.description = %q{Extracts the Plex API into easy to write ruby code}
|
14
14
|
|
data/test/test_client.rb
ADDED
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Episode do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@episode = Plex::Episode.new(FakeParent.new, '/libary/metadata/6')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should pass the proper method calls to its video object" do
|
10
|
+
fake_video = Plex::Video.new( FakeNode.new(FAKE_VIDEO_NODE_HASH) )
|
11
|
+
@episode.instance_variable_set(
|
12
|
+
"@video", fake_video
|
13
|
+
)
|
14
|
+
|
15
|
+
%w(studio type title title_sort content_rating summary rating view_count year
|
16
|
+
tagline thumb art duration originally_available_at updated_at).each { |method|
|
17
|
+
@episode.send(method.to_sym).must_equal fake_video.send(method.to_sym)
|
18
|
+
}
|
19
|
+
|
20
|
+
@episode.media.must_equal fake_video.media
|
21
|
+
|
22
|
+
@episode.genres.must_equal fake_video.genres
|
23
|
+
|
24
|
+
@episode.writers.must_equal fake_video.writers
|
25
|
+
|
26
|
+
@episode.directors.must_equal fake_video.directors
|
27
|
+
|
28
|
+
@episode.roles.must_equal fake_video.roles
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'plex-ruby'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
|
5
|
+
class FakeNode
|
6
|
+
|
7
|
+
def initialize(hash)
|
8
|
+
@hash = hash
|
9
|
+
end
|
10
|
+
|
11
|
+
def attr(value)
|
12
|
+
@hash[Plex.snake_case(value).to_sym]
|
13
|
+
end
|
14
|
+
|
15
|
+
def search(value)
|
16
|
+
Array( @hash[value.to_sym] )
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class FakeParent
|
22
|
+
|
23
|
+
def url
|
24
|
+
'http://localhost:32400'
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
FAKE_SHOW_NODE_HASH = {
|
30
|
+
Directory: FakeNode.new({
|
31
|
+
guid: 'com.plexapp.agents.thetvdb://73545/1?lang=en',
|
32
|
+
studio: 'Big Dog',
|
33
|
+
title: 'Friends',
|
34
|
+
content_rating: 'MV-14',
|
35
|
+
summary: '3 friends go on an adventure',
|
36
|
+
index: '1',
|
37
|
+
rating: '10',
|
38
|
+
year: '3033',
|
39
|
+
thumb: '/file/path.jpg',
|
40
|
+
art: '/other/file/path.png',
|
41
|
+
banner: '/yet/another/file/path.jpg2000',
|
42
|
+
theme: 'Chrismasy?',
|
43
|
+
duration: '2345234',
|
44
|
+
originally_available_at: '1323213639',
|
45
|
+
leaf_count: '1',
|
46
|
+
viewed_leaf_count: '0',
|
47
|
+
added_at: '1323213639',
|
48
|
+
updated_at: '1323220437',
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
FAKE_SEASON_NODE_HASH = {
|
53
|
+
Directory: FakeNode.new({
|
54
|
+
key: '/library/metadata/10/children',
|
55
|
+
rating_key: '10',
|
56
|
+
guid: 'com.plexapp.agents.thetvdb://73545/1?lang=en',
|
57
|
+
type: 'season',
|
58
|
+
title: 'Season 1',
|
59
|
+
summary: '',
|
60
|
+
index: '1',
|
61
|
+
thumb: '/library/metadata/10/thumb?t=1323220437',
|
62
|
+
leaf_count: '13',
|
63
|
+
viewed_leaf_count: '0',
|
64
|
+
added_at: '1323213639',
|
65
|
+
updated_at: '1323220437'
|
66
|
+
})
|
67
|
+
}
|
68
|
+
|
69
|
+
FAKE_SECTION_NODE_HASH = {
|
70
|
+
refreshing: '0',
|
71
|
+
key: '1',
|
72
|
+
type: 'movie',
|
73
|
+
title: 'Movies',
|
74
|
+
art: '/:/resources/movie-fanart.jpg',
|
75
|
+
agent: 'com.plexapp.agents.imdb',
|
76
|
+
scanner: 'Plex Movie Scanner',
|
77
|
+
language: 'en',
|
78
|
+
updated_at: '1323213684'
|
79
|
+
}
|
80
|
+
|
81
|
+
FAKE_LIBRARY_NODE_HASH = {
|
82
|
+
:Directory => FakeNode.new(FAKE_SECTION_NODE_HASH),
|
83
|
+
:"Directory[@key='#{FAKE_SECTION_NODE_HASH[:key]}']" => FakeNode.new(FAKE_SECTION_NODE_HASH)
|
84
|
+
}
|
85
|
+
|
86
|
+
FAKE_STREAM_NODE_HASH = {
|
87
|
+
id: '100',
|
88
|
+
stream_type: 'fast',
|
89
|
+
codec: 'aac',
|
90
|
+
index: '5',
|
91
|
+
language: 'English',
|
92
|
+
language_code: 'en'
|
93
|
+
}
|
94
|
+
|
95
|
+
FAKE_PART_NODE_HASH = {
|
96
|
+
id: '45',
|
97
|
+
key: '1',
|
98
|
+
duration: '1600',
|
99
|
+
file: '/some/file/path/blah.mkv',
|
100
|
+
size: '6500',
|
101
|
+
Stream: FakeNode.new( FAKE_STREAM_NODE_HASH )
|
102
|
+
}
|
103
|
+
|
104
|
+
FAKE_MEDIA_NODE_HASH = {
|
105
|
+
id: '63',
|
106
|
+
durration: '3200',
|
107
|
+
bitrate: '24p',
|
108
|
+
aspect_ratio: '4:3',
|
109
|
+
audio_channels: '2',
|
110
|
+
audio_codec: 'mp3',
|
111
|
+
video_codec: 'mp4',
|
112
|
+
video_resolution: '720p',
|
113
|
+
container: 'mkv',
|
114
|
+
video_frame_rate: '32/2',
|
115
|
+
Part: FakeNode.new( FAKE_PART_NODE_HASH )
|
116
|
+
}
|
117
|
+
|
118
|
+
FAKE_GENRE_NODE_HASH = {
|
119
|
+
id: '13',
|
120
|
+
tag: 'Action'
|
121
|
+
}
|
122
|
+
|
123
|
+
FAKE_WRITER_NODE_HASH = {
|
124
|
+
id: '14',
|
125
|
+
tag: 'Poe'
|
126
|
+
}
|
127
|
+
|
128
|
+
FAKE_DIRECTOR_NODE_HASH = {
|
129
|
+
id: '15',
|
130
|
+
tag: 'King'
|
131
|
+
}
|
132
|
+
|
133
|
+
FAKE_ROLE_NODE_HASH = {
|
134
|
+
id: '16',
|
135
|
+
tag: 'Red Haired Person',
|
136
|
+
role: "Ron"
|
137
|
+
}
|
138
|
+
|
139
|
+
FAKE_VIDEO_NODE_HASH = {
|
140
|
+
rating_key: '7',
|
141
|
+
key: '/library/7',
|
142
|
+
studio: 'Six',
|
143
|
+
type: 'movie',
|
144
|
+
title: 'Men in Black (2011)',
|
145
|
+
title_sort: 'Men in Black',
|
146
|
+
content_rating: 'MA',
|
147
|
+
summary: 'Two men fight the entire world!',
|
148
|
+
rating: '9.9',
|
149
|
+
view_count: '0',
|
150
|
+
year: '2011',
|
151
|
+
tagline: 'Fight the Power!',
|
152
|
+
thumb: '/some/long/filename.jpg',
|
153
|
+
art: '/some/other/long/filename.jpg',
|
154
|
+
duration: '3400',
|
155
|
+
originally_available_at: '324124',
|
156
|
+
updated_at: '342214',
|
157
|
+
Media: FakeNode.new( FAKE_MEDIA_NODE_HASH ),
|
158
|
+
Genre: FakeNode.new( FAKE_GENRE_NODE_HASH ),
|
159
|
+
Writer: FakeNode.new( FAKE_WRITER_NODE_HASH ),
|
160
|
+
Director: FakeNode.new( FAKE_DIRECTOR_NODE_HASH ),
|
161
|
+
Role: FakeNode.new( FAKE_ROLE_NODE_HASH )
|
162
|
+
}
|
163
|
+
|
164
|
+
FAKE_PARSER_NODE_HASH = {
|
165
|
+
MediaContainer: FakeNode.new(FAKE_VIDEO_NODE_HASH)
|
166
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Library do
|
4
|
+
before do
|
5
|
+
@library = Plex::Library.new(FakeParent.new)
|
6
|
+
@library.instance_variable_set("@xml_doc", FakeNode.new(FAKE_LIBRARY_NODE_HASH))
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
it "should return a list of sections" do
|
11
|
+
@library.sections.must_equal(
|
12
|
+
Array( Plex::Section.new(nil, FakeNode.new(FAKE_SECTION_NODE_HASH)) )
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return the proper section when specisfied" do
|
17
|
+
@library.section(FAKE_SECTION_NODE_HASH[:key]).must_equal(
|
18
|
+
Plex::Section.new(nil, FakeNode.new(FAKE_SECTION_NODE_HASH))
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
data/test/test_media.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Media do
|
4
|
+
before do
|
5
|
+
@media = Plex::Media.new( FakeNode.new(FAKE_MEDIA_NODE_HASH) )
|
6
|
+
end
|
7
|
+
|
8
|
+
%w(id durration bitrate aspect_ratio audio_channels audio_codec video_codec
|
9
|
+
video_resolution container video_frame_rate).each { |method|
|
10
|
+
it "should properly respond to ##{method}" do
|
11
|
+
@media.send(method.to_sym).must_equal FAKE_MEDIA_NODE_HASH[method.to_sym]
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
it "should properly respond to #parts" do
|
16
|
+
@media.parts.must_equal Array( Plex::Part.new(FakeNode.new(FAKE_PART_NODE_HASH)) )
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/test/test_movie.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Movie do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@movie = Plex::Movie.new(FakeParent.new, '/libary/metadata/6')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should pass the proper method calls to its video object" do
|
10
|
+
fake_video = Plex::Video.new( FakeNode.new(FAKE_VIDEO_NODE_HASH) )
|
11
|
+
@movie.instance_variable_set(
|
12
|
+
"@video", fake_video
|
13
|
+
)
|
14
|
+
|
15
|
+
%w(studio type title title_sort content_rating summary rating view_count year
|
16
|
+
tagline thumb art duration originally_available_at updated_at).each { |method|
|
17
|
+
@movie.send(method.to_sym).must_equal fake_video.send(method.to_sym)
|
18
|
+
}
|
19
|
+
|
20
|
+
@movie.media.must_equal fake_video.media
|
21
|
+
|
22
|
+
@movie.genres.must_equal fake_video.genres
|
23
|
+
|
24
|
+
@movie.writers.must_equal fake_video.writers
|
25
|
+
|
26
|
+
@movie.directors.must_equal fake_video.directors
|
27
|
+
|
28
|
+
@movie.roles.must_equal fake_video.roles
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/test/test_part.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Part do
|
4
|
+
before do
|
5
|
+
@part = Plex::Part.new( FakeNode.new(FAKE_PART_NODE_HASH) )
|
6
|
+
end
|
7
|
+
|
8
|
+
%w(id key duration file size).each { |method|
|
9
|
+
it "should properly respond to ##{method}" do
|
10
|
+
@part.send(method.to_sym).must_equal FAKE_PART_NODE_HASH[method.to_sym]
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
it "should properly respond to #streams" do
|
15
|
+
@part.streams.must_equal Array( Plex::Stream.new(FakeNode.new(FAKE_STREAM_NODE_HASH)) )
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
data/test/test_plex.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex do
|
4
|
+
|
5
|
+
it "converts words from camelCase to snake_case" do
|
6
|
+
Plex.snake_case("camelCase").must_equal "camel_case"
|
7
|
+
Plex.snake_case("snake_case").must_equal "snake_case"
|
8
|
+
Plex.snake_case("normal").must_equal "normal"
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
data/test/test_season.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Season do
|
4
|
+
before do
|
5
|
+
@season = Plex::Season.new(FakeParent.new, '/library/metadata/10')
|
6
|
+
@season.instance_variable_set("@xml_doc", FakeNode.new(FAKE_SEASON_NODE_HASH))
|
7
|
+
end
|
8
|
+
|
9
|
+
Plex::Season::ATTRIBUTES.map{|m| Plex.snake_case(m)}.each { |method|
|
10
|
+
it "should properly respond to ##{method}" do
|
11
|
+
@season.send(method.to_sym).must_equal FAKE_SEASON_NODE_HASH[:Directory].attr(method)
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
it "should return a list of episodes" do
|
16
|
+
@season.instance_variable_set(
|
17
|
+
"@children", FakeNode.new({Video: FakeNode.new(FAKE_VIDEO_NODE_HASH)})
|
18
|
+
)
|
19
|
+
@season.episodes.must_equal(
|
20
|
+
[ Plex::Episode.new(FakeParent.new, FAKE_VIDEO_NODE_HASH[:key]) ]
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Section do
|
4
|
+
before do
|
5
|
+
@section = Plex::Section.new(FakeParent.new, FakeNode.new(FAKE_SECTION_NODE_HASH))
|
6
|
+
end
|
7
|
+
|
8
|
+
%w(refreshing type title art agent scanner language updated_at).each { |method|
|
9
|
+
it "should respond to ##{method}" do
|
10
|
+
@section.send(method.to_sym).must_equal FAKE_SECTION_NODE_HASH[method.to_sym]
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
data/test/test_server.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Server do
|
4
|
+
before do
|
5
|
+
@server = Plex::Server.new('localhost', 3000)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "has a host" do
|
9
|
+
@server.host.must_equal 'localhost'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has a port" do
|
13
|
+
@server.port.must_equal 3000
|
14
|
+
end
|
15
|
+
|
16
|
+
it "properly formats its url" do
|
17
|
+
@server.url.must_equal "http://localhost:3000"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has a libary" do
|
21
|
+
@server.library.must_equal Plex::Library.new(@server)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/test/test_show.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Show do
|
4
|
+
before do
|
5
|
+
@show = Plex::Show.new(FakeParent.new, '/library/metadata/10')
|
6
|
+
@show.instance_variable_set("@xml_doc", FakeNode.new(FAKE_SHOW_NODE_HASH))
|
7
|
+
end
|
8
|
+
|
9
|
+
Plex::Show::ATTRIBUTES.map{|m| Plex.snake_case(m)}.each { |method|
|
10
|
+
it "should properly respond to ##{method}" do
|
11
|
+
@show.send(method.to_sym).must_equal FAKE_SHOW_NODE_HASH[:Directory].attr(method)
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
it "should return a list of episodes" do
|
16
|
+
@show.instance_variable_set(
|
17
|
+
"@children", FakeNode.new(FAKE_SEASON_NODE_HASH)
|
18
|
+
)
|
19
|
+
@show.seasons.must_equal(
|
20
|
+
[ Plex::Season.new(FakeParent.new, FAKE_SEASON_NODE_HASH[:Directory].attr('key')[0..-10]) ]
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/test/test_stream.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Stream do
|
4
|
+
before do
|
5
|
+
@stream = Plex::Stream.new( FakeNode.new(FAKE_STREAM_NODE_HASH) )
|
6
|
+
end
|
7
|
+
|
8
|
+
%w(id stream_type codec index language language_code).each { |method|
|
9
|
+
it "should properly respond to ##{method}" do
|
10
|
+
@stream.send(method.to_sym).must_equal FAKE_STREAM_NODE_HASH[method.to_sym]
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
|
data/test/test_video.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe Plex::Video do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@video = Plex::Video.new( FakeNode.new(FAKE_VIDEO_NODE_HASH) )
|
7
|
+
end
|
8
|
+
|
9
|
+
%w(key studio type title title_sort content_rating summary rating view_count year
|
10
|
+
tagline thumb art duration originally_available_at updated_at).each { |method|
|
11
|
+
it "should correctly respond to ##{method}" do
|
12
|
+
@video.send(method.to_sym).must_equal FAKE_VIDEO_NODE_HASH[method.to_sym]
|
13
|
+
end
|
14
|
+
}
|
15
|
+
|
16
|
+
it "should correctly referance its media object" do
|
17
|
+
@video.media.must_equal Plex::Media.new(FAKE_VIDEO_NODE_HASH[:Media])
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should correctly referance its genre objects" do
|
21
|
+
@video.genres.must_equal Array( Plex::Genre.new(FAKE_VIDEO_NODE_HASH[:Genre]) )
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should correctly referance its writer objects" do
|
25
|
+
@video.writers.must_equal Array( Plex::Writer.new(FAKE_VIDEO_NODE_HASH[:Writer]) )
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should correctly referance its director objects" do
|
29
|
+
@video.directors.must_equal Array( Plex::Director.new(FAKE_VIDEO_NODE_HASH[:Director]) )
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should correctly referance its role objects" do
|
33
|
+
@video.roles.must_equal Array( Plex::Role.new(FAKE_VIDEO_NODE_HASH[:Role]) )
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: plex-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eric Koslow
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-09 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -69,9 +69,22 @@ files:
|
|
69
69
|
- lib/plex-ruby/version.rb
|
70
70
|
- lib/plex-ruby/video.rb
|
71
71
|
- plex-ruby.gemspec
|
72
|
+
- test/test_client.rb
|
73
|
+
- test/test_episode.rb
|
72
74
|
- test/test_helper.rb
|
75
|
+
- test/test_library.rb
|
76
|
+
- test/test_media.rb
|
77
|
+
- test/test_movie.rb
|
78
|
+
- test/test_part.rb
|
79
|
+
- test/test_plex.rb
|
80
|
+
- test/test_season.rb
|
81
|
+
- test/test_section.rb
|
82
|
+
- test/test_server.rb
|
83
|
+
- test/test_show.rb
|
84
|
+
- test/test_stream.rb
|
85
|
+
- test/test_video.rb
|
73
86
|
has_rdoc: true
|
74
|
-
homepage:
|
87
|
+
homepage: https://github.com/ekosz/Plex-Ruby
|
75
88
|
licenses: []
|
76
89
|
|
77
90
|
post_install_message:
|
@@ -99,4 +112,17 @@ signing_key:
|
|
99
112
|
specification_version: 3
|
100
113
|
summary: Plex APIs in easy ruby code
|
101
114
|
test_files:
|
115
|
+
- test/test_client.rb
|
116
|
+
- test/test_episode.rb
|
102
117
|
- test/test_helper.rb
|
118
|
+
- test/test_library.rb
|
119
|
+
- test/test_media.rb
|
120
|
+
- test/test_movie.rb
|
121
|
+
- test/test_part.rb
|
122
|
+
- test/test_plex.rb
|
123
|
+
- test/test_season.rb
|
124
|
+
- test/test_section.rb
|
125
|
+
- test/test_server.rb
|
126
|
+
- test/test_show.rb
|
127
|
+
- test/test_stream.rb
|
128
|
+
- test/test_video.rb
|