Create a GEM Package task library.  Automatically define the gem
 if a block is given.  If no block is supplied, then +define+
 needs to be called to define the task.
 Initialization tasks without the "yield self" or define
 operations.
556461
def init(gem)
      super(gem.name, gem.version)
      @gem_spec = gem
      @package_files += gem_spec.files if gem_spec.files
    end
1238005
function Task(options) {
  if (!(this instanceof Task)) {
    return new Task(options);
  }

  utils.is(this, 'task');
  use(this);

  this.options = options || {};
  if (utils.isTask(options)) {
    this.options = {};
    this.addTargets(options);
    return this;
  }
}
294688
def with(&block)
      raise ArgumentError.new("Must pass a block") unless block_given?
      case block.arity
        when 1
          yield self
        when 0
          instance_methods_eval(&block)
        else
          raise "block arity must be 0 or 1"
      end
    end
122878
def and_yield(*args)
      yield eval_context = Object.new if block_given?
      @plan = Proc.new do |&block|
        eval_context.instance_exec(*args, &block)
      end
      self
    end
274897
function definePackage(name, dependencies, callback) {
    // Adjust arguments
    if (typeof name === "function") {
        callback = name;
        name = null;
        dependencies = null;
    } else if (typeof dependencies === "function") {
        callback = dependencies;
        dependencies = null;

        if (name instanceof Array) {
            dependencies = name;
            name = null;
        }
    }

    // Check name conflicts
    if (typeof name === "string") {
        if (packages.has(name)) {
            throw new Error("Package '" + name + "' is already loaded!");
        }
    }

    // Resolve timeout
    var timeout = _config2.default.get('package_timeout', 5000),
        timer = null;

    return new _es6Promise.Promise(function (succeed, fail) {

        // Start timeout
        if (typeof timeout === "number") {
            timer = setTimeout(function () {
                timer = null;

                if (_config2.default.get("debug", true)) {
                    throw new Error("Package '" + name + "' timed out!");
                }
            }, timeout);
        }

        // Resolve dependencies
        requireDependencies(dependencies).then(function (requirements) {
            try {

                // register package
                var register = function register(pack) {
                    // cancel timeout
                    if (timer) {
                        clearTimeout(timer);
                        timer = null;
                    }

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

                    if (typeof name === "string") {
                        packages.set(name, pack);
                        events.emit("load:" + name, packages.get(name));
                    }

                    return succeed(pack);
                };

                // Check boot response


                var bootResponse = typeof callback === "function" ? callback(requirements) : callback;return bootResponse instanceof _es6Promise.Promise ? bootResponse.then(register) : register(bootResponse);
            } catch (ex) {
                if (_config2.default.get("debug", true)) {
                    console.error(ex);
                }

                return fail(ex);
            }
        });
    });
}
517219
def init(app_name="rake", argv = ARGV)
      standard_exception_handling do
        @name = app_name
        begin
          args = handle_options argv
        rescue ArgumentError
          # Backward compatibility for capistrano
          args = handle_options
        end
        collect_command_line_tasks(args)
      end
    end
1055081
def with_gemfile(path, *args, &block)
      # Make sure that if block calls  #gemfile we still return the gemfile for this
      # process, regardless of what's in ENV temporarily
      @gemfile_changed = true
      @process_gemfile = ENV['BUNDLE_GEMFILE']
      Bundler.with_clean_env do
        ENV['BUNDLE_GEMFILE'] = path
        block.call(*args)
      end
    ensure
      @gemfile_changed = false
      ENV['BUNDLE_GEMFILE'] = @process_gemfile
    end
1019048
def create_directive(tag_name, tag_buf)
      if library.has_directive?(tag_name)
        dir = library.directive_create(tag_name, tag_buf, self)
        if dir.is_a?(Tags::Directive)
          @directives << dir
          dir
        end
      else
        log.warn "Unknown directive @!#{tag_name}" +
                 (object ? " in file `#{object.file}` near line #{object.line}" : "")
        nil
      end
    rescue Tags::TagFormatError
      log.warn "Invalid directive format for @!#{tag_name}" +
               (object ? " in file `#{object.file}` near line #{object.line}" : "")
      nil
    end
814458
def recipe_installs_gem(type, action = :install)
      case type
        when :simple
          write_recipe %Q{
            gem_package "bluepill" do
              action :#{action}
             end
          }.strip
        when :compile_time
          write_recipe %Q{
            r = gem_package "mysql" do
              action :nothing
            end

            r.run_action(:#{action})
            Gem.clear_paths
          }.strip
        when :compile_time_from_array
          write_recipe %Q{
            ['foo', 'bar', 'baz'].each do |pkg|
              r = gem_package pkg do
                action :nothing
              end
              r.run_action(:#{action})
            end
          }.strip
        when :compile_time_from_word_list
          write_recipe %Q{
            %w{foo bar baz}.each do |pkg|
              r = gem_package pkg do
                action :nothing
              end
              r.run_action(:#{action})
            end
          }.strip
        else
          raise "Unrecognised type: #{type}"
      end
    end
828352
def load
      load_source_and_set_module
      module_callbacks if @module
      yield if block_given? # load dependencies
      detect_additions { load_commands } if load_commands?
      set_library_commands
      loaded_correctly? && (@loaded = true)
    end
549649
def build_tasks
      all_output.split("\n").map do |task|
        next unless task.start_with? "rake"
        task.split("#").map { |t| t.strip.sub(/^rake /, "") }
      end.compact
    end
398112
def load_tasks(app = self)
      if Rails::VERSION::MAJOR < 4
        railties.all { |r| r.load_tasks(app) }
      end

      extend Rake::DSL if defined? Rake::DSL
      self.class.rake_tasks.each { |block| instance_exec(app, &block) }
      paths['lib/tasks'].existent.sort.each { |ext| load(ext) }
      self
    end
843414
def execute_tasks(tasks,template_path)
      
      if File.exists?(File.expand_path(File.join(template_path,'tasks.rb')))
        load File.expand_path(File.join(template_path,'tasks.rb'))
      end
       
      tasks.each{
        |task|
        
        puts 'Running Task: ' + task
        
        task = replace_tags(task);
        
        options = task.split(', ')
        action = options.slice!(0)
        
        if(Tasks.respond_to?(action))
          Tasks.send action, options.join(', ')
        else
          send action, options.join(', ')
        end
        
      }
                  
    end
1087999
def task(name, *args)
      klass = Fudge::Tasks.discover(name)

      task = klass.new(*args)
      current_scope.tasks << task

      with_scope(task) { yield if block_given? }
    end
434204
def define(&block)
      if block && block.arity > 0
        block.call @ns
      elsif block
        @ns.instance_eval(&block)
      end
      @ns
    end
565148
def define_per_project_config_builder_tasks
      
      projects.each do |project|
        project.targets.each do |target|
          target.configs.each do |config|
            
            builder_actions.each do |action|
              
              description = "#{action.capitalize} #{project.name} #{target.name} #{config.name}"
              task_name = friendlyname("#{name}:#{project.name}:#{target.name}:#{config.name}:#{action}")
            
              define_task_with description, task_name do
                config.builder.send(action)
              end
              
            end
            
          end
        end
      end
      
      
    end
650505
def install
      extend Rake::DSL
      # Core Halite tasks
      unless options[:no_gem]
        desc "Convert #{gemspec.name}-#{gemspec.version} to a cookbook in the pkg directory"
        task 'chef:build' do
          build_cookbook
        end

        desc "Push #{gemspec.name}-#{gemspec.version} to Supermarket"
        task 'chef:release' => ['chef:build'] do
          release_cookbook(pkg_path)
        end

        # Patch the core gem tasks to run ours too
        task 'build' => ['chef:build']
        task 'release' => ['chef:release']
      else
        desc "Push #{gem_name} to Supermarket"
        task 'chef:release' do
          release_cookbook(base)
        end
      end

      # Foodcritic doesn't have a config file, so just always try to add it.
      unless options[:no_foodcritic]
        install_foodcritic
      end

      # If a .kitchen.yml exists, install the Test Kitchen tasks.
      unless options[:no_kitchen] || !File.exist?(File.join(@base, '.kitchen.yml'))
        install_kitchen
      end
    end