sheldon 6.1.1 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fcd9ba0fc6e8476ca29295ab5cabd422e9c173fd44081d3c609938f50c4264e
4
- data.tar.gz: a89f27bb6197bac5852a97ddbe7dc3439931b3c7a440ed5d2705ec062b970900
3
+ metadata.gz: ae77eea72d0cbd8122af494ca74a65b695239441e9404ec638264d177c3402e4
4
+ data.tar.gz: d75771ef4eeefc50b7d7797d3a7e0acc9bade0b1e82d0f4c7b05868414339c61
5
5
  SHA512:
6
- metadata.gz: 1ccb496b56e38481a305313bc81f3bf4cfcd41ffc034e750a5a9d2c386608b82845229d9e4cbbdaa4345a662c79df43d84013c7e96d034b2dc1e9b71e06d2439
7
- data.tar.gz: 03b69b577dc3089beae54eae843327eb1f7471c4362d215afe31b7e8a70bd81fa4d76b90895712b7cff61449b1f5cb54c6864b7b80b44c6ffbe39f647a864d13
6
+ metadata.gz: 8a23ca4c9ad09b76eeaba8b08bc080867dce4525a5ac6257efeb9455252686cbba41bdf6429110b25053ecb0c0c319f73e8c7c36be4969ce1498ea9c1172a446
7
+ data.tar.gz: 1292f1dc3fd7929d64c216381204d3faaf73cc230246f944fe5e2b7c9ba45452b08630645b84aa4af781bfccd743210ffc10df390a84dd4578fd294a904d315f
@@ -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)
@@ -47,15 +47,16 @@ class Brain
47
47
  memory.present?
48
48
  end
49
49
 
50
- def recall(recall_cue)
50
+ def recall(recall_cue, opts={})
51
51
  entry = memory.recall(recall_cue)
52
52
  destination_path = add_home(entry[:filepath])
53
53
  destination_dir = File.dirname(destination_path)
54
- raise DestinationNotEmptyException, "#{destination_path} already exists." if File.exist?(destination_path)
54
+
55
+ raise DestinationNotEmptyException, "#{destination_path} already exists." if File.exist?(destination_path) && !opts[:overwrite]
55
56
 
56
57
  FileUtils.mkdir_p(destination_dir) unless File.directory?(destination_dir)
57
58
  brain_path = brain_directory_for_cue(recall_cue)
58
- FileUtils.ln_s(get_content(brain_path), destination_path)
59
+ FileUtils.ln_s(get_content(brain_path), destination_path, force: opts[:overwrite])
59
60
  return true
60
61
  end
61
62
 
@@ -1,7 +1,7 @@
1
1
  require "fileutils"
2
2
 
3
3
  class Sheldon
4
- VERSION = "6.1.1".freeze
4
+ VERSION = "6.2.0".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.1
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Jones
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-28 00:00:00.000000000 Z
11
+ date: 2019-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor