Class: Dply::CodeArchive

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/dply/code_archive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#cmd, #error, #git, #logger, #sh, #symlink

Constructor Details

#initialize(name, revision:) ⇒ CodeArchive

Returns a new instance of CodeArchive.



12
13
14
15
16
17
18
19
# File 'lib/dply/code_archive.rb', line 12

def initialize(name, revision:)
  @name = name
  @branch = get_branch
  @revision = revision
  @dir = "#{Dir.pwd}/tmp/build_artifacts"
  @skip_depcheck = false
  validate
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



9
10
11
# File 'lib/dply/code_archive.rb', line 9

def branch
  @branch
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/dply/code_archive.rb', line 9

def name
  @name
end

#skip_depcheck=(value) ⇒ Object (writeonly)

Sets the attribute skip_depcheck

Parameters:

  • value

    the value to set the attribute skip_depcheck to.



10
11
12
# File 'lib/dply/code_archive.rb', line 10

def skip_depcheck=(value)
  @skip_depcheck = value
end

Instance Method Details

#build(empty: false, gnu_tar: false, &block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/dply/code_archive.rb', line 21

def build(empty: false, gnu_tar: false, &block)
  make_dir
  create_tar empty, gnu_tar
  instance_eval(&block) if block
  add_git_commit_id
  add_revision
  add_archive_name
end

#compress!Object



38
39
40
# File 'lib/dply/code_archive.rb', line 38

def compress!
  cmd %(#{gzip} -f -9 "#{tar}")
end

#depcheck!Object



30
31
32
33
34
35
36
# File 'lib/dply/code_archive.rb', line 30

def depcheck!
  return if @skip_depcheck
  command = %(ruby -W0 "#{__dir__}/scripts/depcheck.rb" #{tar})
  logger.bullet "depcheck #{tar}"
  env = logger.debug? ? { "LOG_DEBUG" => "true" } : {}
  cmd command, display: false, env: env
end