backup_client 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ffdbd32da9101971d5bb807cd5cdcd173c0855cb72b559ca2f2e2d3b49687e6d
4
+ data.tar.gz: 140b702e7f96e14bbc9e459c79ebc163580443c097696697c44879f73bb8b1ee
5
+ SHA512:
6
+ metadata.gz: 818cbe72a8e802fb13ec3b6cf1dd2aac53c120508bca35d3ba6bacba0a763a5b048f9ff1950957c0c5ac419648f0e039f01f07b4305971501ae5bc9784109003
7
+ data.tar.gz: ef8144feb65d482c0008f453b66d317e2e1efa59f6f6c3e93bb1af4ea48391a6a83f967ffb64e59ddb450829132d9ed77d5c89d6120e28108d97c7973b80b332
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-05-20
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Alex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # BackupClient
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/backup_client`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/backup_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/backup_client/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the BackupClient project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/backup_client/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BackupClient
4
+ module Components
5
+ module Ftp
6
+ module Commands
7
+ class CreateFolder
8
+ include ::BackupClient::Helpers::LogHelper
9
+ include ::BackupClient::Helpers::FtpHelper
10
+
11
+ def initialize(ftp_client, destination_path)
12
+ @ftp_client = ftp_client
13
+ @destination_path = destination_path
14
+ @force_root = force_root
15
+ end
16
+
17
+ def call
18
+ return if ftp_dir_exists?(ftp_client, destination_path)
19
+ return if ftp_mkdir(destination_path)
20
+
21
+ ftp_mkdir_p(destination_path)
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :ftp_client, :destination_path, :force_root
27
+
28
+ def skip_processing?
29
+ ftp_dir_exists?(ftp_client, destination_path)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BackupClient
4
+ module Components
5
+ module Ftp
6
+ module Commands
7
+ class FileUpload
8
+ include ::BackupClient::Helpers::LogHelper
9
+ include ::BackupClient::Helpers::FtpHelper
10
+
11
+ def initialize(ftp_client, file, destination_folder)
12
+ @ftp_client = ftp_client
13
+ @file = file
14
+ @destination_folder = destination_folder
15
+ end
16
+
17
+ def call
18
+ File.open(file, "rb") do |file_handle|
19
+ remote_file_path = destination_folder + "/" + File.basename(file)
20
+ remote_file_path = remote_file_path.gsub(%r{//+}, "/")
21
+ ftp_client.putbinaryfile(file_handle, remote_file_path)
22
+ log("Uploaded file #{file} → #{remote_file_path}")
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :ftp_client, :file, :destination_folder
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BackupClient
4
+ module Components
5
+ module Ftp
6
+ module Commands
7
+ class FolderUpload
8
+ include ::BackupClient::Helpers::LogHelper
9
+ include ::BackupClient::Helpers::FtpHelper
10
+
11
+ def initialize(ftp_client, local_path, destination_folder)
12
+ @ftp_client = ftp_client
13
+ @local_path = local_path
14
+ @destination_folder = destination_folder
15
+ end
16
+
17
+ def call
18
+ current_destination_folder = destination_folder + local_path
19
+ ftp_mkdir_p(current_destination_folder)
20
+ Dir.glob("#{local_path}/**/*", File::FNM_DOTMATCH).each do |path|
21
+ basename = File.basename(path)
22
+ next if %w[. .. .git].include?(basename)
23
+
24
+ if File.directory?(path)
25
+ ::BackupClient::Components::Ftp::Commands::CreateFolder.new(ftp_client, destination_folder + path).call
26
+ else
27
+ upload_file_ftp(path, destination_folder)
28
+ end
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :ftp_client, :local_path, :destination_folder
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BackupClient
4
+ module Components
5
+ module Ftp
6
+ module Commands
7
+ class Upload
8
+ include ::BackupClient::Helpers::LogHelper
9
+ include ::BackupClient::Helpers::FtpHelper
10
+
11
+ FTP_PORT = 21
12
+
13
+ def initialize(provider, source_paths, timestamp:, use_timestamp: false)
14
+ @provider = provider
15
+ @source_paths = source_paths
16
+ @timestamp = timestamp
17
+ @use_timestamp = use_timestamp
18
+ end
19
+
20
+ def call
21
+ ftp_mkdir_p(destination_path)
22
+
23
+ ftp_processing
24
+
25
+ ftp_client.close
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :provider, :source_paths, :use_timestamp, :timestamp
31
+
32
+ def ftp_processing
33
+ source_paths.each do |path|
34
+ if File.file?(path)
35
+ upload_file_ftp(path, destination_path)
36
+ elsif File.directory?(path)
37
+ upload_dir_ftp(path, destination_path)
38
+ else
39
+ log "Invalid path: #{path}"
40
+ end
41
+ end
42
+ end
43
+
44
+ def ftp_client
45
+ @ftp_client ||=
46
+ begin
47
+ ftp = Net::FTP.new
48
+ ftp.connect(provider["host"], FTP_PORT)
49
+ ftp.login(provider["user"], provider["password"])
50
+ ftp.passive = true
51
+ ftp
52
+ end
53
+ end
54
+
55
+ def destination_path
56
+ @destination_path ||=
57
+ begin
58
+ folder = provider["path"]
59
+ folder = "/#{folder}" unless folder.start_with?("/")
60
+ folder += "/#{timestamp}" if use_timestamp
61
+ folder.gsub("//", "/")
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "backup_client/helpers/log_helper"
5
+
6
+ module BackupClient
7
+ module Components
8
+ module Local
9
+ module Commands
10
+ class Upload
11
+ include BackupClient::Helpers::LogHelper
12
+
13
+ def initialize(paths, provider, use_timestamp = true)
14
+ @paths = paths
15
+ @provider = provider
16
+ @use_timestamp = use_timestamp
17
+ @timestamp = Time.now.strftime("%Y-%m-%d-%H-%M-%S")
18
+ end
19
+
20
+ def call
21
+ create_destination_folder
22
+ upload_files
23
+ upload_folders
24
+ end
25
+
26
+ private
27
+
28
+ def create_destination_folder
29
+ FileUtils.mkdir_p(destination_path)
30
+ end
31
+
32
+ def upload_files
33
+ @paths["files"]&.each do |file|
34
+ next unless File.file?(file)
35
+
36
+ target_path = File.join(destination_path, File.basename(file))
37
+ FileUtils.cp(file, target_path)
38
+ log("Copied file #{file} → #{target_path}")
39
+ end
40
+ end
41
+
42
+ def upload_folders
43
+ @paths["folders"]&.each do |folder|
44
+ next unless File.directory?(folder)
45
+
46
+ target_path = File.join(destination_path, File.basename(folder))
47
+ FileUtils.cp_r(folder, target_path)
48
+ log("Copied directory #{folder} → #{target_path}")
49
+ end
50
+ end
51
+
52
+ def destination_path
53
+ path = @provider["path"]
54
+ path = File.join(path, @timestamp) if @use_timestamp
55
+ path
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BackupClient
4
+ module Components
5
+ module Tasks
6
+ module Commands
7
+ class Processor
8
+ include ::BackupClient::Helpers::LogHelper
9
+
10
+ def initialize(task, config:)
11
+ @task = task
12
+ @providers = config["providers"]
13
+ @source_paths = task["paths"]
14
+ @use_timestamp = task.fetch("timestamped_subfolder", true)
15
+ @timestamp = Time.now.strftime("%Y-%m-%d-%H-%M-%S")
16
+ end
17
+
18
+ def call
19
+ log("Processing task #{task["name"]}")
20
+
21
+ task["providers"].each do |provider_name|
22
+ provider = fetch_provider(provider_name)
23
+ next if provider.nil?
24
+
25
+ log("Processing provider #{provider_name}")
26
+
27
+ processing_task_for_provider(provider)
28
+ rescue StandardError => e
29
+ log("Unexpected error: #{e}, #{provider["type"].upcase}: #{provider["name"].upcase}")
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :task, :providers, :source_paths, :use_timestamp, :timestamp
36
+
37
+ def processing_task_for_provider(provider)
38
+ case provider["type"]
39
+ when "ftp"
40
+ upload_to_ftp(provider, source_paths, use_timestamp)
41
+ when "local"
42
+ copy_to_local(provider, source_paths, use_timestamp)
43
+ else
44
+ log("Provider type #{provider["type"]} is not supported")
45
+ end
46
+ end
47
+
48
+ def upload_to_ftp(provider, source_paths, use_timestamp)
49
+ ::BackupClient::Components::Ftp::Commands::Upload
50
+ .new(source_paths, provider, timestamp: Time.now).call
51
+ end
52
+
53
+ def copy_to_local(provider, local_paths, use_timestamp)
54
+ target_path = provider["path"]
55
+ target_path = File.join(target_path, timestamp) if use_timestamp
56
+ FileUtils.mkdir_p(target_path)
57
+
58
+ local_paths.each do |path|
59
+ if File.file?(path)
60
+ FileUtils.cp(path, target_path)
61
+ log("Copied file #{path} → #{target_path}")
62
+ elsif File.directory?(path)
63
+ FileUtils.cp_r(path, target_path)
64
+ log("Copied directory #{path} → #{target_path}")
65
+ else
66
+ log("Invalid path: #{path}")
67
+ end
68
+ end
69
+ end
70
+
71
+ def fetch_provider(provider_name)
72
+ providers[provider_name]
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BackupClient
4
+ module Helpers
5
+ module FtpHelper
6
+ def ftp_chdir(ftp_client, path)
7
+ return if ftp_client.pwd == path
8
+
9
+ ftp_client.chdir(path)
10
+ end
11
+
12
+ def root_chdir(ftp_client)
13
+ ftp_chdir(ftp_client, "/")
14
+ end
15
+
16
+ def upload_dir_ftp(local_folder, destination_folder)
17
+ ::BackupClient::Components::Ftp::Commands::FolderUpload.new(ftp_client, local_folder, destination_folder).call
18
+ end
19
+
20
+ def upload_file_ftp(local_file_path, remote_folder_path)
21
+ ::BackupClient::Components::Ftp::Commands::FileUpload.new(ftp_client, local_file_path, remote_folder_path).call
22
+ end
23
+
24
+ def ftp_dir_exists?(ftp_client, path)
25
+ current = ftp_client.pwd
26
+ ftp_client.chdir(path)
27
+ ftp_client.chdir(current)
28
+ true
29
+ rescue Net::FTPPermError
30
+ false
31
+ end
32
+
33
+ def ftp_mkdir_p(path)
34
+ root_chdir(ftp_client)
35
+ return if ftp_mkdir(path)
36
+
37
+ parts = path.split("/").reject(&:empty?)
38
+ parts.each do |part|
39
+ begin
40
+ ftp_client.mkdir(part)
41
+ # ftp_chdir(ftp_client, path)
42
+ log "Created folder: #{ftp_client.pwd}/#{part}"
43
+ rescue Net::FTPPermError
44
+ # already exists
45
+ end
46
+ ftp_chdir(ftp_client, part)
47
+ end
48
+ end
49
+
50
+ def ftp_mkdir(path)
51
+ ftp_client.mkdir(path)
52
+ log "Created folder: #{path}"
53
+ true
54
+ rescue Net::FTPPermError
55
+ false
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BackupClient
4
+ module Helpers
5
+ module LogHelper
6
+ def log(msg)
7
+ puts "[#{Time.now.strftime("%H:%M:%S")}] #{msg}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "yaml"
4
+ require "net/ftp"
5
+ require "fileutils"
6
+ require "time"
7
+ require "byebug"
8
+ require_relative "backup_client/helpers/log_helper"
9
+ require_relative "backup_client/helpers/ftp_helper"
10
+ require_relative "backup_client/components/ftp/commands/create_folder"
11
+ require_relative "backup_client/components/ftp/commands/file_upload"
12
+ require_relative "backup_client/components/ftp/commands/folder_upload"
13
+ require_relative "backup_client/components/ftp/commands/upload"
14
+ require_relative "backup_client/components/tasks/commands/processor"
15
+
16
+ Dir.glob("components/**/*.rb").sort.each do |file|
17
+ require_relative file
18
+ end
19
+
20
+ module BackupClient
21
+ VERSION = "0.1.0"
22
+
23
+ class Processor
24
+ include ::BackupClient::Helpers::LogHelper
25
+
26
+ def initialize(config)
27
+ @config = config
28
+ @tasks = config["tasks"]
29
+ end
30
+
31
+ def call
32
+ return false if tasks.nil?
33
+
34
+ tasks.each { |task| processing_task(task) }
35
+ end
36
+
37
+ private
38
+
39
+ attr_reader :tasks, :config
40
+
41
+ def processing_task(task)
42
+ ::BackupClient::Components::Tasks::Commands::Processor.new(task, config:).call
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,4 @@
1
+ module BackupClient
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backup_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: net-ftp
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.2.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.2.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: byebug
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '11.1'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '11.1'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rubocop
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.21'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.21'
68
+ description: A simple gem for doing backups
69
+ email:
70
+ - savio.km.ua@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".rspec"
76
+ - ".rubocop.yml"
77
+ - CHANGELOG.md
78
+ - CODE_OF_CONDUCT.md
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/backup_client.rb
83
+ - lib/backup_client/components/ftp/commands/create_folder.rb
84
+ - lib/backup_client/components/ftp/commands/file_upload.rb
85
+ - lib/backup_client/components/ftp/commands/folder_upload.rb
86
+ - lib/backup_client/components/ftp/commands/upload.rb
87
+ - lib/backup_client/components/local/commands/upload.rb
88
+ - lib/backup_client/components/tasks/commands/processor.rb
89
+ - lib/backup_client/helpers/ftp_helper.rb
90
+ - lib/backup_client/helpers/log_helper.rb
91
+ - sig/backup_client.rbs
92
+ homepage: https://rubygems.org/gems/backup_client
93
+ licenses:
94
+ - MIT
95
+ metadata:
96
+ homepage_uri: https://rubygems.org/gems/backup_client
97
+ source_code_uri: https://github.com/saviokmua/backup-client
98
+ changelog_uri: https://github.com/saviokmua/backup-client/blob/main/CHANGELOG.md
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.4.0
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubygems_version: 3.6.9
114
+ specification_version: 4
115
+ summary: Backup client
116
+ test_files: []