Class: ReleaseCeremony::Project
- Inherits:
-
Object
- Object
- ReleaseCeremony::Project
- Defined in:
- lib/release_ceremony/project.rb
Overview
The repository-specific facts the release ceremony needs: the gem name, the release file paths, the GitHub repository URL, and the verification commands. Project.load reads overrides from .release_ceremony.yml and falls back to the repository's gemspec and conventional defaults.
Defined Under Namespace
Modules: Config Classes: GemspecFacts
Constant Summary collapse
- CONFIG_FILE =
'.release_ceremony.yml'- CONFIG_KEYS =
%w[gem_name repo_url version_file changelog_file verification_commands workflow_file default_branch remote].freeze
- REPO_URL_PATTERN =
%r{\Ahttps://github\.com/[A-Za-z0-9._-]+/[A-Za-z0-9._-]+\z}- DEFAULT_VERIFICATION_COMMANDS =
[ %w[bundle install], %w[bundle exec rspec], %w[bundle exec rubocop], %w[bundle exec rake build] ].freeze
Instance Attribute Summary collapse
-
#changelog_file ⇒ Object
readonly
Returns the value of attribute changelog_file.
-
#default_branch ⇒ Object
readonly
Returns the value of attribute default_branch.
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#repo_url ⇒ Object
readonly
Returns the value of attribute repo_url.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#verification_commands ⇒ Object
readonly
Returns the value of attribute verification_commands.
-
#version_file ⇒ Object
readonly
Returns the value of attribute version_file.
-
#workflow_file ⇒ Object
readonly
Returns the value of attribute workflow_file.
Class Method Summary collapse
Instance Method Summary collapse
- #actions_run_url(run_id) ⇒ Object
- #compare_base ⇒ Object
-
#initialize(root:, gem_name:, repo_url:, version_file: nil, changelog_file: nil, verification_commands: nil, workflow_file: nil, default_branch: nil, remote: nil) ⇒ Project
constructor
A new instance of Project.
Constructor Details
#initialize(root:, gem_name:, repo_url:, version_file: nil, changelog_file: nil, verification_commands: nil, workflow_file: nil, default_branch: nil, remote: nil) ⇒ Project
Returns a new instance of Project.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/release_ceremony/project.rb', line 45 def initialize(root:, gem_name:, repo_url:, version_file: nil, changelog_file: nil, verification_commands: nil, workflow_file: nil, default_branch: nil, remote: nil) @root = validated_string(:root, root) @gem_name = validated_string(:gem_name, gem_name) @repo_url = validated_repo_url(repo_url) @version_file = validated_string(:version_file, version_file || default_version_file) @changelog_file = validated_string(:changelog_file, changelog_file || 'CHANGELOG.md') @verification_commands = validated_commands(verification_commands || DEFAULT_VERIFICATION_COMMANDS) @workflow_file = validated_string(:workflow_file, workflow_file || 'release.yml') @default_branch = validated_string(:default_branch, default_branch || 'main') @remote = validated_string(:remote, remote || 'origin') end |
Instance Attribute Details
#changelog_file ⇒ Object (readonly)
Returns the value of attribute changelog_file.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def changelog_file @changelog_file end |
#default_branch ⇒ Object (readonly)
Returns the value of attribute default_branch.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def default_branch @default_branch end |
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def gem_name @gem_name end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def remote @remote end |
#repo_url ⇒ Object (readonly)
Returns the value of attribute repo_url.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def repo_url @repo_url end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def root @root end |
#verification_commands ⇒ Object (readonly)
Returns the value of attribute verification_commands.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def verification_commands @verification_commands end |
#version_file ⇒ Object (readonly)
Returns the value of attribute version_file.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def version_file @version_file end |
#workflow_file ⇒ Object (readonly)
Returns the value of attribute workflow_file.
23 24 25 |
# File 'lib/release_ceremony/project.rb', line 23 def workflow_file @workflow_file end |
Class Method Details
.discover(runner: Runner.new) ⇒ Object
27 28 29 |
# File 'lib/release_ceremony/project.rb', line 27 def discover(runner: Runner.new) load(root: runner.capture('git', 'rev-parse', '--show-toplevel').strip) end |
.load(root:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/release_ceremony/project.rb', line 31 def load(root:) config = Config.read(root) gemspec = GemspecFacts.new(root) overrides = config.slice('version_file', 'changelog_file', 'verification_commands', 'workflow_file', 'default_branch', 'remote').transform_keys(&:to_sym) new( root: root, gem_name: config.fetch('gem_name') { gemspec.name }, repo_url: config.fetch('repo_url') { gemspec.repo_url }, **overrides ) end |
Instance Method Details
#actions_run_url(run_id) ⇒ Object
62 63 64 |
# File 'lib/release_ceremony/project.rb', line 62 def actions_run_url(run_id) "#{repo_url}/actions/runs/#{run_id}" end |
#compare_base ⇒ Object
58 59 60 |
# File 'lib/release_ceremony/project.rb', line 58 def compare_base "#{repo_url}/compare/" end |