=begin
Function to add the module dependency gems to project Gemfile.
=end
429413
def add_gems
      file = File.open("#{@target_dir}/Gemfile", "r+")
      file.each do |line|
        while line == "gem 'oauth2'\n" do
          return
        end
      end
      File.open("#{@target_dir}/Gemfile", "a+") do |f|
        f.write("gem 'multi_json'\ngem 'oauth2'\ngem 'songkick-oauth2-provider'\ngem 'ruby_regex'\ngem 'oauth'\n")
      end
      $stdout.puts "\e[1;35m \tGemfile\e[0m\tgem 'multi_json'\n\t\tgem 'oauth2'
\t\tgem 'songkick-oauth2-provider'\n\t\tgem 'ruby_regex'\n\t\tgem 'oauth'\n"
      $stdout.puts "\e[1;32m \trun\e[0m\tbundle install"
      system("bundle install")
    end
309164
function compile(source_file_path) {
    let pathParsed = path.parse(source_file_path);
    let nameParsed = path.parse(pathParsed.name);

    if (nameParsed.ext == '.module') {
      return Promise.reject({
        message: 'Modules are not supposed to be loaded'
      });
    }

    var str = fs.readFileSync(source_file_path, {
      encoding: 'utf8'
    });

    return getCompiler(str, source_file_path).render();
  }
414019
def configure_module_files
      source = "#{@target_dir}/app/apis/#{@project_name}/modules/#{@module_name}_apis.rb"
      application_module = @project_name.split('_').map(&:capitalize)*''
      file = File.read(source)
      replace = file.gsub(/module Rammer/, "module #{application_module}")
      File.open(source, "w"){|f|
        f.puts replace
      }
    end
163083
def build_module(project, env=None):
        ''''''
        from pyspider.libs import base_handler
        assert 'name' in project, 'need name of project'
        assert 'script' in project, 'need script of project'

        if env is None:
            env = {}
        # fix for old non-package version scripts
        pyspider_path = os.path.join(os.path.dirname(__file__), "..")
        if pyspider_path not in sys.path:
            sys.path.insert(1, pyspider_path)

        env = dict(env)
        env.update({
            'debug': project.get('status', 'DEBUG') == 'DEBUG',
        })

        loader = ProjectLoader(project)
        module = loader.load_module(project['name'])

        # logger inject
        module.log_buffer = []
        module.logging = module.logger = logging.Logger(project['name'])
        if env.get('enable_stdout_capture', True):
            handler = SaveLogHandler(module.log_buffer)
            handler.setFormatter(LogFormatter(color=False))
        else:
            handler = logging.StreamHandler()
            handler.setFormatter(LogFormatter(color=True))
        module.logger.addHandler(handler)

        if '__handler_cls__' not in module.__dict__:
            BaseHandler = module.__dict__.get('BaseHandler', base_handler.BaseHandler)
            for each in list(six.itervalues(module.__dict__)):
                if inspect.isclass(each) and each is not BaseHandler \
                        and issubclass(each, BaseHandler):
                    module.__dict__['__handler_cls__'] = each
        _class = module.__dict__.get('__handler_cls__')
        assert _class is not None, "need BaseHandler in project module"

        instance = _class()
        instance.__env__ = env
        instance.project_name = project['name']
        instance.project = project

        return {
            'loader': loader,
            'module': module,
            'class': _class,
            'instance': instance,
            'exception': None,
            'exception_log': '',
            'info': project,
            'load_time': time.time(),
        }
1240156
function(mod) {
  // XXX: consider using `Module.parent` and `delete require.cache[module.id]`
  if (!(mod instanceof Module)) {
    throw new TypeError(
      'Module required (e.g., "var __ = require(\'@carbon-io/fibers\').__(module)")')
  }
  var __ = function(f, cb) {
    if (typeof __ensure._getCurrentFiber() === 'undefined') {
      return __spawn(f, cb, _debugLogger.bind(undefined, mod))
    }
    var ret = undefined
    try {
      ret = f()
      if (cb) {
        cb(null, ret)
      }
    } catch (e) {
      // XXX: do we want to log to stderr here? setting mod to undefined for 
      //      now to disable stderr
      _debugLogger(
        undefined, 'Exception caught with cb undefined in __: ' + inspect(e))
      if (cb) {
        cb(e)
      } else {
        throw e
      }
    }
  }

  //  __(.main)?
  __.main = function() {
    console.warn('"__.main" is DEPRECATED and no longer necessary')
    return __.apply(undefined, arguments)
  }

  //  __(.ensure)*(.main)?
  __.ensure = __

  //  __(.(ensure|main))*
  __.main.ensure = __

  //  __(.(ensure|main))*(.spawn)?
  __.spawn = __spawn

  //  __(.(ensure|main))*(.spawn(.main(.(ensure|main))*)?)?
  __.spawn.main = __.main

  //  __(.(ensure|main))*(.spawn(.(ensure|main))*)?
  __.spawn.ensure = __

  //  __(.(spawn|ensure|main))*
  __.spawn.spawn = __spawn

  return __
}
1336266
function _loadDependencies(moduleName, localParams) {
                    var loadedModule,
                        requires,
                        diff,
                        promisesList = [],
                        self = this;

                    moduleName = self._getModuleName(moduleName);

                    if (moduleName === null) {
                        return $q.when();
                    } else {
                        try {
                            loadedModule = self._getModule(moduleName);
                        } catch (e) {
                            return reject(e);
                        }
                        // get unloaded requires
                        requires = self.getRequires(loadedModule);
                    }

                    angular.forEach(requires, function (requireEntry) {
                        // If no configuration is provided, try and find one from a previous load.
                        // If there isn't one, bail and let the normal flow run
                        if (angular.isString(requireEntry)) {
                            var config = self.getModuleConfig(requireEntry);
                            if (config === null) {
                                moduleCache.push(requireEntry); // We don't know about this module, but something else might, so push it anyway.
                                return;
                            }
                            requireEntry = config;
                            // ignore the name because it's probably not a real module name
                            config.name = undefined;
                        }

                        // Check if this dependency has been loaded previously
                        if (self.moduleExists(requireEntry.name)) {
                            // compare against the already loaded module to see if the new definition adds any new files
                            diff = requireEntry.files.filter(function (n) {
                                return self.getModuleConfig(requireEntry.name).files.indexOf(n) < 0;
                            });

                            // If the module was redefined, advise via the console
                            if (diff.length !== 0) {
                                self._$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency. "', requireEntry.name, '"\n Additional Files Loaded:', diff);
                            }

                            // Push everything to the file loader, it will weed out the duplicates.
                            if (angular.isDefined(self.filesLoader)) {
                                // if a files loader is defined
                                promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
                                    return self._loadDependencies(requireEntry);
                                }));
                            } else {
                                return reject(new Error('Error: New dependencies need to be loaded from external files (' + requireEntry.files + '), but no loader has been defined.'));
                            }
                            return;
                        } else if (angular.isArray(requireEntry)) {
                            var files = [];
                            angular.forEach(requireEntry, function (entry) {
                                // let's check if the entry is a file name or a config name
                                var config = self.getModuleConfig(entry);
                                if (config === null) {
                                    files.push(entry);
                                } else if (config.files) {
                                    files = files.concat(config.files);
                                }
                            });
                            if (files.length > 0) {
                                requireEntry = {
                                    files: files
                                };
                            }
                        } else if (angular.isObject(requireEntry)) {
                            if (requireEntry.hasOwnProperty('name') && requireEntry['name']) {
                                // The dependency doesn't exist in the module cache and is a new configuration, so store and push it.
                                self.setModuleConfig(requireEntry);
                                moduleCache.push(requireEntry['name']);
                            }
                        }

                        // Check if the dependency has any files that need to be loaded. If there are, push a new promise to the promise list.
                        if (angular.isDefined(requireEntry.files) && requireEntry.files.length !== 0) {
                            if (angular.isDefined(self.filesLoader)) {
                                // if a files loader is defined
                                promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
                                    return self._loadDependencies(requireEntry);
                                }));
                            } else {
                                return reject(new Error('Error: the module "' + requireEntry.name + '" is defined in external files (' + requireEntry.files + '), but no loader has been defined.'));
                            }
                        }
                    });

                    // Create a wrapper promise to watch the promise list and resolve it once everything is done.
                    return $q.all(promisesList);
                }
665136
def install_gem(gemname, version=None, conservative=True, ri=False, rdoc=False,
                development=False, format_executable=False, force=False,
                gem_source=None):
    """"""
    cmdline = ['gem', 'install']
    if conservative:
        cmdline.append('--conservative')
    if ri:
        cmdline.append('--ri')
    else:
        cmdline.append('--no-ri')
    if rdoc:
        cmdline.append('--rdoc')
    else:
        cmdline.append('--no-rdoc')
    if development:
        cmdline.append('--development')
    if format_executable:
        cmdline.append('--format-executable')
    if force:
        cmdline.append('--force')
    if version:
        cmdline.extend(['--version', version])
    cmdline.extend(['--clear-sources',
                    '--source', gem_source or RubyGems().gem_source])

    cmdline.append(gemname)

    msg = 'Installing ruby gem: %s' % gemname
    if version:
        msg += ' Version requested: %s' % version
    log.debug(msg)

    try:
        subprocess.check_output(cmdline, shell=False)
    except (OSError, subprocess.CalledProcessError) as err:
        raise error.ButcherError(
            'Gem install failed. Error was: %s. Output: %s' % (
                err, err.output))
900706
function resolveTransitiveDependencies(module, hash) {
    if (!(module instanceof Module)) {
      return Promise.reject("Unable to resolve module of type " + typeof(module));
    }

    var promises = [];
    for (var i in module.dependencies) {
      (function(dependencyName) {

        /* Ignore already resolved dependencies */
        if (hash[dependencyName]) return;

        /* Get a module or a promise to it and put it in the hash NOW! */
        var dependency = hash[dependencyName] = moduleOrPromise(dependencyName);

        /* Transitively resolve the dependency */
        promises.push(Promise.resolve(dependency).then(function(dependency) {
          hash[dependencyName] = dependency;
          return resolveTransitiveDependencies(dependency, hash);
        }));

      })(module.dependencies[i]);
    }

    return Promise.all(promises).then(function() {
      return hash;
    });
  }
963863
def create_gemspec(file=nil)
      file = gemspec if !file
      #require 'gemdo/gemspec'
      yaml = project.to_gemspec.to_yaml
      File.open(file, 'w') do |f|
        f << yaml
      end
      status File.basename(file) + " updated."
      return file
    end
876692
function analyzeModuleDefinition(node) {
	var args = node.arguments;
	var arg = 0;
	if ( arg < args.length
		 && args[arg].type === Syntax.Literal && typeof args[arg].value === 'string' ) {
		warning("module explicitly defined a module name '" + args[arg].value + "'");
		currentModule.name = args[arg].value;
		arg++;
	}
	if ( arg < args.length && args[arg].type === Syntax.ArrayExpression ) {
		currentModule.dependencies = convertValue(args[arg], "string[]");
		arg++;
	}
	if ( arg < args.length && args[arg].type === Syntax.FunctionExpression ) {
		currentModule.factory = args[arg];
		arg++;
	}
	if ( currentModule.dependencies && currentModule.factory ) {
		for ( var i = 0; i < currentModule.dependencies.length && i < currentModule.factory.params.length; i++ ) {
			var name = currentModule.factory.params[i].name;
			var module = resolveModuleName(currentModule.module, currentModule.dependencies[i]);
			debug("  import " + name + " from '" + module + "'");
			currentModule.localNames[name] = {
				module: module
				// no (or empty) path
			};
		}
	}
	if ( currentModule.factory ) {
		collectShortcuts(currentModule.factory.body);
	}
}
997852
function useModule(name, moduleClass) {
    if (arguments.length === 1) {
        moduleClass = name;
        name = null;
    }

    // create module
    var module = new moduleClass(),
        bootResponse = void 0;

    // Wrapper methods
    function boot() {
        var initialResponse = typeof module.boot === "function" ? module.boot() : null;

        if (initialResponse === false) {
            return false;
        }

        return initialResponse instanceof _es6Promise.Promise ? initialResponse.then(function (response) {
            bootResponse = response;
            return module;
        }) : module;
    }

    function ready() {
        if (typeof module.ready === "function") {
            return module.ready(bootResponse);
        }
    }

    return typeof name === "string" ? (0, _packages.define)(name, boot).then(ready) : (0, _packages.define)(boot).then(ready);
}
330437
def dependency(lib = nil)
      lib ? require(lib) : yield
    rescue LoadError, NameError => e
      self.load_error = e
    end
115192
def modify_files
      gemspec_file = "#{@base_path}/conduit-#{@dasherized_name}.gemspec"

      # add gemspec dependencies
      str = "  # Dependencies\n"\
            "  #\n"\
            "  spec.add_dependency \"conduit\", \"~> 1.0.6\"\n"\
            "  # xml parser\n"\
            "  spec.add_dependency \"nokogiri\"\n\n"\
            "  # Development Dependencies\n"\
            "  #\n"\
            "  # to compare xml files in tests\n"\
            "  spec.add_development_dependency \"equivalent-xml\"\n"\
            "  spec.add_development_dependency \"rspec-its\"\n"\
            "  # for building CLI\n"\
            "  spec.add_development_dependency \"thor\"\n"\
            "  # for debugging\n"\
            "  spec.add_development_dependency \"byebug\"\n"

      insert_into_file gemspec_file, str, after: "spec.require_paths = [\"lib\"]\n\n"

      # remove description
      gsub_file(gemspec_file, /spec\.description(.*)\n/, "")

      # update summary
      new_summary = "spec.summary       = \"#{ActiveSupport::Inflector.humanize @underscored_name} Driver for Conduit\""
      gsub_file(gemspec_file, /spec\.summary(.*)/, new_summary)

      # update homepage
      new_homepage = "spec.homepage      = \"http://www.github.com/conduit/conduit-#{@dasherized_name}\""
      gsub_file(gemspec_file, /spec\.homepage(.*)/, new_homepage)
    end
840120
function _define(/* <exports>, name, dependencies, factory */) {
            var
                // extract arguments
                argv = arguments,
                argc = argv.length,

                // extract arguments from function call - (exports?, name?, modules?, factory)
                exports = argv[argc - 4] || {},
                name = argv[argc - 3] || Math.floor(new Date().getTime() * (Math.random())), // if name is undefined or falsy value we add some timestamp like to name.
                dependencies = argv[argc - 2] || [],
                factory = argv[argc - 1],

                // helper variables
                params = [],
                dependencies_satisfied = true,
                dependency_name,
                result,
                config_dependencies_iterator = 0,
                dependencies_iterator = 0,
                config_dependencies_index = -1;

            if (DEVELOPMENT) {
                _set_debug_timer();
            }

            // config dependecies
            if (_define.prototype.config_dependencies && _define.prototype.config_dependencies.constructor === Array) {
                var config_dependencies = _define.prototype.config_dependencies || [];

                var config_dependencies_size = config_dependencies.length;
                for (; config_dependencies_iterator < config_dependencies_size; config_dependencies_iterator++) {
                    if (name === config_dependencies[config_dependencies_iterator]) {
                        config_dependencies_index = config_dependencies_iterator;
                    }
                }
                if (config_dependencies_index !== -1) {
                    config_dependencies.splice(config_dependencies_index, 1)
                } else {
                    dependencies = dependencies.concat(config_dependencies);
                }
            }

            // find params
            for (; dependencies_iterator < dependencies.length; dependencies_iterator++) {
                dependency_name = dependencies[dependencies_iterator];

                // if this dependency exists, push it to param injection
                if (modules.hasOwnProperty(dependency_name)) {
                    params.push(modules[dependency_name]);
                } else if (dependency_name === 'exports') {
                    params.push(exports);
                } else {
                    if (argc !== 4) { // if 4 values, is reexecuting
                        // no module found. save these arguments for future execution.
                        define_queue[dependency_name] = define_queue[dependency_name] || [];
                        define_queue[dependency_name].push([exports, name, dependencies, factory]);
                    }

                    dependencies_satisfied = false;
                }
            }

            // all dependencies are satisfied, so proceed
            if (dependencies_satisfied) {
                if (!modules.hasOwnProperty(name)) {
                    // execute this module
                    result = factory.apply(this, params);

                    if (result) {
                        modules[name] = result;
                    } else {
                        // assuming result is in exports object
                        modules[name] = exports;
                    }
                }

                // execute others waiting for this module
                while (define_queue[name] && (argv = define_queue[name].pop())) {
                    _define.apply(this, argv);
                }
            }
        }
10063
def add_versions
      new_gemfile = Tempfile.new("Gemfile.versioned")
      begin
        gemfile_content.each do |gem_line|
          if is_gem_line?(gem_line)
            new_gemfile.puts(build_gem_line(gem_line))
          else
            new_gemfile.puts(gem_line)
          end
        end
        File.truncate(gemfile_path, 0)
        new_gemfile.rewind
        File.open(gemfile_path, "w") {|f| f.write(new_gemfile.read)}
      rescue Exception => e
        puts "ERROR: #{e}"
        puts "Restoring Gemfile at #{gemfile_path}"
        File.open(gemfile_path, "w") {|f| f.write(@orig_gemfile)}
      ensure
        new_gemfile.close
        new_gemfile.unlink
      end
    end
659871
def activate!
      begin
        require gem_path unless required?
      rescue LoadError => e
        warn "Found plugin #{name}, but could not require gem '#{gem_name}'"
        warn e.to_s
      rescue StandardError => e
        warn "require gem '#{gem_name}' failed with: #{e}"
      end

      @required = true
    end
1294036
@SuppressWarnings("UnstableApiUsage")
    private void computeProjectDependencies(IdeaModule module) {
        ARTIFACT_DEPS_OF_PRJ.computeIfAbsent(module.getName(), moduleName -> {
            Map<String, Set<ArtifactSpec>> dependencies = new HashMap<>();
            module.getDependencies().forEach(dep -> {
                if (dep instanceof IdeaModuleDependency) {
                    // Add the dependency to the list.
                    String name = ((IdeaModuleDependency) dep).getTargetModuleName();
                    PRJ_DEPS_OF_PRJ.computeIfAbsent(moduleName, key -> new HashSet<>()).add(name);
                } else if (dep instanceof ExternalDependency) {
                    ExternalDependency extDep = (ExternalDependency) dep;
                    GradleModuleVersion gav = extDep.getGradleModuleVersion();
                    ArtifactSpec spec = new ArtifactSpec("compile", gav.getGroup(), gav.getName(), gav.getVersion(),
                                                         "jar", null, extDep.getFile());
                    String depScope = dep.getScope().getScope();
                    dependencies.computeIfAbsent(depScope, s -> new HashSet<>()).add(spec);
                }
            });
            return dependencies;
        });
    }