Class: Ayadn::CheckAccounts
- Defined in:
- lib/ayadn/diagnostics.rb
Instance Attribute Summary collapse
-
#active_account ⇒ Object
Returns the value of attribute active_account.
-
#db ⇒ Object
Returns the value of attribute db.
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#sql_path ⇒ Object
Returns the value of attribute sql_path.
-
#userDB ⇒ Object
Returns the value of attribute userDB.
Attributes inherited from CheckBase
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize ⇒ CheckAccounts
constructor
A new instance of CheckAccounts.
Methods inherited from CheckBase
#check_response_code, #get_response, #rescue_network
Constructor Details
#initialize ⇒ CheckAccounts
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_account ⇒ Object
Returns the value of attribute active_account.
142 143 144 |
# File 'lib/ayadn/diagnostics.rb', line 142 def active_account @active_account end |
#db ⇒ Object
Returns the value of attribute db.
142 143 144 |
# File 'lib/ayadn/diagnostics.rb', line 142 def db @db end |
#handle ⇒ Object
Returns the value of attribute handle.
142 143 144 |
# File 'lib/ayadn/diagnostics.rb', line 142 def handle @handle end |
#paths ⇒ Object
Returns the value of attribute paths.
142 143 144 |
# File 'lib/ayadn/diagnostics.rb', line 142 def paths @paths end |
#sql_path ⇒ Object
Returns the value of attribute sql_path.
142 143 144 |
# File 'lib/ayadn/diagnostics.rb', line 142 def sql_path @sql_path end |
#userDB ⇒ Object
Returns the value of attribute userDB.
142 143 144 |
# File 'lib/ayadn/diagnostics.rb', line 142 def userDB @userDB end |
Instance Method Details
#check ⇒ Object
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 find_active_account 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 |