class Spark::Shard::ShardContent
- Spark::Shard::ShardContent
- Reference
- Object
Defined in:
spark/shard/shard_content.crConstructors
-
.new(name : String, github : String? = nil, git : String? = nil, version : String? = nil, branch : String? = nil)
Given some basic shard information, provides an object that can be written to
shard.yml
with#to_s
.
Instance Method Summary
-
#branch : String?
The branch of the shard to use.
-
#git : String?
The git URL of the shard.
-
#github : String?
The GitHub spath of the shard.
-
#name : String
The name of the shard
-
#source
Intelligently determine whether to use the GitHub or git source for a shard.
-
#to_s
Outputs a
shard.yml
-friendly representation of the given shard content. -
#version : String?
The version of the shard.
-
#version_or_branch
Intelligently determine whether to use the branch or a version string for the shard.
Constructor Detail
Given some basic shard information, provides an object that can be written to shard.yml
with #to_s
.
Instance Method Detail
The branch of the shard to use.
Either #version
or #branch
may be optionally provided, but not both.
Example:
main
The git URL of the shard.
Example:
https://mycustomserver.com/stephendolan/spark
Intelligently determine whether to use the GitHub or git source for a shard.
Outputs a shard.yml
-friendly version of the source.
Example:
Spark::Shard::ShardContent.new(name: "test", github: "stephendolan/spark").source # => "github: stephendolan/spark"
Spark::Shard::ShardContent.new(name: "test", git: "https://custom-git.com/stephendolan/spark.git").source # => "git: https://custom-git.com/stephendolan/spark.git"
Outputs a shard.yml
-friendly representation of the given shard content.
Every shard should be nested under a header section, so we always indent with two spaces.
Example:
shard_content = Spark::Shard::ShardContent.new(name: "spark", github: "stephendolan/spark", version: "~> 1.0.3")
shard_content.to_s # => <<-CONTENT
spark:
github: stephendolan/spark
version: ~> 1.0.3
CONTENT
The version of the shard.
Either #version
or #branch
may be optionally provided, but not both.
Example:
~> 1.0.3
Intelligently determine whether to use the branch or a version string for the shard.
Outputs a shard.yml
-friendly variant of the version or branch, which is always suffixed
with a newline since it is the last line in a shard definition. This allows for a simpler #to_s
implementation.
Example:
Spark::Shard::ShardContent.new(name: "test", github: "stephendolan/spark", version: "~> 1.0.3").version_or_branch # => "version: ~> 1.0.3\n"
Spark::Shard::ShardContent.new(name: "test", github: "stephendolan/spark", branch: "main").version_or_branch # => "branch: main\n"