From 4273bfbbae24688388f2cfccc52a5948a45f6673 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Wed, 31 Aug 2022 00:43:19 -0400 Subject: [PATCH] Added functionality to initialize video repository --- src/repository.rb | 18 ++++++++++++++++++ src/util.rb | 7 +++++++ src/zealot.rb | 6 ++++++ 3 files changed, 31 insertions(+) create mode 100644 src/repository.rb create mode 100644 src/util.rb diff --git a/src/repository.rb b/src/repository.rb new file mode 100644 index 0000000..28ce619 --- /dev/null +++ b/src/repository.rb @@ -0,0 +1,18 @@ +require_relative 'util.rb' + +class Repository + + def initialize(path) + @basePath = path + + # create repository base directory + createDirectory(@basePath) + + # create sub-directories + subPaths = ['ingest', 'archive', 'output'] + subPaths.each { |p| + createDirectory(File.join(@basePath, p)) + } + end + +end diff --git a/src/util.rb b/src/util.rb new file mode 100644 index 0000000..743357e --- /dev/null +++ b/src/util.rb @@ -0,0 +1,7 @@ +def createDirectory(path) + if Dir.exists?(path) + puts "Directory #{path} already exists." + else + puts "Creating directory #{path}." + end +end diff --git a/src/zealot.rb b/src/zealot.rb index 4e8673b..2007d41 100755 --- a/src/zealot.rb +++ b/src/zealot.rb @@ -1,7 +1,13 @@ #!/usr/bin/env ruby require_relative 'config.rb' +require_relative 'repository.rb' +# create new configuration instance c = Config.new('~/.config/zealot.toml') +# create new repository instance +r = Repository.new(c.get('transcoder.repository')) + +# print repository directory as a test puts c.get('transcoder.repository')