Module: Slugforge::Helper::Build

Defined in:
lib/slugforge/helper/build.rb

Instance Method Summary collapse

Instance Method Details

#date_stampObject



39
40
41
42
# File 'lib/slugforge/helper/build.rb', line 39

def date_stamp
  # Keep this as a class variable so the date stamp remains the same throughought the lifecycle of the app.
  @@date_stamp ||= Time.now.strftime('%Y%m%d%H%M%S')
end

#get_ruby_version_from_fileObject



18
19
20
21
22
23
24
25
# File 'lib/slugforge/helper/build.rb', line 18

def get_ruby_version_from_file
  ruby_version = read_from_file
  if ruby_version.nil? or ruby_version.empty?
    raise error_class, "You don't have a ruby version specified in your .ruby-version file!!! Why you no set ruby version."
  else
    return ruby_version
  end
end

#has_ruby_version_file?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/slugforge/helper/build.rb', line 14

def has_ruby_version_file?
  File.exist?(project_path('.ruby-version'))
end

#package_file_nameObject



35
36
37
# File 'lib/slugforge/helper/build.rb', line 35

def package_file_name
  "#{project_name}-#{date_stamp}-#{git_sha}.slug"
end

#read_from_fileObject



27
28
29
30
31
32
33
# File 'lib/slugforge/helper/build.rb', line 27

def read_from_file
  begin
    File.read(project_path('.ruby-version')).delete("\n")
  rescue Exception => e
    raise error_class, "There were issues reading the .ruby-version file. Make sure it exists in the project path and it has valid content, #{e}."
  end
end

#ruby_version_specified?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/slugforge/helper/build.rb', line 10

def ruby_version_specified?
  options[:ruby] and !options[:ruby].empty?
end

#verify_procfile_exists!Object



4
5
6
7
8
# File 'lib/slugforge/helper/build.rb', line 4

def verify_procfile_exists!
  unless File.exist?(project_path('Procfile'))
    logger.say_status :warning, "Slugforge should normally be run in a project with a Procfile (#{project_path('Procfile')})", :yellow
  end
end