Skip to content

Commit

Permalink
Add :streams option (AKA -numStreams) to Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sshaw committed Jan 25, 2015
1 parent 75d188a commit d49481c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ This can be fixed by modifying +iTMSTransporter.CMD+ (note that the following do
<b>Note that options with a value must contain the equals character</b> (<code>"="</code>).
The format is <code>--option=value</code> and not <code>--option value</code>.

==== Examples:
==== Examples

itms upload --username=sshaw --password=w3cAllYoU --transport=aspera a_package.itmsp
itms version
Expand Down
12 changes: 6 additions & 6 deletions lib/itunes/store/transporter/command/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ module ITunes
module Store
module Transporter
module Command # :nodoc:

##
# Retrieve the status of a previously uploaded package
#
class Status < Mode
def initialize(*config)
super
super
options.on *VENDOR_ID
end

protected
def handle_success(stdout_lines, stderr_lines, options)
protected
def handle_success(stdout_lines, stderr_lines, options)
status = {}
while line = stdout_lines.shift
next unless line =~ /\S+/
Expand All @@ -33,15 +33,15 @@ def handle_success(stdout_lines, stderr_lines, options)
end
end
status
end
end

def parse_line(line)
key, value = line.split(/:\s+/, 2).map(&:strip)
key.gsub!(/\s+/, "_")
key.downcase!
[key.to_sym, value]
end
end
end
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/itunes/store/transporter/command/upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def initialize(*config)
options.on *SUCCESS
options.on *FAILURE
options.on :delete, "-delete", Optout::Boolean
options.on :rate, "-k", Integer # Required if TRANSPORT is Aspera or Signiant
options.on :rate, "-k", Integer # Required if TRANSPORT is Aspera or Signiant
options.on :streams, "-numStreams", Integer # Only valid if TRANSPORT is Signiant
options.on :log_history, "-loghistory", Optout::Dir.exists
end
end
Expand Down
110 changes: 55 additions & 55 deletions lib/itunes/store/transporter/itms_transporter.rb
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
module ITunes
module Store
module Store
module Transporter
##
# Upload and manage your assets in the iTunes Store using the iTunes Store's Transporter (+iTMSTransporter+).
class ITMSTransporter

##
# === Arguments
# === Arguments
#
# [options (Hash)] Transporter options
#
# === Options
#
#
# Options given here will be used as defaults for all subsequent method calls. Thus you can set method specific options here but, if you call a method that does not accept one of these options, an OptionError will be raised.
#
# See specific methods for a list of options.
#
# See specific methods for a list of options.
#
# [:username (String)] Your username
# [:password (String)] Your password
# [:shortname (String)] Your shortname. Optional, not every iTunes account has one
# [:path (String)] The path to the +iTMSTransporter+. Optional.
# [:print_stdout (Boolean)] Print +iTMSTransporter+'s stdout to your stdout. Defaults to +false+.
# [:print_stderr (Boolean)] Print +iTMSTransporter+'s stderr to your stderr. Defaults to +false+.
# [:print_stdout (Boolean)] Print +iTMSTransporter+'s stdout to your stdout. Defaults to +false+.
# [:print_stderr (Boolean)] Print +iTMSTransporter+'s stderr to your stderr. Defaults to +false+.
#

def initialize(options = nil)
@defaults = create_options(options)
@config = {
@config = {
:path => @defaults.delete(:path),
:print_stdout => @defaults.delete(:print_stdout),
:print_stderr => @defaults.delete(:print_stderr),
}
:print_stdout => @defaults.delete(:print_stdout),
:print_stderr => @defaults.delete(:print_stderr),
}
end

##
# :method: lookup
# :call-seq:
# :call-seq:
# lookup(options = {})
#
# Retrieve the metadata for a previously delivered package.
#
# === Arguments
# Retrieve the metadata for a previously delivered package.
#
# === Arguments
#
# [options (Hash)] Transporter options
#
Expand All @@ -55,15 +55,15 @@ def initialize(options = nil)
# === Returns
#
# [String] The metadata

##
# :method: providers
# :call-seq:
# :call-seq:
# providers(options = {})
#
# List of Providers for whom your account is authorzed to deliver for.
#
# === Arguments
# === Arguments
#
# [options (Hash)] Transporter options
#
Expand All @@ -74,15 +74,15 @@ def initialize(options = nil)
# === Returns
#
# [Array] Each element is a +Hash+ with two keys: +:shortname+ and +:longname+ representing the given provider's long and short names

##
# :method: schema
# :call-seq:
# :call-seq:
# schema(options = {})
#
# Download a RelaxNG schema file for a particular metadata specification.
#
# === Arguments
#
# === Arguments
#
# [options (Hash)] Transporter options
#
Expand All @@ -93,24 +93,24 @@ def initialize(options = nil)
#
# === Errors
#
# TransporterError, OptionError, ExecutionError
# TransporterError, OptionError, ExecutionError
#
# === Returns
#
# [String] The schema

##
# :method: status
# :call-seq:
# :call-seq:
# status(options = {})
#
# Retrieve the status of a previously uploaded package.
#
# === Arguments
#
# === Arguments
#
# [options (Hash)] Transporter options
#
# === Options
# === Options
#
# [:vendor_id (String)] ID of the package you want status info on
#
Expand All @@ -121,44 +121,45 @@ def initialize(options = nil)
# === Returns
#
# [Hash] Descibes various facets of the package's status.

##
# :method: upload
# :call-seq:
# :call-seq:
# upload(package, options = {})
#
# Upload a package to the iTunes Store.
#
# === Arguments
#
#
# [package (String)] The path to the package directory to upload. Package names must end in +.itmsp+.
# [options (Hash)] Transporter options
#
#
# === Options
#
# [:transport (String)] The method/protocol used to upload your package. Optional. Can be one of: <code>"Aspera"</code>, <code>"Signiant"</code>, or <code>"DEV"</code>. By default +iTMSTransporter+ automatically selects the transport.
# [:rate (Integer)] Target bitrate in Kbps. Optional, only used with +Aspera+ and +Signiant+
# [:rate (Integer)] Target bitrate in Kbps. Optional, only used with +Aspera+ and +Signiant+
# [:success (String)] A directory to move the package to if the upload succeeds
# [:failure (String)] A directory to move the package to if the upload fails
# [:delete (Boolean)] Delete the package if the upload succeeds. Defaults to +false+.
# [:log_history (String)] Write an +iTMSTransporter+ log to this directory. Off by default.
# [:streams (Integer)] Number of data streams to use. Optional, only used with +Signiant+
#
# === Errors
#
# TransporterError, OptionError, ExecutionError
#
# === Returns
#
#
# +true+ if the upload was successful.

##
# :method: verify
# :call-seq:
# :method: verify
# :call-seq:
# verify(package, options = {})
#
# Validate the contents of a package's metadata and assets.
#
# If verification fails an ExecutionError containing the errors will be raised.
# Validate the contents of a package's metadata and assets.
#
# If verification fails an ExecutionError containing the errors will be raised.
# Each error message is an instance of TransporterMessage.
#
# === Arguments
Expand All @@ -175,44 +176,43 @@ def initialize(options = nil)
# TransporterError, OptionError, ExecutionError
#
# === Returns
#
#
# +true+ if the package was verified.

##
# :method: version
# :call-seq:
# :call-seq:
# version
#
# Return the underlying +iTMSTransporter+ version.
#
# === Returns
#
# [String] The version number

%w|upload verify|.each do |command|
define_method(command) do |package, *options|
define_method(command) do |package, *options|
cmd_options = create_options(options.first)
cmd_options[:package] = package
run_command(command, cmd_options)
end
end

%w|lookup providers schema status version|.each do |command|
define_method(command) { |*options| run_command(command, options.shift) }
end
private
def run_command(name, options)
end

private
def run_command(name, options)
Command.const_get(name.capitalize).new(@config, @defaults).run(create_options(options))
end

def create_options(options)
options ||= {}
raise ArgumentError, "options must be a Hash" unless Hash === options
options.dup
end
end
end
end
end
end

0 comments on commit d49481c

Please sign in to comment.