rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
542264
def task_info
      info = {}

      info[:name] = name
      info[:timestamp] = timestamp.to_s
      info[:investigation] = investigation

      info[:full_comment] = full_comment if full_comment
      info[:arg_names] = arg_names if arg_names.any?
      info[:arg_description] = arg_description if arg_description
      info[:locations] = locations if locations.any?
      info[:sources] = sources if sources.any?

      if prerequisite_tasks.any?
        info[:prerequisite_tasks] = prerequisite_tasks.map do |p|
          p.__send__(:task_info)
        end
      end

      info
    end
781497
def method_missing(sym, *args, &block)
      cache_method_call(sym) if ::Builder::XmlBase.cache_method_calls
      tag!(sym, *args, &block)
    end
521963
def execute!
      begin
        options   = Options.new(argv)

        generator = ErbGenerator.new(Data.new(options.data_sources))
        generator.compile(options.source, options.destination)

        exitstatus = 0
      rescue Interrupt
        Filegen::Ui.warning 'You told me to stop command execution.'
        exitstatus = 2
      rescue Exceptions::ErbTemplateHasSyntaxErrors => e
        Filegen::Ui.error "Syntax error in ERB-Template: \n" + e.message
        exitstatus = 3
      rescue Exceptions::YamlFileNotFound => e
        Filegen::Ui.error "Yaml-file \"#{JSON.parse(e.message)['file']}\" not found."
        exitstatus = 4
      rescue StandardError => e
        Filegen::Ui.error "#{e.class} - #{e.message}"
        exitstatus = 99
      end

      @kernel.exit(exitstatus)
    end
1248386
def models(parent = nil)
      model_paths = Dir["#{Rails.root}/app/models/*_jobs/*.rb"]
      model_paths.each{ |path| require path }
      sanitized_model_paths = model_paths.map { |path| path.gsub(/.*\/app\/models\//, '').gsub('.rb', '') }
      model_constants = sanitized_model_paths.map do |path|
        path.split('/').map { |token| token.camelize }.join('::').constantize
      end
      model_constants.select { |model| superclasses(model).include?(::Ohm::Model) }

      if parent
        model_constants.select { |model| model.included_modules.include?(parent) }
      else
        model_constants
      end
    end
1247949
def init_app(state):
    
    app = state.app

    app.config.setdefault('SPLIT_ALLOW_MULTIPLE_EXPERIMENTS', False)
    app.config.setdefault('SPLIT_DB_FAILOVER', False)
    app.config.setdefault('SPLIT_IGNORE_IP_ADDRESSES', [])
    app.config.setdefault('SPLIT_ROBOT_REGEX', r"""
        (?i)\b(
            Baidu|
            Gigabot|
            Googlebot|
            libwww-perl|
            lwp-trivial|
            msnbot|
            SiteUptime|
            Slurp|
            WordPress|
            ZIBB|
            ZyBorg
        )\b
    """)

    app.jinja_env.globals.update({
        'ab_test': ab_test,
        'finished': finished
    })

    @app.template_filter()
    def percentage(number):
        number *= 100
        if abs(number) < 10:
            return "%.1f%%" % round(number, 1)
        else:
            return "%d%%" % round(number)
329177
def map_gems_to_specs(gems)
      gems.map.with_index do |gemfile, index|
        # rubocop:disable Metrics/LineLength
        Utils.logger.info("[#{index + 1}/#{gems.size}]: Processing #{gemfile.split('/')[-1]}")
        # rubocop:enable Metrics/LineLength

        if File.size(gemfile).zero?
          Utils.logger.warn("Skipping zero-length gem: #{gemfile}")
          next
        end

        begin
          spec = if ::Gem::Package.respond_to? :open
                   ::Gem::Package
                     .open(File.open(gemfile, 'rb'), 'r', &:metadata)
                 else
                   ::Gem::Package.new(gemfile).spec
                 end

          spec.loaded_from = gemfile

          # HACK: fuck this shit - borks all tests that use pl1
          if File.basename(gemfile, '.gem') != spec.original_name
            exp = spec.full_name
            exp << " (#{spec.original_name})" if
              spec.original_name != spec.full_name
            msg = "Skipping misnamed gem: #{gemfile} should be named #{exp}"
            Utils.logger.warn(msg)
            next
          end

          version = spec.version.version
          unless version =~ /^\d+\.\d+\.\d+.*/
            msg = "Skipping gem #{spec.full_name} - invalid version #{version}"
            Utils.logger.warn(msg)
            next
          end

          if ::Gem::VERSION >= '2.5.0'
            spec.abbreviate
            spec.sanitize
          else
            abbreviate spec
            sanitize spec
          end

          spec
        rescue SignalException
          msg = 'Received signal, exiting'
          Utils.logger.error(msg)
          raise
        rescue StandardError => e
          msg = ["Unable to process #{gemfile}",
                 "#{e.message} (#{e.class})",
                 "\t#{e.backtrace.join "\n\t"}"].join("\n")
          Utils.logger.debug(msg)
        end
      end.compact
    end
235496
def C_Initialize(args=nil)
      case args
        when Hash
          pargs = CK_C_INITIALIZE_ARGS.new
          args.each{|k,v| pargs.send("#{k}=", v) }
        else
          pargs = args
      end
      unwrapped_C_Initialize(pargs)
    end
969412
def reload
      # Make sure we have a fresh cache after we reload
      config.cache.clear if config.cache.respond_to?(:clear)

      # Reload dependencies as well, if necessary
      ActiveSupport::Dependencies.clear if defined?(ActiveSupport::Dependencies)

      # Use current configuration, but skip bundle and autoloading initializers
      current_config = config.marshal_dump.dup
      current_config.merge! :skip_bundle => true#, :skip_autoloading => true)

      initialize current_config
    end
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
845210
def create_model_file
      dir = "/app/models/#{@scaffold_name}.rb"
      unless File.exists?(File.join(Dir.pwd,dir))
        File.join(Dir.pwd,dir)
        source = "#{@gem_path}/lib/modules/scaffold/model.rb"
        FileUtils.cp(source,File.join(Dir.pwd,dir))
        config_model
        @valid = true
        $stdout.puts "\e[1;32m \tcreate\e[0m\t#{dir}"
      else
        $stdout.puts "\e[1;31mError:\e[0m Model named #{@scaffold_name} already exists, aborting."
      end
    end
155986
def method_missing(method_sym, *args, &block) # rubocop:disable Style/MethodMissingSuper
      return nil.__send__(method_sym, *args, &block) if nil.respond_to?(method_sym)

      self
    end
1161030
def method_missing(meth, *args, &block)
      raise NoMethodError, "undefined method #{meth} for #{self.class.to_s}" if WotApiRu::Constants::PATH[meth.to_sym].nil?
      options = args[0] || {}
      options[:application_id] ||= WotApiRu::Settings[:application_id]
      path = WotApiRu::Constants::HOST + WotApiRu::Constants::PATH[meth.to_sym]
      invoke(path, options)
    end
902710
function apimpull(opts, cb) {
  var options = {
    host: opts.host || '127.0.0.1',
    port: opts.port || 443, // assume SSL
    timeout: opts.timeout * 1000 || 30 * 1000,
    srvca: opts.srvca ? opts.srvca : null,
    clikey: opts.clikey ? opts.clikey : null,
    clipass: opts.clipass,
    clicert: opts.clicert ? opts.clicert : null,
    indir: opts.indir,
    outdir: opts.outdir || 'apim',
    clientid: opts.clientid || '1111-1111' };

  if (opts.indir) {
    try {
      indirFiles = fs.readdirSync(opts.indir);
    } catch (e) {
      logger.info(e);
      // not fatal; continue
    }
  }

  /* First, start w/ catalogs */
  pullcatalog(options, function(err, catalogs, models) {
    if (err) {
      cb(err, response);
    } else if (typeof catalogs !== 'undefined') {
      getDataBasedOnCatalog(options, catalogs, models, cb);
    } else {
      cb(null, response);
    }
  });
}
1239956
def execute
      args = ['rubocop'] + arguments
      todo = target_directory.join('.rubocop_todo.yml')

      replacements = []

      # if adding the .rb extension is enabled, remove the extension again from
      # any output so it matches the actual files names we are linting
      replacements << [/\.erb\.rb/, '.erb'] if rb_extension_enabled

      result = Dir.chdir(target_directory) do
        replacements.unshift([/^#{Regexp.quote(Dir.pwd)}/, current_directory.to_s])
        stdout, stderr, status = Open3.capture3(*args)

        munge_output(stdout, stderr, replacements)

        status.exitstatus
      end

      # copy the todo file back for the case where we've used --auto-gen-config
      FileUtils.cp(todo, current_directory) if todo.exist?

      result
    end
1162225
def machined(config = {})
      @machined = nil if config.delete(:reload)
      @machined ||= Machined::Environment.new(config.reverse_merge(:skip_bundle => true, :skip_autoloading => true))
    end
342102
def redis
      ::RSpec.configure do |config|
        config.add_setting :redis
        config.redis = Rails.redis if defined?(Rails.redis)
        config.add_setting :flush_redis_proc
        config.flush_redis_proc = ->(*) { Array.wrap(config.redis).each(&:flushdb) }
        config.before(flush_redis: true) { instance_exec(&config.flush_redis_proc) }
        config.after(:suite) { instance_exec(&config.flush_redis_proc) }
      end
    end
476969
function(deps, cb, refPath) {
		var unreadyModules = [];

		for (var i = deps.length; i--;) {
			var moduleId = resolveModuleId(deps[i], refPath),
				module = getModule(moduleId);

			if (!areDeepDepsDefined(moduleId)) {
				unreadyModules.push(moduleId);
			}
		}

		if (unreadyModules.length) {
			addCallback(unreadyModules, function() {
				cb(createRequireFunc(refPath));
			});
			queueModules(unreadyModules);
		}
		else {
			setTimeout(function() {
				cb(createRequireFunc(refPath));
			}, 0);
		}
	}