Class: Lazylead::Task::Svn::Grep
- Inherits:
-
Object
- Object
- Lazylead::Task::Svn::Grep
- Defined in:
- lib/lazylead/task/svn/grep.rb
Overview
Detect particular text in diff commit.
Instance Method Summary collapse
-
#initialize(log = Log.new) ⇒ Grep
constructor
A new instance of Grep.
- #run(_, postman, opts) ⇒ Object
-
#svn_log(opts) ⇒ Object
Return all svn commits for particular date range in repo.
Constructor Details
Instance Method Details
#run(_, postman, opts) ⇒ Object
42 43 44 45 46 |
# File 'lib/lazylead/task/svn/grep.rb', line 42 def run(_, postman, opts) text = opts.slice("text", ",") commits = svn_log(opts).select { |c| c.includes? text } postman.send(opts.merge(entries: commits)) unless commits.empty? end |
#svn_log(opts) ⇒ Object
Return all svn commits for particular date range in repo
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lazylead/task/svn/grep.rb', line 49 def svn_log(opts) now = if opts.key? "now" DateTime.parse(opts["now"]) else DateTime.now end start = (now.to_time - opts["period"].to_i).to_datetime cmd = [ "svn log --diff --no-auth-cache", "--username #{opts.decrypt('svn_user', 'svn_salt')}", "--password #{opts.decrypt('svn_password', 'svn_salt')}", "-r {#{start}}:{#{now}} #{opts['svn_url']}" ] stdout = `#{cmd.join(" ")}` stdout.split("-" * 72).reject(&:blank?).reverse .map { |e| Entry.new(e) } end |