Initialize the converter with a File
 @param [Array] files The list of Gimli::MarkupFile to convert (passing a single file will still work)
 @param [Gimli::Config] config
 Convert the file and save it as a PDF file
519367
def convert!
      merged_contents = []
      @files.each do |file|
        markup = Markup::Renderer.new file, @config.remove_front_matter
        html = convert_image_urls markup.render, file.filename
        if @config.merge
          html = "<div class=\"page-break\"></div>#{html}" unless merged_contents.empty?
          merged_contents << html
        else
          output_pdf(html, file)
        end
        puts html if @config.debug
      end

      unless merged_contents.empty?
        html = merged_contents.join
        output_pdf(html, nil)
      end
    end
546278
def collect_lints(file, linter_selector, config)
      begin
        document = HamlLint::Document.new(File.read(file), file: file, config: config)
      rescue HamlLint::Exceptions::ParseError => e
        return [HamlLint::Lint.new(HamlLint::Linter::Syntax.new(config), file,
                                   e.line, e.to_s, :error)]
      end

      linter_selector.linters_for_file(file).map do |linter|
        linter.run(document)
      end.flatten
    end
748517
def setup_config_file(file=nil)
      if file.nil? or ! File.exists?(file)
        # config does not exist
        setup_config_dir
        dst_file = File.join(default_retrospec_dir, 'config.yaml')
        src_file = File.join(gem_dir,'config.yaml.sample')
        safe_copy_file(src_file, dst_file)
        file = dst_file
      end
      @config_file = file
    end
894772
def convert
      @assets.each do |asset|
        # Convert asset multiple times if more than one converter is found
        finished = false
        while finished == false
          # Find a converter to use
          klass = JAPR::Converter.klass(asset.filename)

          # Convert asset if converter is found
          if klass.nil?
            finished = true
          else
            convert_asset(klass, asset)
          end
        end
      end
    end
214074
function ContentManager( config ) {

  var self = this;
  var filingCabinet;
  var contextFactory;

  //region Initialization

  function initialize() {
    var getRenderer = require( config.getRenderer ?
      path.join( './../../../', config.getRenderer ) :
      markedRenderer
    );
    var renderer = getRenderer( marked );
    filingCabinet = new FilingCabinet( config );

    readControls(
      config.controls,
      filingCabinet
    );
    readReferences(
      config.components,
      config.referenceFile,
      filingCabinet
    );
    readComponents(
      config.components,
      config.referenceFile,
      config.localeFile,
      config.layoutSegment,
      config.contentSegment,
      filingCabinet,
      renderer
    );
    readContents(
      config.contents,
      config.submenuFile,
      filingCabinet,
      renderer
    );

    logger.showInfo( '*** Validating elements...' );
    filingCabinet.finalize();
    logger.showInfo( '*** Content manager is initialized.' );

    contextFactory = new ContextFactory( config, filingCabinet );
  }

  //endregion

  initialize();

  //region Public properties

  /**
   * Gets the list of the supported locales.
   * @member {Array.<string>}
   * @readonly
   */
  Object.defineProperty( this, 'supportedLocales', {
    get: function () {
      return filingCabinet.languages;
    },
    enumerable: true,
    configurable: false
  } );

  //endregion

  //region Public methods

  /**
   * Sets up the middlewares of the markdown site engine.
   * @param {Express.Application} app - The express.js application.
   */
  this.setMiddlewares = function( app ) {

    // Set up language.
    app.use( function( req, res, next ) {

      if (!req.session)
        req.session = { language: negotiateLanguage(
          req.headers["accept-language"], filingCabinet.languages, config.defaultLocale
        ) };
      else if (!req.session.language)
        req.session.language = negotiateLanguage(
          req.headers["accept-language"], filingCabinet.languages, config.defaultLocale
        );
      next();
    } );

    // Set up request context.
    app.use( function( req, res, next ) {

      var language = req.session.language;
      var url = req.url;
      var definition = filingCabinet.contents.getDefinition( language, url );
      req.ctx = contextFactory.create( language, url, definition );

      // Apply eventual redirection.
      if (definition.rewrite)
        req.url = definition.rewrite;

      next();
    } );
  };

  /**
   * Sets up the routes of the user defined actions.
   * @param {Express.Application} app - The express.js application.
   * @param {object} actions - An object containing the URLs and paths of the actions.
   */
  this.setActions = function( app, actions ) {

    for (var property in actions) {
      var method = 'post';
      var url = property.toLowerCase();

      // Does property have method?
      var pos = url.indexOf( ':' );
      if (pos > 0) {
        method = url.substring( 0, pos );
        url = url.substring( pos + 1 );
      }
      // Add action handler.
      app[ method ]( url, function( req, res, next) {

        // Get action function.
        var action = require( path.join( '../../../', actions[ property ] ) );

        // Execute the action.
        action( req, req.ctx, function( resultUrl ) {
          req.url = resultUrl || '/404';
          next();
        });
      } );
      logger.routeAdded( url, method.toUpperCase() );
    }
  };

  /**
   * Sets up the routes of the markdown site engine.
   * @param {Express.Application} app - The express.js application.
   * @param {Boolean} isDevelopment - True when the application runs in environment environment.
   */
  this.setRoutes = function( app, isDevelopment ) {

    // Change language.
    app.use( config.paths.setLanguage, function( req, res ) {

      var len = req.baseUrl.length;
      var url = req.originalUrl.split( '?' )[ 0 ].substr( len );
      var curLanguage = req.session.language;
      var newLanguage = url.length > 1 ? url.substr( 1 ) : config.defaultLocale;

      req.session.language = newLanguage;
      var localizedPath = filingCabinet.getLocalizedPath(
        curLanguage, req.query[ 'id' ], newLanguage
      );
      res.redirect( localizedPath );
    } );
    logger.routeAdded( config.paths.setLanguage );

    // Reread the contents.
    app.use( config.paths.reboot, function( req, res ) {

      initialize();
      res.redirect( '/' );
    } );
    logger.routeAdded( config.paths.reboot );

    // Search the contents.
    var searchPaths = [ ];

    filingCabinet.languages.forEach( function( language ) {

      var searchPath = filingCabinet.contents.searchPath( language );
      if (searchPath && searchPaths.indexOf( searchPath ) < 0)
        searchPaths.push( searchPath );
    } );
    searchPaths.forEach( function( searchPath ) {

      app.post( searchPath, searchTheContents );
      logger.routeAdded( searchPath, 'POST' );
    } );

    // Developer methods.
    if (isDevelopment)
      setDeveloperRoutes( app, filingCabinet, config.paths, config.develop );

    // Serve contents.
    app.use( '*', function( req, res ) {

      var language = req.session.language;
      var url = req.baseUrl;
      var context = req.ctx;
      if (req.originalUrl !== req.baseUrl) {

        // Recreate the context for the rewritten path.
        var data = context.data;
        var definition = filingCabinet.contents.getDefinition( language, url );
        context = contextFactory.create( language, url, definition );
        Object.assign( context.data, data );
      }
      // Add eventual highlight text to context data.
      if (req.query.hl)
        context.data.highlight = req.query.hl;

      res.status( 200 ).send( filingCabinet.get( language, url, context ) );
    } );
    logger.routeAdded( '/* <all-contents>' );
  };

  function searchTheContents( req, res, next ) {

    // Initialize data.
    req.ctx.data.text2search = '';
    req.ctx.data.results = [ ];

    if (req.body) {
      // Search the required text in the contents.
      req.ctx.data.text2search = req.body.text2search;
      req.ctx.data.results = filingCabinet.contents.search( req.ctx );
    }
    else
      logger.showError( 'Middleware "body-parser" is not applied.' );

    next();
  }

  //endregion
}
513261
def init_config(loader)
      case loader
      when String, Hash, nil
        @config_loader = ConfigLoaders::FileOrHashLoader.new(loader)
      else
        @config_loader = loader
      end
      load_config
    end
1114221
private static function includeConfigFile(array &$config, $config_file, File $base_dir, ConfigReader $reader)
    {
        // try relative path
        $file = new File($config_file, $base_dir);
        
        if ( $file->exists() ){
            $included = self::loadConfigFileByFormat( $file, $reader );
            $config = array_merge_recursive($config, $included);
            return;
        }
        
        // try full path
        $file = new File($config_file);
        
        if ( $file->exists() ){
            $included = self::loadConfigFileByFormat( $file, $reader );
            $config = array_merge_recursive($config, $included);
            return;
        }
        
        throw new IncludeConfigFileNotFoundException($config_file);
    }
758081
def init_config(options={})
      options = options.to_symbol_keys

      if !options[:method]
        abort "Please provide a deployment method. e.g. #{METHODS.keys}"
      end

      @options = DEFAULT_OPTIONS.deep_merge(options)
      write_config
      check_gitignore
    end
446930
def init_options(args = nil)
      @args = case args
              when nil    then []
              when String then args.split
              else             args
              end

      @options = load_config || {}

      Kat.options(@args).tap do |o|
        @options.merge!(o) { |k, ov, nv| o["#{ k }_given".intern] ? nv : ov }
      end

      Kat::Colour.colour = @options[:colour]
    rescue NoMethodError => e
      @options = {}
      warn "Wrong config file format: #{ e }"
    end
612777
def initialize(self, configfile=None):
        

        method = "initialize"

        A = None
        metadata = {method: configfile}

        send_array(self.socket, A, metadata)
        A, metadata = recv_array(
            self.socket, poll=self.poll, poll_timeout=self.poll_timeout,
            flags=self.zmq_flags)
215392
public static function loadExtensionsFiles($files, array $config = []) : array
    {
        $callbacks = [];
        $files     = !is_array($files) ? static::findExtensionsFiles($files) : $files;
        foreach ($files as $file) {
            $item = require  $file;
            if ($item instanceof \Closure) {
                $callbacks[] = $item;
            }
            if (is_array($item)) {
                $config = array_replace_recursive($config, $item);
            }
        }
        foreach ($callbacks as $callback) {
            $config = $callback($config);
        }
        return $config;
    }
1149727
def read_config_files(files)
      configuration = clone

      begin
        files.each do |config_file|
          next if config_file.nil? || config_file.empty?

          new_config = read_config_file(config_file)
          configuration = Utils.deep_merge_hashes(configuration, new_config)
        end
      rescue ArgumentError => e
        Jekyll.logger.warn "WARNING:", "Error reading configuration. " \
                     "Using defaults (and options)."
        warn e
      end

      configuration.backwards_compatibilize.add_default_collections
    end
242836
def to_htmls(files, options = {})
      FileUtils.chdir(File.expand_path(options[:base_dir]))
      files.each_with_index do |file, index|
        puts "FYI: process file #{index + 1} of #{files.size} : #{file}"
        to_html(file, options)
      end
    end
14336
function saveFiles(config, [css, fonts]) {

	let res = Q().then(() => {
		let deferred = Q.defer()
		if(!config.simulate) {
			mkdirp(config.outputDir, error => {
				if(error) {
					deferred.reject(new Error(error))
				} else {
					deferred.resolve()
				}
			})
		} else {
			deferred.resolve()
		}
		return deferred.promise
	})
	fonts
		.forEach(({inputFont, outputFont, inputText, outputText}) => {
			res = res.then(() => {
				let deferred = Q.defer()
				let mime = 'font/woff2' // For Base64
				if(config.verbose)
					console.log(config.base64 ?
						`Writing in file ${inputFont}` :
						`Saving ${outputFont}`)
				let req = request({
					url: inputFont,
					header: {
						'User-Agent': config.userAgent
					}
				})
				.on('response', response => {
					if(config.base64) {
						mime = response.headers['content-type'] || 'font/woff2'
						deferred.resolve()
					}
				})
				.on('error', e => {
					deferred.reject(new Error(e))
				})
				if(!config.base64) {
					let file = path.resolve(config.outputDir, outputFont)
					css = css.replace(inputText, outputText);
					if(!config.simulate
					&&(config.overwriting
					  || !fs.existsSync(file))) {
						req.pipe(fs.createWriteStream(file))
						req.on('end', () => {
							deferred.resolve()
						})
					} else {
						if(!config.overwriting
						|| fs.existsSync(file)) {
							if(config.verbose)
								console.log('Passing - overwriting is disabled')
						}
						deferred.resolve()
					}
				} else {
					let chunks = []
					req.on('data', chunk => {
						chunks.push(chunk)
					}).on('end', (x) => {
						res = res.then(() => {
							let body = Buffer.concat(chunks).toString('base64')
							css = css.replace(inputText, `url('data:${mime};base64,${body}')`)
						})
					})
				}
				return deferred.promise
			})
		})
	res.then(() => {
		let deferred  = Q.defer()
		let file = path.resolve(config.outputDir, config.cssFile)
		if(config.verbose)
			console.log(`Saving ${path.basename(config.cssFile)}`)
		if(!config.simulate&&(config.overwriting||!fs.existsSync(file))) {
			fs.writeFile(file, css, 'utf8', e => {
				if(e) {
					deferred.reject(new Error(e))
					return;
				}
				deferred.resolve()
			})
		} else deferred.resolve()
		return deferred.promise
	})
	return res
}
863805
def set_with_string(config)
      if File.exists?(config)
        set_with_yaml(File.read(config))
      else
        set_with_yaml(config)
      end
    end
970486
def load_config(config_file)
      if dir_exists?
        begin
          config_file = File.join(config_dir, "#{config_file}.yml")
          config = YAML::load(File.open(config_file))

        rescue StandardError => e
          raise FileAccessError, e.message
        end
      else
        raise ConfigDirMissingError, 'Config dir missing. Run init command'
      end
    end
1078309
def create_file_ios(files)
      # UploadIO is from the multipart-post gem's lib/composite_io.rb:57
      # where it has this documentation:
      #
      # ********************************************************************
      # Create an upload IO suitable for including in the params hash of a
      # Net::HTTP::Post::Multipart.
      #
      # Can take two forms. The first accepts a filename and content type, and
      # opens the file for reading (to be closed by finalizer).
      #
      # The second accepts an already-open IO, but also requires a third argument,
      # the filename from which it was opened (particularly useful/recommended if
      # uploading directly from a form in a framework, which often save the file to
      # an arbitrarily named RackMultipart file in /tmp).
      #
      # Usage:
      #
      #     UploadIO.new('file.txt', 'text/plain')
      #     UploadIO.new(file_io, 'text/plain', 'file.txt')
      # ********************************************************************
      #
      # There is also a 4th undocumented argument, opts={}, which allows us
      # to send in not only the Content-Disposition of 'file' as required by
      # DocuSign, but also the documentId parameter which is required as well
      #
      ios = []
      files.each_with_index do |file, index|
        ios << UploadIO.new(
                 file[:io] || file[:path],
                 file[:content_type] || 'application/pdf',
                 file[:name],
                 'Content-Disposition' => "file; documentid=#{index + 1}"
               )
      end
      ios
    end