Sha256: 0668d5aa836e01f0e3d9b8860af41ba74bc1986ab22407a163537dd731f44718

Contents?: true

Size: 1.13 KB

Versions: 173

Compression:

Stored size: 1.13 KB

Contents

require "claide_plugin"
require "danger/commands/dangerfile/init"

module Danger
  class DangerfileGem < DangerfileCommand
    self.summary = "Create a gem-based Dangerfile quickly."
    def self.description
      <<-DESC
                Creates a scaffold for the development of a new gem based Dangerfile
                named `NAME` according to the best practices.
      DESC
    end
    self.command = "gem"
    self.arguments = [
      CLAide::Argument.new("NAME", true)
    ]

    def initialize(argv)
      @name = argv.shift_argument
      prefix = "dangerfile" + "-"
      unless @name.nil? || @name.empty? || @name.start_with?(prefix)
        @name = prefix + @name.dup
      end
      @template_url = argv.shift_argument
      super
    end

    def validate!
      super
      if @name.nil? || @name.empty?
        help! "A name for the plugin is required."
      end

      help! "The plugin name cannot contain spaces." if @name =~ /\s/
    end

    def run
      runner = CLAide::TemplateRunner.new(@name, "https://github.com/danger/dangerfile-gem-template")
      runner.clone_template
      runner.configure_template
    end
  end
end

Version data entries

173 entries across 173 versions & 2 rubygems

Version Path
danger-4.0.5 lib/danger/commands/dangerfile/gem.rb
danger-4.0.4 lib/danger/commands/dangerfile/gem.rb
danger-4.0.3 lib/danger/commands/dangerfile/gem.rb
danger-4.0.2 lib/danger/commands/dangerfile/gem.rb
danger-4.0.1 lib/danger/commands/dangerfile/gem.rb
danger-4.0.0 lib/danger/commands/dangerfile/gem.rb
danger-3.6.0 lib/danger/commands/dangerfile/gem.rb
danger-3.5.5 lib/danger/commands/dangerfile/gem.rb
danger-3.5.4 lib/danger/commands/dangerfile/gem.rb
danger-3.5.3 lib/danger/commands/dangerfile/gem.rb
danger-3.5.2 lib/danger/commands/dangerfile/gem.rb
danger-3.5.1 lib/danger/commands/dangerfile/gem.rb
danger-3.5.0 lib/danger/commands/dangerfile/gem.rb