crawling 0.3.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d55d7bcfdfbdab051217b31f045dc643dce1f3606525e5423ac02c8ad948be10
4
- data.tar.gz: 52fc3441f5fa0a2290949e7694afc6a3df0f4819f937237345618e42889926a1
3
+ metadata.gz: f24e27ea229eaf1f3bd1760fefd0b53a759b16aa3354b06f68bc9710d874501a
4
+ data.tar.gz: eab9333641ee6dcde030089df2970b253f9e514362be54df3a55d6cb3bf71971
5
5
  SHA512:
6
- metadata.gz: 13b0b1f073279e368e81440f0bd4f5c5d95aa8817a8327f9dc40e1aa53a3131051ee85a3edc2540137bf6e683a0cda5088a079e111af4312dd0a84dbf3772e33
7
- data.tar.gz: fca726ff6feba6de569195d8677a470030e30f5d5133a5868d366038dcca49121ebf515c3b06e133416ef55b1753a16ad0a9a69dca31130dbe94b14da86c69fd
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 'clone', 'clone or pull latest store using configured commands'
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 'clone'
66
- crawling.clone
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", "~> 10.0"
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
 
@@ -1,3 +1,3 @@
1
1
  module Crawling
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.5"
3
3
  end
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 = { 'home' => @home_dir }
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::mkdir_p @config_dir unless Dir.exists? @config_dir
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.exists? path
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.exists? storage_path
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 clone
173
- raise "clone: command not supported yet"
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.exists?(path) ? Crawling.child_files_recursive(path) : [path]
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.exists? file
216
- if File.exists? storage_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.exists? storage_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.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: 2019-03-09 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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.0.2
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: []