soft-sort 1.0.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 +7 -0
- data/CHANGELOG.md +35 -0
- data/LICENSE +5 -0
- data/README.md +146 -0
- data/bin/soft-sort +6 -0
- data/config/default_rules.yml +74 -0
- data/lib/soft_sort/classification/ai_provider.rb +17 -0
- data/lib/soft_sort/classification/classification_result.rb +6 -0
- data/lib/soft_sort/classification/content_classifier.rb +38 -0
- data/lib/soft_sort/classification/context_classifier.rb +23 -0
- data/lib/soft_sort/classification/rule_matcher.rb +41 -0
- data/lib/soft_sort/classification/sensitive_file_detector.rb +14 -0
- data/lib/soft_sort/classification/type_classifier.rb +54 -0
- data/lib/soft_sort/cli.rb +167 -0
- data/lib/soft_sort/configuration.rb +72 -0
- data/lib/soft_sort/duplicates/duplicate_detector.rb +17 -0
- data/lib/soft_sort/errors.rb +7 -0
- data/lib/soft_sort/execution/executor.rb +66 -0
- data/lib/soft_sort/execution/recovery_manager.rb +87 -0
- data/lib/soft_sort/execution/undo_manager.rb +45 -0
- data/lib/soft_sort/metadata/image_metadata.rb +24 -0
- data/lib/soft_sort/planning/organization_planner.rb +115 -0
- data/lib/soft_sort/reporting/json_reporter.rb +7 -0
- data/lib/soft_sort/reporting/preview_formatter.rb +17 -0
- data/lib/soft_sort/reporting/statistics_reporter.rb +13 -0
- data/lib/soft_sort/scanning/directory_scanner.rb +69 -0
- data/lib/soft_sort/scanning/file_metadata.rb +6 -0
- data/lib/soft_sort/storage/root_lock.rb +21 -0
- data/lib/soft_sort/storage/transaction_journal.rb +56 -0
- data/lib/soft_sort/version.rb +5 -0
- data/lib/soft_sort/watching/directory_watcher.rb +42 -0
- data/lib/soft_sort.rb +36 -0
- metadata +75 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SoftSort
|
|
4
|
+
class DirectoryWatcher
|
|
5
|
+
def initialize(root, config:, recursive: false, interval: 5, stability_window: 2)
|
|
6
|
+
@root = root
|
|
7
|
+
@config = config
|
|
8
|
+
@recursive = recursive
|
|
9
|
+
@interval = [interval.to_i, 1].max
|
|
10
|
+
@stability_window = [stability_window.to_i, 1].max
|
|
11
|
+
@seen = {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def run(apply: false, iterations: nil)
|
|
15
|
+
cycles = 0
|
|
16
|
+
loop do
|
|
17
|
+
scan = DirectoryScanner.new(@root, config: @config, recursive: @recursive).scan
|
|
18
|
+
stable = scan[:files].select { |file| stable?(file) }
|
|
19
|
+
items = OrganizationPlanner.new(@root, @config).plan(stable)
|
|
20
|
+
yield(items, apply) if block_given?
|
|
21
|
+
cycles += 1
|
|
22
|
+
break if iterations && cycles >= iterations
|
|
23
|
+
|
|
24
|
+
sleep @interval
|
|
25
|
+
end
|
|
26
|
+
rescue Interrupt
|
|
27
|
+
nil
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def stable?(file)
|
|
33
|
+
key = file.absolute_path
|
|
34
|
+
current = [file.size, file.modified_at.to_f]
|
|
35
|
+
previous = @seen[key]
|
|
36
|
+
@seen[key] = { signature: current, changed_at: Time.now }
|
|
37
|
+
return false unless previous && previous[:signature] == current
|
|
38
|
+
|
|
39
|
+
Time.now - previous[:changed_at] >= @stability_window
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/lib/soft_sort.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
require 'optparse'
|
|
6
|
+
require 'pathname'
|
|
7
|
+
require 'fileutils'
|
|
8
|
+
require 'digest'
|
|
9
|
+
require 'securerandom'
|
|
10
|
+
require 'time'
|
|
11
|
+
require_relative 'soft_sort/version'
|
|
12
|
+
require_relative 'soft_sort/errors'
|
|
13
|
+
require_relative 'soft_sort/configuration'
|
|
14
|
+
require_relative 'soft_sort/scanning/file_metadata'
|
|
15
|
+
require_relative 'soft_sort/scanning/directory_scanner'
|
|
16
|
+
require_relative 'soft_sort/classification/type_classifier'
|
|
17
|
+
require_relative 'soft_sort/classification/context_classifier'
|
|
18
|
+
require_relative 'soft_sort/classification/classification_result'
|
|
19
|
+
require_relative 'soft_sort/classification/rule_matcher'
|
|
20
|
+
require_relative 'soft_sort/classification/sensitive_file_detector'
|
|
21
|
+
require_relative 'soft_sort/classification/content_classifier'
|
|
22
|
+
require_relative 'soft_sort/planning/organization_planner'
|
|
23
|
+
require_relative 'soft_sort/reporting/preview_formatter'
|
|
24
|
+
require_relative 'soft_sort/reporting/json_reporter'
|
|
25
|
+
require_relative 'soft_sort/storage/transaction_journal'
|
|
26
|
+
require_relative 'soft_sort/storage/root_lock'
|
|
27
|
+
require_relative 'soft_sort/execution/executor'
|
|
28
|
+
require_relative 'soft_sort/execution/recovery_manager'
|
|
29
|
+
require_relative 'soft_sort/execution/undo_manager'
|
|
30
|
+
require_relative 'soft_sort/duplicates/duplicate_detector'
|
|
31
|
+
require_relative 'soft_sort/reporting/statistics_reporter'
|
|
32
|
+
require_relative 'soft_sort/watching/directory_watcher'
|
|
33
|
+
require_relative 'soft_sort/classification/ai_provider'
|
|
34
|
+
require_relative 'soft_sort/metadata/image_metadata'
|
|
35
|
+
require_relative 'soft_sort/cli'
|
|
36
|
+
module SoftSort; end
|
metadata
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: soft-sort
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- SoftSort contributors
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-11-13 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
executables:
|
|
16
|
+
- soft-sort
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- CHANGELOG.md
|
|
21
|
+
- LICENSE
|
|
22
|
+
- README.md
|
|
23
|
+
- bin/soft-sort
|
|
24
|
+
- config/default_rules.yml
|
|
25
|
+
- lib/soft_sort.rb
|
|
26
|
+
- lib/soft_sort/classification/ai_provider.rb
|
|
27
|
+
- lib/soft_sort/classification/classification_result.rb
|
|
28
|
+
- lib/soft_sort/classification/content_classifier.rb
|
|
29
|
+
- lib/soft_sort/classification/context_classifier.rb
|
|
30
|
+
- lib/soft_sort/classification/rule_matcher.rb
|
|
31
|
+
- lib/soft_sort/classification/sensitive_file_detector.rb
|
|
32
|
+
- lib/soft_sort/classification/type_classifier.rb
|
|
33
|
+
- lib/soft_sort/cli.rb
|
|
34
|
+
- lib/soft_sort/configuration.rb
|
|
35
|
+
- lib/soft_sort/duplicates/duplicate_detector.rb
|
|
36
|
+
- lib/soft_sort/errors.rb
|
|
37
|
+
- lib/soft_sort/execution/executor.rb
|
|
38
|
+
- lib/soft_sort/execution/recovery_manager.rb
|
|
39
|
+
- lib/soft_sort/execution/undo_manager.rb
|
|
40
|
+
- lib/soft_sort/metadata/image_metadata.rb
|
|
41
|
+
- lib/soft_sort/planning/organization_planner.rb
|
|
42
|
+
- lib/soft_sort/reporting/json_reporter.rb
|
|
43
|
+
- lib/soft_sort/reporting/preview_formatter.rb
|
|
44
|
+
- lib/soft_sort/reporting/statistics_reporter.rb
|
|
45
|
+
- lib/soft_sort/scanning/directory_scanner.rb
|
|
46
|
+
- lib/soft_sort/scanning/file_metadata.rb
|
|
47
|
+
- lib/soft_sort/storage/root_lock.rb
|
|
48
|
+
- lib/soft_sort/storage/transaction_journal.rb
|
|
49
|
+
- lib/soft_sort/version.rb
|
|
50
|
+
- lib/soft_sort/watching/directory_watcher.rb
|
|
51
|
+
homepage: https://github.com/soft-sort/soft-sort
|
|
52
|
+
licenses:
|
|
53
|
+
- MIT
|
|
54
|
+
metadata:
|
|
55
|
+
rubygems_mfa_required: 'true'
|
|
56
|
+
post_install_message:
|
|
57
|
+
rdoc_options: []
|
|
58
|
+
require_paths:
|
|
59
|
+
- lib
|
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '3.2'
|
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
requirements: []
|
|
71
|
+
rubygems_version: 3.5.11
|
|
72
|
+
signing_key:
|
|
73
|
+
specification_version: 4
|
|
74
|
+
summary: A safe, local-first file organization planner
|
|
75
|
+
test_files: []
|