class RBT::Cookbooks::CreateSnapcraftFile

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

[](i = '') click to toggle source
#

[]

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 384
def self.[](i = '')
  self.new(i)
end
new( program_name = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 41
def initialize(
    program_name = nil,
    run_already  = true
  )
  reset
  set_program_name(
    program_name
  )
  run if run_already
end

Public Instance Methods

add( i = '', add_newline = true ) click to toggle source
#

add (add tag)

Add onto the main string through this method.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 115
def add(
    i = '',
    add_newline = true
  )
  @snapcraft_file_content << i
  @snapcraft_file_content << N if add_newline
end
add_apps() click to toggle source
#

add_apps (apps tag)

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 287
  def add_apps
    heredoc_variable = <<-EOF
apps:
 #{binaries?.first}:
  command: #{binaries?.first}
EOF
    add(heredoc_variable)
  end
add_confinement( use_this_confinement = 'strict' ) click to toggle source
#

add_confinement

Can be either 'devmode' or 'strict'.

Unconfined applications, specified with 'devmode', can only be released to the hidden “edge” channel.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 199
def add_confinement(
    use_this_confinement = 'strict'
  )
  add('confinement: '+use_this_confinement)
end
add_grade( use_this_grade = 'stable' ) click to toggle source
#

add_grade (grade tag)

The grade can be 'devel' or 'stable'. Only stable will be used for release into candidate/stable channels.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 185
def add_grade(
    use_this_grade = 'stable'
  )
  add('grade: '+use_this_grade)
end
add_name() click to toggle source
#

add_name

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 166
def add_name
  add('name: '+short_name?)
end
add_newline() click to toggle source
#

add_newline

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 126
def add_newline
  add
end
add_parts() click to toggle source
#

add_parts (parts tag)

This method denotes the necessary parts (components) of our program at hand.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 273
  def add_parts
    heredoc_variable = <<-EOF
parts:
 #{name_of_this_individual_program?}:
  # See 'snapcraft plugins' for more information.
  plugin: #{plugin_type?}
  source: #{remote_url?}
EOF
    add(heredoc_variable)
  end
add_program_description() click to toggle source
#

add_program_description (desc tag)

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 315
def add_program_description
  description_to_use = "description: |#{N}".dup
  _ = @dataset.description?
  _.split(N).each {|line|
    description_to_use << ' '+line+N
  }
  add(description_to_use.strip.chomp)
end
add_program_licence() click to toggle source
#

add_program_licence

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 222
def add_program_licence
  if licence?
    add('license: '+licence?)
  end
end
add_program_summary() click to toggle source
#

add_program_summary

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 215
def add_program_summary
  add('summary: |'+N+' '+short_desc?)
end
add_program_version() click to toggle source
#

add_program_version (version tag)

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 208
def add_program_version
  add("version: '#{program_version?}'")
end
binaries?() click to toggle source
#

binaries?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 299
def binaries?
  @dataset.binaries?
end
generate_the_snapcraft_file( into = into? ) click to toggle source
#

generate_the_snapcraft_file

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 344
def generate_the_snapcraft_file(
    into = into?
  )
  what = what?
  remove_file(into) if File.exist? into
  opnn; e "Now saving the content into the file `#{sfile(into)}`."
  write_what_into(what, into)
end
into?() click to toggle source
#

into?

Where to store into - a file.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 106
def into?
  @store_into_this_file
end
licence?() click to toggle source
#

licence?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 242
def licence?
  @dataset.licence?
end
name_of_this_individual_program?() click to toggle source
#

name_of_this_individual_program?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 256
def name_of_this_individual_program?
  @name_of_this_individual_program
end
notify_the_user_that_we_will_create_a_new_snapcraft_file_next( _ = programs? ) click to toggle source
#

notify_the_user_that_we_will_create_a_new_snapcraft_file_next

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 327
def notify_the_user_that_we_will_create_a_new_snapcraft_file_next(
    _ = programs?
  )
  result = 'Creating a snapcraft file next for the program'.dup
  if _.size > 1
    result << 's'
  end
  if _.is_a? Array
    _ = _.join(', ').strip
  end
  result << "  called #{royalblue(_)}."
  opnn; e result
end
plugin_type?() click to toggle source
#

plugin_type?

This is currently hardcoded.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 308
def plugin_type?
  'autotools'
end
program_name?() click to toggle source
#

program_name?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 140
def program_name?
  @program_name
end
Also aliased as: programs?
program_version?() click to toggle source
#

program_version?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 159
def program_version?
  @dataset.program_version?
end
programs?()
Alias for: program_name?
remote_url?() click to toggle source
#

remote_url?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 249
def remote_url?
  @dataset.remote_url?
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::Base#reset
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 55
def reset
  super()
  @namespace = NAMESPACE
  # ======================================================================= #
  # The following instance variable, a String, is the one that is used
  # to store all content that will be written into the snapcraft yaml
  # file. It will be used to store the file in the current directory.
  # ======================================================================= #
  @snapcraft_file_content = ''.dup
  # ======================================================================= #
  # Denote into which file we will store that content.
  # ======================================================================= #
  @store_into_this_file = 'snapcraft.yaml' 
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 356
def run
  programs?.each {|this_program|
    reset
    try_to_find_corresponding_program(this_program) # <- Must come first as it sets the @dataset variable.
    set_name_of_this_individual_program(this_program)
    set_store_into_this_file(
      this_program+'-'+program_version?+'-snapcraft'
    )
    notify_the_user_that_we_will_create_a_new_snapcraft_file_next(
      this_program
    )
    add_name
    add_program_version
    add_program_summary
    add_program_licence
    add_program_description
    add_grade
    add_confinement
    add_newline
    add_apps
    add_parts
    generate_the_snapcraft_file
  }
end
set_name_of_this_individual_program(i) click to toggle source
#

set_name_of_this_individual_program

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 263
def set_name_of_this_individual_program(i)
  @name_of_this_individual_program = i
end
set_program_name(i = '') click to toggle source
#

set_program_name

Denote onto which program we will work on.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 84
def set_program_name(i = '')
  if i.nil?
    opnn; e 'Please provide a valid name for a program to this class.'
    exit
  end
  i = [i].flatten.compact
  if i.first.is_a?(String) and i.first.include?(',')
    i = i.map {|entry|
      if entry.include? ','
        entry = entry.split(',')
      end
      entry
    }.flatten.compact
  end
  @program_name = i
end
set_store_into_this_file(i) click to toggle source
#

set_store_into_this_file

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 73
def set_store_into_this_file(i)
  i = i.dup if i.frozen?
  i << '.yaml' unless i.end_with? '.yaml'
  @store_into_this_file = i
end
short_desc?() click to toggle source
#

short_desc?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 231
def short_desc?
  _ = @dataset.short_desc?
  if _.size > 66
    _ = _[0 .. 60] # Truncate it in this case.
  end
  return _
end
short_name?() click to toggle source
#

short_name?

Tap into @dataset to find out the real short name of the program at hand.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 175
def short_name?
  @dataset.real_short_name?
end
try_to_find_corresponding_program( program_name = program_name? ) click to toggle source
#

try_to_find_corresponding_program

This method attempts to find a corresponding entry from the individual yaml files.

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 150
def try_to_find_corresponding_program(
    program_name = program_name?
  )
  @dataset = RBT::Cookbooks::Cookbook.new(program_name) { :bypass_menu_check }
end
what?() click to toggle source
#

what?

#
# File lib/rbt/utility_scripts/create_snapcraft_file.rb, line 133
def what?
  @snapcraft_file_content
end