Sha256: 943658c8f5a524b755bf7e41bd79b454bd826d8821e8d878cff1f2d934f8cddc

Contents?: true

Size: 610 Bytes

Versions: 1

Compression:

Stored size: 610 Bytes

Contents

module Jenkins
  module Build
    class Build
      BUILDS = %w[\d+ lastBuild lastStableBuild lastSuccessfulBuild lastFailedBuild lastUnstableBuild lastUnsuccessfulBuild lastCompletedBuild].freeze
      JENKINS_PATH = %r{^/jobs/(?<job>[\w-]+)/(?<build_number>#{Regexp.union(BUILDS)})}.freeze
      NUMBER = /\A\d+\z/.freeze

      attr_reader :uri, :job, :number

      def initialize(url)
        @uri = URI(url)

        match = @uri.path.match(JENKINS_PATH) or return

        @job = match[:job]
        @number = (number = match[:build_number]) =~ NUMBER ? number.to_i : number
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jenkins-build-0.2.0.pre1 lib/jenkins/build/build.rb