Class: Zoom::Profile::Ack
- Inherits:
-
Zoom::Profile
- Object
- Hash
- Zoom::Profile
- Zoom::Profile::Ack
- Defined in:
- lib/zoom/profile/ack.rb
Instance Attribute Summary
Attributes inherited from Zoom::Profile
#exts, #files, #format_flags, #regex, #taggable
Instance Method Summary collapse
- #grep_like_format_flags(all = false) ⇒ Object
-
#initialize(n = nil, t = nil, f = nil, b = nil, a = nil) ⇒ Ack
constructor
A new instance of Ack.
- #only_exts ⇒ Object
- #translate(from) ⇒ Object
Methods inherited from Zoom::Profile
#after, #before, #class_name, #exe, #flags, from_json, #grep_like_tags?, #name, #only_exts_and_files, #preprocess, profile_by_name, subclasses, #to_s, #tool
Constructor Details
#initialize(n = nil, t = nil, f = nil, b = nil, a = nil) ⇒ Ack
Returns a new instance of Ack.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/zoom/profile/ack.rb', line 15 def initialize(n = nil, t = nil, f = nil, b = nil, a = nil) f ||= "--smart-case" # Special case because of debian t ||= "ack" if ((t == "ack") && ScoobyDoo.where_are_you("ack-grep")) t = "ack-grep" end super(n, t, f, b, a) end |
Instance Method Details
#grep_like_format_flags(all = false) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/zoom/profile/ack.rb', line 2 def grep_like_format_flags(all = false) super @format_flags = [ "-H", "--nobreak", "--nocolor", "--nogroup", "--noheading", "-s" ].join(" ") @taggable = true end |
#only_exts ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/zoom/profile/ack.rb', line 27 def only_exts f = Array.new @exts.each do |ext| f.push("--type-add \"zoom:ext:#{ext}\"") end @files.each do |file| f.push("--type-add \"zoom:is:#{file}\"") end f.push("--type zoom") if (!@exts.empty? || !@files.empty?) return f.join(" ") end |
#translate(from) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/zoom/profile/ack.rb', line 39 def translate(from) to = Array.new from.each do |flag, value| case flag when "all" grep_like_format_flags(true) when "follow" to.push("--follow") when "ignore" value.each do |v| # Convert GLOB to regex v.gsub!(/\./, "\\.") v.gsub!(/\*/, ".*") to.push("--ignore-dir=\"#{v}\"") to.push("--ignore-file=\"match:/#{v}/\"") end when "word-regexp" to.push("-w") end end return to.join(" ") end |