danger 0.8.5 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/bin/danger +2 -2
- data/lib/danger.rb +13 -13
- data/lib/danger/ci_source/buildkite.rb +5 -5
- data/lib/danger/ci_source/ci_source.rb +3 -3
- data/lib/danger/ci_source/circle.rb +13 -13
- data/lib/danger/ci_source/circle_api.rb +4 -4
- data/lib/danger/ci_source/drone.rb +5 -5
- data/lib/danger/ci_source/jenkins.rb +4 -4
- data/lib/danger/ci_source/local_git_repo.rb +13 -13
- data/lib/danger/ci_source/semaphore.rb +5 -5
- data/lib/danger/ci_source/surf.rb +24 -0
- data/lib/danger/ci_source/teamcity.rb +4 -4
- data/lib/danger/ci_source/travis.rb +6 -6
- data/lib/danger/ci_source/xcode_server.rb +2 -2
- data/lib/danger/commands/init.rb +93 -82
- data/lib/danger/commands/init_helpers/interviewer.rb +15 -15
- data/lib/danger/commands/local.rb +13 -13
- data/lib/danger/commands/plugins/plugin_lint.rb +11 -8
- data/lib/danger/commands/plugins/plugin_readme.rb +15 -11
- data/lib/danger/commands/runner.rb +31 -20
- data/lib/danger/core_ext/string.rb +3 -3
- data/lib/danger/danger_core/dangerfile.rb +31 -31
- data/lib/danger/danger_core/dangerfile_dsl.rb +1 -1
- data/lib/danger/danger_core/environment_manager.rb +6 -6
- data/lib/danger/danger_core/plugins/dangerfile_git_plugin.rb +5 -5
- data/lib/danger/danger_core/plugins/dangerfile_github_plugin.rb +2 -2
- data/lib/danger/danger_core/plugins/dangerfile_import_plugin.rb +9 -9
- data/lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb +3 -3
- data/lib/danger/danger_core/standard_error.rb +6 -6
- data/lib/danger/plugin_support/plugin.rb +1 -1
- data/lib/danger/plugin_support/plugin_file_resolver.rb +6 -6
- data/lib/danger/plugin_support/plugin_parser.rb +75 -31
- data/lib/danger/request_source/request_source.rb +4 -4
- data/lib/danger/scm_source/git_repo.rb +3 -3
- data/lib/danger/version.rb +2 -2
- metadata +17 -4
- data/lib/danger/commands/plugins/plugin_abstract.rb +0 -11
- data/lib/danger/commands/plugins/plugin_new.rb +0 -34
| @@ -7,19 +7,19 @@ module Danger | |
| 7 7 | 
             
                end
         | 
| 8 8 |  | 
| 9 9 | 
             
                def show_prompt
         | 
| 10 | 
            -
                  ui.print  | 
| 10 | 
            +
                  ui.print "> ".bold.green
         | 
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 13 | 
             
                def yellow_bang
         | 
| 14 | 
            -
                   | 
| 14 | 
            +
                  "! ".yellow
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 17 | 
             
                def green_bang
         | 
| 18 | 
            -
                   | 
| 18 | 
            +
                  "! ".green
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| 21 21 | 
             
                def red_bang
         | 
| 22 | 
            -
                   | 
| 22 | 
            +
                  "! ".red
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                def say(output)
         | 
| @@ -28,12 +28,12 @@ module Danger | |
| 28 28 |  | 
| 29 29 | 
             
                def header(title)
         | 
| 30 30 | 
             
                  say title.yellow
         | 
| 31 | 
            -
                  say  | 
| 31 | 
            +
                  say ""
         | 
| 32 32 | 
             
                  pause 0.6
         | 
| 33 33 | 
             
                end
         | 
| 34 34 |  | 
| 35 35 | 
             
                def link(url)
         | 
| 36 | 
            -
                  say  | 
| 36 | 
            +
                  say " -> " + url.underline + "\n"
         | 
| 37 37 | 
             
                end
         | 
| 38 38 |  | 
| 39 39 | 
             
                def pause(time)
         | 
| @@ -48,12 +48,12 @@ module Danger | |
| 48 48 |  | 
| 49 49 | 
             
                def run_command(command, output_command = nil)
         | 
| 50 50 | 
             
                  output_command ||= command
         | 
| 51 | 
            -
                  ui.puts  | 
| 51 | 
            +
                  ui.puts "  " + output_command.magenta
         | 
| 52 52 | 
             
                  system command
         | 
| 53 53 | 
             
                end
         | 
| 54 54 |  | 
| 55 55 | 
             
                def ask(question)
         | 
| 56 | 
            -
                  answer =  | 
| 56 | 
            +
                  answer = ""
         | 
| 57 57 | 
             
                  loop do
         | 
| 58 58 | 
             
                    ui.puts "\n#{question}?"
         | 
| 59 59 |  | 
| @@ -73,26 +73,26 @@ module Danger | |
| 73 73 | 
             
                  print_info = proc do
         | 
| 74 74 | 
             
                    possible_answers.each_with_index do |answer, i|
         | 
| 75 75 | 
             
                      the_answer = (i == 0) ? answer.underline : answer
         | 
| 76 | 
            -
                      ui.print  | 
| 77 | 
            -
                      ui.print( | 
| 76 | 
            +
                      ui.print " " + the_answer
         | 
| 77 | 
            +
                      ui.print(" /") if i != possible_answers.length - 1
         | 
| 78 78 | 
             
                    end
         | 
| 79 79 | 
             
                    ui.print " ]\n"
         | 
| 80 80 | 
             
                  end
         | 
| 81 81 | 
             
                  print_info.call
         | 
| 82 82 |  | 
| 83 | 
            -
                  answer =  | 
| 83 | 
            +
                  answer = ""
         | 
| 84 84 |  | 
| 85 85 | 
             
                  loop do
         | 
| 86 86 | 
             
                    show_prompt
         | 
| 87 87 | 
             
                    answer = @no_waiting ? possible_answers[0].downcase : STDIN.gets.downcase.chomp
         | 
| 88 88 |  | 
| 89 | 
            -
                    answer =  | 
| 90 | 
            -
                    answer =  | 
| 89 | 
            +
                    answer = "yes" if answer == "y"
         | 
| 90 | 
            +
                    answer = "no" if answer == "n"
         | 
| 91 91 |  | 
| 92 92 | 
             
                    # default to first answer
         | 
| 93 | 
            -
                    if answer ==  | 
| 93 | 
            +
                    if answer == ""
         | 
| 94 94 | 
             
                      answer = possible_answers[0].downcase
         | 
| 95 | 
            -
                      ui.puts  | 
| 95 | 
            +
                      ui.puts "Using: " + answer.yellow
         | 
| 96 96 | 
             
                    end
         | 
| 97 97 |  | 
| 98 98 | 
             
                    break if possible_answers.map(&:downcase).include? answer
         | 
| @@ -1,30 +1,30 @@ | |
| 1 1 | 
             
            module Danger
         | 
| 2 2 | 
             
              class Local < Runner
         | 
| 3 | 
            -
                self.summary =  | 
| 4 | 
            -
                self.command =  | 
| 3 | 
            +
                self.summary = "Run the Dangerfile locally."
         | 
| 4 | 
            +
                self.command = "local"
         | 
| 5 5 |  | 
| 6 6 | 
             
                def initialize(argv)
         | 
| 7 | 
            -
                  @dangerfile_path =  | 
| 8 | 
            -
                  @pr_num = argv.option( | 
| 7 | 
            +
                  @dangerfile_path = "Dangerfile" if File.exist? "Dangerfile"
         | 
| 8 | 
            +
                  @pr_num = argv.option("use-merged-pr")
         | 
| 9 9 | 
             
                  super
         | 
| 10 10 | 
             
                end
         | 
| 11 11 |  | 
| 12 12 | 
             
                def self.options
         | 
| 13 13 | 
             
                  [
         | 
| 14 | 
            -
                    [ | 
| 14 | 
            +
                    ["--use-merged-pr=[#id]", "The ID of an already merged PR inside your history to use as a reference for the local run."]
         | 
| 15 15 | 
             
                  ].concat(super)
         | 
| 16 16 | 
             
                end
         | 
| 17 17 |  | 
| 18 18 | 
             
                def validate!
         | 
| 19 19 | 
             
                  super
         | 
| 20 20 | 
             
                  unless @dangerfile_path
         | 
| 21 | 
            -
                    help!  | 
| 21 | 
            +
                    help! "Could not find a Dangerfile."
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                def run
         | 
| 26 | 
            -
                  ENV[ | 
| 27 | 
            -
                  ENV[ | 
| 26 | 
            +
                  ENV["DANGER_USE_LOCAL_GIT"] = "YES"
         | 
| 27 | 
            +
                  ENV["LOCAL_GIT_PR_ID"] = @pr_num if @pr_num
         | 
| 28 28 |  | 
| 29 29 | 
             
                  env = EnvironmentManager.new(ENV)
         | 
| 30 30 | 
             
                  dm = Dangerfile.new(env, cork)
         | 
| @@ -32,7 +32,7 @@ module Danger | |
| 32 32 |  | 
| 33 33 | 
             
                  source = dm.env.ci_source
         | 
| 34 34 | 
             
                  if source.nil? or source.repo_slug.empty?
         | 
| 35 | 
            -
                    cork.puts  | 
| 35 | 
            +
                    cork.puts "danger local failed because it only works with GitHub projects at the moment. Sorry.".red
         | 
| 36 36 | 
             
                    exit 0
         | 
| 37 37 | 
             
                  end
         | 
| 38 38 |  | 
| @@ -41,20 +41,20 @@ module Danger | |
| 41 41 | 
             
                  cork.puts "Running your Dangerfile against this PR - https://#{gh.host}/#{source.repo_slug}/pull/#{source.pull_request_id}"
         | 
| 42 42 |  | 
| 43 43 | 
             
                  if verbose != true
         | 
| 44 | 
            -
                    cork.puts  | 
| 44 | 
            +
                    cork.puts "Turning on --verbose"
         | 
| 45 45 | 
             
                    dm.verbose = true
         | 
| 46 46 | 
             
                  end
         | 
| 47 47 |  | 
| 48 48 | 
             
                  cork.puts
         | 
| 49 49 |  | 
| 50 50 | 
             
                  # We can use tokenless here, as it's running on someone's computer
         | 
| 51 | 
            -
                  # and is IP locked, as opposed | 
| 51 | 
            +
                  # and is IP locked, as opposed to on the CI.
         | 
| 52 52 | 
             
                  gh.support_tokenless_auth = true
         | 
| 53 53 |  | 
| 54 54 | 
             
                  begin
         | 
| 55 55 | 
             
                    gh.fetch_details
         | 
| 56 56 | 
             
                  rescue Octokit::NotFound
         | 
| 57 | 
            -
                    cork.puts "Local repository was not found on GitHub. If you're trying to test a private repository please provide a valid API token through " +  | 
| 57 | 
            +
                    cork.puts "Local repository was not found on GitHub. If you're trying to test a private repository please provide a valid API token through " + "DANGER_GITHUB_API_TOKEN".yellow + " environment variable."
         | 
| 58 58 | 
             
                    return
         | 
| 59 59 | 
             
                  end
         | 
| 60 60 |  | 
| @@ -63,7 +63,7 @@ module Danger | |
| 63 63 | 
             
                  begin
         | 
| 64 64 | 
             
                    dm.env.fill_environment_vars
         | 
| 65 65 | 
             
                    dm.env.ensure_danger_branches_are_setup
         | 
| 66 | 
            -
                    dm.env.scm.diff_for_folder( | 
| 66 | 
            +
                    dm.env.scm.diff_for_folder(".", from: Danger::EnvironmentManager.danger_base_branch, to: Danger::EnvironmentManager.danger_head_branch)
         | 
| 67 67 | 
             
                    dm.parse(Pathname.new(@dangerfile_path))
         | 
| 68 68 | 
             
                    dm.print_results
         | 
| 69 69 | 
             
                  ensure
         | 
| @@ -1,18 +1,21 @@ | |
| 1 | 
            -
            require  | 
| 2 | 
            -
            require  | 
| 3 | 
            -
            require 'danger/plugin_support/plugin_file_resolver'
         | 
| 1 | 
            +
            require "danger/plugin_support/plugin_parser"
         | 
| 2 | 
            +
            require "danger/plugin_support/plugin_file_resolver"
         | 
| 4 3 |  | 
| 5 4 | 
             
            module Danger
         | 
| 6 | 
            -
              class PluginLint <  | 
| 7 | 
            -
                self.summary =  | 
| 8 | 
            -
                self.command =  | 
| 5 | 
            +
              class PluginLint < CLAide::Command::Plugins
         | 
| 6 | 
            +
                self.summary = "Lints a plugin"
         | 
| 7 | 
            +
                self.command = "lint"
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                attr_accessor :cork
         | 
| 9 10 |  | 
| 10 11 | 
             
                def initialize(argv)
         | 
| 11 12 | 
             
                  @refs = argv.arguments! unless argv.arguments.empty?
         | 
| 13 | 
            +
                  @cork = Cork::Board.new(silent: argv.option("silent", false),
         | 
| 14 | 
            +
                                          verbose: argv.option("verbose", false))
         | 
| 12 15 | 
             
                  super
         | 
| 13 16 | 
             
                end
         | 
| 14 17 |  | 
| 15 | 
            -
                self.summary =  | 
| 18 | 
            +
                self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
         | 
| 16 19 |  | 
| 17 20 | 
             
                self.description = <<-DESC
         | 
| 18 21 | 
             
                  Converts a collection of file paths of Danger plugins into a JSON format.
         | 
| @@ -21,7 +24,7 @@ module Danger | |
| 21 24 | 
             
                DESC
         | 
| 22 25 |  | 
| 23 26 | 
             
                self.arguments = [
         | 
| 24 | 
            -
                  CLAide::Argument.new( | 
| 27 | 
            +
                  CLAide::Argument.new("Paths, Gems or Nothing", false, true)
         | 
| 25 28 | 
             
                ]
         | 
| 26 29 |  | 
| 27 30 | 
             
                def run
         | 
| @@ -1,19 +1,23 @@ | |
| 1 | 
            -
            require  | 
| 2 | 
            -
            require  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 1 | 
            +
            require "danger/plugin_support/plugin_parser"
         | 
| 2 | 
            +
            require "danger/plugin_support/plugin_file_resolver"
         | 
| 3 | 
            +
            require "json"
         | 
| 4 | 
            +
            require "erb"
         | 
| 5 5 |  | 
| 6 6 | 
             
            module Danger
         | 
| 7 | 
            -
              class PluginReadme <  | 
| 8 | 
            -
                self.summary =  | 
| 9 | 
            -
                self.command =  | 
| 7 | 
            +
              class PluginReadme < CLAide::Command::Plugins
         | 
| 8 | 
            +
                self.summary = "Generates a README from a set of plugins"
         | 
| 9 | 
            +
                self.command = "readme"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                attr_accessor :cork
         | 
| 10 12 |  | 
| 11 13 | 
             
                def initialize(argv)
         | 
| 12 14 | 
             
                  @refs = argv.arguments! unless argv.arguments.empty?
         | 
| 15 | 
            +
                  @cork = Cork::Board.new(silent: argv.option("silent", false),
         | 
| 16 | 
            +
                                          verbose: argv.option("verbose", false))
         | 
| 13 17 | 
             
                  super
         | 
| 14 18 | 
             
                end
         | 
| 15 19 |  | 
| 16 | 
            -
                self.summary =  | 
| 20 | 
            +
                self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."
         | 
| 17 21 |  | 
| 18 22 | 
             
                self.description = <<-DESC
         | 
| 19 23 | 
             
                  Converts a collection of file paths of Danger plugins into a format usable in a README.
         | 
| @@ -21,7 +25,7 @@ module Danger | |
| 21 25 | 
             
                DESC
         | 
| 22 26 |  | 
| 23 27 | 
             
                self.arguments = [
         | 
| 24 | 
            -
                  CLAide::Argument.new( | 
| 28 | 
            +
                  CLAide::Argument.new("Paths, Gems or Nothing", false, true)
         | 
| 25 29 | 
             
                ]
         | 
| 26 30 |  | 
| 27 31 | 
             
                attr_accessor :json, :markdown
         | 
| @@ -35,8 +39,8 @@ module Danger | |
| 35 39 | 
             
                  self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_intra_emphasis: true)
         | 
| 36 40 | 
             
                  self.json = JSON.parse(parser.to_json)
         | 
| 37 41 |  | 
| 38 | 
            -
                  template = File.join(Danger.gem_path,  | 
| 39 | 
            -
                  cork.puts ERB.new(File.read(template), 0,  | 
| 42 | 
            +
                  template = File.join(Danger.gem_path, "lib/danger/plugin_support/templates/readme_table.html.erb")
         | 
| 43 | 
            +
                  cork.puts ERB.new(File.read(template), 0, "-").result(binding)
         | 
| 40 44 | 
             
                end
         | 
| 41 45 | 
             
              end
         | 
| 42 46 | 
             
            end
         | 
| @@ -1,11 +1,22 @@ | |
| 1 1 | 
             
            module Danger
         | 
| 2 2 | 
             
              class Runner < CLAide::Command
         | 
| 3 | 
            -
                require  | 
| 4 | 
            -
                require  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
                 | 
| 8 | 
            -
                 | 
| 3 | 
            +
                require "danger/commands/init"
         | 
| 4 | 
            +
                require "danger/commands/local"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                # manually set claide plugins as a subcommand
         | 
| 7 | 
            +
                require "claide_plugin"
         | 
| 8 | 
            +
                @subcommands << CLAide::Command::Plugins
         | 
| 9 | 
            +
                CLAide::Plugins.config =
         | 
| 10 | 
            +
                  CLAide::Plugins::Configuration.new("Danger",
         | 
| 11 | 
            +
                                                     "danger",
         | 
| 12 | 
            +
                                                     "https://raw.githubusercontent.com/danger/danger.systems/master/plugins-search-generated.json",
         | 
| 13 | 
            +
                                                     "https://github.com/danger/danger-plugin-template")
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                require "danger/commands/plugins/plugin_lint"
         | 
| 16 | 
            +
                require "danger/commands/plugins/plugin_readme"
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                self.summary = "Run the Dangerfile."
         | 
| 19 | 
            +
                self.command = "danger"
         | 
| 9 20 | 
             
                self.version = Danger::VERSION
         | 
| 10 21 |  | 
| 11 22 | 
             
                self.plugin_prefixes = %w(claide danger)
         | 
| @@ -13,29 +24,29 @@ module Danger | |
| 13 24 | 
             
                attr_accessor :cork
         | 
| 14 25 |  | 
| 15 26 | 
             
                def initialize(argv)
         | 
| 16 | 
            -
                  dangerfile = argv.option( | 
| 27 | 
            +
                  dangerfile = argv.option("dangerfile", "Dangerfile")
         | 
| 17 28 | 
             
                  @dangerfile_path = dangerfile if File.exist? dangerfile
         | 
| 18 | 
            -
                  @base = argv.option( | 
| 19 | 
            -
                  @head = argv.option( | 
| 20 | 
            -
                  @danger_id = argv.option( | 
| 21 | 
            -
                  @cork = Cork::Board.new(silent: argv.option( | 
| 22 | 
            -
                                          verbose: argv.option( | 
| 29 | 
            +
                  @base = argv.option("base")
         | 
| 30 | 
            +
                  @head = argv.option("head")
         | 
| 31 | 
            +
                  @danger_id = argv.option("danger_id", "danger")
         | 
| 32 | 
            +
                  @cork = Cork::Board.new(silent: argv.option("silent", false),
         | 
| 33 | 
            +
                                          verbose: argv.option("verbose", false))
         | 
| 23 34 | 
             
                  super
         | 
| 24 35 | 
             
                end
         | 
| 25 36 |  | 
| 26 37 | 
             
                def validate!
         | 
| 27 38 | 
             
                  super
         | 
| 28 39 | 
             
                  if self.class == Runner && !@dangerfile_path
         | 
| 29 | 
            -
                    help!  | 
| 40 | 
            +
                    help! "Could not find a Dangerfile."
         | 
| 30 41 | 
             
                  end
         | 
| 31 42 | 
             
                end
         | 
| 32 43 |  | 
| 33 44 | 
             
                def self.options
         | 
| 34 45 | 
             
                  [
         | 
| 35 | 
            -
                    [ | 
| 36 | 
            -
                    [ | 
| 37 | 
            -
                    [ | 
| 38 | 
            -
                    [ | 
| 46 | 
            +
                    ["--base=[master|dev|stable]", "A branch/tag/commit to use as the base of the diff"],
         | 
| 47 | 
            +
                    ["--head=[master|dev|stable]", "A branch/tag/commit to use as the head"],
         | 
| 48 | 
            +
                    ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
         | 
| 49 | 
            +
                    ["--danger_id=<id>", "The identifier of this Danger instance"]
         | 
| 39 50 | 
             
                  ].concat(super)
         | 
| 40 51 | 
             
                end
         | 
| 41 52 |  | 
| @@ -55,7 +66,7 @@ module Danger | |
| 55 66 | 
             
                      # Offer the chance for a user to specify a branch through the command line
         | 
| 56 67 | 
             
                      ci_base = @base || EnvironmentManager.danger_base_branch
         | 
| 57 68 | 
             
                      ci_head = @head || EnvironmentManager.danger_head_branch
         | 
| 58 | 
            -
                      dm.env.scm.diff_for_folder( | 
| 69 | 
            +
                      dm.env.scm.diff_for_folder(".", from: ci_base, to: ci_head)
         | 
| 59 70 |  | 
| 60 71 | 
             
                      dm.parse Pathname.new(@dangerfile_path)
         | 
| 61 72 |  | 
| @@ -65,7 +76,7 @@ module Danger | |
| 65 76 | 
             
                      dm.env.clean_up
         | 
| 66 77 | 
             
                    end
         | 
| 67 78 | 
             
                  else
         | 
| 68 | 
            -
                    cork.puts  | 
| 79 | 
            +
                    cork.puts "Not a Pull Request - skipping `danger` run"
         | 
| 69 80 | 
             
                  end
         | 
| 70 81 | 
             
                end
         | 
| 71 82 |  | 
| @@ -81,7 +92,7 @@ module Danger | |
| 81 92 | 
             
                  raise exception if exception.kind_of?(SystemExit)
         | 
| 82 93 | 
             
                  message = "#{exception.message.red} (#{exception.class.to_s.yellow})"
         | 
| 83 94 | 
             
                  if exception.backtrace
         | 
| 84 | 
            -
                    danger_lib = File.expand_path( | 
| 95 | 
            +
                    danger_lib = File.expand_path("../../..", __FILE__)
         | 
| 85 96 | 
             
                    message << "\n\t" << exception.backtrace.reverse_each.
         | 
| 86 97 | 
             
                                         drop_while { |bt| !bt.start_with?(danger_lib) }.reverse.
         | 
| 87 98 | 
             
                                         join("\n\t")
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            class String
         | 
| 2 2 | 
             
              def danger_class
         | 
| 3 | 
            -
                split( | 
| 3 | 
            +
                split("_").collect!(&:capitalize).join
         | 
| 4 4 | 
             
              end
         | 
| 5 5 |  | 
| 6 6 | 
             
              def danger_pluralize(count)
         | 
| @@ -8,10 +8,10 @@ class String | |
| 8 8 | 
             
              end
         | 
| 9 9 |  | 
| 10 10 | 
             
              def danger_underscore
         | 
| 11 | 
            -
                self.gsub(/::/,  | 
| 11 | 
            +
                self.gsub(/::/, "/").
         | 
| 12 12 | 
             
                  gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
         | 
| 13 13 | 
             
                  gsub(/([a-z\d])([A-Z])/, '\1_\2').
         | 
| 14 | 
            -
                  tr( | 
| 14 | 
            +
                  tr("-", "_").
         | 
| 15 15 | 
             
                  downcase
         | 
| 16 16 | 
             
              end
         | 
| 17 17 | 
             
            end
         | 
| @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            # So much was ripped direct from CocoaPods-Core - thanks!
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 3 | 
            +
            require "danger/danger_core/dangerfile_dsl"
         | 
| 4 | 
            +
            require "danger/danger_core/standard_error"
         | 
| 5 5 |  | 
| 6 | 
            -
            require  | 
| 7 | 
            -
            require  | 
| 8 | 
            -
            require  | 
| 9 | 
            -
            require  | 
| 6 | 
            +
            require "danger/danger_core/plugins/dangerfile_messaging_plugin"
         | 
| 7 | 
            +
            require "danger/danger_core/plugins/dangerfile_import_plugin"
         | 
| 8 | 
            +
            require "danger/danger_core/plugins/dangerfile_git_plugin"
         | 
| 9 | 
            +
            require "danger/danger_core/plugins/dangerfile_github_plugin"
         | 
| 10 10 |  | 
| 11 | 
            -
            require  | 
| 11 | 
            +
            require "danger/danger_core/plugins/dangerfile_github_plugin"
         | 
| 12 12 |  | 
| 13 13 | 
             
            module Danger
         | 
| 14 14 | 
             
              class Dangerfile
         | 
| @@ -25,7 +25,7 @@ module Danger | |
| 25 25 | 
             
                #         presented to the user.
         | 
| 26 26 | 
             
                #
         | 
| 27 27 | 
             
                def to_s
         | 
| 28 | 
            -
                   | 
| 28 | 
            +
                  "Dangerfile"
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 31 | 
             
                # These are the classes that are allowed to also use method_missing
         | 
| @@ -73,7 +73,7 @@ module Danger | |
| 73 73 | 
             
                  @env = env_manager
         | 
| 74 74 |  | 
| 75 75 | 
             
                  # Triggers local plugins from the root of a project
         | 
| 76 | 
            -
                  Dir[ | 
| 76 | 
            +
                  Dir["./danger_plugins/*.rb"].each do |file|
         | 
| 77 77 | 
             
                    require File.expand_path(file)
         | 
| 78 78 | 
             
                  end
         | 
| 79 79 |  | 
| @@ -115,10 +115,10 @@ module Danger | |
| 115 115 | 
             
                    methods.map do |method|
         | 
| 116 116 | 
             
                      case method
         | 
| 117 117 | 
             
                      when :api
         | 
| 118 | 
            -
                        value =  | 
| 118 | 
            +
                        value = "Octokit::Client"
         | 
| 119 119 |  | 
| 120 120 | 
             
                      when :pr_json
         | 
| 121 | 
            -
                        value =  | 
| 121 | 
            +
                        value = "[Skipped]"
         | 
| 122 122 |  | 
| 123 123 | 
             
                      when :pr_body
         | 
| 124 124 | 
             
                        value = plugin.send(method)
         | 
| @@ -140,20 +140,20 @@ module Danger | |
| 140 140 | 
             
                def print_known_info
         | 
| 141 141 | 
             
                  rows = []
         | 
| 142 142 | 
             
                  rows += method_values_for_plugin_hashes(core_dsl_attributes)
         | 
| 143 | 
            -
                  rows << [ | 
| 143 | 
            +
                  rows << ["---", "---"]
         | 
| 144 144 | 
             
                  rows += method_values_for_plugin_hashes(external_dsl_attributes)
         | 
| 145 | 
            -
                  rows << [ | 
| 146 | 
            -
                  rows << [ | 
| 147 | 
            -
                  rows << [ | 
| 148 | 
            -
                  rows << [ | 
| 149 | 
            -
                  rows << [ | 
| 150 | 
            -
                  rows << [ | 
| 145 | 
            +
                  rows << ["---", "---"]
         | 
| 146 | 
            +
                  rows << ["SCM", env.scm.class]
         | 
| 147 | 
            +
                  rows << ["Source", env.ci_source.class]
         | 
| 148 | 
            +
                  rows << ["Requests", env.request_source.class]
         | 
| 149 | 
            +
                  rows << ["Base Commit", env.meta_info_for_base]
         | 
| 150 | 
            +
                  rows << ["Head Commit", env.meta_info_for_head]
         | 
| 151 151 |  | 
| 152 152 | 
             
                  params = {}
         | 
| 153 153 | 
             
                  params[:rows] = rows.each { |current| current[0] = current[0].yellow }
         | 
| 154 154 | 
             
                  params[:title] = "Danger v#{Danger::VERSION}\nDSL Attributes".green
         | 
| 155 155 |  | 
| 156 | 
            -
                  ui.section( | 
| 156 | 
            +
                  ui.section("Info:") do
         | 
| 157 157 | 
             
                    ui.puts
         | 
| 158 158 | 
             
                    ui.puts Terminal::Table.new(params)
         | 
| 159 159 | 
             
                    ui.puts
         | 
| @@ -165,23 +165,23 @@ module Danger | |
| 165 165 | 
             
                def parse(path, contents = nil)
         | 
| 166 166 | 
             
                  print_known_info if verbose
         | 
| 167 167 |  | 
| 168 | 
            -
                  contents ||= File.open(path,  | 
| 168 | 
            +
                  contents ||= File.open(path, "r:utf-8", &:read)
         | 
| 169 169 |  | 
| 170 170 | 
             
                  # Work around for Rubinius incomplete encoding in 1.9 mode
         | 
| 171 | 
            -
                  if contents.respond_to?(:encoding) && contents.encoding.name !=  | 
| 172 | 
            -
                    contents.encode!( | 
| 171 | 
            +
                  if contents.respond_to?(:encoding) && contents.encoding.name != "UTF-8"
         | 
| 172 | 
            +
                    contents.encode!("UTF-8")
         | 
| 173 173 | 
             
                  end
         | 
| 174 174 |  | 
| 175 | 
            -
                  if contents.tr!( | 
| 175 | 
            +
                  if contents.tr!("“”‘’‛", %(""'''))
         | 
| 176 176 | 
             
                    # Changes have been made
         | 
| 177 177 | 
             
                    ui.puts "Your #{path.basename} has had smart quotes sanitised. " \
         | 
| 178 | 
            -
                       | 
| 179 | 
            -
                       | 
| 180 | 
            -
                       | 
| 178 | 
            +
                      "To avoid issues in the future, you should not use " \
         | 
| 179 | 
            +
                      "TextEdit for editing it. If you are not using TextEdit, " \
         | 
| 180 | 
            +
                      "you should turn off smart quotes in your editor of choice.".red
         | 
| 181 181 | 
             
                  end
         | 
| 182 182 |  | 
| 183 | 
            -
                  if contents.include?( | 
| 184 | 
            -
                    ui.puts  | 
| 183 | 
            +
                  if contents.include?("puts")
         | 
| 184 | 
            +
                    ui.puts "You used `puts` in your Dangerfile. To print out text to GitHub use `message` instead"
         | 
| 185 185 | 
             
                  end
         | 
| 186 186 |  | 
| 187 187 | 
             
                  self.defined_in_file = path
         | 
| @@ -203,9 +203,9 @@ module Danger | |
| 203 203 | 
             
                  status = status_report
         | 
| 204 204 | 
             
                  return if (status[:errors] + status[:warnings] + status[:messages] + status[:markdowns]).count == 0
         | 
| 205 205 |  | 
| 206 | 
            -
                  ui.section( | 
| 206 | 
            +
                  ui.section("Results:") do
         | 
| 207 207 | 
             
                    [:errors, :warnings, :messages].each do |key|
         | 
| 208 | 
            -
                      formatted = key.to_s.capitalize +  | 
| 208 | 
            +
                      formatted = key.to_s.capitalize + ":"
         | 
| 209 209 | 
             
                      title = case key
         | 
| 210 210 | 
             
                              when :errors
         | 
| 211 211 | 
             
                                formatted.red
         | 
| @@ -219,7 +219,7 @@ module Danger | |
| 219 219 | 
             
                    end
         | 
| 220 220 |  | 
| 221 221 | 
             
                    if status[:markdowns].count > 0
         | 
| 222 | 
            -
                      ui.section( | 
| 222 | 
            +
                      ui.section("Markdown:") do
         | 
| 223 223 | 
             
                        status[:markdowns].each do |current_markdown|
         | 
| 224 224 | 
             
                          ui.puts current_markdown
         | 
| 225 225 | 
             
                        end
         |