Module: Verto::DSL::Syntax
- Included in:
- Interpreter
- Defined in:
- lib/verto/dsl/syntax.rb
Instance Method Summary collapse
- #after(&block) ⇒ Object
- #after_command(command_name, &block) ⇒ Object
- #after_command_tag_up(&block) ⇒ Object
- #before(&block) ⇒ Object
- #before_command(command_name, &block) ⇒ Object
- #before_command_tag_up(&block) ⇒ Object
- #before_tag_creation(&block) ⇒ Object
- #branch(*branch_names) ⇒ Object
- #command_options ⇒ Object
- #config(&block) ⇒ Object
-
#confirm(text) ⇒ Object
TODO: Use delegator.
- #context(condition, &block) ⇒ Object
- #current_branch ⇒ Object
- #env(environment_name) ⇒ Object
- #error(text) ⇒ Object
- #error!(text) ⇒ Object
- #file(filepath) ⇒ Object
- #git(subcommand, output: :from_config) ⇒ Object
- #git!(subcommand, output: :from_config) ⇒ Object
- #latest_pre_release_version ⇒ Object
- #latest_release_version ⇒ Object
- #latest_version ⇒ Object
- #on(moment, &block) ⇒ Object
- #sh(command, output: :from_config) ⇒ Object
- #sh!(command, output: :from_config) ⇒ Object
-
#update_changelog(with: :merged_pull_requests_with_bracketed_labels, confirmation: true, filename: 'CHANGELOG.md') ⇒ Object
Start the flow to Update the CHANGELOG file.
- #verto_version(expected_version_string) ⇒ Object
Instance Method Details
#after(&block) ⇒ Object
71 72 73 |
# File 'lib/verto/dsl/syntax.rb', line 71 def after(&block) Verto.config.hooks << Hook.new(moment: :after, &block) end |
#after_command(command_name, &block) ⇒ Object
87 88 89 90 91 |
# File 'lib/verto/dsl/syntax.rb', line 87 def after_command(command_name, &block) deprecate('after_command', use: 'after_command_tag_up') Verto.config.hooks << Hook.new(moment: "after_#{command_name}", &block) end |
#after_command_tag_up(&block) ⇒ Object
97 98 99 |
# File 'lib/verto/dsl/syntax.rb', line 97 def after_command_tag_up(&block) Verto.config.hooks << Hook.new(moment: 'after_tag_up', &block) end |
#before(&block) ⇒ Object
67 68 69 |
# File 'lib/verto/dsl/syntax.rb', line 67 def before(&block) Verto.config.hooks << Hook.new(moment: :before, &block) end |
#before_command(command_name, &block) ⇒ Object
81 82 83 84 85 |
# File 'lib/verto/dsl/syntax.rb', line 81 def before_command(command_name, &block) deprecate('before_command', use: 'before_command_tag_up') Verto.config.hooks << Hook.new(moment: "before_#{command_name}", &block) end |
#before_command_tag_up(&block) ⇒ Object
93 94 95 |
# File 'lib/verto/dsl/syntax.rb', line 93 def before_command_tag_up(&block) Verto.config.hooks << Hook.new(moment: 'before_tag_up', &block) end |
#before_tag_creation(&block) ⇒ Object
101 102 103 |
# File 'lib/verto/dsl/syntax.rb', line 101 def before_tag_creation(&block) Verto.config.hooks << Hook.new(moment: 'before_tag_creation', &block) end |
#branch(*branch_names) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/verto/dsl/syntax.rb', line 35 def branch(*branch_names) branch_names.any? do |branch| return branch.match?(current_branch) if branch.is_a?(Regexp) branch.to_s.include? current_branch end end |
#command_options ⇒ Object
63 64 65 |
# File 'lib/verto/dsl/syntax.rb', line 63 def Verto.config. end |
#config(&block) ⇒ Object
15 16 17 |
# File 'lib/verto/dsl/syntax.rb', line 15 def config(&block) Verto.config.instance_eval(&block) end |
#confirm(text) ⇒ Object
TODO: Use delegator
136 137 138 |
# File 'lib/verto/dsl/syntax.rb', line 136 def confirm(text) CliHelpers.confirm(text) end |
#context(condition, &block) ⇒ Object
43 44 45 |
# File 'lib/verto/dsl/syntax.rb', line 43 def context(condition, &block) block.call if condition end |
#current_branch ⇒ Object
31 32 33 |
# File 'lib/verto/dsl/syntax.rb', line 31 def current_branch @current_branch ||= git('rev-parse --abbrev-ref HEAD', output: false).output.chomp.strip end |
#env(environment_name) ⇒ Object
131 132 133 |
# File 'lib/verto/dsl/syntax.rb', line 131 def env(environment_name) ENV[environment_name] end |
#error(text) ⇒ Object
140 141 142 |
# File 'lib/verto/dsl/syntax.rb', line 140 def error(text) stderr.puts text end |
#error!(text) ⇒ Object
144 145 146 147 148 |
# File 'lib/verto/dsl/syntax.rb', line 144 def error!(text) error(text) raise Verto::ExitError end |
#file(filepath) ⇒ Object
127 128 129 |
# File 'lib/verto/dsl/syntax.rb', line 127 def file(filepath) DSL::File.new(filepath) end |
#git(subcommand, output: :from_config) ⇒ Object
47 48 49 |
# File 'lib/verto/dsl/syntax.rb', line 47 def git(subcommand, output: :from_config) sh("git #{subcommand}", output: output) end |
#git!(subcommand, output: :from_config) ⇒ Object
51 52 53 |
# File 'lib/verto/dsl/syntax.rb', line 51 def git!(subcommand, output: :from_config) sh!("git #{subcommand}", output: output) end |
#latest_pre_release_version ⇒ Object
27 28 29 |
# File 'lib/verto/dsl/syntax.rb', line 27 def latest_pre_release_version @latest_pre_release_version ||= latest_semantic_version_for(:pre_release_only) end |
#latest_release_version ⇒ Object
23 24 25 |
# File 'lib/verto/dsl/syntax.rb', line 23 def latest_release_version @latest_release_version ||= latest_semantic_version_for(:release_only) end |
#latest_version ⇒ Object
19 20 21 |
# File 'lib/verto/dsl/syntax.rb', line 19 def latest_version @latest_version ||= latest_semantic_version_for(:all) end |
#on(moment, &block) ⇒ Object
75 76 77 78 79 |
# File 'lib/verto/dsl/syntax.rb', line 75 def on(moment, &block) deprecate('on', use: 'before_tag_creation') Verto.config.hooks << Hook.new(moment: moment, &block) end |
#sh(command, output: :from_config) ⇒ Object
55 56 57 |
# File 'lib/verto/dsl/syntax.rb', line 55 def sh(command, output: :from_config) command_executor(output: output).run command end |
#sh!(command, output: :from_config) ⇒ Object
59 60 61 |
# File 'lib/verto/dsl/syntax.rb', line 59 def sh!(command, output: :from_config) raise Verto::ExitError, command unless sh(command, output: output).success? end |
#update_changelog(with: :merged_pull_requests_with_bracketed_labels, confirmation: true, filename: 'CHANGELOG.md') ⇒ Object
Start the flow to Update the CHANGELOG file
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/verto/dsl/syntax.rb', line 115 def update_changelog(with: :merged_pull_requests_with_bracketed_labels, confirmation: true, filename: 'CHANGELOG.md') permitted_moments = %w[before_tag_creation after_tag_up] unless permitted_moments.include? Verto.current_moment.to_s raise ExitError, 'update_changelog is only supported in before_tag_creation or after_command_tag_up' end UpdateChangelog.new.call(with: with, new_version: new_version, confirmation: confirmation, filename: filename) end |
#verto_version(expected_version_string) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/verto/dsl/syntax.rb', line 6 def verto_version(expected_version_string) expected_version = Verto::SemanticVersion.new(expected_version_string) verto_version = Verto::SemanticVersion.new(Verto::VERSION) = "Current Verto version is #{verto_version}, required version is #{expected_version} or higher" raise Verto::ExitError, unless expected_version <= verto_version end |