crawling 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/crawling +3 -3
- data/crawling.gemspec +1 -1
- data/lib/crawling/version.rb +1 -1
- data/lib/crawling.rb +20 -16
- metadata +8 -8
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/bin/crawling
CHANGED
@@ -35,7 +35,7 @@ module Crawling::Command
|
|
35
35
|
op.subcommand 'merge,m [*paths]', 'merge differences between store directory and filesystem' do |subop|
|
36
36
|
subop.on '-m', '--merge-app app', 'command used to merge files', 'merge_app'
|
37
37
|
end
|
38
|
-
op.subcommand '
|
38
|
+
op.subcommand 'pull,p', 'pull latest store'
|
39
39
|
|
40
40
|
parsed_cfg = op.parse(args)
|
41
41
|
command = parsed_cfg.command
|
@@ -62,8 +62,8 @@ module Crawling::Command
|
|
62
62
|
crawling.diff nil_if_empty(command_cfg.paths)
|
63
63
|
when 'merge'
|
64
64
|
crawling.merge nil_if_empty(command_cfg.paths)
|
65
|
-
when '
|
66
|
-
crawling.
|
65
|
+
when 'pull'
|
66
|
+
crawling.pull
|
67
67
|
end
|
68
68
|
rescue RuntimeError => e
|
69
69
|
puts e.to_s
|
data/crawling.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = "crawling"
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_development_dependency "rake", "~>
|
30
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.8"
|
32
32
|
spec.add_development_dependency "rspec_junit_formatter", "~> 0.4"
|
33
33
|
|
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
|
@@ -169,8 +166,9 @@ module Crawling
|
|
169
166
|
end
|
170
167
|
end
|
171
168
|
|
172
|
-
def
|
173
|
-
|
169
|
+
def pull
|
170
|
+
Dir.chdir @config_dir
|
171
|
+
system 'git pull'
|
174
172
|
end
|
175
173
|
|
176
174
|
private
|
@@ -186,11 +184,17 @@ module Crawling
|
|
186
184
|
end
|
187
185
|
end
|
188
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
|
189
189
|
def get_path_pair path
|
190
190
|
path = File.absolute_path path
|
191
191
|
@stores.each do |store|
|
192
192
|
sys_path = store.get_sys_path path
|
193
193
|
return [ sys_path, path ] if sys_path
|
194
|
+
end
|
195
|
+
|
196
|
+
# path is not in the store
|
197
|
+
@stores.each do |store|
|
194
198
|
store_path = store.get_store_path path
|
195
199
|
return [ path, store_path ] if store_path
|
196
200
|
end
|
@@ -208,17 +212,17 @@ module Crawling
|
|
208
212
|
end
|
209
213
|
|
210
214
|
def files_from path
|
211
|
-
Dir.
|
215
|
+
Dir.exist?(path) ? Crawling.child_files_recursive(path) : [path]
|
212
216
|
end
|
213
217
|
|
214
218
|
def file_or_storage_file_doesnt_exist file, storage_file
|
215
|
-
if not File.
|
216
|
-
if File.
|
219
|
+
if not File.exist? file
|
220
|
+
if File.exist? storage_file
|
217
221
|
'system'
|
218
222
|
else
|
219
223
|
'system directory or store'
|
220
224
|
end
|
221
|
-
elsif not File.
|
225
|
+
elsif not File.exist? storage_file
|
222
226
|
'store'
|
223
227
|
end
|
224
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
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '12.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '12.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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: []
|