Class: GitHooker::Action::DSL
- Inherits:
-
Object
- Object
- GitHooker::Action::DSL
- Includes:
- Repo
- Defined in:
- lib/githooker/action.rb
Constant Summary
Constants included from Repo
Repo::CHANGE_TYPES, Repo::CHANGE_TYPE_SYMBOLS, Repo::DEFAULT_DIFF_INDEX_OPTIONS
Instance Method Summary collapse
-
#args ⇒ Object
DSL Methods.
- #call ⇒ Object
- #execute(cmd, output_line_prefix = nil) ⇒ Object
-
#initialize(block) ⇒ DSL
constructor
A new instance of DSL.
- #on(options = {}, &block) ⇒ Object
Methods included from Repo
#diff_index, #match, #match_file, #match_files_on, #match_phase, #root_path, #run_while_stashed, #staged_manifest, #stash, #unstaged_manifest, #unstash, #use_unstaged?, #while_stashed
Constructor Details
#initialize(block) ⇒ DSL
Returns a new instance of DSL.
71 72 73 |
# File 'lib/githooker/action.rb', line 71 def initialize(block) @block = block end |
Instance Method Details
#args ⇒ Object
DSL Methods
78 |
# File 'lib/githooker/action.rb', line 78 def args() ARGV.dup; end |
#call ⇒ Object
75 |
# File 'lib/githooker/action.rb', line 75 def call() instance_eval(&@block); end |
#execute(cmd, output_line_prefix = nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/githooker/action.rb', line 87 def execute(cmd, output_line_prefix=nil) Open3.popen3(cmd) { |i, o, e, t| o.read.split(/\n/).each do |line| $stdout.puts output_line_prefix ? "#{output_line_prefix}: #{line}" : line end e.read.split(/\n/).each do |line| $stderr.puts output_line_prefix ? "#{output_line_prefix}: #{line}" : line end t.value }.success? end |
#on(options = {}, &block) ⇒ Object
80 81 82 83 84 85 |
# File 'lib/githooker/action.rb', line 80 def on( = {}, &block) block = block || .delete(:call) Repo.match_files_on().collect { |file| block.call(file) }.all? # test that they all returned true end |