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
-
#from(opts) ⇒ Object
The start date & time for search range.
-
#initialize(log = Log.new) ⇒ Grep
constructor
A new instance of Grep.
-
#now(opts) ⇒ Object
The current date & time for search range.
- #run(_, postman, opts) ⇒ Object
-
#svn_log(opts) ⇒ Object
Return all svn commits for particular date range in repo.
Constructor Details
Instance Method Details
#from(opts) ⇒ Object
The start date & time for search range
61 62 63 |
# File 'lib/lazylead/task/svn/grep.rb', line 61 def from(opts) (now(opts).to_time - opts["period"].to_i).to_datetime end |
#now(opts) ⇒ Object
The current date & time for search range
66 67 68 69 70 71 72 |
# File 'lib/lazylead/task/svn/grep.rb', line 66 def now(opts) if opts.key? "now" DateTime.parse(opts["now"]) else DateTime.now end end |
#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 |
# File 'lib/lazylead/task/svn/grep.rb', line 49 def svn_log(opts) cmd = [ "svn log --diff --no-auth-cache", "--username #{opts.decrypt('svn_user', 'svn_salt')}", "--password #{opts.decrypt('svn_password', 'svn_salt')}", "-r {#{from(opts)}}:{#{now(opts)}} #{opts['svn_url']}" ] stdout = `#{cmd.join(" ")}` stdout.split("-" * 72).reject(&:blank?).reverse.map { |e| Entry.new(e) } end |