rubeepass 3.4.1 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rpass +40 -75
  3. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 966b64731923309c08bfa13dbcc0c449fe134a0f4c5995a6a7af7980a7bee879
4
- data.tar.gz: 1365a3a62c8a1bf3b0c4b178eb235b827de72de638ae17388a615b21f013f31e
3
+ metadata.gz: 36a76dde7f5f12b9e591c3ec0147a1e5dcbe6a4316ceb1d006f06a4b8131c728
4
+ data.tar.gz: b2471a888adf6ef93a9f95e0580c7808720a166ef6b065a7cfb40dd9bf914358
5
5
  SHA512:
6
- metadata.gz: 3b9041e4eb2c49f8db7e839e489232ff6fa3baf080c738294a183694b32a4fa6ee52c043b474c2c1a82a57e37d51cdc5fb3d1d45a84f8d737c5bb41322a22a4b
7
- data.tar.gz: ca95904d016acb29b237b1dba1f859fcbd143d49fe797f8d19d875b2f6b661bda067ceaec43b8aab1be107723a14e78786cb52cbb4251ed5434385ec82050688
6
+ metadata.gz: 8bed9a37a826ee088f51d113ebfc153f70a6afe28e44c7dfd1116f075538e30302a5551c3bfcdfae4a0c766be22d70fcb2c1bfb679b4942931b9a5660438191c
7
+ data.tar.gz: a2d315b67eeabf46f9d024dd34c12238e1af4d0ad2079255c217b36505f74588598dbaff116c052a70b30a06d8ca30da4b83954f3e4433ba2e557b0d637f64e6
data/bin/rpass CHANGED
@@ -19,37 +19,20 @@ class RubeePassExit
19
19
  end
20
20
 
21
21
  class RubeePassConfig < JSONConfig
22
- def default_config
23
- set("last_kdbx", nil)
24
- set("last_keyfile", nil)
25
- set("timeout", 10)
26
- end
27
-
28
- def last_kdbx(kdbx = nil)
29
- set("last_kdbx", Pathname.new(kdbx).expand_path) if (kdbx)
30
- kdbx = get("last_kdbx").to_s
31
- return nil if (kdbx.nil? || kdbx.empty?)
32
- return kdbx
33
- end
34
-
35
- def last_keyfile(kf = nil)
36
- file = nil
37
- file = Pathname.new(kf).expand_path if (kf && !kf.empty?)
38
- set("last_keyfile", file) if (kf)
39
- kf = get("last_keyfile").to_s
40
- return nil if (kf.nil? || kf.empty?)
41
- return kf
42
- end
43
-
44
- def timeout(t = nil)
45
- set("timeout", t) if (t)
46
- t = get("timeout")
47
- case t.to_s
48
- when /[0-9]+/
49
- return t.to_i
50
- else
51
- return nil
52
- end
22
+ extend JSONConfig::Keys
23
+
24
+ add_key("kdbx")
25
+ add_key("keyfile")
26
+ add_key("timeout")
27
+
28
+ def initialize(file = nil)
29
+ file ||= "~/.config/rubeepass/rc"
30
+ @defaults = {
31
+ "kdbx" => nil,
32
+ "keyfile" => nil,
33
+ "timeout" => 10
34
+ }
35
+ super(file)
53
36
  end
54
37
  end
55
38
 
@@ -63,11 +46,10 @@ end
63
46
  def parse(args)
64
47
  options = Hash.new
65
48
  options["command"] = nil
49
+ options["config"] = RubeePassConfig.new
66
50
  options["export_file"] = nil
67
51
  options["export_format"] = "xml"
68
52
  options["password"] = nil
69
- options["keyfile"] = nil
70
- options["timeout"] = nil
71
53
  options["verbose"] = false
72
54
 
73
55
  info = "KeePass 2.x read-only client."
@@ -121,7 +103,8 @@ def parse(args)
121
103
  "--keyfile=KEYFILE",
122
104
  "Use specified keyfile"
123
105
  ) do |keyfile|
124
- options["keyfile"] = keyfile
106
+ k = Pathname.new(keyfile).expand_path
107
+ options["config"].set_keyfile(k)
125
108
  end
126
109
 
127
110
  opts.on("--nocolor", "Disable colorized output") do
@@ -136,8 +119,13 @@ def parse(args)
136
119
  options["password"] = password
137
120
  end
138
121
 
139
- opts.on("-t", "--timeout=TIMEOUT", "Clipboard timeout") do |t|
140
- options["timeout"] = t.to_i
122
+ opts.on(
123
+ "-t",
124
+ "--timeout=TIMEOUT",
125
+ Integer,
126
+ "Clipboard timeout"
127
+ ) do |t|
128
+ options["config"].set_timeout(t)
141
129
  end
142
130
 
143
131
  opts.on(
@@ -183,59 +171,36 @@ def parse(args)
183
171
  exit RubeePassExit::AMBIGUOUS_ARGUMENT
184
172
  end
185
173
 
186
- if (args.length > 1)
187
- puts parser
188
- exit RubeePassExit::EXTRA_ARGUMENTS
189
- end
190
-
191
- # Read config
192
- rc = RubeePassConfig.new("~/.rpassrc")
193
-
194
- # Determine kdbx and keyfile
195
174
  if (args.length == 1)
196
- # Use specified kdbx (and keyfile if specified)
197
- options["kdbx"] = args[0]
198
- options["keyfile"] ||= ""
199
- else
200
- # Use kdbx from config if stored
201
- if (rc.last_kdbx)
202
- options["kdbx"] = rc.last_kdbx
203
- end
175
+ k = Pathname.new(args[0]).expand_path
176
+ options["config"].set_kdbx(k)
204
177
 
205
- # Use keyfile from config if stored and not specified already
206
- if (options["keyfile"].nil?)
207
- if (rc.last_keyfile)
208
- options["keyfile"] = rc.last_keyfile
209
- end
210
- end
211
- end
212
-
213
- # Determine timeout
214
- if (options["timeout"].nil?)
215
- options["timeout"] = 10
216
- options["timeout"] = rc.timeout if (rc.timeout)
178
+ # Save keyfile even if not specified
179
+ options["config"].savediff
180
+ elsif (args.length > 1)
181
+ puts parser
182
+ exit RubeePassExit::EXTRA_ARGUMENTS
217
183
  end
218
184
 
219
185
  # Throw error if kdbx not specified or in config
220
- if (options["kdbx"].nil?)
186
+ if (!options["config"].kdbx?)
221
187
  puts parser
222
188
  exit RubeePassExit::MISSING_ARGUMENT
223
189
  end
224
190
 
225
- # Store data in config
226
- options["kdbx"] = rc.last_kdbx(options["kdbx"])
227
- options["keyfile"] = rc.last_keyfile(options["keyfile"])
228
- options["timeout"] = rc.timeout(options["timeout"])
229
-
230
191
  return options
231
192
  end
232
193
 
233
194
  options = parse(ARGV)
234
195
 
235
196
  begin
236
- kdbx = options["kdbx"]
197
+ rc = options["config"]
198
+ kdbx = Pathname.new(rc.get_kdbx).expand_path
237
199
  password = options["password"] || get_password
238
- keyfile = options["keyfile"]
200
+ keyfile = nil
201
+ if (rc.keyfile?)
202
+ keyfile = Pathname.new(rc.get_keyfile).expand_path
203
+ end
239
204
 
240
205
  # Read password from file if filename was provided
241
206
  pfile = Pathname.new(password).expand_path
@@ -283,7 +248,7 @@ begin
283
248
  {
284
249
  "keepass" => keepass,
285
250
  "cwd" => keepass.db,
286
- "clipboard_timeout" => options["timeout"]
251
+ "clipboard_timeout" => options["config"].get_timeout
287
252
  }
288
253
  )
289
254
  keepass.wait_to_exit
@@ -292,7 +257,7 @@ begin
292
257
  {
293
258
  "keepass" => keepass,
294
259
  "cwd" => keepass.db,
295
- "clipboard_timeout" => options["timeout"],
260
+ "clipboard_timeout" => options["config"].get_timeout,
296
261
  "prompt_color" => "light_white"
297
262
  },
298
263
  "rpass:/> ".light_white
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubeepass
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-09 00:00:00.000000000 Z
11
+ date: 2019-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -94,22 +94,22 @@ dependencies:
94
94
  name: json_config
95
95
  requirement: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: 0.2.0
100
97
  - - "~>"
101
98
  - !ruby/object:Gem::Version
102
- version: '0.2'
99
+ version: '0.3'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 0.3.1
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: 0.2.0
110
107
  - - "~>"
111
108
  - !ruby/object:Gem::Version
112
- version: '0.2'
109
+ version: '0.3'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.3.1
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: os
115
115
  requirement: !ruby/object:Gem::Requirement