Class: Zoom::Profile::Passwords

Inherits:
Zoom::Profile show all
Defined in:
lib/zoom/profile/passwords.rb

Instance Attribute Summary

Attributes inherited from Zoom::Profile

#immutable, #taggable

Instance Method Summary collapse

Methods inherited from Zoom::Profile

#append, cache_file, #flags, from_json, #operator, #prepend, profile_by_name

Constructor Details

#initialize(operator = nil, flags = "", envprepend = "", append = "") ⇒ Passwords

Returns a new instance of Passwords.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/zoom/profile/passwords.rb', line 25

def initialize(
    operator = nil,
    flags = "",
    envprepend = "",
    append = ""
)
    @passwd_regex = "\"pass(word|wd)?[^:=,>]? *[:=,>]\""

    if (ScoobyDoo.where_are_you("ag"))
        @profile = Zoom::Profile::Ag.new(
            nil,
            "-uS",
            "",
            @passwd_regex
        )
    elsif (
        ScoobyDoo.where_are_you("ack") ||
        ScoobyDoo.where_are_you("ack-grep")
    )
        @profile = Zoom::Profile::Ack.new(
            nil,
            "--smart-case",
            "",
            @passwd_regex
        )
    else
        @profile = Zoom::Profile::Grep.new(
            nil,
            "--color=always -EHinR",
            "",
            @passwd_regex
        )
    end

    super(
        @profile.operator,
        @profile.flags,
        @profile.prepend,
        @profile.append
    )
    @immutable = true
    @taggable = true
end

Instance Method Details

#colors ⇒ Object



7
8
9
# File 'lib/zoom/profile/passwords.rb', line 7

def colors
    return @profile.colors
end

#exe(args, pattern) ⇒ Object



11
12
13
# File 'lib/zoom/profile/passwords.rb', line 11

def exe(args, pattern)
    @profile.exe(args, pattern)
end

#info ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/zoom/profile/passwords.rb', line 15

def info
    [
        "Class   : #{self.class.to_s}",
        "Prepend : #{@profile.prepend}",
        "Operator: #{@profile.operator}",
        "Flags   : #{@profile.flags}",
        "Append  : #{@profile.append}"
    ].join("\n").strip
end

#to_s ⇒ Object



69
70
71
# File 'lib/zoom/profile/passwords.rb', line 69

def to_s
    return @porfile.to_s
end