class Base

Constants

ATTACHMENTS_FOLDER
PAGE_OBJECTS_FOLDER
ROOT_DIR
TIMESTAMP

Public Instance Methods

clear() click to toggle source
# File lib/skeleton/base.rb, line 20
def clear
  FileUtils.rm_rf(PAGE_OBJECTS_FOLDER)
  FileUtils.rm_rf(ATTACHMENTS_FOLDER)
  FileUtils.rm_rf("#{ROOT_DIR}/server/screenshot.png")
  Language.all.each do |lang|
    FileUtils.rm_rf("#{ROOT_DIR}/server/#{lang}.html")
  end
end
devices() click to toggle source
# File lib/skeleton/base.rb, line 18
def devices; end
precondition() click to toggle source
# File lib/skeleton/base.rb, line 6
def precondition
  clear
  FileUtils.mkdir_p(PAGE_OBJECTS_FOLDER)
  FileUtils.mkdir_p(ATTACHMENTS_FOLDER)
rescue
  Log.error("Advice you to use not system ruby \n" \
            'For more info read: https://github.com/alter-al/' \
            'skeleton/blob/master/docs/permissions_error.md')
end
skeletoner() click to toggle source
# File lib/skeleton/base.rb, line 16
def skeletoner; end

Protected Instance Methods

camel_style(method_name) click to toggle source
# File lib/skeleton/base.rb, line 47
def camel_style(method_name)
  method_name.tr!("@()[]'\"*!?{}:;#$^.,\/\\", '')
  camel = method_name.split(/_|-|\ /).inject([]) do |buffer, e|
    buffer.push(buffer.empty? ? e : e.capitalize)
  end.join
  if camel == camel.upcase
    camel.downcase
  else
    camel[0] = camel[0].downcase
    camel
  end
end
code_generation() click to toggle source
# File lib/skeleton/base.rb, line 68
def code_generation; end
increment_locator_id() click to toggle source
# File lib/skeleton/base.rb, line 60
def increment_locator_id
  @locator_index = @locator_index.nil? ? 1 : @locator_index + 1
end
page_source() click to toggle source
# File lib/skeleton/base.rb, line 66
def page_source; end
save(code:, format: 'xml') click to toggle source
# File lib/skeleton/base.rb, line 31
def save(code:, format: 'xml')
  file_path = "#{PAGE_OBJECTS_FOLDER}/#{@platform}_#{TIMESTAMP}.#{format}"
  File.open(file_path, 'a') { |f| f.write(code) }
end
screenshot() click to toggle source
# File lib/skeleton/base.rb, line 64
def screenshot; end
snake_style(method_name) click to toggle source
# File lib/skeleton/base.rb, line 36
def snake_style(method_name)
  method_name
    .tr("@()[]'\"*!?{}:;#$^.,\/\\", '')
    .tr('-', '_')
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .gsub(/\s/, '_')
    .gsub(/__+/, '_')
    .downcase
end