class Object

Constants

ORIGEN_COMMAND_ALIASES
PatSeq

Provides APIs to enable applications to support concurrency

QUIET_ATTRS

Public Class Methods

_application_gemfile() click to toggle source
# File lib/origen/commands/plugin.rb, line 71
def self._application_gemfile
  "#{Origen.app.root}/Gemfile"
end
_gem_basename(gem) click to toggle source
# File lib/origen/commands/plugin.rb, line 79
def self._gem_basename(gem)
  "#{Pathname(gem[:location]).basename}"
end
_gem_rc_version(gem) click to toggle source
# File lib/origen/commands/plugin.rb, line 83
def self._gem_rc_version(gem)
  gem[:version]
end
_local_gems() click to toggle source
# File lib/origen/commands/plugin.rb, line 50
def self._local_gems
  gems = {}
  Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by(&:name).map do |name, specs|
    gems[name.to_sym] = {
      name:     name,
      version:  specs.map(&:version).join(','),
      location: specs.map(&:full_gem_path).join(','),
      authors:  specs.map(&:authors).join(',')
    }
  end
  gems
end
_local_gems_orig() click to toggle source
# File lib/origen/commands/plugin.rb, line 63
def self._local_gems_orig
  Gem::Specification.sort_by { |g| [g.name.downcase, g.version] }.group_by(&:name)
end
_local_path_to_gem(gem) click to toggle source
# File lib/origen/commands/plugin.rb, line 75
def self._local_path_to_gem(gem)
  "#{_session_gem_path}/#{Pathname(gem[:location]).basename}"
end
_session_gem_path() click to toggle source
# File lib/origen/commands/plugin.rb, line 67
def self._session_gem_path
  "#{Origen.app.root}/tmp/gems"
end
_update_gemfile() click to toggle source
# File lib/origen/commands/plugin.rb, line 87
def self._update_gemfile
  content = File.read(_application_gemfile)

  search_regexp = "# ORIGEN PLUGIN AUTO-GENERATED.*# /ORIGEN PLUGIN AUTO-GENERATED.*?\n"

  if Origen.app.session.gems.keys.empty?
    new_contents = content.gsub(/#{search_regexp}/m, '')
  else
    replacement_string = "# ORIGEN PLUGIN AUTO-GENERATED---------------DO NOT REMOVE THIS LINE-------------\n"
    replacement_string += "# -- DO NOT CHECK IN WITH THIS SECTION!\n"
    replacement_string += "# -- DO NOT HAND MODIFY!\n"
    replacement_string += "# -- USE 'origen pl clean all' to reset\n"
    replacement_string += "\n"

    Origen.app.session.gems.keys.sort.each do |g|
      replacement_string += "gem '#{g}', path: '#{Origen.app.session.gems[g.to_sym]}'\n"
      replacement_string += "puts \"\\e[1;93;40mWARNING: Using session gem for '#{g}'\\e[0m\"\n"
    end

    replacement_string += "def gem(*args)\n"
    replacement_string += "  return if [#{Origen.app.session.gems.keys.sort.map { |e| "'" + e.to_s + "'" }.join(',')}].include? args[0]\n"
    replacement_string += "  super(*args)\n"
    replacement_string += "end\n"
    replacement_string += "#\n"
    replacement_string += "# /ORIGEN PLUGIN AUTO-GENERATED---------------DO NOT REMOVE THIS LINE------------\n"

    if content =~ /#{search_regexp}/m
      new_contents = content.gsub(/#{search_regexp}/m, replacement_string)
    else
      new_contents = replacement_string + content
    end
  end
  File.open(_application_gemfile, 'w') { |file| file.puts new_contents }
end
_with_doc_tester(options) { || ... } click to toggle source
# File lib/origen/commands/generate.rb, line 36
def self._with_doc_tester(options)
  if options[:doc] || options[:html]
    Origen.app.with_doc_tester(options) do
      yield
    end
  else
    yield
  end
end

Public Instance Methods

_unmanaged_dirs() click to toggle source
# File lib/origen/commands/rc.rb, line 22
def _unmanaged_dirs
  # List of unmanaged files and directories for an Origen workspace
  unmanaged_dirs = Origen::RevisionControl::IGNORE_DIRS
  unmanaged_dirs += config.unmanaged_dirs || []

  # If the given dirs are not full paths then prefix with Origen.root
  unmanaged_dirs.map do |d|
    if Pathname.new(d).absolute?
      d
    else
      "#{Origen.root}/#{d}"
    end
  end
end
_unmanaged_files() click to toggle source
# File lib/origen/commands/rc.rb, line 6
def _unmanaged_files
  unmanaged_files = Origen::RevisionControl::IGNORE_FILES
  unmanaged_files += config.unmanaged_files || []
  # unmanaged_files += Origen.import_manager.all_symlinks || []

  # If the given files are not full paths then prefix with Origen.root, unless they
  # are wildcards
  unmanaged_files.map do |f|
    if f =~ /\*/ || Pathname.new(f).absolute?
      f
    else
      "#{Origen.root}/#{f}"
    end
  end
end
debugger() click to toggle source
# File lib/origen/commands.rb, line 125
def debugger
  caller[0] =~ /.*\/(\w+\.rb):(\d+).*/
  puts 'The debugger gem is not installed, add the following to your Gemfile:'
  puts
  puts "  gem 'byebug', '~>8'"
  puts
end
min_ruby_version() click to toggle source
# File lib/origen/ruby_version_check.rb, line 7
def min_ruby_version
  if Origen.os.windows?
    '1.9.3'
  else
    '2.1.0'
  end
end
origen_sub_block?()
Alias for: origen_subblock?
origen_subblock?() click to toggle source

Indicates whether the object is or can be used as an Origen subblock, where being an Origen subblock is defined as inheriting from either {Origen::Model} or {Origen::Controller}. @return [True/False] @example Subblock NVM (from the Origen guides)

dut.nvm.origen_subblock? #=> true

@example Non-subblocks

'hi'.origen_subblock? #=> false

@see origen-sdk.org/origen/guides/models/defining/#Adding_Sub_Blocks

# File lib/origen/core_ext/object.rb, line 23
def origen_subblock?
  is_a?(Origen::Model) || is_a?(Origen::Controller) || is_a?(Origen::SubBlocks::Placeholder)
end
Also aliased as: origen_sub_block?
require_type_or_id(options) click to toggle source
# File lib/origen/commands/lsf.rb, line 6
def require_type_or_id(options)
  unless options[:id] || options[:type]
    puts 'You must supply a job type or ID'
    exit 1
  end
end
ruby_acceptable_to_run?() click to toggle source
# File lib/origen/ruby_version_check.rb, line 3
def ruby_acceptable_to_run?
  RUBY_VERSION >= min_ruby_version
end
try(*methods) click to toggle source

Tries the given methods and returns the first one to return a value, ultimately returns nil if no value is found.

# File lib/origen/core_ext/object.rb, line 4
def try(*methods)
  methods.each do |method|
    if respond_to?(method)
      val = send(method)
      return val if val
    end
  end
  nil
end
use_packaged_generators() click to toggle source
# File lib/origen/commands/new.rb, line 67
def use_packaged_generators
  puts "Using origen_app_generators that was packaged with Origen #{Origen.version}"
  FileUtils.cp_r Origen.top.join('origen_app_generators').to_s, '.'
  FileUtils.mv 'origen_app_generators', '0'
end
workspace_dirs() click to toggle source
# File lib/origen/commands/rc.rb, line 37
def workspace_dirs
  "#{Origen.root} " + Origen.app.config.external_app_dirs.join(' ')
end