Class: GetZilla

Inherits:
Object
  • Object
show all
Includes:
OSZILLA
Defined in:
lib/getZilla.rb

Overview

Main class of GetZilla Gem.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OSZILLA

#linux?, #mac?, #unix?, #windows?

Constructor Details

#initialize(override = false) ⇒ GetZilla

Constructor of this class. He is used for define the path of FileZilla site manager. You can override the default paths !


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/getZilla.rb', line 19

def initialize override = false
  @pathZilla = (override || (
      case true
      when linux?
        [ENV['HOME'] + '/.config/filezilla/sitemanager.xml']
      when mac?
        fail 'Macintosh is not supported for now, you can contribute on github for change that.'
      when windows?
        [ENV['APPDATA'] + '\FileZilla\sitemanager.xml']
      else
        fail 'Unable to detect OS !'
      end
    ))
end

Instance Attribute Details

#pathZillaObject

Returns the value of attribute pathZilla


12
13
14
# File 'lib/getZilla.rb', line 12

def pathZilla
  @pathZilla
end

Instance Method Details

#get?(match) ⇒ Boolean

Main method.

Returns:

  • (Boolean)

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/getZilla.rb', line 95

def get? match
  return false unless genericFilter! targetFile? @pathZilla
  filter = {
    targetName: [],
    targetSite: [],
    targetFinal: '',
    style: {
      jump: "\n",
      space: '-'
    }
  }

  # First level.
  genericFilter!(targetFile? @pathZilla).each do |targetSite|
    filter[:targetName].push targetSite
  end

  # Second level.
  filter[:targetName][0][1]['Servers']['Server'].each do |targetName|
    if match
      targetName['Name'] =~ match ? filter[:targetSite].push(targetName) : ''
    else
      filter[:targetSite].push targetName
    end
  end

  filter[:targetFinal] << "
      ▄████ ▓█████▄▄▄█████▓▒███████▒ ██▓ ██▓     ██▓    ▄▄▄
     ██▒ ▀█▒▓█   ▀▓  ██▒ ▓▒▒ ▒ ▒ ▄▀░▓██▒▓██▒    ▓██▒   ▒████▄
    ▒██░▄▄▄░▒███  ▒ ▓██░ ▒░░ ▒ ▄▀▒░ ▒██▒▒██░    ▒██░   ▒██  ▀█▄
    ░▓█  ██▓▒▓█  ▄░ ▓██▓ ░   ▄▀▒   ░░██░▒██░    ▒██░   ░██▄▄▄▄██
    ░▒▓███▀▒░▒████▒ ▒██▒ ░ ▒███████▒░██░░██████▒░██████▒▓█   ▓██▒
     ░▒   ▒ ░░ ▒░ ░ ▒ ░░   ░▒▒ ▓░▒░▒░▓  ░ ▒░▓  ░░ ▒░▓  ░▒▒   ▓▒█░
      ░   ░  ░ ░  ░   ░    ░░▒ ▒ ░ ▒ ▒ ░░ ░ ▒  ░░ ░ ▒  ░ ▒   ▒▒ ░
    ░ ░   ░    ░    ░      ░ ░ ░ ░ ░ ▒ ░  ░ ░     ░ ░    ░   ▒
          ░    ░  ░          ░ ░     ░      ░  ░    ░  ░     ░  ░
                           ░

         By Yanis A. >> https://github.com/solikate/getZilla
       Usage : getzilla [options] or --help for more details" << filter[:style][:jump] * 1

  # Header.
  filter[:targetFinal] << filter[:style][:jump] * 1 << filter[:style][:space] * 60 << filter[:style][:jump] * 1
  filter[:targetFinal] << filter[:targetSite].length.to_s << ' result(s) found(s) !' << filter[:style][:jump] * 2

  # Content.
  filter[:targetSite].each do |targetFinal|
    filter[:targetFinal] << formatFilter!(targetFinal) << filter[:style][:jump] * 1
  end

  # Footer.
  filter[:targetFinal] << filter[:style][:space] * 60 << filter[:style][:jump] * 2
end