class QrcodeGenerator::Initer

Attributes

workspace[R]

Public Class Methods

new(workspace) click to toggle source
# File lib/qrcode-generator/initer.rb, line 11
def initialize(workspace)
  @workspace = workspace
end

Public Instance Methods

init() click to toggle source
# File lib/qrcode-generator/initer.rb, line 15
def init
  if !workspace_empty?
    puts "ERROR: Count not init, because current folder is not empty"
    return
  end

  init_workspace
end
init_workspace() click to toggle source

copy files into workspace

# File lib/qrcode-generator/initer.rb, line 36
def init_workspace
  source = File.expand_path("../workspace", __dir__)

  FileUtils.cp_r("#{source}/.", workspace)
end
workspace_empty?() click to toggle source
# File lib/qrcode-generator/initer.rb, line 24
def workspace_empty?
  total_size = 0

  Find.find(workspace) do |path|
    next if path == workspace or File.basename(path)[0] == ?.
    total_size += 1
  end

  total_size == 0
end