rubocop:disable Metrics/CyclomaticComplexity
508180
def re_raise_error(body)
      error = body.fetch(:message, nil)
      case body.fetch(:glimrerrorcode, nil)
      when 511 # FeeLiability not found for FeeLiabilityID
        raise FeeLiabilityNotFound, error
      when 512 # PBA account \w+ not found
        raise AccountNotFound, error
      when 513 # Invalid PBAAccountNumber/PBAConfirmationCode combination
        raise InvalidAccountAndConfirmation, error
      when 514 # Invalid AmountToPay
        raise InvalidAmount, error
      when 521 # PBAGlobalStatus is inactive
        raise GlobalStatusInactive, error
      when 522  # PBAJurisdictionStatus is inactive
        raise JurisdictionStatusInactive, error
      end
      super(message: error)
    end
1016440
def rubocop_checksum
      ResultCache.source_checksum ||=
        begin
          lib_root = File.join(File.dirname(__FILE__), '..')
          exe_root = File.join(lib_root, '..', 'exe')

          # These are all the files we have `require`d plus everything in the
          # exe directory. A change to any of them could affect the cop output
          # so we include them in the cache hash.
          source_files = $LOADED_FEATURES + Find.find(exe_root).to_a
          sources = source_files
                    .select { |path| File.file?(path) }
                    .sort
                    .map { |path| IO.read(path, encoding: Encoding::UTF_8) }
          Digest::SHA1.hexdigest(sources.join)
        end
    end
12213
def run_on_modifications(paths)
      return pending_result if paths.empty?
      Guard::UI.info("Running: #{paths.join(', ')}", reset: true)
      do_run{ @runner.run(paths) }
    end
1348589
def reset!
      Artifactory::Configurable.keys.each do |key|
        instance_variable_set(:"@#{key}", Defaults.options[key])
      end
      self
    end
1125744
def load!(path, environment = nil)
      require 'yaml'
      environment ||= Rails.env
      conf = YAML.load(File.new(path).read).with_indifferent_access[environment]
      load_configuration(conf)
    end
1244951
def fix_cdata(body)
      # <![CDATA[ = &lt;![CDATA[
      # ]]> =  ]]&gt;
      if !body.nil? && body.include?('&lt;![CDATA[')
        body.gsub! '&lt;![CDATA[', '<![CDATA['
        body.gsub! ']]&gt', ']]>'
      end
      body
    end
1276772
def checks_pass?
      rv = true
      unless File.exist?(@platform)
        puts "No platform or invalid platform configuration given: (#{@platform}) !"
        puts "Use either property 'platform' via RakeOE::Config object in the Rakefile or environment variable TOOLCHAIN_ENV"
        rv = false
      end
      rv
    end
583888
def run_on_change(paths)
      if @options[:dry_run]
        paths.each { |path| UI.info "Dry run: #{path}" }
        return
      end

      total    = 0
      failures = 0
      duration = 0
      run_command("mix test #{paths.join(' ')}") do |line|
        puts line
        if /Finished in ([0-9.]+) seconds/.match(line)
          duration = Regexp::last_match[1]
        elsif /([0-9]+) tests, ([0-9]+) failures/.match(line)
          total = Regexp::last_match[1].to_i
          failures = Regexp::last_match[2].to_i
        end
      end

      Notifier.notify(
        guard_message(total, failures, duration),
        :title => "Elixir results",
        :image => guard_image(failures),
        :priority => guard_priority(failures)
      )
    end
904118
def define
      lib_path = @libs.join(File::PATH_SEPARATOR)
      actual_name = Hash === name ? name.keys.first : name
      unless Rake.application.last_comment
        desc "Analyze code coverage with tests" + 
          (@name==:rcov ? "" : " for #{actual_name}")
      end
      task @name do
        run_code = ''
        RakeFileUtils.verbose(@verbose) do
          run_code =
          case rcov_path
          when nil, ''
            "-S rcov"
          else %!"#{rcov_path}"!
          end
          ruby_opts = @ruby_opts.clone
          ruby_opts.push( "-I#{lib_path}" )
          ruby_opts.push run_code
          ruby_opts.push( "-w" ) if @warning
          ruby ruby_opts.join(" ") + " " + option_list +
          %[ -o "#{@output_dir}" ] +
          file_list.collect { |fn| %["#{fn}"] }.join(' ')
        end
      end

      desc "Remove rcov products for #{actual_name}"
      task paste("clobber_", actual_name) do
        rm_r @output_dir rescue nil
      end

      clobber_task = paste("clobber_", actual_name)
      task :clobber => [clobber_task]

      task actual_name => clobber_task
      self
    end
136021
def lints_and_stats_switch(ext, lint_opts)
        result = {
          lints: {},
          statistics: {}
        }

        lints = result[:lints]
        statistics = result[:statistics]

        case ext
          when :scss
            lints[:scsslint] = Maximus::Scsslint.new(lint_opts).result

            # @todo stylestat is singular here because model name in Rails is singular.
            #   But adding a .classify when it's converted to a model chops off the end s on 'phantomas',
            #   which breaks the model name.
            statistics[:stylestat] = Maximus::Stylestats.new({config: @config}).result

            # @todo double pipe here is best way to say, if it's already run, don't run again, right?
            statistics[:phantomas] ||= Maximus::Phantomas.new({config: @config}).result
            statistics[:wraith] ||= Maximus::Wraith.new({config: @config}).result
          when :js
            lints[:jshint] = Maximus::Jshint.new(lint_opts).result

            statistics[:phantomas] ||= Maximus::Phantomas.new({config: @config}).result

            # @todo double pipe here is best way to say, if it's already run, don't run again, right?
            statistics[:wraith] ||= Maximus::Wraith.new({config: @config}).result
          when :ruby
            lints[:rubocop] = Maximus::Rubocop.new(lint_opts).result
            lints[:railsbp] ||= Maximus::Railsbp.new(lint_opts).result
            lints[:brakeman] = Maximus::Brakeman.new(lint_opts).result
          when :rails
            lints[:railsbp] ||= Maximus::Railsbp.new(lint_opts).result
        end

        result
      end
168021
function renderComplexRuby( $ruby ) {
  var frag = $.create( '!' )
  var clazz = $ruby.classList
  var $cloned, $rb, $ru, maxspan

  frag.appendChild( $.clone( $ruby ))
  $cloned = frag.firstChild

  $rb = $ru = $.tag( 'rb', $cloned )
  maxspan = $rb.length

  // First of all, deal with Zhuyin containers
  // individually
  //
  // Note that we only support one single Zhuyin
  // container in each complex ruby
  void function( $rtc ) {
    if ( !$rtc )  return

    $ru = $
      .tag( 'rt', $rtc )
      .map(function( $rt, i ) {
        if ( !$rb[ i ] )  return
        var ret = createZhuyinRu( $rb[ i ], $rt )

        try {
          $rb[ i ].parentNode.replaceChild( ret, $rb[ i ] )
        } catch ( e ) {}
        return ret
      })

    // Remove the container once it's useless
    $.remove( $rtc )
    $cloned.setAttribute( 'rightangle', 'true' )
  }( $cloned.querySelector( 'rtc.zhuyin' ))

  // Then, normal annotations other than Zhuyin
  $
  .qsa( 'rtc:not(.zhuyin)', $cloned )
  .forEach(function( $rtc, order ) {
    var ret
    ret = $
      .tag( 'rt', $rtc )
      .map(function( $rt, i ) {
        var rbspan = Number( $rt.getAttribute( 'rbspan' ) || 1 )
        var span = 0
        var aRb = []
        var $rb, ret

        if ( rbspan > maxspan )  rbspan = maxspan

        do {
          try {
            $rb = $ru.shift()
            aRb.push( $rb )
          } catch (e) {}

          if ( typeof $rb === 'undefined' )  break
          span += Number( $rb.getAttribute( 'span' ) || 1 )
        } while ( rbspan > span )

        if ( rbspan < span ) {
          if ( aRb.length > 1 ) {
            console.error( 'An impossible `rbspan` value detected.', ruby )
            return
          }
          aRb  = $.tag( 'rb', aRb[0] )
          $ru  = aRb.slice( rbspan ).concat( $ru )
          aRb  = aRb.slice( 0, rbspan )
          span = rbspan
        }

        ret = createNormalRu( aRb, $rt, {
          'class': clazz,
          span: span,
          order: order
        })

        try {
          aRb[0].parentNode.replaceChild( ret, aRb.shift() )
          aRb.map( $.remove )
        } catch (e) {}
        return ret
      })
    $ru = ret
    if ( order === 1 )  $cloned.setAttribute( 'doubleline', 'true' )

    // Remove the container once it's useless
    $.remove( $rtc )
  })
  return createCustomRuby( frag )
}
263835
def start # rubocop:disable Metrics/MethodLength
      ARGV.clear
      IRB.setup nil

      IRB.conf[:PROMPT]          = {}
      IRB.conf[:IRB_NAME]        = 'espsdk'
      IRB.conf[:PROMPT][:ESPSDK] = {
        PROMPT_I: '%N:%03n:%i> ',
        PROMPT_N: '%N:%03n:%i> ',
        PROMPT_S: '%N:%03n:%i%l ',
        PROMPT_C: '%N:%03n:%i* ',
        RETURN: "# => %s\n"
      }
      IRB.conf[:PROMPT_MODE] = :ESPSDK

      IRB.conf[:RC] = false

      require 'irb/completion'
      require 'irb/ext/save-history'
      IRB.conf[:READLINE]     = true
      IRB.conf[:SAVE_HISTORY] = 1000
      IRB.conf[:HISTORY_FILE] = '~/.esp_sdk_history'

      context = Class.new do
        include ESP
      end

      irb                     = IRB::Irb.new(IRB::WorkSpace.new(context.new))
      IRB.conf[:MAIN_CONTEXT] = irb.context

      trap("SIGINT") do
        irb.signal_handle
      end

      begin
        catch(:IRB_EXIT) do
          irb.eval_input
        end
      ensure
        IRB.irb_at_exit
      end
    end
1365224
def parse!(*argv)
      super

      if Options[:version] && Bini.version
        puts Bini.version
        # don't exit if RSpec is around, we are in a testing environment.
        exit 0 if !Object.constants.include? :RSpec
      end
    end
1112923
def freeze(plugins_directory):
    '''
    
    '''
    # Check existing version (if any).
    package_versions = []
    for plugin_path_i in plugins_directory.dirs():
        try:
            plugin_metadata = yaml.load(plugin_path_i
                                        .joinpath('properties.yml').bytes())
            if plugin_path_i.name != plugin_metadata['package_name']:
                continue
            package_versions.append((plugin_metadata['package_name'],
                                     plugin_metadata['version']))
        except:
            continue
    return ['%s==%s' % v for v in package_versions]
75759
def check_overlapping_keys?(yaml_data, errors_array)
      overlap_detector = KeyOverlapDetector.new
      data = Psych.parser.parse(yaml_data)

      overlap_detector.parse(data)

      overlap_detector.overlapping_keys.each do |key|
        err_meg = "The same key is defined more than once: #{key.join('.')}"
        errors_array << err_meg
      end

      overlap_detector.overlapping_keys.empty?
    end
238438
def run!
      Thinner.configure do |config|
        @options.each_pair do |key, value|
          config.send("#{key}=".to_sym, value)
        end
      end
      Thinner.purge! @urls
    end
834667
def update
      config.update(:remotes) do |rmts|
        yield(rmts || {}).tap do |new_rmts|
          raise_invalid unless validate(new_rmts)
        end
      end
    end