plex-ruby 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -50,7 +50,7 @@ shows = section.all # Returns a list of shows/movies
50
50
  bsg = shows.select { |s| s.title =~ /Battlestar/ }.first # Pick a great show
51
51
  bsg.seasons # array of its seasons
52
52
  episodes = bsg.seasons.last.episodes # Array the last seasons episodes
53
- episode = episodes[4] # The fith episode in the season
53
+ episode = episodes[4] # The fifth episode in the season
54
54
  puts "#{episode.title} - #{episode.summary}" # Looks good
55
55
  client.play_media(episode) # Play it!
56
56
  ```
data/lib/plex-ruby.rb CHANGED
@@ -9,7 +9,7 @@ module Plex
9
9
  #
10
10
  # @param [String] camel case name to be converted
11
11
  # @return [String] snake case form
12
- def self.snake_case(string)
12
+ def self.underscore(string)
13
13
  string.gsub(/::/, '/').
14
14
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
15
15
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
@@ -17,6 +17,16 @@ module Plex
17
17
  downcase
18
18
  end
19
19
 
20
+ # Converts ruby style snake case names into the cammel case names that are
21
+ # used in the Plex APIs. I.E. <tt>play_media</tt> -> <tt>playMedia</tt>
22
+ def self.camelize(string, first_letter_uppercase = false)
23
+ if first_letter_uppercase
24
+ string.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
25
+ else
26
+ string.to_s[0].chr.downcase + camelize(string, true)[1..-1]
27
+ end
28
+ end
29
+
20
30
  end
21
31
 
22
32
  require 'plex-ruby/parser'
@@ -9,7 +9,7 @@ module Plex
9
9
 
10
10
  ATTRIBUTES = %w(name host address port machineIdentifier version)
11
11
 
12
- attr_reader *ATTRIBUTES.map {|m| Plex.snake_case(m) }
12
+ attr_reader *ATTRIBUTES.map {|m| Plex.underscore(m) }
13
13
  attr_reader :server
14
14
 
15
15
 
@@ -18,7 +18,7 @@ module Plex
18
18
  def initialize(server, node)
19
19
  @server = server
20
20
  ATTRIBUTES.each { |e|
21
- instance_variable_set("@#{Plex.snake_case(e)}", node.attr(e))
21
+ instance_variable_set("@#{Plex.underscore(e)}", node.attr(e))
22
22
  }
23
23
  end
24
24
 
@@ -29,7 +29,7 @@ module Plex
29
29
  # the console for the error message
30
30
  NAV_METHODS.each { |nav|
31
31
  class_eval %(
32
- def #{Plex.snake_case(nav)}
32
+ def #{Plex.underscore(nav)}
33
33
  ping player_url+'/navigation/#{nav}'
34
34
  end
35
35
  )
@@ -42,7 +42,7 @@ module Plex
42
42
  # the console for the error message
43
43
  PLAYBACK_METHODS.each { |playback|
44
44
  class_eval %(
45
- def #{Plex.snake_case(playback)}
45
+ def #{Plex.underscore(playback)}
46
46
  ping player_url+'/playback/#{playback}'
47
47
  end
48
48
  )
@@ -4,15 +4,16 @@ module Plex
4
4
  ATTRIBUTES = %w(id durration bitrate aspectRatio audioChannels
5
5
  audioCodec videoCodec videoResolution container videoFrameRate)
6
6
 
7
- attr_reader *ATTRIBUTES.map {|m| Plex.snake_case(m) }
8
7
  attr_reader :parts
9
8
 
10
9
  # @param [Nokogiri::XML::Element] nokogiri element that represents this
11
10
  # Media
12
11
  def initialize(node)
13
- ATTRIBUTES.each { |e|
14
- instance_variable_set("@#{Plex.snake_case(e)}", node.attr(e))
15
- }
12
+ node.attributes.each do |method, val|
13
+ define_singleton_method(Plex.underscore(method).to_sym) do
14
+ val.value
15
+ end
16
+ end
16
17
 
17
18
  @parts = node.search("Part").map { |m| Plex::Part.new(m) }
18
19
  end
@@ -3,15 +3,16 @@ module Plex
3
3
 
4
4
  ATTRIBUTES = %w(id key duration file size)
5
5
 
6
- attr_reader *ATTRIBUTES.map {|m| Plex.snake_case(m) }
7
6
  attr_reader :streams
8
7
 
9
8
  # @param [Nokogiri::XML::Element] nokogiri element that represents this
10
9
  # part
11
10
  def initialize(node)
12
- ATTRIBUTES.each { |e|
13
- instance_variable_set("@#{Plex.snake_case(e)}", node.attr(e))
14
- }
11
+ node.attributes.each do |method, val|
12
+ define_singleton_method(Plex.underscore(method).to_sym) do
13
+ val.value
14
+ end
15
+ end
15
16
 
16
17
  @streams = node.search('Stream').map { |m| Plex::Stream.new(m) }
17
18
  end
@@ -12,20 +12,17 @@ module Plex
12
12
  def initialize(show, key)
13
13
  @show = show
14
14
  @key = key
15
- end
16
15
 
17
- # A Season has a key, which allows us to do lazy loading. A season will
18
- # not be fully loaded unless one of its attributes is called. Then the
19
- # Season will load itself from its key. Once loaded it caches its self.
20
- # For every attribute there is a cache busting version wich is just the
21
- # name of the attribute followed by '!'. For exsample <tt>season.type</tt>
22
- # and <tt>season.type!</tt>
23
- ATTRIBUTES.each { |method|
24
- class_eval %(
25
- def #{Plex.snake_case(method)}; directory.attr('#{method}') end
26
- def #{Plex.snake_case(method)}!; directory!.attr('#{method}') end
27
- )
28
- }
16
+ directory.attributes.each do |method, val|
17
+ define_singleton_method(Plex.underscore(method).to_sym) do
18
+ val.value
19
+ end
20
+ define_singleton_method(Plex.underscore(method+'!').to_sym) do
21
+ puts "Plex::Season##{Plex.underscore(method+'!')} IS DEPRECATED! Use Plex::Season##{Plex.underscore(method)} instead."
22
+ self.send(Plex.underscore(method))
23
+ end
24
+ end
25
+ end
29
26
 
30
27
  # Returns the list of episodes in the library that are a part of this Season
31
28
  #
@@ -34,9 +31,12 @@ module Plex
34
31
  @episodes ||= episodes_from_video(children)
35
32
  end
36
33
 
37
- # Cache busting version of #episodes
38
- def episodes!
39
- @episodes = episodes_from_video(children!)
34
+ # Select a particular episode
35
+ #
36
+ # @param [Fixnum, String] episode index number
37
+ # @return [Episode] episode with the index of number
38
+ def episode(number)
39
+ episodes.select { |epi| epi.index.to_i == number.to_i }.first
40
40
  end
41
41
 
42
42
  def url
@@ -65,18 +65,10 @@ module Plex
65
65
  @xml_doc ||= base_doc
66
66
  end
67
67
 
68
- def xml_doc!
69
- @xml_doc = base_doc
70
- end
71
-
72
68
  def children
73
69
  @children ||= base_children_doc
74
70
  end
75
71
 
76
- def children!
77
- @children = base_children_doc
78
- end
79
-
80
72
  def episodes_from_video(node)
81
73
  node.search("Video").map { |m| Plex::Episode.new(self, m.attr('key')) }
82
74
  end
@@ -85,9 +77,5 @@ module Plex
85
77
  @directory ||= xml_doc.search("Directory").first
86
78
  end
87
79
 
88
- def directory!
89
- @directory = xml_doc!.search("Directory").first
90
- end
91
-
92
80
  end
93
81
  end
@@ -7,7 +7,7 @@ module Plex
7
7
 
8
8
  CATEGORIES = %w(collection firstCharacter genre year contentRating folder)
9
9
 
10
- attr_reader *ATTRIBUTES.map {|m| Plex.snake_case(m) }
10
+ attr_reader *ATTRIBUTES.map {|m| Plex.underscore(m) }
11
11
  attr_reader :library
12
12
 
13
13
  # @param [Library] library this Section belongs to
@@ -16,7 +16,7 @@ module Plex
16
16
  def initialize(library, node)
17
17
  @library = library
18
18
  ATTRIBUTES.each { |e|
19
- instance_variable_set("@#{Plex.snake_case(e)}", node.attr(e))
19
+ instance_variable_set("@#{Plex.underscore(e)}", node.attr(e))
20
20
  }
21
21
  end
22
22
 
@@ -37,7 +37,7 @@ module Plex
37
37
  # @return [Array] list of Shows or Movies in that group
38
38
  GROUPS.each { |method|
39
39
  class_eval %(
40
- def #{Plex.snake_case(method)}
40
+ def #{Plex.underscore(method)}
41
41
  Plex::Parser.new( self, Nokogiri::XML(open(url+key+'/#{method}')) ).parse
42
42
  end
43
43
  )
@@ -64,13 +64,13 @@ module Plex
64
64
  # folder - where the video is stored
65
65
  CATEGORIES.each { |method|
66
66
  class_eval %(
67
- def #{Plex.snake_case(method)}s
68
- @#{Plex.snake_case(method)}s ||= grab_keys('#{method}')
67
+ def #{Plex.underscore(method)}s
68
+ @#{Plex.underscore(method)}s ||= grab_keys('#{method}')
69
69
  end
70
- def #{Plex.snake_case(method)}s!
71
- @#{Plex.snake_case(method)}s = grab_keys('#{method}')
70
+ def #{Plex.underscore(method)}s!
71
+ @#{Plex.underscore(method)}s = grab_keys('#{method}')
72
72
  end
73
- def by_#{Plex.snake_case(method)}(val)
73
+ def by_#{Plex.underscore(method)}(val)
74
74
  Plex::Parser.new( self, Nokogiri::XML(open(url+key+"/#{method}/\#{val}")) ).parse
75
75
  end
76
76
  )
@@ -1,10 +1,9 @@
1
1
  module Plex
2
- # Found at /library/metadata/:key
3
2
  class Show
4
3
 
5
- ATTRIBUTES = %w(guid studio title contentRating summary index rating year thumb
6
- art banner theme duration originallyAvailableAt leafCount
7
- viewedLeafCount addedAt updatedAt)
4
+ ATTRIBUTES = %w(ratingKey guid studio type title contentRating summary index
5
+ rating year thumb art leafCount viewedLeafCount addedAt
6
+ updatedAt)
8
7
 
9
8
  attr_reader :section, :key
10
9
 
@@ -13,17 +12,17 @@ module Plex
13
12
  def initialize(section, key)
14
13
  @section = section
15
14
  @key = key
16
- end
17
15
 
18
- # A Show has a key, which allows us to do lazy loading. A Show will
19
- # not be fully loaded unless one of its attributes is called. Then the
20
- # Show will load itself from its key. Once loaded it caches its self.
21
- ATTRIBUTES.each { |method|
22
- class_eval %(
23
- def #{Plex.snake_case(method)}; @#{method} ||= directory.attr('#{method}') end
24
- def #{Plex.snake_case(method)}!; @#{method} = directory!.attr('#{method}') end
25
- )
26
- }
16
+ directory.attributes.each do |method, val|
17
+ define_singleton_method(Plex.underscore(method).to_sym) do
18
+ val.value
19
+ end
20
+ define_singleton_method(Plex.underscore(method+'!').to_sym) do
21
+ puts "Plex::Show##{Plex.underscore(method+'!')} IS DEPRECATED! Use Plex::Show##{Plex.underscore(method)} instead."
22
+ self.send(Plex.underscore(method))
23
+ end
24
+ end
25
+ end
27
26
 
28
27
  # The list of seasons in the library that belong to this Show
29
28
  #
@@ -32,8 +31,12 @@ module Plex
32
31
  @seasons ||= search_children children
33
32
  end
34
33
 
35
- def seasons!
36
- @seasons = search_children children!
34
+ # Select a particular season
35
+ #
36
+ # @param [Fixnum, String] season index number
37
+ # @return [Season] season with the index of number
38
+ def season(number)
39
+ seasons.select { |sea| sea.index.to_i == sea.to_i }.first
37
40
  end
38
41
 
39
42
  def url
@@ -62,32 +65,24 @@ module Plex
62
65
  @xml_doc ||= base_doc
63
66
  end
64
67
 
65
- def xml_doc!
66
- @xml_doc = base_doc
67
- end
68
-
69
68
  def children
70
69
  @children ||= children_base
71
70
  end
72
71
 
73
- def children!
74
- @children = children_base
75
- end
76
-
77
72
  def directory
78
73
  @directory ||= xml_doc.search('Directory').first
79
74
  end
80
75
 
81
- def directory!
82
- @directory = xml_doc!.search('Directory').first
83
- end
84
-
85
76
  def search_children(node)
86
77
  node.search('Directory').map do |season|
87
- Plex::Season.new(self, season.attr('key')[0..-10]) # Remove /children
78
+ plex_season.new(self, season.attr('key')[0..-10]) # Remove /children
88
79
  end
89
80
  end
90
81
 
82
+ def plex_season
83
+ @plex_season ||= Plex::Season
84
+ end
85
+
91
86
  end
92
87
 
93
88
  end
@@ -3,14 +3,14 @@ module Plex
3
3
 
4
4
  ATTRIBUTES = %w(id streamType codec index language languageCode)
5
5
 
6
- attr_reader *ATTRIBUTES.map {|m| Plex.snake_case(m) }
7
-
8
6
  # @param [Nokogiri::XML::Element] nokogiri element that represents this
9
7
  # Stream
10
8
  def initialize(node)
11
- ATTRIBUTES.each { |e|
12
- instance_variable_set("@#{Plex.snake_case(e)}", node.attr(e))
13
- }
9
+ node.attributes.each do |method, val|
10
+ define_singleton_method(Plex.underscore(method).to_sym) do
11
+ val.value
12
+ end
13
+ end
14
14
  end
15
15
 
16
16
  def ==(other)
@@ -1,3 +1,3 @@
1
1
  module Plex
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -5,15 +5,16 @@ module Plex
5
5
  rating viewCount year tagline thumb art duration
6
6
  originallyAvailableAt updatedAt)
7
7
 
8
- attr_reader *ATTRIBUTES.map {|m| Plex.snake_case(m) }
9
8
  attr_reader :media, :genres, :writers, :directors, :roles
10
9
 
11
10
  # @param [Nokogiri::XML::Element] nokogiri element that represents this
12
11
  # Video
13
12
  def initialize(node)
14
- ATTRIBUTES.each { |e|
15
- instance_variable_set("@#{Plex.snake_case(e)}", node.attr(e))
16
- }
13
+ node.attributes.each do |method, val|
14
+ define_singleton_method(Plex.underscore(method).to_sym) do
15
+ val.value
16
+ end
17
+ end
17
18
 
18
19
  @media = Plex::Media.new(node.search('Media').first)
19
20
  @genres = node.search('Genre').map { |m| Plex::Genre.new(m) }
data/test/test_client.rb CHANGED
@@ -13,15 +13,15 @@ describe Plex::Client do
13
13
  end
14
14
 
15
15
  Plex::Client::NAV_METHODS.each { |method|
16
- it "should properly communicate its ##{Plex.snake_case(method)} method" do
17
- assert @client.send(Plex.snake_case(method).to_sym)
16
+ it "should properly communicate its ##{Plex.underscore(method)} method" do
17
+ assert @client.send(Plex.underscore(method).to_sym)
18
18
  FakeWeb.last_request.path.must_equal "/system/players/#{@client.name}/navigation/#{method}"
19
19
  end
20
20
  }
21
21
 
22
22
  Plex::Client::PLAYBACK_METHODS.each { |method|
23
- it "should properly communicate its ##{Plex.snake_case(method)} method" do
24
- assert @client.send(Plex.snake_case(method).to_sym)
23
+ it "should properly communicate its ##{Plex.underscore(method)} method" do
24
+ assert @client.send(Plex.underscore(method).to_sym)
25
25
  FakeWeb.last_request.path.must_equal "/system/players/#{@client.name}/playback/#{method}"
26
26
  end
27
27
  }
data/test/test_episode.rb CHANGED
@@ -13,7 +13,7 @@ describe Plex::Episode do
13
13
  "@video", fake_video
14
14
  )
15
15
 
16
- (Plex::Video::ATTRIBUTES - %w(key)).map {|m| Plex.snake_case(m) }.each { |method|
16
+ (Plex::Video::ATTRIBUTES - %w(key)).map {|m| Plex.underscore(m) }.each { |method|
17
17
  @episode.send(method.to_sym).must_equal fake_video.send(method.to_sym)
18
18
  }
19
19
 
data/test/test_helper.rb CHANGED
@@ -1,6 +1,18 @@
1
1
  require 'plex-ruby'
2
2
  require 'minitest/autorun'
3
3
 
4
+ class FakeAttr
5
+
6
+ def initialize(val)
7
+ @val = val
8
+ end
9
+
10
+ def value
11
+ @val
12
+ end
13
+
14
+ end
15
+
4
16
 
5
17
  class FakeNode
6
18
 
@@ -9,7 +21,13 @@ class FakeNode
9
21
  end
10
22
 
11
23
  def attr(value)
12
- @hash[Plex.snake_case(value).to_sym]
24
+ @hash[Plex.underscore(value).to_sym]
25
+ end
26
+
27
+ def attributes
28
+ @hash.each_with_object({}) do |(key, val), obj|
29
+ obj[Plex.camelize(key)] = FakeAttr.new(val)
30
+ end
13
31
  end
14
32
 
15
33
  def search(value)
@@ -37,41 +55,43 @@ FAKE_CLIENT_NODE_HASH = {
37
55
 
38
56
  FAKE_SHOW_NODE_HASH = {
39
57
  Directory: FakeNode.new({
40
- guid: 'com.plexapp.agents.thetvdb://73545/1?lang=en',
41
- studio: 'Big Dog',
42
- title: 'Friends',
43
- content_rating: 'MV-14',
44
- summary: '3 friends go on an adventure',
45
- index: '1',
46
- rating: '10',
47
- year: '3033',
48
- thumb: '/file/path.jpg',
49
- art: '/other/file/path.png',
50
- banner: '/yet/another/file/path.jpg2000',
51
- theme: 'Chrismasy?',
52
- duration: '2345234',
53
- originally_available_at: '1323213639',
54
- leaf_count: '1',
55
- viewed_leaf_count: '0',
56
- added_at: '1323213639',
57
- updated_at: '1323220437',
58
+ rating_key: "9",
59
+ guid: "com.plexapp.agents.thetvdb://73545?lang=en",
60
+ studio: "SciFi",
61
+ type: "show",
62
+ title: "Battlestar Galactica (2003)",
63
+ content_rating: "TV-14",
64
+ summary: "In a distant part of the universe, a civilization of humans live on planets known as the Twelve Colonies. In the past, the Colonies have been at war with a cybernetic race known as the Cylons. 40 years after the first war the Cylons launch a devastating attack on the Colonies. The only military ship that survived the attack takes up the task of leading a small fugitive fleet of survivors into space in search of a fabled refuge known as Earth.",
65
+ index: "1",
66
+ rating: "9.3",
67
+ year: "2003",
68
+ thumb: "/library/metadata/9/thumb?t=1323220437",
69
+ art: "/library/metadata/9/art?t=1323220437",
70
+ banner: "/library/metadata/9/banner?t=1323220437",
71
+ theme: "/library/metadata/9/theme?t=1323220437",
72
+ duration: "3600000",
73
+ originally_available_at: "2003-12-08",
74
+ leaf_count: "13",
75
+ viewed_leaf_count: "0",
76
+ added_at: "1323213639",
77
+ updated_at: "1323220437"
58
78
  })
59
79
  }
60
80
 
61
81
  FAKE_SEASON_NODE_HASH = {
62
82
  Directory: FakeNode.new({
63
- key: '/library/metadata/10/children',
64
- rating_key: '10',
65
- guid: 'com.plexapp.agents.thetvdb://73545/1?lang=en',
66
- type: 'season',
67
- title: 'Season 1',
68
- summary: '',
69
- index: '1',
70
- thumb: '/library/metadata/10/thumb?t=1323220437',
71
- leaf_count: '13',
72
- viewed_leaf_count: '0',
73
- added_at: '1323213639',
74
- updated_at: '1323220437'
83
+ rating_key: "10",
84
+ key: "/library/metadata/10/children",
85
+ guid: "com.plexapp.agents.thetvdb://73545/1?lang=en",
86
+ type: "season",
87
+ title: "Season 1",
88
+ summary: "",
89
+ index: "1",
90
+ thumb: "/library/metadata/10/thumb?t=1323220437",
91
+ leaf_count: "13",
92
+ viewed_leaf_count: "0",
93
+ added_at: "1323213639",
94
+ updated_at: "1323220437"
75
95
  })
76
96
  }
77
97
 
data/test/test_media.rb CHANGED
@@ -5,7 +5,7 @@ describe Plex::Media do
5
5
  @media = Plex::Media.new( FakeNode.new(FAKE_MEDIA_NODE_HASH) )
6
6
  end
7
7
 
8
- Plex::Media::ATTRIBUTES.map {|m| Plex.snake_case(m) }.each { |method|
8
+ Plex::Media::ATTRIBUTES.map {|m| Plex.underscore(m) }.each { |method|
9
9
  it "should properly respond to ##{method}" do
10
10
  @media.send(method.to_sym).must_equal FAKE_MEDIA_NODE_HASH[method.to_sym]
11
11
  end
data/test/test_movie.rb CHANGED
@@ -13,7 +13,7 @@ describe Plex::Movie do
13
13
  "@video", fake_video
14
14
  )
15
15
 
16
- (Plex::Video::ATTRIBUTES - %w(key)).map {|m| Plex.snake_case(m) }.each { |method|
16
+ (Plex::Video::ATTRIBUTES - %w(key)).map {|m| Plex.underscore(m) }.each { |method|
17
17
  @movie.send(method.to_sym).must_equal fake_video.send(method.to_sym)
18
18
  }
19
19
 
data/test/test_part.rb CHANGED
@@ -5,7 +5,7 @@ describe Plex::Part do
5
5
  @part = Plex::Part.new( FakeNode.new(FAKE_PART_NODE_HASH) )
6
6
  end
7
7
 
8
- Plex::Part::ATTRIBUTES.map {|m| Plex.snake_case(m) }.each { |method|
8
+ Plex::Part::ATTRIBUTES.map {|m| Plex.underscore(m) }.each { |method|
9
9
  it "should properly respond to ##{method}" do
10
10
  @part.send(method.to_sym).must_equal FAKE_PART_NODE_HASH[method.to_sym]
11
11
  end
data/test/test_plex.rb CHANGED
@@ -2,10 +2,10 @@ require 'test_helper'
2
2
 
3
3
  describe Plex do
4
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"
5
+ it "converts words from camelCase to underscore" do
6
+ Plex.underscore("camelCase").must_equal "camel_case"
7
+ Plex.underscore("snake_case").must_equal "snake_case"
8
+ Plex.underscore("normal").must_equal "normal"
9
9
  end
10
10
 
11
11
  end
data/test/test_season.rb CHANGED
@@ -1,13 +1,19 @@
1
1
  require 'test_helper'
2
2
 
3
+ class TestSeason < Plex::Season
4
+ def initialize(parent, key)
5
+ @xml_doc = FakeNode.new(FAKE_SEASON_NODE_HASH)
6
+ super(parent, key)
7
+ end
8
+ end
9
+
3
10
  describe Plex::Season do
4
11
  before do
5
12
  @show = FakeParent.new
6
- @season = Plex::Season.new(@show, '/library/metadata/10')
7
- @season.instance_variable_set("@xml_doc", FakeNode.new(FAKE_SEASON_NODE_HASH))
13
+ @season = TestSeason.new(@show, '/library/metadata/10')
8
14
  end
9
15
 
10
- Plex::Season::ATTRIBUTES.map{|m| Plex.snake_case(m)}.each { |method|
16
+ Plex::Season::ATTRIBUTES.map{|m| Plex.underscore(m)}.each { |method|
11
17
  it "should properly respond to ##{method}" do
12
18
  @season.send(method.to_sym).must_equal FAKE_SEASON_NODE_HASH[:Directory].attr(method)
13
19
  end
data/test/test_section.rb CHANGED
@@ -6,7 +6,7 @@ describe Plex::Section do
6
6
  @section = Plex::Section.new(@library, FakeNode.new(FAKE_SECTION_NODE_HASH))
7
7
  end
8
8
 
9
- (Plex::Section::ATTRIBUTES - %w(key)).map{|m| Plex.snake_case(m)}.each { |method|
9
+ (Plex::Section::ATTRIBUTES - %w(key)).map{|m| Plex.underscore(m)}.each { |method|
10
10
  it "should respond to ##{method}" do
11
11
  @section.send(method.to_sym).must_equal FAKE_SECTION_NODE_HASH[method.to_sym]
12
12
  end
data/test/test_show.rb CHANGED
@@ -1,24 +1,32 @@
1
1
  require 'test_helper'
2
2
 
3
+ class TestShow < Plex::Show
4
+ def initialize(parent, key)
5
+ @xml_doc = FakeNode.new(FAKE_SHOW_NODE_HASH)
6
+ super(parent, key)
7
+ end
8
+ end
9
+
10
+
3
11
  describe Plex::Show do
4
12
  before do
5
13
  @section = FakeParent.new
6
- @show = Plex::Show.new(@section, '/library/metadata/10')
7
- @show.instance_variable_set("@xml_doc", FakeNode.new(FAKE_SHOW_NODE_HASH))
14
+ @show = TestShow.new(@section, '/library/metadata/10')
8
15
  end
9
16
 
10
- Plex::Show::ATTRIBUTES.map{|m| Plex.snake_case(m)}.each { |method|
17
+ Plex::Show::ATTRIBUTES.map{|m| Plex.underscore(m)}.each { |method|
11
18
  it "should properly respond to ##{method}" do
12
19
  @show.send(method.to_sym).must_equal FAKE_SHOW_NODE_HASH[:Directory].attr(method)
13
20
  end
14
21
  }
15
22
 
16
- it "should return a list of episodes" do
23
+ it "should return a list of seasons" do
17
24
  @show.instance_variable_set(
18
25
  "@children", FakeNode.new(FAKE_SEASON_NODE_HASH)
19
26
  )
27
+ @show.instance_variable_set( "@plex_season", TestSeason )
20
28
  @show.seasons.must_equal(
21
- [ Plex::Season.new(FakeParent.new, FAKE_SEASON_NODE_HASH[:Directory].attr('key')[0..-10]) ]
29
+ [ TestSeason.new(FakeParent.new, FAKE_SEASON_NODE_HASH[:Directory].attr('key')[0..-10]) ]
22
30
  )
23
31
  end
24
32
 
data/test/test_stream.rb CHANGED
@@ -5,7 +5,7 @@ describe Plex::Stream do
5
5
  @stream = Plex::Stream.new( FakeNode.new(FAKE_STREAM_NODE_HASH) )
6
6
  end
7
7
 
8
- Plex::Stream::ATTRIBUTES.map{|m| Plex.snake_case(m)}.each { |method|
8
+ Plex::Stream::ATTRIBUTES.map{|m| Plex.underscore(m)}.each { |method|
9
9
  it "should properly respond to ##{method}" do
10
10
  @stream.send(method.to_sym).must_equal FAKE_STREAM_NODE_HASH[method.to_sym]
11
11
  end
data/test/test_video.rb CHANGED
@@ -6,14 +6,14 @@ describe Plex::Video do
6
6
  @video = Plex::Video.new( FakeNode.new(FAKE_VIDEO_NODE_HASH) )
7
7
  end
8
8
 
9
- Plex::Video::ATTRIBUTES.map {|m| Plex.snake_case(m) }.each { |method|
9
+ Plex::Video::ATTRIBUTES.map {|m| Plex.underscore(m) }.each { |method|
10
10
  it "should correctly respond to ##{method}" do
11
11
  @video.send(method.to_sym).must_equal FAKE_VIDEO_NODE_HASH[method.to_sym]
12
12
  end
13
13
  }
14
14
 
15
15
  it "should correctly referance its media object" do
16
- @video.media.must_equal Plex::Media.new(FAKE_VIDEO_NODE_HASH[:Media])
16
+ @video.instance_variable_get("@media").must_equal Plex::Media.new(FAKE_VIDEO_NODE_HASH[:Media])
17
17
  end
18
18
 
19
19
  it "should correctly referance its genre objects" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: plex-ruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Eric Koslow
@@ -10,11 +10,12 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-12-19 00:00:00 -05:00
13
+ date: 2011-12-21 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: minitest
18
+ prerelease: false
18
19
  requirement: &id001 !ruby/object:Gem::Requirement
19
20
  none: false
20
21
  requirements:
@@ -22,10 +23,10 @@ dependencies:
22
23
  - !ruby/object:Gem::Version
23
24
  version: "0"
24
25
  type: :development
25
- prerelease: false
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
+ prerelease: false
29
30
  requirement: &id002 !ruby/object:Gem::Requirement
30
31
  none: false
31
32
  requirements:
@@ -33,10 +34,10 @@ dependencies:
33
34
  - !ruby/object:Gem::Version
34
35
  version: "0"
35
36
  type: :development
36
- prerelease: false
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: fakeweb
40
+ prerelease: false
40
41
  requirement: &id003 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
@@ -44,10 +45,10 @@ dependencies:
44
45
  - !ruby/object:Gem::Version
45
46
  version: "0"
46
47
  type: :development
47
- prerelease: false
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: nokogiri
51
+ prerelease: false
51
52
  requirement: &id004 !ruby/object:Gem::Requirement
52
53
  none: false
53
54
  requirements:
@@ -55,7 +56,6 @@ dependencies:
55
56
  - !ruby/object:Gem::Version
56
57
  version: "0"
57
58
  type: :runtime
58
- prerelease: false
59
59
  version_requirements: *id004
60
60
  description: Extracts the Plex API into easy to write ruby code
61
61
  email:
@@ -119,18 +119,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- hash: -4420716880571956707
123
- segments:
124
- - 0
125
122
  version: "0"
126
123
  required_rubygems_version: !ruby/object:Gem::Requirement
127
124
  none: false
128
125
  requirements:
129
126
  - - ">="
130
127
  - !ruby/object:Gem::Version
131
- hash: -4420716880571956707
132
- segments:
133
- - 0
134
128
  version: "0"
135
129
  requirements: []
136
130