kbsecret 0.0.10 → 0.0.11

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
  SHA1:
3
- metadata.gz: fbc13cb4e4be9699119df9e1a40229636c033c24
4
- data.tar.gz: bfd30dd12815a1ef6b5e7ad7ced9b0a94e9523da
3
+ metadata.gz: a5b1955e05178ea6bd3da7538fc4d756de0bcef4
4
+ data.tar.gz: f33e38c1524dc6c3a7d8b5524e1e4640c5911402
5
5
  SHA512:
6
- metadata.gz: 75b37e82e7b7f798a149b458d94575bce3c2708dcede2ede334d75d11fe251a517ab35a619f352a0bb3c1b0b81265e7319e8e7a6739beb21253bf42accbb5066
7
- data.tar.gz: 87526553d6e2b39798df1923e775c54d6e7860610bd342153f9dab3b8eabbdd38194fe91cb1bbc880dad65160d037ed09a11223a985b8d12131ef7865460168c
6
+ metadata.gz: 95d789fa03e62389714673915f277876d4ae795f5d079920577d8ca87145a79c4fa40fec86dbebd6105e4da423e33f658bb696f2129ec61b8db983e483d67c04
7
+ data.tar.gz: 895de053efda4a7a314f9f3cbb2a4b64804175387aef51839e3606f9debb635802b50b336b2d45726b6f3babfd7567dfb2be2a6c4c284cd1de7e3164101e0e2f
data/README.md CHANGED
@@ -89,3 +89,4 @@ Please feel free to contribute completion scripts for other shells!
89
89
  ### TODO
90
90
 
91
91
  * zsh/fish completions
92
+ * a TODO record type?
data/bin/kbsecret-pass CHANGED
@@ -41,12 +41,10 @@ label = opts.args.shift
41
41
  login_records = session.records.select { |r| r.type == "login" }
42
42
  record = login_records.find { |r| r.label == label }
43
43
 
44
- if record
45
- if opts.clipboard?
46
- Clipboard.copy record.password
47
- else
48
- puts record.password
49
- end
44
+ abort("Fatal: No such login record.") unless record
45
+
46
+ if opts.clipboard?
47
+ Clipboard.copy record.password
50
48
  else
51
- abort "Fatal: No such record."
49
+ puts record.password
52
50
  end
@@ -42,7 +42,7 @@ label = opts.args.shift
42
42
  record = session.records.find { |r| r.label == label}
43
43
 
44
44
  if record
45
- `#{ENV["EDITOR"]} #{record.path}`
45
+ Process.spawn("#{ENV["EDITOR"]} #{record.path}")
46
46
  else
47
47
  abort "Fatal: No such record."
48
48
  end
data/bin/kbsecret-todo ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "kbsecret"
4
+ require "slop"
5
+
6
+ opts = Slop.parse suppress_errors: true do |o|
7
+ o.banner = <<~EOS
8
+ Manage 'to do' records.
9
+
10
+ Usage:
11
+ kbsecret todo <start|suspend|complete> <label>
12
+
13
+ Examples:
14
+ kbsecret todo start unit-tests
15
+ kbsecret todo suspend laundry
16
+ kbsecret todo complete shopping
17
+ EOS
18
+
19
+ o.string "-s", "--session", "the session name", default: :default
20
+
21
+ o.on "-h", "--help" do
22
+ puts o
23
+ exit
24
+ end
25
+
26
+ o.on "--introspect-flags" do
27
+ subcmds = ["start", "suspend", "complete"]
28
+ comp = o.options.flat_map { |o| o.flags } + subcmds
29
+ puts comp.join "\n"
30
+ exit
31
+ end
32
+ end
33
+
34
+ sess_name = opts[:session]
35
+
36
+ unless KBSecret::Config.session? sess_name
37
+ abort "Fatal: Unknown session: '#{sess_name}'."
38
+ end
39
+
40
+ session = KBSecret::Session.new label: sess_name
41
+ command, label = opts.args.shift 2
42
+
43
+ abort("Fatal: Missing subcommand.") unless command && label
44
+
45
+ todo_records = session.records.select { |r| r.type == "todo" }
46
+ todo = todo_records.find { |r| r.label == label }
47
+
48
+ abort("Fatal: No such todo record.") unless todo
49
+
50
+ case command
51
+ when "start"
52
+ abort("That task is already started!") if todo.started?
53
+ todo.start!
54
+ puts "#{todo.label}: '#{todo.todo}' marked as started at #{todo.start}"
55
+ when "suspend"
56
+ abort("That task is already suspended!") if todo.suspended?
57
+ todo.suspend!
58
+ puts "#{todo.label}: '#{todo.todo}' marked as suspended at #{todo.stop}"
59
+ when "complete"
60
+ abort("That task is already completed!") if todo.completed?
61
+ todo.complete!
62
+ puts "#{todo.label}: '#{todo.todo}' marked as completed at #{todo.stop}"
63
+ else
64
+ abort("Fatal: Unknown action: #{command}.")
65
+ end
@@ -0,0 +1,82 @@
1
+ module KBSecret
2
+ module Record
3
+ # Represents a record containing a 'to do' item and its status.
4
+ #
5
+ # Apart from the text of the item itself, each record contains three
6
+ # relevant fields: the item's status, a start time, and a stop time.
7
+ #
8
+ # The status is one of `"started"`, `"suspended"`, or `"complete"`, each
9
+ # of which should be self-explanatory.
10
+ #
11
+ # The start time is the date and time at which the item was started via
12
+ # {#start!}.
13
+ #
14
+ # The stop top is the date and time at which the item was *either*
15
+ # last suspended via {#suspend!} *or* finished via {#complete!}.
16
+ class ToDo < Abstract
17
+ data_field :todo
18
+ data_field :status
19
+ data_field :start
20
+ data_field :stop
21
+
22
+ # @param session [Session] the session to associate with
23
+ # @param label [Symbol] the new record's label
24
+ # @param todo [String] the to do item
25
+ def initialize(session, label, todo)
26
+ super(session, label)
27
+
28
+ @data = {
29
+ todo: {
30
+ todo: todo,
31
+ status: "suspended",
32
+ start: nil,
33
+ stop: nil,
34
+ },
35
+ }
36
+ end
37
+
38
+ # @return [Boolean] whether or not the item is marked as started
39
+ def started?
40
+ status == "started"
41
+ end
42
+
43
+ # @return [Boolean] whether or not the item is marked as suspended
44
+ def suspended?
45
+ status == "suspended"
46
+ end
47
+
48
+ # @return [Boolean] whether or not the item is marked as completed
49
+ def completed?
50
+ !(started? || suspended?)
51
+ end
52
+
53
+ # Start the to do item.
54
+ # @return [void]
55
+ # @note Does nothing if the item is already started.
56
+ def start!
57
+ return if started?
58
+
59
+ self.status = "started"
60
+ self.start = Time.now.to_s
61
+ end
62
+
63
+ # Suspend the to do item.
64
+ # @return [void]
65
+ # @note Does nothing if the item is already suspended.
66
+ def suspend!
67
+ return if suspended?
68
+ self.status = "suspended"
69
+ self.stop = Time.now.to_s
70
+ end
71
+
72
+ # Complete the to do item.
73
+ # @return [void]
74
+ # @note Does nothing if the item is already completed.
75
+ def complete!
76
+ return if completed?
77
+ self.status = "complete"
78
+ self.stop = Time.now.to_s
79
+ end
80
+ end
81
+ end
82
+ end
@@ -40,7 +40,7 @@ module KBSecret
40
40
  def self.load_record!(session, path)
41
41
  hsh = JSON.parse(File.read(path), symbolize_names: true)
42
42
  klass = record_classes.find { |c| c.type == hsh[:type] }
43
- klass.load!(session, hsh)
43
+ klass.load!(session, hsh) if klass
44
44
  end
45
45
  end
46
46
  end
data/lib/kbsecret.rb CHANGED
@@ -8,7 +8,7 @@ require_relative "kbsecret/session"
8
8
  # The primary namespace for kbsecret.
9
9
  module KBSecret
10
10
  # kbsecret's current version
11
- VERSION = "0.0.10".freeze
11
+ VERSION = "0.0.11".freeze
12
12
 
13
13
  # fail very early if the user doesn't have keybase and KBFS running
14
14
  raise Keybase::KeybaseNotRunningError unless Keybase.running?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kbsecret
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: keybase-unofficial
@@ -74,6 +74,7 @@ executables:
74
74
  - kbsecret-rm
75
75
  - kbsecret-login
76
76
  - kbsecret-raw-edit
77
+ - kbsecret-todo
77
78
  - kbsecret-new
78
79
  - kbsecret-env
79
80
  - kbsecret-new-session
@@ -95,6 +96,7 @@ files:
95
96
  - bin/kbsecret-raw-edit
96
97
  - bin/kbsecret-rm
97
98
  - bin/kbsecret-sessions
99
+ - bin/kbsecret-todo
98
100
  - lib/kbsecret.rb
99
101
  - lib/kbsecret/config.rb
100
102
  - lib/kbsecret/exceptions.rb
@@ -103,6 +105,7 @@ files:
103
105
  - lib/kbsecret/record/environment.rb
104
106
  - lib/kbsecret/record/login.rb
105
107
  - lib/kbsecret/record/snippet.rb
108
+ - lib/kbsecret/record/todo.rb
106
109
  - lib/kbsecret/record/unstructured.rb
107
110
  - lib/kbsecret/session.rb
108
111
  homepage: https://github.com/woodruffw/kbsecret