This repository has been archived by the owner on Sep 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added view model for the Project in detail
- Loading branch information
Showing
4 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require_relative "../../shared/models/build" | ||
require_relative "../../shared/json_convertible" | ||
|
||
module FastlaneCI | ||
# View model to expose the basic info about a build. | ||
class BuildSummaryViewModel | ||
include FastlaneCI::JSONConvertible | ||
|
||
# @return [Integer] | ||
attr_accessor :number | ||
|
||
# @return [String] | ||
attr_reader :status | ||
|
||
# @return [Integer] | ||
attr_reader :duration | ||
|
||
# @return [String] The git sha of the commit this build was run for | ||
attr_reader :sha | ||
|
||
# @return [DateTime] Start time | ||
attr_reader :timestamp | ||
|
||
def initialize(build:) | ||
raise "Incorrect object type. Expected Build, got #{build.class}" unless build.kind_of?(Build) | ||
|
||
@number = build.number | ||
@status = build.status | ||
@duration = build.duration | ||
@sha = build.sha | ||
@timestamp = build.timestamp | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require_relative "./build_summary_view_model" | ||
require_relative "../../shared/models/project" | ||
require_relative "../../shared/json_convertible" | ||
|
||
module FastlaneCI | ||
# View model to expose the basic info about a project. | ||
class ProjectViewModel | ||
include FastlaneCI::JSONConvertible | ||
|
||
# @return [String] Name of the project, also shows up in status as "fastlane.ci: #{project_name}" | ||
attr_accessor :name | ||
|
||
# @return [String] Is a UUID so we're not open to ID guessing attacks | ||
attr_reader :id | ||
|
||
# @return [Array[BuildSummaryViewModel]] | ||
attr_reader :builds | ||
|
||
def initialize(project:) | ||
raise "Incorrect object type. Expected Project, got #{project.class}" unless project.kind_of?(Project) | ||
|
||
@name = project.project_name | ||
@id = project.id | ||
@builds = project.builds.map { |build| BuildSummaryViewModel.new(build: build) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters