Class: Erika

Inherits:
Object
  • Object
show all
Defined in:
lib/erika/audio.rb,
lib/erika/image.rb,
lib/erika/video.rb,
lib/erika/config.rb,
lib/erika/runner.rb,
lib/erika/version.rb,
lib/erika/slideshow.rb

Defined Under Namespace

Classes: Audio, Image, Runner, SlideShow, Video

Constant Summary collapse

Config =
begin
  config_file_path = File.absolute_path('../../config.yml', __dir__).to_s
  data             = Psych.load_file(config_file_path)
  root             = `pwd`.chomp
  
  output_dir, output_file = _get_output_info_from(data, $erika_options)
  
  source = $erika_options.source ? File.expand_path($erika_options.source) : "#{root}/#{data['source']}"
  audio  = $erika_options.audio ? File.expand_path($erika_options.audio) : File.expand_path('../../../library/bensound-ukulele.mp3', __FILE__)
  
  source_files = "#{source}/*.{#{data['file_types'].join(',')}}"
  data.merge({
                 no_of_images:    Dir[source_files].count,
                 output_dir:      output_dir,
                 output_file:     output_file,
                 source_files:    source_files,
                 audio:           audio,
                 slide_duration:  $erika_options.slide_duration.to_f || data['slide_duration'],
                 slide_animation: $erika_options.transition_duration.to_f || data['slide_animation'],
             }).to_o
end
TempRoot =

home

File.expand_path('~/erika')
Default =
{
    temp: {
        dir:               TempRoot + '/tmp',
        image_dir:         TempRoot + '/tmp/images',
        video_dir:         TempRoot + '/tmp/videos',
        image_path:        TempRoot + '/tmp/images/%05d.jpg',
        video_path:        TempRoot + '/tmp/videos/%05d.mp4',
        video_list:        TempRoot + '/tmp/videos/list.txt',
        filename:          TempRoot + "/tmp/temp_video.mp4",
        audio_filename:    TempRoot + "/tmp/temp_audio.mp3",
        subtitle_filename: TempRoot + "/tmp/subtitle.srt"
    }
}.to_o
VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

._get_output_info_from(data, options) ⇒ dir, file

Returns:

  • (dir, file)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/erika/config.rb', line 5

def _get_output_info_from(data, options)
  if options.output
    file_part = options.output.split('/').last
    
    if !file_part.include?('.')
      [File.expand_path(options.output),
       File.expand_path("#{options.output}/#{data['output']['filename'].split('/').last}")]
    elsif file_part.include?('.')
      [File.expand_path(options.output.split('/')[0 .. -2].join('/')),
       File.expand_path(options.output)]
    end
  else
    [File.expand_path(data['output']['filename'].split('/')[0 .. -2].join('/')),
     File.expand_path(data['output']['filename'])]
  end
end