plex-ruby 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@
22
22
 
23
23
  ## 0.3.1
24
24
 
25
- * Fix `gem install plex-ruby`, require `open-uri` as a runtime dependecy
25
+ * Fix `gem install plex-ruby`, require `open-uri` as a runtime dependency
26
26
  wasn't a good idea
27
27
 
28
28
  ## 1.0.0
@@ -50,12 +50,27 @@
50
50
  * snake_case() -> underscore()
51
51
  * Added Plex class method `camalize`
52
52
  * Added singular season and episode methods
53
- * Attribute methods are now dynamicly created in the initializer. This gets ride of
53
+ * Attribute methods are now dynamically created in the initializer. This gets ride of
54
54
  the lazy loading, but allows this gem to grow with Plex without having to update
55
- the code everytime the API changes.
55
+ the code every time the API changes.
56
56
 
57
57
  ## 1.3.1
58
58
 
59
59
  * Got rid of stdout garbage
60
60
  * Fixed `Show#season` not working
61
61
  * Added tests
62
+
63
+ ## 1.4.0
64
+
65
+ * Switched from Array#select().first to Array#detect for performance
66
+ * Plex::Season helper methods
67
+ * #first_episode
68
+ * #last_episode
69
+ * Plex::Show helper methods
70
+ * #first_season
71
+ * #last_season
72
+ * #special_season
73
+ * #first_episode
74
+ * #last_episode
75
+ * Updated Readme to use new helper methods
76
+ * Cleaned up docs by adding @private to internal public methods
data/README.md CHANGED
@@ -26,7 +26,7 @@ lesser versions of Ruby.
26
26
 
27
27
  ## Usage
28
28
 
29
- Everything Stems from the Plex MediaServer. Create a server with the host and
29
+ Everything Stems from the Plex Media Server. Create a server with the host and
30
30
  port number.
31
31
 
32
32
  ```ruby
@@ -45,13 +45,13 @@ Lets search the libary.
45
45
 
46
46
  ```ruby
47
47
  sections = server.library.sections
48
- section = # Pick the section you want I.E. TV, Movies, Home Videos
49
- shows = section.all # Returns a list of shows/movies
50
- bsg = shows.select { |s| s.title =~ /Battlestar/ }.first # Pick a great show
51
- season = bsg.seasons.last # Pick the last season
52
- episode = season.episode(5) # The fifth episode in the season
53
- puts "#{episode.title} - #{episode.summary}" # Looks good
54
- client.play_media(episode) # Play it!
48
+ section = # Pick the section you want I.E. TV, Movies, Home Videos
49
+ shows = section.all # Returns a list of shows/movies
50
+ bsg = shows.detect { |s| s.title =~ /Battlestar/ } # Pick a great show
51
+ season = bsg.last_season # Pick the last season
52
+ episode = season.episode(5) # The fifth episode in the season
53
+ puts "#{episode.title} - #{episode.summary}" # Looks good
54
+ client.play_media(episode) # Play it!
55
55
  ```
56
56
 
57
57
  For a full list of commands check out the [documentation](http://rubydoc.info/github/ekosz/Plex-Ruby/master/frames).
@@ -120,10 +120,12 @@ module Plex
120
120
  ping player_url+"/application/sendVirtualKey?code=#{CGI::escape(code.to_s)}"
121
121
  end
122
122
 
123
+ # @private
123
124
  def url #:nodoc:
124
125
  server.url
125
126
  end
126
127
 
128
+ # @private
127
129
  def inspect #:nodoc:
128
130
  "#<Plex::Client: name=\"#{name}\" host=\"#{host}\" port=\"#{port}\">"
129
131
  end
@@ -20,10 +20,12 @@ module Plex
20
20
  end
21
21
  end
22
22
 
23
+ # @private
23
24
  def url #:nodoc:
24
25
  season.url
25
26
  end
26
27
 
28
+ # @private
27
29
  def ==(other) #:nodoc:
28
30
  if other.is_a? Plex::Episode
29
31
  key == other.key
@@ -32,6 +34,7 @@ module Plex
32
34
  end
33
35
  end
34
36
 
37
+ # @private
35
38
  def inspect #:nodoc:
36
39
  "#<Plex::Episode key=\"#{key}\" title=\"#{title}\" index=\"#{index}\" season=\"#{season.index}\" show=\"#{season.show.title}\">"
37
40
  end
@@ -33,14 +33,17 @@ module Plex
33
33
  @sections = search_sections(xml_doc!)
34
34
  end
35
35
 
36
+ # @private
36
37
  def key #:nodoc:
37
38
  "/library/sections"
38
39
  end
39
40
 
41
+ # @private
40
42
  def url #:nodoc:
41
43
  server.url
42
44
  end
43
45
 
46
+ # @private
44
47
  def ==(other) #:nodoc:
45
48
  if other.is_a? Library
46
49
  server == other.server
@@ -49,6 +52,7 @@ module Plex
49
52
  end
50
53
  end
51
54
 
55
+ # @private
52
56
  def inspect #:nodoc:
53
57
  "#<Plex::Libary: server=#{server.inspect}>"
54
58
  end
@@ -10,10 +10,6 @@ module Plex
10
10
  @key = key
11
11
  end
12
12
 
13
- def url #:nodoc:
14
- section.url
15
- end
16
-
17
13
  # Delegates all method calls to the video object that represents this
18
14
  # movie, if that video object responds to the method.
19
15
  def method_missing(method, *args, &block)
@@ -24,6 +20,12 @@ module Plex
24
20
  end
25
21
  end
26
22
 
23
+ # @private
24
+ def url #:nodoc:
25
+ section.url
26
+ end
27
+
28
+ # @private
27
29
  def inspect #:nodoc:
28
30
  "#<Plex::Movie: key=\"#{key}\" title=\"#{title}\">"
29
31
  end
@@ -36,13 +36,29 @@ module Plex
36
36
  # @param [Fixnum, String] episode index number
37
37
  # @return [Episode] episode with the index of number
38
38
  def episode(number)
39
- episodes.select { |epi| epi.index.to_i == number.to_i }.first
39
+ episodes.detect { |epi| epi.index.to_i == number.to_i }
40
40
  end
41
41
 
42
+ # Selects the first episode of this season that is on the Plex Server
43
+ #
44
+ # @return [Episode] episode with the lowest index
45
+ def first_episode
46
+ episodes.inject { |a, b| a.index < b.index ? a : b }
47
+ end
48
+
49
+ # Selects the last episode of this season that is on the Plex Server
50
+ #
51
+ # @return [Episode] episode with the highest index
52
+ def last_episode
53
+ episodes.inject { |a, b| a.index > b.index ? a : b }
54
+ end
55
+
56
+ # @private
42
57
  def url #:nodoc:
43
58
  show.url
44
59
  end
45
60
 
61
+ # @private
46
62
  def ==(other) #:nodoc:
47
63
  if other.is_a? Plex::Season
48
64
  key == other.key
@@ -51,6 +67,7 @@ module Plex
51
67
  end
52
68
  end
53
69
 
70
+ # @private
54
71
  def inspect #:nodoc:
55
72
  "#<Plex::Season: key=\"#{key}\" title=\"#{title}\" index=\"#{index}\" show=\"#{show.title}\">"
56
73
  end
@@ -76,14 +76,17 @@ module Plex
76
76
  )
77
77
  }
78
78
 
79
+ # @private
79
80
  def key #:nodoc:
80
81
  "/library/sections/#{@key}"
81
82
  end
82
83
 
84
+ # @private
83
85
  def url #:nodoc:
84
86
  library.url
85
87
  end
86
88
 
89
+ # @private
87
90
  def ==(other) #:nodoc:
88
91
  if other.is_a? Plex::Section
89
92
  key == other.key
@@ -92,6 +95,7 @@ module Plex
92
95
  end
93
96
  end
94
97
 
98
+ # @private
95
99
  def inspect #:nodoc:
96
100
  "#<Plex::Section: key=\"#{key}\" type=\"#{type}\" title=\"#{title}\">"
97
101
  end
@@ -27,10 +27,12 @@ module Plex
27
27
  @clients = search_clients clients_doc!
28
28
  end
29
29
 
30
+ # @private
30
31
  def url #:nodoc:
31
32
  "http://#{host}:#{port}"
32
33
  end
33
34
 
35
+ # @private
34
36
  def inspect #:nodoc:
35
37
  "#<Plex::Server: host=#{host} port=#{port}>"
36
38
  end
@@ -36,13 +36,55 @@ module Plex
36
36
  # @param [Fixnum, String] season index number
37
37
  # @return [Season] season with the index of number
38
38
  def season(number)
39
- seasons.select { |sea| sea.index.to_i == number.to_i }.first
39
+ seasons.detect { |sea| sea.index.to_i == number.to_i }
40
40
  end
41
41
 
42
+ # Helper method for selecting the special Season of this show
43
+ # Season 0 is where Plex stores episodes that are not part of a
44
+ # regular season. i.e. Christmas Specials
45
+ #
46
+ # @return [Season] season with index of 0
47
+ def special_season
48
+ season(0)
49
+ end
50
+
51
+ # Selects the first season of this show that is on the Plex Server
52
+ # Does not select season 0
53
+ #
54
+ # @return [Season] season with the lowest index (but not 0)
55
+ def first_season
56
+ seasons.inject { |a, b| a.index < b.index && a.index > 0 ? a : b }
57
+ end
58
+
59
+ # Selects the last season of this show that is on the Plex Server
60
+ #
61
+ # @return [Season] season with the highest index
62
+ def last_season
63
+ seasons.inject { |a, b| a.index > b.index ? a : b }
64
+ end
65
+
66
+ # Selects the first episode of this show that is on the Plex Server
67
+ #
68
+ # @return [Episode] episode with the lowest index of the season of the
69
+ # lowest index
70
+ def first_episode
71
+ first_season.first_episode
72
+ end
73
+
74
+ # Selects the last episode of this show that is on the Plex Server
75
+ #
76
+ # @return [Episode] episode with the highest index of the season of the
77
+ # highest index
78
+ def last_episode
79
+ last_season.last_episode
80
+ end
81
+
82
+ # @private
42
83
  def url #:nodoc:
43
84
  section.url
44
85
  end
45
86
 
87
+ # @private
46
88
  def ==(other) #:nodoc:
47
89
  if other.is_a? Plex::Show
48
90
  key == other.key
@@ -51,6 +93,7 @@ module Plex
51
93
  end
52
94
  end
53
95
 
96
+ # @private
54
97
  def inspect #:nodoc:
55
98
  "#<Plex::Show: key=\"#{key}\" title=\"#{title}\">"
56
99
  end
@@ -1,3 +1,3 @@
1
1
  module Plex
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: plex-ruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.3.1
5
+ version: 1.4.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: 2012-01-02 00:00:00 -05:00
13
+ date: 2012-01-03 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency