Class: NeocitiesRed::Services::Site::Pusher
- Inherits:
-
Object
- Object
- NeocitiesRed::Services::Site::Pusher
- Defined in:
- lib/neocities_red/services/site/pusher.rb
Overview
Recursively uploads a local directory to the Neocities site.
Orchestrates the full push workflow:
- Validates the root path
- Optionally prunes remote files not present locally
- Collects all files via glob
- Applies .gitignore rules, dotfile filtering, exclusions, and optimized (hash-based) filtering
- Uploads remaining files in parallel via a worker pool
Constant Summary collapse
- MAX_THREADS =
Warning: a high thread count may be flagged as DDOS-like traffic by Neocities, potentially resulting in a temporary IP ban.
5
Instance Method Summary collapse
-
#initialize(client, display, root:, no_gitignore:, ignore_dotfiles:, exclude:, dry_run:, prune:, optimized:) ⇒ Pusher
constructor
A new instance of Pusher.
-
#push ⇒ void
Executes the full push workflow.
Constructor Details
#initialize(client, display, root:, no_gitignore:, ignore_dotfiles:, exclude:, dry_run:, prune:, optimized:) ⇒ Pusher
Returns a new instance of Pusher.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/neocities_red/services/site/pusher.rb', line 47 def initialize(client, display, root:, no_gitignore:, ignore_dotfiles:, exclude:, dry_run:, prune:, optimized:) @client = client @display = display @root = root @no_gitignore = no_gitignore @ignore_dotfiles = ignore_dotfiles @exclude = exclude @dry_run = dry_run @prune = prune @optimized = optimized end |
Instance Method Details
#push ⇒ void
This method returns an undefined value.
Executes the full push workflow.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/neocities_red/services/site/pusher.rb', line 63 def push root_path = Pathname(@root) validate_root_path!(root_path) @display.display_dry_run_notice if @dry_run prune_remote_files if @prune excluded_files = Services::Common::Exclusions.build(@exclude) Dir.chdir(root_path) do paths = Dir.glob(::File.join("**", "*"), ::File::FNM_DOTMATCH) paths = apply_gitignore(paths) unless @no_gitignore excluded_files += paths.select { |path| path.start_with?(".") } if @ignore_dotfiles excluded_files += optimized_exclusions(paths) if @optimized filtered_paths = paths.difference(excluded_files).map { |path| Pathname(path) } upload_files(filtered_paths) end end |