lib/danger/ci_source/travis.rb in danger-0.1.0 vs lib/danger/ci_source/travis.rb in danger-0.1.1
- old
+ new
@@ -1,19 +1,20 @@
# http://docs.travis-ci.com/user/osx-ci-environment/
# http://docs.travis-ci.com/user/environment-variables/
module Danger
- class Travis
+ module CISource
+ class Travis < CI
+ def self.validates?(env)
+ return !env["HAS_JOSH_K_SEAL_OF_APPROVAL"].nil?
+ end
- attr_accessor :repo_slug, :pull_request_id
-
- def self.validates?(env)
- return env["HAS_JOSH_K_SEAL_OF_APPROVAL"] != nil
+ def initialize(env)
+ self.repo_slug = env["TRAVIS_REPO_SLUG"]
+ # from https://docs.travis-ci.com/user/pull-requests, as otherwise it's "false"
+ if env["TRAVIS_PULL_REQUEST"].to_i > 0
+ self.pull_request_id = env["TRAVIS_PULL_REQUEST"]
+ end
+ end
end
-
- def initialize(env)
- self.repo_slug = env["TRAVIS_REPO_SLUG"]
- self.pull_request_id = env["TRAVIS_PULL_REQUEST"]
- end
-
end
end