Class: Roebe::ObtainAudioRecordingsFromVoiceRecorder

Inherits:
Base
  • Object
show all
Defined in:
lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb,
lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/run.rb,
lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/help.rb,
lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/constants.rb

Overview

Roebe::ObtainAudioRecordingsFromVoiceRecorder

Constant Summary collapse

COPY_OR_MOVE =
#

COPY_OR_MOVE

Can be :copy or :move

#
:copy
REPORT_THE_NAME_OF_THE_CLASS =
#

REPORT_THE_NAME_OF_THE_CLASS

If this constant is set to true then we will use Opn.opn() to tell the user which class is reporting all of this.

#
false
STORE_IN_A_SUBDIRECTORY_CALLED_AUDIO =
#

STORE_IN_A_SUBDIRECTORY_CALLED_AUDIO

If the following constant is true, then we will store in the subdirectory called “audio/”. That way, we can neatly arrange our recorded audio files.

#
true
AUDIO_SUBDIRECTORY =
#

AUDIO_SUBDIRECTORY

#
'audio'

Constants inherited from Base

Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opnesystem, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow

Methods included from Base::CommandlineArguments

#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments

Constructor Details

#initialize(i = nil, run_already = true) ⇒ ObtainAudioRecordingsFromVoiceRecorder

#

initialize

#


45
46
47
48
49
50
51
52
53
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 45

def initialize(
    i           = nil,
    run_already = true
  )
  register_sigint
  reset
  set_input(i)
  run if run_already
end

Class Method Details

.[](i = '') ⇒ Object

#

[]

#


423
424
425
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 423

def self.[](i = '')
  self.new(i)
end

Instance Method Details

#clear_old_files(shall_we_exit = true) ⇒ Object

#

clear_old_files

This will remove the old files.

#


511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 511

def clear_old_files(shall_we_exit = true)
  if @target.nil?
    determine_target
  end
  scan_for_audio_files if @copy_these_files.empty? # Try to find something.
  _ = @copy_these_files
  unless _.empty?
    opne "#{rev}Now clearing the old files, then syncing."
    _.each {|file|
      if File.exist? file
        e 'Next removing the file -> '+sfile(file)
        File.delete(file)
      else
        e 'Can not delete file '+sfile(file)+' as it does not exist.'
      end
    }
    do_sync
  end
  exit if shall_we_exit # Must exit usually.
end

#considering_moving_into_the_audio_subdirectoryObject

#

considering_moving_into_the_audio_subdirectory

#


491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 491

def considering_moving_into_the_audio_subdirectory
  if store_in_a_subdirectory_called_audio?
    _ = AUDIO_SUBDIRECTORY
    unless File.directory? _
      mkdir(_)
    end
    # ===================================================================== #
    # Next, batch-move all created files into that subdirectory.
    # ===================================================================== #
    @array_copied_files.each {|file|
      mv(file, _)
    } unless @array_copied_files.empty?
  end
end

#copy_file(this_audio_file, to_this_target = return_pwd, be_verbose = :be_verbose) ⇒ Object Also known as: copy

#

copy_file

This method is the main “copy action” of this class.

The first argument is the file that we wish to copy.

The second argument is the target directory.

The third argument is whether we shall be verbose (and thus output to the user what we are doing) or whether we shall not be verbose.

#


314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 314

def copy_file(
    this_audio_file,
    to_this_target = return_pwd,
    be_verbose     = :be_verbose
  )
  if this_audio_file.is_a? Array
    this_audio_file.each {|entry|
      copy_file(entry, to_this_target, be_verbose)
    }
  else
    if be_verbose == :be_verbose
      be_verbose = true
    end
    if File.directory?(to_this_target)
      to_this_target << '/' unless to_this_target.end_with? '/'
    end
    if to_this_target.end_with? '/'
      to_this_target = to_this_target+File.basename(this_audio_file)
    end
    if be_verbose
      opne 'Now copying '+sfile(this_audio_file)+' to '+
               sfile(to_this_target)
    end
    FileUtils.cp(this_audio_file, to_this_target)
  end
end

#copy_only_the_first_entryObject

#

copy_only_the_first_entry

#


457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 457

def copy_only_the_first_entry
  gather_mountpoints
  report_if_we_did_not_find_any_mountpoints
  first = @mountpoints.first
  results = Dir[first+'**/**.MP3']
  results = results.first
  # ======================================================================= #
  # Notify the user that we could not find any .mp3 file.
  # ======================================================================= #
  if results.empty?
    opne 'No .mp3 file was found on target '\
         '`'+simp(first)+'` (and subdirectories).'
    opne 'Perhaps the mounted device is empty?'
  else
    e 'We found the following results:'
    e # The newlines constitute some "padding".
    pp results
    e
    copy(results)
  end
end

#create_log_fileObject

#

create_log_file

#


430
431
432
433
434
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 430

def create_log_file
  what = YAML.dump(@array_copied_files)
  into = '/root/audio_recordings_obtained.yml'
  write_what_into(what, into)
end

#determine_targetObject

#

determine_target

#


115
116
117
118
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 115

def determine_target
  obtain_available_mountpoints if mountpoints?.nil?
  @target = @mountpoints.first
end

#do_syncObject

#

do_sync

#


291
292
293
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 291

def do_sync
  esystem 'sync'
end

#filter_for_these_allowed_files(i) ⇒ Object

#

filter_for_these_allowed_files

In the past this class was only usable for audio files. Since as of August 2021 we may also allow image files.

#


598
599
600
601
602
603
604
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 598

def filter_for_these_allowed_files(i)
  if is_audio_file?(i) or
     is_an_image_file?(i)
    return true
  end
  return false
end

#gather_mountpoints(i = ) ⇒ Object

#

gather_mountpoints

This method will set the available mountpoints.

#


215
216
217
218
219
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 215

def gather_mountpoints(
    i = Mountpoints[]
  )
  set_mountpoints(i) # @mountpounts may only be nil or an Array.
end

#input?Boolean

#

input?

#

Returns:

  • (Boolean)


94
95
96
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 94

def input?
  @input
end
#

menu (menu tag)

#


366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 366

def menu(i = input?)
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === obtain --available?
    # ===================================================================== #
    when /-?-?available\??/
      show_available_audio_files
      exit
    # ===================================================================== #
    # === obtain --purge
    # ===================================================================== #
    when '--clear','-clear','clear',/-?-?delete/,'--remove',
         /-?-?purge/,'PURGE',/-?-?delete-?original-?files/
      clear_old_files
    # ===================================================================== #
    # === obtain --show_mountpoints
    # ===================================================================== #
    when /show(_|-)?mountpoints/
      show_mountpoints
      exit
    # ===================================================================== #
    # === obtain --help
    # ===================================================================== #
    when /help/
      show_help
      exit
    # ===================================================================== #
    # === obtain "--use /Mount/USB4/"
    # ===================================================================== #
    when /-?-?use (.+)/
      set_mountpoint($1.to_s.dup) # Set another mountpoint.
    # ===================================================================== #
    # === obtain --first
    # ===================================================================== #
    when /^-?-?first/
      copy_only_the_first_entry
      exit
    else
      set_mountpoint(i)
    end
  end
end

#mkdir(i, be_verbose = :be_verbose) ⇒ Object

#

mkdir

#


269
270
271
272
273
274
275
276
277
278
279
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 269

def mkdir(i, be_verbose = :be_verbose)
  if be_verbose == :be_verbose
    be_verbose = true
  end
  if be_verbose
    unless return_pwd.include? 'audio'
      opne "Next creating the directory `#{sdir('audio/')}`."
    end
  end
  FileUtils.mkdir_p(i)
end

#mountpoints?Boolean Also known as: mountpoints

#

mountpoints?

#

Returns:

  • (Boolean)


240
241
242
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 240

def mountpoints?
  @mountpoints
end

#move_file(from_here, to_here, be_verbose = :be_verbose) ⇒ Object Also known as: rename, mv

#

move_file (move tag)

#


247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 247

def move_file(
    from_here, to_here, be_verbose = :be_verbose
  )
  if File.exist? from_here
    if be_verbose
      e 'Now moving from `'+simp(from_here)+'` to `'+
        sfancy(to_here)+'`.'
    end
    FileUtils.mv(from_here, to_here)
    @array_copied_files << to_here unless @array_copied_files.include? to_here
  else
    if be_verbose
      e 'Can not move '+sfile(from_here)+' as it does not exist. Exiting thus.'
    end
    exit
  end
end

#obtain_available_mountpointsObject

#

obtain_available_mountpoints

#


108
109
110
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 108

def obtain_available_mountpoints
  @mountpoints = Mountpoints[]
end

#obtain_available_mountpoints_and_determine_targetObject

#

obtain_available_mountpoints_and_determine_target

#


130
131
132
133
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 130

def obtain_available_mountpoints_and_determine_target
  obtain_available_mountpoints
  determine_target
end

#old_files?Boolean

#

old_files?

#

Returns:

  • (Boolean)


415
416
417
418
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 415

def old_files?
  first = gather_mountpoints.first
  Dir[first+'**/**.MP3']
end

#opne(i = '') ⇒ Object

#

opne

#


232
233
234
235
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 232

def opne(i = '')
  consider_using_opn
  e i
end

#opnn(report_the_name_of_the_class = REPORT_THE_NAME_OF_THE_CLASS) ⇒ Object Also known as: consider_using_opn

#

opn

#


535
536
537
538
539
540
541
542
543
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 535

def opnn(
    report_the_name_of_the_class = REPORT_THE_NAME_OF_THE_CLASS
  )
  case report_the_name_of_the_class
  when :report_the_name_of_the_class
    report_the_name_of_the_class = true
  end
  super(namespace?) if report_the_name_of_the_class
end

#report_how_many_mp3_files_can_be_found_there(target_directory = target? ) ⇒ Object

#

report_how_many_mp3_files_can_be_found_there

This method will tell us how many .mp3 files can be found in the target directory.

#


442
443
444
445
446
447
448
449
450
451
452
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 442

def report_how_many_mp3_files_can_be_found_there(
    target_directory = target?
  )
  if File.exist? target_directory
    all_mp3_files = Dir[target_directory+'**/**.MP3']
    unless all_mp3_files.empty?
      e '  This directory has '+sfancy(all_mp3_files.size.to_s)+
        ' .mp3 files.'
    end
  end
end

#report_if_we_did_not_find_any_mountpointsObject

#

report_if_we_did_not_find_any_mountpoints

#


482
483
484
485
486
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 482

def report_if_we_did_not_find_any_mountpoints
  if @mountpoints.empty?
    opne 'We did not find any mountpoints.'
  end
end

#resetObject

#

reset (reset tag)

#


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 58

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @copy_these_files
  # ======================================================================= #
  @copy_these_files = []
  # ======================================================================= #
  # === @target
  # ======================================================================= #
  @target = nil # Initialized value.
  # ======================================================================= #
  # === @array_copied_files
  # ======================================================================= #
  @array_copied_files = [] # This Array will keep track of which files were copied.
  # ======================================================================= #
  # === @mountpoints
  # ======================================================================= #
  @mountpoints = nil # Must be nil initially.
end

#return_day_month_yearObject

#

return_day_month_year

#


101
102
103
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 101

def return_day_month_year
  ::Time.now.strftime('%d.%m.%Y') # => '20.10.2015
end

#runObject

#

run (run tag)

#


12
13
14
15
16
17
18
19
20
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/run.rb', line 12

def run
  obtain_available_mountpoints
  menu
  determine_target
  scan_for_audio_files
  show_available_audio_files
  try_to_copy_the_audio_files
  create_log_file # Create a log file.
end

#scan_for_audio_filesObject

#

scan_for_audio_files (scan tag)

#


577
578
579
580
581
582
583
584
585
586
587
588
589
590
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 577

def scan_for_audio_files
  if @target
    available_files = Dir[@target+'**/**']
pp available_files
pp '^^^^^^^'
    @copy_these_files = available_files.select {|line|
      filter_for_these_allowed_files(line)
    }
    return @copy_these_files
  else
    opnn(:report_the_name_of_the_class)
    e 'Could not find any results. Is a USB device mounted?'
  end
end

#set_input(i = ARGV) ⇒ Object

#

set_input

#


82
83
84
85
86
87
88
89
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 82

def set_input(i = ARGV)
  if i.is_a? Array
    i.flatten!
  else
    i = [i]
  end
  @input = i # Will be an Array.
end

#set_mountpoints(i) ⇒ Object Also known as: set_mountpoint

#

set_mountpoints

#


224
225
226
227
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 224

def set_mountpoints(i)
  i = [i] unless i.is_a? Array # Must be an Array.
  @mountpoints = i
end

#show_available_audio_filesObject

#

show_available_audio_files

Use this method if you wish to show the available audio files.

#


550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 550

def show_available_audio_files
  if @copy_these_files.empty?
    obtain_available_mountpoints_and_determine_target
    scan_for_audio_files
  end
  if @copy_these_files.empty?
    opne "#{rev}No audio file was found on #{sfancy(target?)}."
  else
    result = "#{rev}The following #{slateblue(@copy_these_files.size.to_s)}"\
            " audio file".dup
    result << 's' if @copy_these_files.size > 1
    if @copy_these_files.size < 2
      result << ' was'
    else
      result << ' were'
    end
    result << " found on #{sfancy(target?)}."
    opne result
    e
    @copy_these_files.each {|file| e "  #{sfile(file)}" }
    e
  end
end

#show_helpObject

#

show_help (help tag)

#


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/help.rb', line 12

def show_help
  opnn
  e 'The following options are available:'
  e
  e yellow('  --delete')+'            # (aliases are --clear or '\
    '--delete-original-files)'
  e '                      # ^^^ This will remove the original files.'
  e
  e yellow('  --show_mountpoints')+'  # show the available mountpoints'
  e
  e yellow('  --first')+'             # show only the first entry'
  e yellow('  --available?')+'        # show the available audio files'
  e
end

#show_mountpointsObject

#

show_mountpoints

Use this method to show the available mountpoints.

Invocation example:

obtain --show-mountpoints
#


351
352
353
354
355
356
357
358
359
360
361
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 351

def show_mountpoints
  array_showing_all_mountpoints = Mountpoints[]
  array_showing_all_mountpoints.each {|this_mountpoint|
    e 'A mountpoint has been found at `'+sdir(this_mountpoint)+'`.'
  }
  unless array_showing_all_mountpoints.empty?
    report_how_many_mp3_files_can_be_found_there(
      array_showing_all_mountpoints.first
    )
  end
end

#store_in_a_subdirectory_called_audio?Boolean

#

store_in_a_subdirectory_called_audio?

#

Returns:

  • (Boolean)


298
299
300
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 298

def store_in_a_subdirectory_called_audio?
  STORE_IN_A_SUBDIRECTORY_CALLED_AUDIO
end

#target?Boolean

#

target?

#

Returns:

  • (Boolean)


123
124
125
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 123

def target?
  @target
end

#today_in_german?Boolean

#

today_in_german?

#

Returns:

  • (Boolean)


284
285
286
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 284

def today_in_german?
  ::Roebe::EnglishToGerman[::Time.now.strftime('%A')]
end

#try_to_copy_the_audio_filesObject

#

try_to_copy_the_audio_files

#


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/roebe/classes/obtain_audio_recordings_from_voice_recorder/obtain_audio_recordings_from_voice_recorder.rb', line 138

def try_to_copy_the_audio_files
  if @copy_these_files.empty?
    opne "We were unable to find any audio files on target #{sfancy(target?)}."
  else
    # ===================================================================== #
    # Ok, we can copy then.
    # ===================================================================== #
    @copy_these_files.each {|this_audio_file|
      copy_file(this_audio_file, return_pwd, :be_verbose)
      new_audio_file = (return_pwd+File.basename(this_audio_file)).squeeze '/'
      # =================================================================== #
      # === Downcase .MP3 extensions next.
      # =================================================================== #
      if new_audio_file.end_with? '.MP3'
        new_target = new_audio_file.dup
        new_target[-4,4] = '.mp3'
        opne 'Downcasing to `'+sfile(new_target)+'` next.'
        rename(new_audio_file, new_target)
        new_audio_file = new_target.dup
      end
      # =================================================================== #
      # Next, we check if we are in the STUDIUM subdirectory. If we
      # are, then we will also insert the name of the lecture right
      # before the '.mp3' part.
      # =================================================================== #
      if new_audio_file.include? STUDIUM_DIRECTORY
        old_target = new_audio_file.dup
        name_of_the_lecture = '_'+File.basename(return_pwd)
        new_audio_file[new_audio_file.index('.mp3'),0] = name_of_the_lecture
        e 'Renaming from `'+sfile(old_target)+'` to'+
          '  `'+sfile(new_audio_file)+'` next.'
        rename(old_target, new_audio_file)
      end
      if STORE_IN_A_SUBDIRECTORY_CALLED_AUDIO
        # ================================================================= #
        # We will create a new subdirectory next - but not if the base
        # directory is named "audio".
        # ================================================================= #
        unless File.basename(return_pwd) == 'audio'
          mkdir('audio/', :be_verbose) unless File.directory? 'audio'
          old_file = new_audio_file.dup
          new_audio_file = 'audio/'+File.basename(new_audio_file)
          move_file(old_file, new_audio_file, :be_verbose)
        end
      end
      if is_on_roebe?
        new_name = rds(
          new_audio_file.sub(/\.mp3$/,'')+'_'+
          return_day_month_year+'_'+today_in_german?+
          '_Vorlesungsaudioaufzeichnung_'+File.basename(new_audio_file)
        )
        opne 'Also renaming the copied file to'
        e
        opne '  `'+sfile(new_name)+'`'
        e
        rename(new_audio_file, new_name)
        new_audio_file = new_name
      end
    }
    if is_on_roebe?
      e
      opne 'If you want to delete the original files, you can '\
           'use these commands in your shell:'
      e
      @copy_these_files.each {|entry| e sfancy('  rm '+entry) }
      e "#{N}Alternatively, pass the option #{yellow('--delete')} or "\
        "#{yellow('--delete-original-files')} to do so."
      e
    end
  end
end