crawling 0.3.4 → 0.3.5
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/crawling/version.rb +1 -1
- data/lib/crawling.rb +17 -14
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f24e27ea229eaf1f3bd1760fefd0b53a759b16aa3354b06f68bc9710d874501a
|
4
|
+
data.tar.gz: eab9333641ee6dcde030089df2970b253f9e514362be54df3a55d6cb3bf71971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e9fb2363d3413e29d378f59e507fc9fcca62f1ec6afa385992f88a109fc6334d53ce60c0546c7d02f638a53fe9a5652c0f9744350306cc8da853d4ca1efe09e
|
7
|
+
data.tar.gz: a8c8038e9799dd55287d9c02447a7a327b05e1a5d82296111ac3a7c338e97d693139e6a1643734c9ae4401e196a66a560b245997a26116576f6a9b8f5426534f
|
data/lib/crawling/version.rb
CHANGED
data/lib/crawling.rb
CHANGED
@@ -3,12 +3,6 @@ require "diffy"
|
|
3
3
|
require "pathname"
|
4
4
|
|
5
5
|
module Crawling
|
6
|
-
# path to repository for user(s)
|
7
|
-
HOME_PARENT_DIR = 'home'
|
8
|
-
|
9
|
-
# path to repository for the system
|
10
|
-
SYSTEM_PARENT_DIR = 'system'
|
11
|
-
|
12
6
|
N_LINES_DIFF_CONTEXT = 3
|
13
7
|
|
14
8
|
def self.child_files_recursive path
|
@@ -63,7 +57,10 @@ module Crawling
|
|
63
57
|
@config_pathname = Pathname.new(@config_dir).expand_path
|
64
58
|
@merge_app = merge_app || 'nvim -d %s %h'
|
65
59
|
|
66
|
-
stores = {
|
60
|
+
stores = {
|
61
|
+
'home' => @home_dir,
|
62
|
+
# 'system' => '/',
|
63
|
+
}
|
67
64
|
@stores = stores.map do |store_dir, sys_dir|
|
68
65
|
store_dir = File.join(@config_dir, store_dir)
|
69
66
|
Store.new store_dir, sys_dir
|
@@ -71,7 +68,7 @@ module Crawling
|
|
71
68
|
end
|
72
69
|
|
73
70
|
def cd
|
74
|
-
FileUtils
|
71
|
+
FileUtils.mkdir_p @config_dir unless Dir.exist? @config_dir
|
75
72
|
Dir.chdir @config_dir
|
76
73
|
puts "creating shell in #{@config_dir}, type exit or ctrl-D to exit"
|
77
74
|
system ENV['SHELL']
|
@@ -82,7 +79,7 @@ module Crawling
|
|
82
79
|
raise "add command requires paths" if paths.empty?
|
83
80
|
|
84
81
|
paths.each do |path|
|
85
|
-
raise "path #{path} does not exist" unless File.
|
82
|
+
raise "path #{path} does not exist" unless File.exist? path
|
86
83
|
|
87
84
|
each_with_storage_path(files_from path) do |file, storage_file|
|
88
85
|
Crawling.copy_file file, storage_file
|
@@ -94,7 +91,7 @@ module Crawling
|
|
94
91
|
raise "get command requires paths" if paths.empty?
|
95
92
|
|
96
93
|
each_with_storage_path(paths) do |path, storage_path|
|
97
|
-
raise "path #{path} does not exist in storage" unless File.
|
94
|
+
raise "path #{path} does not exist in storage" unless File.exist? storage_path
|
98
95
|
|
99
96
|
files_from(storage_path).each do |storage_file|
|
100
97
|
if storage_file == storage_path
|
@@ -187,11 +184,17 @@ module Crawling
|
|
187
184
|
end
|
188
185
|
end
|
189
186
|
|
187
|
+
# if path is in the store then return it with the system path, if it
|
188
|
+
# is a system path then return it with the store path
|
190
189
|
def get_path_pair path
|
191
190
|
path = File.absolute_path path
|
192
191
|
@stores.each do |store|
|
193
192
|
sys_path = store.get_sys_path path
|
194
193
|
return [ sys_path, path ] if sys_path
|
194
|
+
end
|
195
|
+
|
196
|
+
# path is not in the store
|
197
|
+
@stores.each do |store|
|
195
198
|
store_path = store.get_store_path path
|
196
199
|
return [ path, store_path ] if store_path
|
197
200
|
end
|
@@ -209,17 +212,17 @@ module Crawling
|
|
209
212
|
end
|
210
213
|
|
211
214
|
def files_from path
|
212
|
-
Dir.
|
215
|
+
Dir.exist?(path) ? Crawling.child_files_recursive(path) : [path]
|
213
216
|
end
|
214
217
|
|
215
218
|
def file_or_storage_file_doesnt_exist file, storage_file
|
216
|
-
if not File.
|
217
|
-
if File.
|
219
|
+
if not File.exist? file
|
220
|
+
if File.exist? storage_file
|
218
221
|
'system'
|
219
222
|
else
|
220
223
|
'system directory or store'
|
221
224
|
end
|
222
|
-
elsif not File.
|
225
|
+
elsif not File.exist? storage_file
|
223
226
|
'store'
|
224
227
|
end
|
225
228
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crawling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Pike
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -119,7 +119,7 @@ licenses:
|
|
119
119
|
- MIT
|
120
120
|
metadata:
|
121
121
|
allowed_push_host: https://rubygems.org
|
122
|
-
post_install_message:
|
122
|
+
post_install_message:
|
123
123
|
rdoc_options: []
|
124
124
|
require_paths:
|
125
125
|
- lib
|
@@ -134,8 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
-
signing_key:
|
137
|
+
rubygems_version: 3.4.20
|
138
|
+
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Tool to manage personal configuration and environment files.
|
141
141
|
test_files: []
|