sheldon 6.1.0 → 6.2.2

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: 83e453e21aa4dff4ea4eff7005a4b39361309ff2598f6a0fb51089d2493d6371
4
- data.tar.gz: 73d869ad35ffc2c51f7f3f397c593c7f0c7f1c2e9ed923828de28eef931d2bda
3
+ metadata.gz: 2da25030d7b1b8c75d8086d1fe49b93b235e403db8fe458462f9ffc4cbb02ebe
4
+ data.tar.gz: e5beeae34230723afe2045230030a65258b09f66466745fa02c31383a8652aba
5
5
  SHA512:
6
- metadata.gz: f1e0bfd62594680c986726e42b5dd732bcce8082df572c62118ffee062d9c6542347fdb1fcbbbe7ee6224f0035800527f871a908be0eb8028b1624175ddfe02b
7
- data.tar.gz: c1553d90cd57ee0e3d285e70403f03c34bf1faae8aa8bde9a69362a008b4b5e8c9424aae27ffdce5f6c37de438936292812a631a5975129693ff6869e9b47e11
6
+ metadata.gz: 117fce31072b4899578ca2da01146b3c0094c674b1b0fe69336266a8f2aa686dad02885c982d5973d90ded664ef5d7147c2b29f3c0cb90bce4ed47fa5a300a4f
7
+ data.tar.gz: 50b1ea6cc8ad3b08bbd71aca9d28ef1f90bfc57ab1efd57320816824c712bd9a1119bff9a3d23f35de3490217921aefed5325741482b6605d6ce3d19d804808b
data/bin/sheldon CHANGED
@@ -66,12 +66,12 @@ module CLI
66
66
 
67
67
  if options[:i]
68
68
  cue_options.each do |recall_cue|
69
- answer = prompt.yes?("Recall #{recall_cue}?")
70
- with_exception_handling { sheldon.recall(recall_cue) if answer == true }
69
+ recall_confirmed = prompt.yes?("Recall #{recall_cue}?")
70
+ perform_recall(recall_cue) if recall_confirmed
71
71
  end
72
72
  else
73
73
  recall_cue ||= cue_picker("What would you like to recall?", cue_options)
74
- with_exception_handling { sheldon.recall(recall_cue) }
74
+ perform_recall(recall_cue)
75
75
  prompt.ok("Sheldon recall complete: #{recall_cue}")
76
76
  end
77
77
  end
@@ -101,17 +101,28 @@ module CLI
101
101
 
102
102
  private
103
103
 
104
+ def cue_picker(message, options=sheldon.list_cues)
105
+ prompt.select(message, options, per_page: 20, filter: true)
106
+ end
107
+
104
108
  def error_and_exit(message)
105
109
  prompt.error(message)
106
110
  exit!
107
111
  end
108
112
 
109
- def prompt
110
- @prompt ||= TTY::Prompt.new(interrupt: :exit)
113
+ def perform_recall(recall_cue)
114
+ with_exception_handling do
115
+ begin
116
+ sheldon.recall(recall_cue)
117
+ rescue DestinationNotEmptyException => e
118
+ overwrite_confirmed = prompt.yes?("File/target already exists. Overwrite?")
119
+ sheldon.recall(recall_cue, overwrite: true) if overwrite_confirmed
120
+ end
121
+ end
111
122
  end
112
123
 
113
- def cue_picker(message, options=sheldon.list_cues)
114
- prompt.select(message, options, per_page: 20, filter: true)
124
+ def prompt
125
+ @prompt ||= TTY::Prompt.new(interrupt: :exit)
115
126
  end
116
127
 
117
128
  def read_from_dotfile(key)
data/lib/sheldon/brain.rb CHANGED
@@ -47,16 +47,29 @@ class Brain
47
47
  memory.present?
48
48
  end
49
49
 
50
- def recall(recall_cue)
50
+ def recall(recall_cue, opts={})
51
+ # Compute the absolute paths for recall
52
+ brain_path = brain_directory_for_cue(recall_cue)
51
53
  entry = memory.recall(recall_cue)
52
54
  destination_path = add_home(entry[:filepath])
53
55
  destination_dir = File.dirname(destination_path)
54
- raise DestinationNotEmptyException, "#{destination_path} already exists." if File.exist?(destination_path)
55
56
 
57
+ # Handle the destination file / directory already existing on the filesystem
58
+ if File.exist?(destination_path) || File.symlink?(destination_path)
59
+ if opts[:overwrite]
60
+ FileUtils.remove_dir(destination_path) # this (badly named) method deletes both files and folders
61
+ else
62
+ raise DestinationNotEmptyException, "#{destination_path} already exists."
63
+ end
64
+ end
65
+
66
+ # Create the destination directory if required
56
67
  FileUtils.mkdir_p(destination_dir) unless File.directory?(destination_dir)
57
- brain_path = brain_directory_for_cue(recall_cue)
68
+
69
+ # Create the symbolic link between sheldon's brain and the destination
58
70
  FileUtils.ln_s(get_content(brain_path), destination_path)
59
- return true
71
+
72
+ return recalled?(recall_cue)
60
73
  end
61
74
 
62
75
  def recalled?(recall_cue)
@@ -2,7 +2,7 @@ class Builder
2
2
  require "fileutils"
3
3
 
4
4
  def build(abs_build_path)
5
- entries = Dir.glob(abs_build_path + "/*")
5
+ entries = Dir.glob(abs_build_path + "/*").sort
6
6
  master_content = entries.inject("") do |buffer, entry|
7
7
  is_config?(entry) ? add_entry_to_buffer(entry, buffer) : buffer
8
8
  end
@@ -1,7 +1,7 @@
1
1
  require "fileutils"
2
2
 
3
3
  class Sheldon
4
- VERSION = "6.1.0".freeze
4
+ VERSION = "6.2.2".freeze
5
5
  attr_reader :brain, :builder
6
6
 
7
7
  def initialize(sheldon_data_dir)
@@ -29,8 +29,8 @@ class Sheldon
29
29
  brain.list_cues
30
30
  end
31
31
 
32
- def recall(recall_cue)
33
- brain.recall(recall_cue)
32
+ def recall(recall_cue, opts={})
33
+ brain.recall(recall_cue, opts)
34
34
  end
35
35
 
36
36
  def setup!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sheldon
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Jones
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-27 00:00:00.000000000 Z
11
+ date: 2022-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -101,7 +101,7 @@ homepage: https://github.com/dvjones89/sheldon
101
101
  licenses:
102
102
  - MIT
103
103
  metadata: {}
104
- post_install_message:
104
+ post_install_message:
105
105
  rdoc_options: []
106
106
  require_paths:
107
107
  - lib
@@ -116,9 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.7.7
121
- signing_key:
119
+ rubygems_version: 3.0.3
120
+ signing_key:
122
121
  specification_version: 4
123
122
  summary: Another config and dotfile manager for unix environments
124
123
  test_files: []