rubeepass 2.0.0 → 2.0.1

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
  SHA1:
3
- metadata.gz: a497c0ba1c2d89f4be0f1c386c3cba1b692d1452
4
- data.tar.gz: ff4a9f75e497c6d7c1c06d21fffe40680798d929
3
+ metadata.gz: 54e5d7978fbfd618209c6f5d38fb222aca339399
4
+ data.tar.gz: 537d3ac1597fefa44e2a81e85705b20a53fcf8d1
5
5
  SHA512:
6
- metadata.gz: d2141b8e46f3f30be2b0bd08f5159ee71692f1aee5ca923dbf48ffe27a534f7598d47b3e2b28466346bb7a09fa90a39472edee09f207eba583a6981397d0aa48
7
- data.tar.gz: 1a702fca0863fc0787d6b3034ff71c1b32a00d8f01d0539dc217466b76072915c7c333c37d57e3705c60432c45930dd78646e34e0f64a5dce403a017db64923f
6
+ metadata.gz: 4b7f8d5e516f29751c59aad5cd466bc5b338244d1470c0e516272a6a644cfe7d57cf4bcab984caca98f7d6dee4b96417f547ceda03db5b2bbb47ce68095c886a
7
+ data.tar.gz: 3fbae9d48900fb97bc6d3f23c81f82235d4d6dfe5f1317b8d5390bdf58924f39406941f21eceac7b165560d47cb6007605332415fe67d12230a324f1f95903b4
@@ -159,15 +159,11 @@ class RubeePass::Entry
159
159
  end
160
160
 
161
161
  def has_attachment?(name)
162
- return @attachments.any? do |k, v|
163
- k.downcase == name.downcase
164
- end
162
+ return !@attachments[name].nil?
165
163
  end
166
164
 
167
165
  def has_attribute?(attr)
168
- return @attributes.any? do |k, v|
169
- k.downcase == attr.downcase
170
- end
166
+ return !@attributes[attr].nil?
171
167
  end
172
168
 
173
169
  def hilight_attr(title)
@@ -51,7 +51,7 @@ class RubeePass::Group
51
51
  end
52
52
  end
53
53
 
54
- def find_group(path)
54
+ def find_group(path, case_insensitive = false)
55
55
  return nil if (@keepass.nil?)
56
56
 
57
57
  path = @keepass.absolute_path(path, @path)
@@ -59,16 +59,30 @@ class RubeePass::Group
59
59
 
60
60
  path.split("/").each do |group|
61
61
  next if (group.empty?)
62
- if (cwd.has_group?(group))
63
- cwd = cwd.groups[group]
62
+ if (case_insensitive)
63
+ if (cwd.has_group_like?(group))
64
+ cwd = cwd.groups.select do |k, v|
65
+ k.downcase == group.downcase
66
+ end.values.first
67
+ else
68
+ return nil
69
+ end
64
70
  else
65
- return nil
71
+ if (cwd.has_group?(group))
72
+ cwd = cwd.groups[group]
73
+ else
74
+ return nil
75
+ end
66
76
  end
67
77
  end
68
78
 
69
79
  return cwd
70
80
  end
71
81
 
82
+ def find_group_like(path)
83
+ return find_group(path, true)
84
+ end
85
+
72
86
  def self.from_xml(keepass, parent, xml)
73
87
  name = "/"
74
88
  name = xml.elements["Name"].text || "" if (parent)
@@ -122,8 +136,10 @@ class RubeePass::Group
122
136
  new_cwd = find_group(path)
123
137
  return [Array.new, Array.new] if (new_cwd.nil?)
124
138
 
125
- if (new_cwd.has_group?(target))
126
- new_cwd = new_cwd.groups[target]
139
+ if (new_cwd.has_group_like?(target))
140
+ new_cwd = new_cwd.groups.select do |k, v|
141
+ k.downcase == target.downcase
142
+ end.values.first
127
143
  target = ""
128
144
  end
129
145
 
@@ -150,15 +166,23 @@ class RubeePass::Group
150
166
  end
151
167
  end
152
168
 
153
- def has_entry?(title)
154
- return entry_titles.any? do |entry|
155
- entry.downcase == title.downcase
169
+ def has_entry?(entry)
170
+ return !@entries[entry].nil?
171
+ end
172
+
173
+ def has_entry_like?(entry)
174
+ return entry_titles.any? do |title|
175
+ title.downcase == entry.downcase
156
176
  end
157
177
  end
158
178
 
159
- def has_group?(name)
160
- return group_names.any? do |group|
161
- group.downcase == name.downcase
179
+ def has_group?(group)
180
+ return !@groups[group].nil?
181
+ end
182
+
183
+ def has_group_like?(group)
184
+ return group_names.any? do |name|
185
+ name.downcase == group.downcase
162
186
  end
163
187
  end
164
188
 
@@ -16,7 +16,7 @@ class CDWish < Djinni::Wish
16
16
  prompt_color = djinni_env["prompt_color"]
17
17
 
18
18
  path = keepass.absolute_path(args, cwd.path)
19
- new_cwd = keepass.find_group(path)
19
+ new_cwd = keepass.find_group_like(path)
20
20
 
21
21
  if (new_cwd.nil?)
22
22
  puts "Group not found"
@@ -32,27 +32,34 @@ class CopyWish < Djinni::Wish
32
32
 
33
33
  path = keepass.absolute_path(path, cwd.path)
34
34
  path, found, target = path.rpartition("/")
35
- new_cwd = keepass.find_group(path)
35
+ new_cwd = keepass.find_group_like(path)
36
36
  timeout = djinni_env["clipboard_timeout"]
37
37
 
38
- if (new_cwd.nil? || !new_cwd.has_entry?(target))
38
+ if (new_cwd.nil? || !new_cwd.has_entry_like?(target))
39
39
  puts "Entry not found"
40
40
  return
41
41
  end
42
42
 
43
+ # Prefer exact match
44
+ entry = new_cwd.entries[target]
45
+ # Fallback to case-insensitive match
46
+ entry ||= new_cwd.entries.select do |k, v|
47
+ k.downcase == target.downcase
48
+ end.values.first
49
+
43
50
  case field
44
51
  when "pass"
45
- new_cwd.entries[target].copy_password_to_clipboard
52
+ entry.copy_password_to_clipboard
46
53
  keepass.send(
47
54
  "clear_clipboard_after_#{timeout}_seconds"
48
55
  )
49
56
  when "url"
50
- new_cwd.entries[target].copy_url_to_clipboard
57
+ entry.copy_url_to_clipboard
51
58
  keepass.send(
52
59
  "clear_clipboard_after_#{timeout}_seconds"
53
60
  )
54
61
  when "user"
55
- new_cwd.entries[target].copy_username_to_clipboard
62
+ entry.copy_username_to_clipboard
56
63
  keepass.send(
57
64
  "clear_clipboard_after_#{timeout}_seconds"
58
65
  )
@@ -32,20 +32,27 @@ class EchoWish < Djinni::Wish
32
32
 
33
33
  path = keepass.absolute_path(path, cwd.path)
34
34
  path, found, target = path.rpartition("/")
35
- new_cwd = keepass.find_group(path)
35
+ new_cwd = keepass.find_group_like(path)
36
36
 
37
- if (new_cwd.nil? || !new_cwd.has_entry?(target))
37
+ if (new_cwd.nil? || !new_cwd.has_entry_like?(target))
38
38
  puts "Entry not found"
39
39
  return
40
40
  end
41
41
 
42
+ # Prefer exact match
43
+ entry = new_cwd.entries[target]
44
+ # Fallback to case-insensitive match
45
+ entry ||= new_cwd.entries.select do |k, v|
46
+ k.downcase == target.downcase
47
+ end.values.first
48
+
42
49
  case field
43
50
  when "pass"
44
- new_cwd.entries[target].echo_password
51
+ entry.echo_password
45
52
  when "url"
46
- new_cwd.entries[target].echo_url
53
+ entry.echo_url
47
54
  when "user"
48
- new_cwd.entries[target].echo_username
55
+ entry.echo_username
49
56
  end
50
57
  end
51
58
 
@@ -15,7 +15,7 @@ class LSWish < Djinni::Wish
15
15
 
16
16
  args = cwd.path if (args.empty?)
17
17
  path = keepass.absolute_path(args, cwd.path)
18
- new_cwd = keepass.find_group(path)
18
+ new_cwd = keepass.find_group_like(path)
19
19
 
20
20
  if (new_cwd.nil?)
21
21
  puts "Group not found"
@@ -16,7 +16,7 @@ class ShowWish < Djinni::Wish
16
16
  args = cwd.path if (args.empty?)
17
17
  path = keepass.absolute_path(args, cwd.path)
18
18
  path, found, target = path.rpartition("/")
19
- new_cwd = keepass.find_group(path)
19
+ new_cwd = keepass.find_group_like(path)
20
20
 
21
21
  if (new_cwd.nil?)
22
22
  puts "Group not found"
@@ -30,22 +30,26 @@ class ShowWish < Djinni::Wish
30
30
  else
31
31
  puts new_cwd
32
32
  end
33
- elsif (new_cwd.has_group?(target))
34
- case djinni_env["djinni_input"]
35
- when "showall"
36
- puts new_cwd.groups[target].details(0, true)
37
- else
38
- puts new_cwd.groups[target]
33
+ elsif (new_cwd.has_group_like?(target))
34
+ new_cwd.groups.select do |k, v|
35
+ k.downcase == target.downcase
36
+ end.values.each do |group|
37
+ case djinni_env["djinni_input"]
38
+ when "showall"
39
+ puts group.details(0, true)
40
+ else
41
+ puts group
42
+ end
39
43
  end
40
- elsif (new_cwd.has_entry?(target))
41
- new_cwd.entry_titles.select do |entry|
42
- target.downcase == entry.downcase
43
- end.each do |entry|
44
+ elsif (new_cwd.has_entry_like?(target))
45
+ new_cwd.entries.select do |k, v|
46
+ k.downcase == target.downcase
47
+ end.values.each do |entry|
44
48
  case djinni_env["djinni_input"]
45
49
  when "showall"
46
- puts new_cwd.entries[entry].details(0, true)
50
+ puts entry.details(0, true)
47
51
  else
48
- puts new_cwd.entries[entry]
52
+ puts entry
49
53
  end
50
54
  end
51
55
  else
data/lib/rubeepass.rb CHANGED
@@ -175,6 +175,10 @@ class RubeePass
175
175
  return @db.find_group(path)
176
176
  end
177
177
 
178
+ def find_group_like(path)
179
+ return @db.find_group(path, true)
180
+ end
181
+
178
182
  def fuzzy_find(input)
179
183
  return @db.fuzzy_find(input)
180
184
  end
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: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest