Class: Cejo::Floss::Archive

Inherits:
Object
  • Object
show all
Defined in:
lib/cejo/floss/archive.rb

Overview

Archive FLOSS Projects

Constant Summary collapse

ARCHIVE_THESE =

FLOSS Projects elected to be archived

%w[lar distro cejo ixi gota].freeze
FMT =

Format to be compressed

'tar'
ARCHIVED_FOLDER =

Folder which compressed files will be stored

Pathname.new(File.join(Dir.home, 'Downloads', 'archived'))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(utils, name, folder, info) ⇒ Archive

Returns a new instance of Archive.



20
21
22
23
24
25
26
# File 'lib/cejo/floss/archive.rb', line 20

def initialize(utils, name, folder, info)
  @utils = utils
  @name = name
  @folder = folder
  @info = info
  @archived_filename = "#{ARCHIVED_FOLDER.join(name)}.#{FMT}"
end

Instance Attribute Details

#archived_filenameObject (readonly)

Returns the value of attribute archived_filename.



18
19
20
# File 'lib/cejo/floss/archive.rb', line 18

def archived_filename
  @archived_filename
end

#folderObject (readonly)

Returns the value of attribute folder.



18
19
20
# File 'lib/cejo/floss/archive.rb', line 18

def folder
  @folder
end

#infoObject (readonly)

Returns the value of attribute info.



18
19
20
# File 'lib/cejo/floss/archive.rb', line 18

def info
  @info
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/cejo/floss/archive.rb', line 18

def name
  @name
end

#utilsObject (readonly)

Returns the value of attribute utils.



18
19
20
# File 'lib/cejo/floss/archive.rb', line 18

def utils
  @utils
end

Instance Method Details

#do_archiveObject

Archiving FLOSS project



29
30
31
32
33
34
35
36
37
# File 'lib/cejo/floss/archive.rb', line 29

def do_archive
  require 'git'

  utils.spin('Archiving') do
    repo = Git.open folder
    repo.archive repo.current_branch, archived_filename, format: FMT # TODO: fiber/multithread
  end
  puts
end

#runObject



39
40
41
42
43
44
45
46
# File 'lib/cejo/floss/archive.rb', line 39

def run
  return unless ARCHIVE_THESE.include? name

  Dir.mkdir ARCHIVED_FOLDER unless ARCHIVED_FOLDER.exist?

  print info
  do_archive
end