fileverse 0.1.7 → 0.1.9
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 +4 -4
- data/lib/fileverse/cli.rb +12 -8
- data/lib/fileverse/files.rb +4 -0
- data/lib/fileverse/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 661f741e89120bb6e2e65d0968d4a5929c85c26da2a6481aa24da4da32ae6ef2
|
4
|
+
data.tar.gz: d633f8b4b73e5a309f7a5f42e1b3d4354f08c3d723b70c774b6d95e7e201b312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7a8a5c2a638eb4debf103b9893f3e1ba420f43f3d4a25d2b0184abee7b0eecf407f16494eee4ca48c640e14ef1bdbf1be2d10b664ce4e66a04362f3f2ff9f23
|
7
|
+
data.tar.gz: a5aaf90449b5ca0e4d132f092bbb69136a615559ac795be7d374794252b4d4fdbc2eb7f2217e20b5dbf476dc787705ae1a7936079133051b165b139bced4ede9
|
data/lib/fileverse/cli.rb
CHANGED
@@ -6,14 +6,14 @@ module Fileverse
|
|
6
6
|
# CLI class
|
7
7
|
class CLI < Thor # rubocop:disable Metrics/ClassLength
|
8
8
|
desc "snap file content", "store current file content"
|
9
|
-
options template: :boolean, name: :string
|
9
|
+
options template: :boolean, name: :string, clear: :boolean
|
10
10
|
def snap(path)
|
11
11
|
setup_options
|
12
12
|
@template ? setup_template_parser(path) : setup_file_parser(path)
|
13
|
-
@parser.parse
|
14
13
|
@parser.add_snapshot(Files.read(@path), @snapshot_name)
|
15
|
-
Files.
|
14
|
+
Files.clear_content(@path) if @clear
|
16
15
|
Files.write_content(@storage_path, @parser.to_writable_lines)
|
16
|
+
puts "snapped#{@clear ? " and cleared" : ""}."
|
17
17
|
rescue StandardError => e
|
18
18
|
puts e.message
|
19
19
|
end
|
@@ -24,6 +24,7 @@ module Fileverse
|
|
24
24
|
def restore(path)
|
25
25
|
setup_options
|
26
26
|
@template ? restore_template_snapshot(path) : restore_file_snapshot(path)
|
27
|
+
puts "#{@snapshot_name || "snapshot at cursor index"} for #{@template ? "template" : "file"} restored."
|
27
28
|
rescue StandardError => e
|
28
29
|
puts e.message
|
29
30
|
end
|
@@ -34,7 +35,6 @@ module Fileverse
|
|
34
35
|
def preview(path)
|
35
36
|
setup_options
|
36
37
|
@template ? setup_template_parser(path) : setup_file_parser(path)
|
37
|
-
@parser.parse
|
38
38
|
setup_previewer
|
39
39
|
@previewer.preview_content = preview_content
|
40
40
|
Files.write_content(@path, @previewer.to_writable_lines)
|
@@ -47,13 +47,13 @@ module Fileverse
|
|
47
47
|
desc "reset", "reset files. both the storage and original"
|
48
48
|
def reset(path)
|
49
49
|
setup_file_parser(path)
|
50
|
-
@parser.parse
|
51
50
|
@parser.reset
|
52
51
|
setup_previewer
|
53
52
|
@previewer.parse
|
54
53
|
@previewer.preview_content = []
|
55
54
|
Files.write_content(@path, @previewer.to_writable_lines)
|
56
55
|
Files.write_content(@storage_path, @parser.to_writable_lines)
|
56
|
+
puts "storage reset."
|
57
57
|
rescue StandardError => e
|
58
58
|
puts e.message
|
59
59
|
end
|
@@ -64,7 +64,9 @@ module Fileverse
|
|
64
64
|
def snap_and_restore_template(path)
|
65
65
|
snap path
|
66
66
|
@snapshot_name = @template_name
|
67
|
+
Files.clear_content path
|
67
68
|
restore_template_snapshot path
|
69
|
+
puts "And restored template '#{@template_name}'."
|
68
70
|
rescue StandardError => e
|
69
71
|
puts e.message
|
70
72
|
end
|
@@ -76,16 +78,19 @@ module Fileverse
|
|
76
78
|
@path = Files.expand_path(path)
|
77
79
|
@storage_path = Files.expand_hidden_path(path)
|
78
80
|
@parser = Parser.new(@storage_path)
|
81
|
+
@parser.parse
|
79
82
|
end
|
80
83
|
|
81
84
|
def setup_template_parser(path)
|
82
85
|
@path = Files.expand_path(path)
|
83
86
|
@storage_path = Files.template_path
|
84
87
|
@parser = Parser.new(@storage_path)
|
88
|
+
@parser.parse
|
85
89
|
end
|
86
90
|
|
87
91
|
def setup_previewer
|
88
92
|
@previewer = Previewer.new(@path)
|
93
|
+
@previewer.parse
|
89
94
|
end
|
90
95
|
|
91
96
|
def setup_options
|
@@ -94,12 +99,12 @@ module Fileverse
|
|
94
99
|
@move_backward = options[:bwd]
|
95
100
|
@move_forward = options[:fwd]
|
96
101
|
@index = options[:index]
|
102
|
+
@clear = options[:clear]
|
97
103
|
@template_name = options[:template_name]
|
98
104
|
end
|
99
105
|
|
100
106
|
def restore_file_snapshot(path)
|
101
107
|
setup_file_parser(path)
|
102
|
-
@parser.parse
|
103
108
|
Files.write_content(@path, @parser.cursor_content)
|
104
109
|
@parser.remove_cursor_snapshot
|
105
110
|
Files.write_content(@storage_path, @parser.to_writable_lines)
|
@@ -107,12 +112,11 @@ module Fileverse
|
|
107
112
|
|
108
113
|
def restore_template_snapshot(path)
|
109
114
|
setup_template_parser(path)
|
110
|
-
@parser.parse
|
111
115
|
Files.write_content(@path, @parser.snapshot_content_by_name(@snapshot_name))
|
112
116
|
end
|
113
117
|
|
114
118
|
def preview_content # rubocop:disable Metrics/MethodLength
|
115
|
-
if @
|
119
|
+
if @snapshot_name
|
116
120
|
@parser.snapshot_content_by_name(options[:name])
|
117
121
|
elsif @move_backward
|
118
122
|
@parser.snapshot_content_backward
|
data/lib/fileverse/files.rb
CHANGED
data/lib/fileverse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileverse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unegbu Kingsley
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|