Class: Castaway::CLI::Build

Inherits:
Object
  • Object
show all
Extended by:
GLI::App
Defined in:
lib/castaway/cli/build.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition, name, options) ⇒ Build

Returns a new instance of Build.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/castaway/cli/build.rb', line 49

def initialize(definition, name, options)
  deliverable = File.basename(name, File.extname(name)) + '.mp4'

  production = definition.new(
    resolution: options[:resolution],
    fps: options[:fps],
    deliverable: options[:output] || deliverable)

  range = Castaway::Range.new(production)

  if options['start-time']
    range.start_time = options['start-time']
  elsif options['start-scene']
    range.start_scene = options['start-scene']
  elsif options['start-frame']
    range.start_frame = options['start-frame']
  end

  if options['end-time']
    range.end_time = options['end-time']
  elsif options['end-scene']
    range.end_scene = options['end-scene']
  elsif options['end-frame']
    range.end_frame = options['end-frame']
  end

  production.produce(range)
rescue Exception => e
  puts "#{e.class} (#{e.message})"
  puts e.backtrace
  abort
end

Class Method Details

.define(command) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/castaway/cli/build.rb', line 13

def self.define(command)
  command.desc 'The resolution at which to generate the frames'
  command.flag %i(r resolution), default_value: '540p'

  command.desc 'How many frames per second to generate'
  command.flag %i(f fps), default_value: 29.97, type: Float

  command.desc 'The frame from which to start producing frames'
  command.flag %i(start-frame), default_value: 0, type: Integer

  command.desc 'The frame after which to stop producing frames'
  command.flag %i(end-frame), type: Integer

  command.desc 'The scene from which to start producing frames'
  command.flag %i(start-scene)

  command.desc 'The scene after which to stop producing frames'
  command.flag %i(end-scene)

  command.desc 'The time from which to start producing frames'
  command.flag %i(start-time)

  command.desc 'The time after which to stop producing frames'
  command.flag %i(end-time)

  command.desc 'What to call the resulting movie'
  command.flag %i(o output)

  command.action do |_globals, options, args|
    exit_now!('you have to supply a castaway program') if args.empty?

    definition = Castaway::Production.from_script(args.first)
    new(definition, args.first, options)
  end
end

.descriptionObject



9
10
11
# File 'lib/castaway/cli/build.rb', line 9

def self.description
  'Builds the given castaway production'
end