Class: Neetob::CLI::Code::Audit

Inherits:
Github::Base show all
Defined in:
lib/neetob/cli/code/audit.rb

Constant Summary

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary collapse

Attributes inherited from Github::Base

#client

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initialize(apps, sandbox = false) ⇒ Audit

Returns a new instance of Audit.



11
12
13
14
15
# File 'lib/neetob/cli/code/audit.rb', line 11

def initialize(apps, sandbox = false)
  super()
  @apps = apps
  @sandbox = sandbox
end

Instance Attribute Details

#appsObject

Returns the value of attribute apps.



9
10
11
# File 'lib/neetob/cli/code/audit.rb', line 9

def apps
  @apps
end

#sandboxObject

Returns the value of attribute sandbox.



9
10
11
# File 'lib/neetob/cli/code/audit.rb', line 9

def sandbox
  @sandbox
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/neetob/cli/code/audit.rb', line 17

def run
  matching_apps = find_all_matching_apps_or_repos(apps, :github, sandbox)
  ui.info("\nListing apps and their tables that doesn't have uuid as primary key type:-")
  has_found_tables_without_uuid = false
  matching_apps.each do |app|
    begin
      db_schema = Base64.decode64(client.contents(app, path: "./db/schema.rb").content)
      tables_without_uuid = find_tables_without_uuid_as_primary_key(db_schema).compact
      if !tables_without_uuid.nil?
        has_found_tables_without_uuid = true
        print_app_and_tables(app, tables_without_uuid)
      end
      verify_unique_email_index(db_schema)
    rescue Octokit::NotFound
      ui.error("There is no \"db/schema.rb\" file in the \"#{app}\" app.")
    rescue StandardError => e
      ExceptionHandler.new(e).process
    end
  end
  ui.info("No apps found to have tables without uuid as primary key type") if !has_found_tables_without_uuid
end