Chris Mague 7 jaren geleden
bovenliggende
commit
bbe3676e2f
10 gewijzigde bestanden met toevoegingen van 42 en 32 verwijderingen
  1. 3 3
      Gemfile
  2. 9 7
      config.ru
  3. 1 2
      lib/neoinfra/accounts.rb
  4. 1 1
      lib/neoinfra/audit.rb
  5. 1 1
      lib/neoinfra/vpcs.rb
  6. 0 2
      tasks/audit.rake
  7. 0 2
      tasks/load_data.rake
  8. 7 2
      web/controllers.rb
  9. 10 7
      web/controllers/dataloader.rb
  10. 10 5
      web/controllers/toppage.rb

+ 3 - 3
Gemfile

@@ -2,9 +2,9 @@
 
 source 'http://rubygems.org'
 
-#gem 'fog-core', '1.44.3'
-#gem 'fog-aws', '1.4.0'
-#gem 'fog', '1.40.0'
+# gem 'fog-core', '1.44.3'
+# gem 'fog-aws', '1.4.0'
+# gem 'fog', '1.40.0'
 gem 'fog'
 gem 'mime-types'
 gem 'neo4j', '7.2.0'

+ 9 - 7
config.ru

@@ -1,15 +1,17 @@
+# frozen_string_literal: true
+
 # controllers to load
-require (File.join(File.dirname(__FILE__), 'web', 'controllers'))
+require File.join(File.dirname(__FILE__), 'web', 'controllers')
 
 # serve up static assets using rack
-#map "/js" do
+# map "/js" do
 #  run Rack::Directory.new("#{File.join(File.dirname(__FILE__), 'web', 'static', 'js')}")
-#end
+# end
 
-map "/" do
-    run Toppage
+map '/' do
+  run Toppage
 end
 
-map "/load" do
-    run Dataloader
+map '/load' do
+  run Dataloader
 end

+ 1 - 2
lib/neoinfra/accounts.rb

@@ -10,10 +10,9 @@ require 'neoinfra/config'
 module NeoInfra
   # Provide informations about the accounts available
   class Accounts
-
     def list_names
       @cfg = NeoInfra::Config.new
-      @cfg.accounts.map{ |x| x[:name] }
+      @cfg.accounts.map { |x| x[:name] }
     end
 
     def load

+ 1 - 1
lib/neoinfra/audit.rb

@@ -22,7 +22,7 @@ module NeoInfra
         }
         aws.regions.each do |region|
           region_conf = { region: region }
-          #Get Instances
+          # Get Instances
           new_conn = Fog::Compute.new(region_conf.merge(base_conf))
           new_conn.servers.all.each do |ec2|
             %i[required recommended]. each do |a|

+ 1 - 1
lib/neoinfra/vpcs.rb

@@ -40,7 +40,7 @@ module NeoInfra
             next unless Vpc.where(vpc_id: vpc.id).empty?
             vpc_name = if vpc.tags.empty?
                          vpc.id
-                       elsif vpc.tags.has_key? 'Name'
+                       elsif vpc.tags.key? 'Name'
                          vpc.tags['Name']
                        else
                          vpc.id

+ 0 - 2
tasks/audit.rake

@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 namespace :audit do
-
   task :audit_nodes do
     puts 'auditing Nodes'
     j = NeoInfra::Audit.new
@@ -10,5 +9,4 @@ namespace :audit do
 
   desc 'Tag Audit'
   task all: %i[audit_nodes]
-
 end

+ 0 - 2
tasks/load_data.rake

@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 namespace :load_data do
-
   desc 'Load accounts into the neo4j container'
   task :accounts do
     puts 'loading accounts'
@@ -39,5 +38,4 @@ namespace :load_data do
 
   desc 'Load Everything'
   task all: %i[accounts regions vpcs buckets nodes]
-
 end

+ 7 - 2
web/controllers.rb

@@ -1,7 +1,12 @@
-# Dynamically pick up all of the controllers
+# frozen_string_literal: true
 
+# Dynamically pick up all of the controllers
 
-Dir.glob(File.join(File.dirname(__FILE__), 'controllers', '*.rb')).select{|c| File.basename(c) != 'controllers.rb' }.each do |x|
+Dir.glob(
+  File.join(
+    File.dirname(__FILE__), 'controllers', '*.rb'
+  )
+).reject { |c| File.basename(c) == 'controllers.rb' }.each do |x|
   begin
     require x
   rescue

+ 10 - 7
web/controllers/dataloader.rb

@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'lib')
 $LOAD_PATH.unshift(lib_dir) unless
   $LOAD_PATH.include?(lib_dir) || $LOAD_PATH.include?(lib_dir)
@@ -7,14 +9,17 @@ require 'sinatra'
 require 'sinatra/base'
 require 'sinatra/respond_to'
 
+# Handle loading data into the graph db
 class Dataloader < Sinatra::Base
   register Sinatra::RespondTo
   set :views, File.join(File.dirname(__FILE__), '..', '/views')
 
   get '/all' do
     respond_to do |wants|
-      wants.html {  erb :load_all,
-      :layout => :base_layout }
+      wants.html do
+        erb :load_all,
+            layout: :base_layout
+      end
     end
   end
 
@@ -29,16 +34,14 @@ class Dataloader < Sinatra::Base
     j = NeoInfra::Aws.new
     j.load_regions
     status 200
-    #{}"Loaded #{j.region_count} regions, #{j.az_count} availablity zones"
-    "suck"
+    # {}"Loaded #{j.region_count} regions, #{j.az_count} availablity zones"
+    'suck'
   end
 
   get '/vpcs' do
     j = NeoInfra::Vpcs.new
-    #j.load_vpcs
+    # j.load_vpcs
     status 200
     "Loaded #{j.default_vpc_count} default vpcs, #{j.non_default_vpc_count} non-default vpcs"
-
   end
-
 end

+ 10 - 5
web/controllers/toppage.rb

@@ -1,21 +1,26 @@
+# frozen_string_literal: true
+
 require 'sinatra'
 require 'sinatra/base'
 require 'sinatra/respond_to'
 
+# Display the Top level Web page
 class Toppage < Sinatra::Base
   register Sinatra::RespondTo
-  set :public_folder, File.join(File.dirname(__FILE__) , '..' , '/static')
+  set :public_folder, File.join(File.dirname(__FILE__), '..', '/static')
   set :views, File.join(File.dirname(__FILE__), '..', '/views')
 
-  #just respond with OK, so that monitoring knows that the application is running
+  # just respond with OK, so that monitoring knows that the application is running
   get '/monitor' do
-    "OK"
+    'OK'
   end
 
   get '/' do
     respond_to do |wants|
-      wants.html {  erb :index,
-      :layout => :base_layout }
+      wants.html do
+        erb :index,
+            layout: :base_layout
+      end
     end
   end
 end