plex-ruby 1.4.0 → 1.5.0

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.
@@ -1,34 +1,47 @@
1
- ## 0.0.1.alpha
1
+ ## 1.5.0
2
2
 
3
- * Initial Release
4
- * Browsing a library works
5
- * Sending commands to a clients works intermittently, needs lots of work
3
+ * Fixed `first_*` and `last_*` helper methods to compare `index.to_i` instead
4
+ of just `index` (which is a string)
5
+ * Added `#attribute_hash` method to `Episode`, `Show`, `Season`, `Movie`, and
6
+ `Video`.
6
7
 
7
- ## 0.1.0
8
+ ## 1.4.0
8
9
 
9
- * Gem released of RubyGems
10
+ * Switched from Array#select().first to Array#detect for performance
11
+ * Plex::Season helper methods
12
+ * #first_episode
13
+ * #last_episode
14
+ * Plex::Show helper methods
15
+ * #first_season
16
+ * #last_season
17
+ * #special_season
18
+ * #first_episode
19
+ * #last_episode
20
+ * Updated Readme to use new helper methods
21
+ * Cleaned up docs by adding @private to internal public methods
10
22
 
11
- ## 0.2.0
23
+ ## 1.3.1
12
24
 
13
- * Added documentation
14
- * Added bang methods that clears caches
15
- * Fix naming of 'libary' to 'library'
16
- * Moved static content into Constants (Wow!\s)
25
+ * Got rid of stdout garbage
26
+ * Fixed `Show#season` not working
27
+ * Added tests
17
28
 
18
- ## 0.3.0
29
+ ## 1.3.0
19
30
 
20
- * Now allows for multiple servers
21
- * Fix a misspelling of 'library' that broke the gem (Sorry!)
31
+ * snake_case() -> underscore()
32
+ * Added Plex class method `camalize`
33
+ * Added singular season and episode methods
34
+ * Attribute methods are now dynamically created in the initializer. This gets ride of
35
+ the lazy loading, but allows this gem to grow with Plex without having to update
36
+ the code every time the API changes.
22
37
 
23
- ## 0.3.1
38
+ ## 1.2.0
24
39
 
25
- * Fix `gem install plex-ruby`, require `open-uri` as a runtime dependency
26
- wasn't a good idea
40
+ * `Plex::Client#play_media` now can take an Object that `responds_to(:key)`
27
41
 
28
- ## 1.0.0
42
+ ## 1.1.1
29
43
 
30
- * Added a test suite that can be run with `rake`
31
- * I feel this a production ready, will continue to add features
44
+ * Fix code breaking bug in 1.1.0
32
45
 
33
46
  ## 1.1.0
34
47
 
@@ -37,40 +50,35 @@
37
50
  * `library.section(1).by_first_letter('H') # [Plex::Movie, ...]`
38
51
  * Read the docs for more info
39
52
 
40
- ## 1.1.1
53
+ ## 1.0.0
41
54
 
42
- * Fix code breaking bug in 1.1.0
55
+ * Added a test suite that can be run with `rake`
56
+ * I feel this a production ready, will continue to add features
43
57
 
44
- ## 1.2.0
58
+ ## 0.3.1
45
59
 
46
- * `Plex::Client#play_media` now can take an Object that `responds_to(:key)`
60
+ * Fix `gem install plex-ruby`, require `open-uri` as a runtime dependency
61
+ wasn't a good idea
47
62
 
48
- ## 1.3.0
63
+ ## 0.3.0
49
64
 
50
- * snake_case() -> underscore()
51
- * Added Plex class method `camalize`
52
- * Added singular season and episode methods
53
- * Attribute methods are now dynamically created in the initializer. This gets ride of
54
- the lazy loading, but allows this gem to grow with Plex without having to update
55
- the code every time the API changes.
65
+ * Now allows for multiple servers
66
+ * Fix a misspelling of 'library' that broke the gem (Sorry!)
56
67
 
57
- ## 1.3.1
68
+ ## 0.2.0
58
69
 
59
- * Got rid of stdout garbage
60
- * Fixed `Show#season` not working
61
- * Added tests
70
+ * Added documentation
71
+ * Added bang methods that clears caches
72
+ * Fix naming of 'libary' to 'library'
73
+ * Moved static content into Constants (Wow!\s)
62
74
 
63
- ## 1.4.0
75
+ ## 0.1.0
76
+
77
+ * Gem released of RubyGems
78
+
79
+ ## 0.0.1.alpha
80
+
81
+ * Initial Release
82
+ * Browsing a library works
83
+ * Sending commands to a clients works intermittently, needs lots of work
64
84
 
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
@@ -54,6 +54,28 @@ puts "#{episode.title} - #{episode.summary}" # Looks good
54
54
  client.play_media(episode) # Play it!
55
55
  ```
56
56
 
57
+ You can also use the `attribute_hash` method on an object to get a full list of
58
+ attributes.
59
+
60
+ ```ruby
61
+ pp episode.attribute_hash
62
+ #=>
63
+ #{"rating_key"=>"23",
64
+ # "key"=>"/library/metadata/23",
65
+ # "guid"=>"com.plexapp.agents.thetvdb://73545/1/13?lang=en",
66
+ # "type"=>"episode",
67
+ # "title"=>"Kobol's Last Gleaming (2)",
68
+ # "summary"=>
69
+ # "When Commander Adama learns that Kara disobeyed orders and Jumped to Caprica on orders from President Roslin, he demands the president's resignation, with the implied threat of a military coup. Roslin refuses his demand and sparks a confrontation.",
70
+ # "index"=>"13",
71
+ # "rating"=>"8.3",
72
+ # "year"=>"2005",
73
+ # "thumb"=>"/library/metadata/23/thumb?t=1323220437",
74
+ # "originally_available_at"=>"2005-01-24",
75
+ # "added_at"=>"1323213639",
76
+ # "updated_at"=>"1323220437"}
77
+ ```
78
+
57
79
  For a full list of commands check out the [documentation](http://rubydoc.info/github/ekosz/Plex-Ruby/master/frames).
58
80
 
59
81
  ## Development
@@ -9,6 +9,11 @@ module Plex
9
9
  @season = season
10
10
  @key = key
11
11
  end
12
+
13
+ # Returns the attribute hash that represents this Episode
14
+ def attribute_hash
15
+ video.attribute_hash.merge({'key' => key})
16
+ end
12
17
 
13
18
  # Delegates all method calls to the video object that represents this
14
19
  # episode, if that video object responds to the method.
@@ -20,6 +25,14 @@ module Plex
20
25
  end
21
26
  end
22
27
 
28
+ def respond_to?(method)
29
+ super || video.respond_to?(method)
30
+ end
31
+
32
+ def methods
33
+ (super + video.methods).uniq
34
+ end
35
+
23
36
  # @private
24
37
  def url #:nodoc:
25
38
  season.url
@@ -10,6 +10,11 @@ module Plex
10
10
  @key = key
11
11
  end
12
12
 
13
+ # Returns the attribute hash that represents this Movie
14
+ def attribute_hash
15
+ video.attribute_hash.merge({'key' => key})
16
+ end
17
+
13
18
  # Delegates all method calls to the video object that represents this
14
19
  # movie, if that video object responds to the method.
15
20
  def method_missing(method, *args, &block)
@@ -20,6 +25,14 @@ module Plex
20
25
  end
21
26
  end
22
27
 
28
+ def respond_to?(method)
29
+ super || video.respond_to?(method)
30
+ end
31
+
32
+ def methods
33
+ (super + video.methods).uniq
34
+ end
35
+
23
36
  # @private
24
37
  def url #:nodoc:
25
38
  section.url
@@ -5,15 +5,17 @@ module Plex
5
5
  ATTRIBUTES = %w(ratingKey guid type title summary index thumb leafCount
6
6
  viewedLeafCount addedAt updatedAt)
7
7
 
8
- attr_reader :show, :key
8
+ attr_reader :show, :key, :attribute_hash
9
9
 
10
10
  # @param [Show] show this Season belongs to
11
11
  # @param [String] key to later grab this Season from
12
12
  def initialize(show, key)
13
13
  @show = show
14
14
  @key = key
15
+ @attribute_hash = {}
15
16
 
16
17
  directory.attributes.each do |method, val|
18
+ @attribute_hash[Plex.underscore(method)] = val.value
17
19
  define_singleton_method(Plex.underscore(method).to_sym) do
18
20
  val.value
19
21
  end
@@ -22,6 +24,8 @@ module Plex
22
24
  self.send(Plex.underscore(method))
23
25
  end
24
26
  end
27
+
28
+ @attribute_hash.merge({'key' => @key})
25
29
  end
26
30
 
27
31
  # Returns the list of episodes in the library that are a part of this Season
@@ -43,14 +47,14 @@ module Plex
43
47
  #
44
48
  # @return [Episode] episode with the lowest index
45
49
  def first_episode
46
- episodes.inject { |a, b| a.index < b.index ? a : b }
50
+ episodes.min_by { |e| e.index.to_i }
47
51
  end
48
52
 
49
53
  # Selects the last episode of this season that is on the Plex Server
50
54
  #
51
55
  # @return [Episode] episode with the highest index
52
56
  def last_episode
53
- episodes.inject { |a, b| a.index > b.index ? a : b }
57
+ episodes.max_by { |e| e.index.to_i }
54
58
  end
55
59
 
56
60
  # @private
@@ -5,15 +5,17 @@ module Plex
5
5
  rating year thumb art leafCount viewedLeafCount addedAt
6
6
  updatedAt)
7
7
 
8
- attr_reader :section, :key
8
+ attr_reader :section, :key, :attribute_hash
9
9
 
10
10
  # @param [Section] section this show belongs to
11
11
  # @param [String] key to use to later grab this Show
12
12
  def initialize(section, key)
13
13
  @section = section
14
14
  @key = key
15
+ @attribute_hash = {}
15
16
 
16
17
  directory.attributes.each do |method, val|
18
+ @attribute_hash[Plex.underscore(method)] = val.value
17
19
  define_singleton_method(Plex.underscore(method).to_sym) do
18
20
  val.value
19
21
  end
@@ -22,6 +24,8 @@ module Plex
22
24
  self.send(Plex.underscore(method))
23
25
  end
24
26
  end
27
+
28
+ @attribute_hash.merge({'key' => @key})
25
29
  end
26
30
 
27
31
  # The list of seasons in the library that belong to this Show
@@ -53,14 +57,14 @@ module Plex
53
57
  #
54
58
  # @return [Season] season with the lowest index (but not 0)
55
59
  def first_season
56
- seasons.inject { |a, b| a.index < b.index && a.index > 0 ? a : b }
60
+ seasons.inject { |a, b| a.index.to_i < b.index.to_i && a.index.to_i > 0 ? a : b }
57
61
  end
58
62
 
59
63
  # Selects the last season of this show that is on the Plex Server
60
64
  #
61
65
  # @return [Season] season with the highest index
62
66
  def last_season
63
- seasons.inject { |a, b| a.index > b.index ? a : b }
67
+ seasons.max_by { |s| s.index.to_i }
64
68
  end
65
69
 
66
70
  # Selects the first episode of this show that is on the Plex Server
@@ -1,3 +1,3 @@
1
1
  module Plex
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -5,12 +5,14 @@ module Plex
5
5
  rating viewCount year tagline thumb art duration
6
6
  originallyAvailableAt updatedAt)
7
7
 
8
- attr_reader :media, :genres, :writers, :directors, :roles
8
+ attr_reader :media, :genres, :writers, :directors, :roles, :attribute_hash
9
9
 
10
10
  # @param [Nokogiri::XML::Element] nokogiri element that represents this
11
11
  # Video
12
12
  def initialize(node)
13
+ @attribute_hash = {}
13
14
  node.attributes.each do |method, val|
15
+ @attribute_hash[Plex.underscore(method)] = val.value
14
16
  define_singleton_method(Plex.underscore(method).to_sym) do
15
17
  val.value
16
18
  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.4.0
5
+ version: 1.5.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-03 00:00:00 -05:00
13
+ date: 2012-01-24 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency