-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: datacollector #2240
base: main
Are you sure you want to change the base?
refactor: datacollector #2240
Conversation
e592e1d
to
96a198f
Compare
Module Datacollector separate business logic * collector.rb: file/folder crawler for a given device * correspondence.rb: set the sender and recipient encompass AR Model logic to create the attachments into the proper containers * configuration.rb: validate the datacollector device config also instantiate the SFTP client if applicable * collector_file: file/folder class for basic file operations independent of whether the file is on local fs or over sftp AdminApi device connection testing: * now rely on Datacollector::Configuration
96a198f
to
39d59e0
Compare
ext { 'chemotion' } | ||
name { File.basename(Faker::File.file_name(ext: ext)) } | ||
root { nil } | ||
touch { true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails/SkipsModelValidations: Avoid using touch
because it skips validations.
initialize_with do | ||
pathname = Pathname.new(prefix ? "#{prefix}-#{name}" : name) | ||
pathname = root.join(pathname) if root | ||
FileUtils.touch(pathname) if touch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails/SkipsModelValidations: Avoid using touch
because it skips validations.
pathname = root.join(pathname) if root | ||
FileUtils.touch(pathname) if touch | ||
FileUtils.cp(copy_from, pathname) if copy_from | ||
pathname.chmod(mode) if touch || copy_from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails/SkipsModelValidations: Avoid using touch
because it skips validations.
@@ -1,5 +1,11 @@ | |||
# frozen_string_literal: true | |||
|
|||
DC_SFTP_USER = ENV['DATACOLLECTOR_FACTORY_SFTP_USER'].presence || `whoami`.strip | |||
DC_DIR = ENV['DATACOLLECTOR_FACTORY_DIR'].presence || | |||
Rails.configuration.datacollectors.dig(:localcollectors, 0, :path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/MultilineOperationIndentation: Align the operands of an expression in an assignment spanning multiple lines.
datacollector_host { '127.0.0.1' } | ||
datacollector_authentication { 'keyfile' } | ||
datacollector_key_name { "#{Dir.home}/.ssh/id_test" } | ||
datacollector_dir { File.join(DC_DIR, "#{name_abbreviation}-#{datacollector_method}#{datacollector_user_level_selected ? '-user' : ''}").to_s } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/LineLength: Line is too long. [149/120]
@@ -1,5 +1,11 @@ | |||
# frozen_string_literal: true | |||
|
|||
DC_SFTP_USER = ENV['DATACOLLECTOR_FACTORY_SFTP_USER'].presence || 'testuser' #`whoami`.strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/LeadingCommentSpace: Missing space after #
.
refactoring
Module Datacollector
separate business logic
SFTPClient
make use of the existing SFTP client wrapper that ensures the connection is closed, instead of initialising the session directly.
AdminApi device connection testing:
Next Time