Class: Ayadn::CheckAccounts

Inherits:
CheckBase show all
Defined in:
lib/ayadn/diagnostics.rb

Instance Attribute Summary collapse

Attributes inherited from CheckBase

#baseURL, #response, #status

Instance Method Summary collapse

Methods inherited from CheckBase

#check_response_code, #get_response, #rescue_network

Constructor Details

#initializeCheckAccounts

Returns a new instance of CheckAccounts.



144
145
146
147
# File 'lib/ayadn/diagnostics.rb', line 144

def initialize
  super
  @sql_path = Dir.home + "/ayadn/accounts.sqlite"
end

Instance Attribute Details

#active_accountObject

Returns the value of attribute active_account.



142
143
144
# File 'lib/ayadn/diagnostics.rb', line 142

def 
  @active_account
end

#dbObject

Returns the value of attribute db.



142
143
144
# File 'lib/ayadn/diagnostics.rb', line 142

def db
  @db
end

#handleObject

Returns the value of attribute handle.



142
143
144
# File 'lib/ayadn/diagnostics.rb', line 142

def handle
  @handle
end

#pathsObject

Returns the value of attribute paths.



142
143
144
# File 'lib/ayadn/diagnostics.rb', line 142

def paths
  @paths
end

#sql_pathObject

Returns the value of attribute sql_path.



142
143
144
# File 'lib/ayadn/diagnostics.rb', line 142

def sql_path
  @sql_path
end

#userDBObject

Returns the value of attribute userDB.



142
143
144
# File 'lib/ayadn/diagnostics.rb', line 142

def userDB
  @userDB
end

Instance Method Details

#checkObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/ayadn/diagnostics.rb', line 149

def check
  begin
    @status.say_header("checking accounts database")
    if 
      users = @db.execute("SELECT * FROM Accounts")
      if users.blank?
        @status.say_red(:abort, "no registered Ayadn users")
      else
        @status.say_green(:accounts, users.map { |user| user[2] }.join(", "))
        if @active_account.blank?
          @status.say_red(:warning, "no active account")
        else
          @status.say_header("checking active account")
          check_id_handle
          check_token
          check_paths
          check_config
          @status.say_header("checking #{@handle}'s account database")
          if find_active_tables
            check_tables_schemas
          end
        end
      end
    end
  rescue Interrupt
    @status.say_error "operation canceled"
    exit
  rescue Amalgalite::SQLite3::Error => e
    @status.say_error "database error"
    @status.say_trace e
  rescue => e
    @status.say_error "unknown error"
    @status.say_trace e
  end
end