ruby-keepassx 0.2.0 → 0.2.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: 35f2f1221b72c8c74d1fa5a93850c16344d45545
4
- data.tar.gz: c0ab67fd645312df9583a7d98304f19c7f287cce
3
+ metadata.gz: becc633558db7f94287984345437f06a2b54428b
4
+ data.tar.gz: 2421c2d007dcbc4ce0499afceeca5631aab4c939
5
5
  SHA512:
6
- metadata.gz: 1f09e9cdd21f2e08a544f02c868877c05f3e3dcb8e30b1e850d6dc3e0f977a305a868064a0abfd2dcd2aab49b9bbf065535503b29ee7252c00f97e579facefb7
7
- data.tar.gz: 4307be70d609093891f1bdf59f2e5cfd263a5ee9febcfec84cf8e29ae4f7dff984a2a0e634758460ada410b8bb01127acb9d57bc90c61d216d3fff94d469f46e
6
+ metadata.gz: 59384fb219670347067b58848b930b05f67510b3e557801070a111a359209c31ec6807e70a229c0254b476eec3902cc90f52b2ca0b9f334bb58d07a285df7eac
7
+ data.tar.gz: 8f939f54f2f68507f8aab8827a0c722c8f159934cbf6fe1cc64751ecfa926c80f9d7708ff2779d263c645e84c075ec97636fa165a7fd48b82eaa1793dfe4529f
data/README.md CHANGED
@@ -26,3 +26,7 @@ puts database.entry("entry's title").password
26
26
  ## Security Warning
27
27
 
28
28
  No attempt is made to protect the memory used by this library; there may be something we can do with libgcrypt's secure-malloc functions, but right now your master password is unencrypted in ram that could possibly be paged to disk.
29
+
30
+
31
+ [![Build Status](https://travis-ci.org/tioteath/ruby-keepassx
32
+ .svg?branch=master)](https://travis-ci.org/tioteath/ruby-keepassx)
@@ -5,6 +5,25 @@ require 'digest/sha2'
5
5
  require 'securerandom'
6
6
  require 'rexml/document'
7
7
 
8
+ # Add backward compatibility stuff
9
+ if RUBY_VERSION =~ /1\.8/
10
+ require 'backports/tools'
11
+ require 'backports/1.9.1/symbol/empty'
12
+ require 'backports/1.9.3/io/write'
13
+ require 'time' # Get Time.parse
14
+
15
+ unless SecureRandom.method_defined? :uuid
16
+ module SecureRandom
17
+ # Based on this post https://www.ruby-forum.com/topic/3171049#1035902
18
+ def self.uuid
19
+ s = hex 16
20
+ [s[0..7], s[8..11], s[12..15], s[16..19], s[20..-1]].join '-'
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+
8
27
  require 'keepassx/exceptions'
9
28
  require 'keepassx/header'
10
29
  require 'keepassx/utilities'
@@ -124,7 +124,7 @@ module Keepassx
124
124
  match_number = opts.length
125
125
  items = []
126
126
  opts.each do |k, v|
127
- items += Array item_list.select { |e| e.send(k).eql?(v) }
127
+ items += Array(item_list.select { |e| e.send(k).eql?(v) })
128
128
  end
129
129
 
130
130
  buffer = Hash.new 0
@@ -87,8 +87,8 @@ module Keepassx
87
87
  fail "'group' is required" if payload[:group].nil?
88
88
  self.group = payload[:group]
89
89
 
90
- field_list = FIELD_MAPPING.keys
91
- data = payload.select { |k| field_list.include? k }
90
+ fields = self.class.fields
91
+ data = payload.reject { |k, _| !fields.include? k }
92
92
  data[:group_id] = group.id
93
93
 
94
94
  @fields = []
@@ -169,7 +169,6 @@ module Keepassx
169
169
 
170
170
 
171
171
  def ascii= value
172
- # TODO: Add spec
173
172
  @data = [value].pack('H*')
174
173
  end
175
174
 
@@ -109,9 +109,9 @@ module Keepassx
109
109
  if previous_group.nil? or group.level.eql? 0
110
110
  group.parent = nil
111
111
 
112
- # If group has level greater than parent's level by one,
113
- # it gets parent set to the first previous group with level less
114
- # than group's level by one
112
+ # If group has level greater than parent's level by one,
113
+ # it gets parent set to the first previous group with level less
114
+ # than group's level by one
115
115
  elsif group.level == previous_group.level + 1 or
116
116
  group.level == previous_group.level
117
117
 
@@ -187,7 +187,7 @@ module Keepassx
187
187
  # Remove groups and entries from options, so new group could be
188
188
  # initialized from incoming Hash
189
189
  fields = Keepassx::Group.fields
190
- group_opts = opts.select { |k, _| fields.include? k }
190
+ group_opts = opts.reject { |k, _| !fields.include? k }
191
191
  group = add_group group_opts
192
192
 
193
193
  entries.each do |e|
@@ -3,16 +3,21 @@ Gem::Specification.new do |s|
3
3
  s.summary = 'Ruby API access for KeePassX databases'
4
4
  s.description = 'This is fork of Tony Pitluga\'s ' \
5
5
  'Ruby API for keepassx with read-write support.'
6
- s.version = '0.2.0'
6
+ s.version = '0.2.1'
7
7
  s.authors = ['Tony Pitluga', 'Paul Hinze', 'Tio Teath']
8
8
  s.email = ['tony.pitluga@gmail.com', 'paul.t.hinze@gmail.com',
9
9
  'tioteath@gmail.com']
10
10
  s.homepage = 'https://github.com/tioteath/ruby-keepassx.git'
11
11
  s.files = `git ls-files`.split "\n"
12
12
 
13
+ # TODO: This won't work, figure out why.
14
+ if RUBY_VERSION =~ /1\.8/
15
+ s.add_dependency 'backports', '~> 3.6.0'
16
+ end
17
+
13
18
  s.add_development_dependency 'rspec', '~> 3.0'
14
19
  s.add_development_dependency 'pry', '~> 0'
15
20
  s.add_development_dependency 'rake', '~> 0.8', '>= 0.8.7'
16
- # s.add_development_dependency 'respect', '~> 0.1.1'
21
+ s.add_development_dependency 'respect', '~> 0.1', '>= 0.1.1'
17
22
  # s.add_development_dependency 'rspec-prof', '~> 0'
18
23
  end
@@ -16,9 +16,8 @@ describe Keepassx::Database do
16
16
  subject { Keepassx }
17
17
  let(:db1) { subject.new data_array }
18
18
  let(:db2) { subject.new data_array }
19
+
19
20
  it 'has the same checksum for the same data' do
20
- # warn "db1: #{File.write '/tmp/db1', db1.entries.inspect}>><<"
21
- # warn "db2: #{File.write '/tmp/db2', db2.entries.inspect}>><<"
22
21
  expect(db1.checksum).to eq db2.checksum
23
22
  end
24
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-keepassx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitluga
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-09-16 00:00:00.000000000 Z
13
+ date: 2014-09-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -60,6 +60,26 @@ dependencies:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: 0.8.7
63
+ - !ruby/object:Gem::Dependency
64
+ name: respect
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.1'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 0.1.1
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.1'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.1
63
83
  description: This is fork of Tony Pitluga's Ruby API for keepassx with read-write
64
84
  support.
65
85
  email:
@@ -120,4 +140,3 @@ signing_key:
120
140
  specification_version: 4
121
141
  summary: Ruby API access for KeePassX databases
122
142
  test_files: []
123
- has_rdoc: