itunes_video 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/itunes_video.rb +59 -5
  2. metadata +28 -19
data/lib/itunes_video.rb CHANGED
@@ -1,3 +1,6 @@
1
+ ##
2
+ # The entire gem is contained in the Itunes_video class.
3
+
1
4
  class Itunes_video
2
5
 
3
6
  require 'pathname'
@@ -5,6 +8,10 @@ class Itunes_video
5
8
 
6
9
  attr_accessor :id, :kind, :category, :name, :genre, :year, :description, :long_description, :comment, :unplayed, :played_count, :rating, :season_num, :episode_num, :show_name
7
10
 
11
+ ##
12
+ # The initialize method imports the video into iTunes and returns an iTunes
13
+ # track ID, which is used to identify the video for the other methods.
14
+
8
15
  def initialize(file)
9
16
  if !(Pathname.new file).absolute?
10
17
  if File.exist?(File.join(FileUtils.pwd, file))
@@ -20,6 +27,10 @@ class Itunes_video
20
27
  @id = import.split(" ")[3]
21
28
  end
22
29
  end
30
+
31
+ ##
32
+ # Set the 'kind' for the video.
33
+ # Must be one of ["tv show", "movie", "music video", "none"]
23
34
 
24
35
  def kind=(kind)
25
36
  kinds = ["tv show", "movie", "music video", "none"]
@@ -33,6 +44,9 @@ class Itunes_video
33
44
  end
34
45
  end
35
46
  end
47
+
48
+ ##
49
+ # Set the 'category' for the video.
36
50
 
37
51
  def category=(category)
38
52
  if `osascript -e 'tell application \"iTunes\" to set category of file track id #{@id} to \"#{category}\"'`
@@ -42,7 +56,11 @@ class Itunes_video
42
56
  end
43
57
  end
44
58
 
45
- # sets episode name for tv show or movie title for movie
59
+ ##
60
+ # Set the 'name' for the video.
61
+ # Sets episode name for a video of kind 'tv show'
62
+ # Sets movie title for a video of kind 'movie'
63
+
46
64
  def name=(name)
47
65
  if `osascript -e 'tell application \"iTunes\" to set name of file track id #{@id} to \"#{name}\"'`
48
66
  @name = name
@@ -50,6 +68,9 @@ class Itunes_video
50
68
  raise "could not set 'name' for video"
51
69
  end
52
70
  end
71
+
72
+ ##
73
+ # Set the 'genre' for the video.
53
74
 
54
75
  def genre=(genre)
55
76
  if `osascript -e 'tell application \"iTunes\" to set genre of file track id #{@id} to \"#{genre}\"'`
@@ -58,6 +79,10 @@ class Itunes_video
58
79
  raise "could not set 'genre' for video"
59
80
  end
60
81
  end
82
+
83
+ ##
84
+ # Set the 'year' for the video.
85
+ # Must be a four digit number or a string with four numbers.
61
86
 
62
87
  def year=(year)
63
88
  year = year.to_s
@@ -69,6 +94,9 @@ class Itunes_video
69
94
  raise "could not set 'year' for video"
70
95
  end
71
96
  end
97
+
98
+ ##
99
+ # Set the 'description' for the video.
72
100
 
73
101
  def description=(desc)
74
102
  if `osascript -e 'tell application \"iTunes\" to set description of file track id #{@id} to \"#{desc}\"'`
@@ -78,6 +106,9 @@ class Itunes_video
78
106
  end
79
107
  end
80
108
 
109
+ ##
110
+ # Set the 'long description' for the video.
111
+
81
112
  def long_description=(long_desc)
82
113
  if `osascript -e 'tell application \"iTunes\" to set long description of file track id #{@id} to \"#{long_desc}\"'`
83
114
  @long_description = long_desc
@@ -85,6 +116,9 @@ class Itunes_video
85
116
  raise "could not set 'long description' for video"
86
117
  end
87
118
  end
119
+
120
+ ##
121
+ # Set the 'comment' for the video.
88
122
 
89
123
  def comment=(comment)
90
124
  if `osascript -e 'tell application \"iTunes\" to set comment of file track id #{@id} to \"#{comment}\"'`
@@ -94,9 +128,12 @@ class Itunes_video
94
128
  end
95
129
  end
96
130
 
131
+ ##
132
+ # Set 'uplayed' for the video.
133
+ # Must be either 'true' or 'false'
134
+
97
135
  def unplayed=(unplayed)
98
- unplayed = unplayed.downcase
99
- if !["true", "false"].include? unplayed
136
+ if ![true, false].include? unplayed
100
137
  raise TypeError, "unplayed must be 'true' or 'false'"
101
138
  elsif `osascript -e 'tell application \"iTunes\" to set unplayed of file track id #{@id} to \"#{unplayed}\"'`
102
139
  @unplayed = unplayed
@@ -104,6 +141,9 @@ class Itunes_video
104
141
  raise "could not set 'unplayed' for video"
105
142
  end
106
143
  end
144
+
145
+ ##
146
+ # Set the 'played count' for the video.
107
147
 
108
148
  def played_count=(played_count)
109
149
  if `osascript -e 'tell application \"iTunes\" to set played count of file track id #{@id} to #{played_count.to_i}'`
@@ -112,6 +152,10 @@ class Itunes_video
112
152
  raise "could not set 'played count' for video"
113
153
  end
114
154
  end
155
+
156
+ ##
157
+ # Set the 'rating' for the video.
158
+ # Must be a number between 0 and 100.
115
159
 
116
160
  def rating=(rating)
117
161
  if !rating.to_i.between?(0,100)
@@ -122,8 +166,12 @@ class Itunes_video
122
166
  raise "could not set 'rating' for video"
123
167
  end
124
168
  end
125
-
126
- # tv show specific methods
169
+
170
+ # :section: tv show-specific methods
171
+
172
+ ##
173
+ # Set the 'season number' for a video of type 'tv show'.
174
+
127
175
  def season_num=(season_num)
128
176
  if `osascript -e 'tell application \"iTunes\" to set season number of file track id #{@id} to #{season_num.to_i}'`
129
177
  @season_num = season_num
@@ -132,6 +180,9 @@ class Itunes_video
132
180
  end
133
181
  end
134
182
 
183
+ ##
184
+ # Set the 'episode number' for a video of type 'tv show'.
185
+
135
186
  def episode_num=(episode_num)
136
187
  if `osascript -e 'tell application \"iTunes\" to set episode number of file track id #{@id} to \"#{episode_num.to_i}\"'`
137
188
  @episode_num = episode_num
@@ -140,6 +191,9 @@ class Itunes_video
140
191
  end
141
192
  end
142
193
 
194
+ ##
195
+ # Set the 'show name' for a video of type 'tv show'.
196
+
143
197
  def show_name=(show_name)
144
198
  if `osascript -e 'tell application \"iTunes\" to set show of file track id #{@id} to \"#{show_name}\"'`
145
199
  @show_name = show_name
metadata CHANGED
@@ -1,46 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: itunes_video
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.2
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.3.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Richard Myers
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-18 00:00:00.000000000 Z
12
+
13
+ date: 2013-08-02 00:00:00 Z
13
14
  dependencies: []
15
+
14
16
  description: A gem to import and organize your video collection in iTunes. OS X only.
15
17
  email: rick.myers@me.com
16
18
  executables: []
19
+
17
20
  extensions: []
21
+
18
22
  extra_rdoc_files: []
19
- files:
23
+
24
+ files:
20
25
  - lib/itunes_video.rb
21
26
  homepage: https://rubygems.org/gems/itunes_video
22
- licenses:
27
+ licenses:
23
28
  - WTFPL
24
29
  post_install_message:
25
30
  rdoc_options: []
26
- require_paths:
31
+
32
+ require_paths:
27
33
  - lib
28
- required_ruby_version: !ruby/object:Gem::Requirement
34
+ required_ruby_version: !ruby/object:Gem::Requirement
29
35
  none: false
30
- requirements:
31
- - - ! '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
41
  none: false
36
- requirements:
37
- - - ! '>='
38
- - !ruby/object:Gem::Version
39
- version: '0'
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
40
46
  requirements: []
47
+
41
48
  rubyforge_project:
42
- rubygems_version: 1.8.24
49
+ rubygems_version: 1.8.23
43
50
  signing_key:
44
51
  specification_version: 3
45
52
  summary: Import and organize videos in iTunes
46
53
  test_files: []
54
+
55
+ has_rdoc: