lib/agile_notifier/ci.rb in agile_notifier-2.1.4 vs lib/agile_notifier/ci.rb in agile_notifier-3.0.0
- old
+ new
@@ -4,69 +4,51 @@
module AgileNotifier
class CI
include Servable
alias_method :original_is_available?, :is_available?
- attr_accessor :jobs
+ attr_accessor :job
- def initialize(url, *jobs)
- @url = url
- jobs.empty? ? @jobs = get_all_jobs : @jobs = jobs
- end
-
def is_available?
original_is_available?(@url)
end
def get_all_jobs
raise(NotImplementedError, "Abstract method [#{__method__}] is called, please implement", caller)
end
- def job
- if @jobs.size == 1
- return @jobs.first
- else
- raise('There are more than one job, please use method [jobs] instead of [job]')
- end
- end
-
class Job
attr_accessor :name, :url
- attr_reader :last_build, :penultimate_build
+ attr_reader :current_build
- def initialize(name, url)
+ def initialize(name, url, build_number = nil)
@name = name
@url = url
- @last_build = get_last_build
- @penultimate_build = get_penultimate_build
+ @current_build = build_number.nil? ? get_last_build : get_specific_build(build_number.to_i)
end
-
- def get_last_build
+
+ def get_specific_build(build_number)
raise(NotImplementedError, "Abstract method [#{__method__}] is called, please implement", caller)
end
- def get_penultimate_build
+ def get_last_build
raise(NotImplementedError, "Abstract method [#{__method__}] is called, please implement", caller)
end
- def update_last_build
- @last_build = get_last_build
- end
-
- def update_penultimate_build
- @penultimate_build = get_penultimate_build
- end
-
class Build
include Trackable
attr_accessor :number, :url, :result, :revision
def initialize(number, url)
@number = number
@url = url
@result = get_result
@revision = get_revision
+ end
+
+ def is_building?
+ raise(NotImplementedError, "Abstract method [#{__method__}] is called, please implement", caller)
end
def get_result
raise(NotImplementedError, "Abstract method [#{__method__}] is called, please implement", caller)
end
\ No newline at end of file