exchange-offline-address-book 0.0.15 → 0.0.16
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01f25de3bcac4f14eb4d86e16ccdbb374f22b278
|
4
|
+
data.tar.gz: f27e58b29d365d8eb2ec5646a6cccf1fdb1a19e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caf89146265979fededa91f135c99684b4470efb643ac900d3e02255573243bf60016a29b51d21d5ba26f0b2976b6789fb835829c0ea3be37b8ea811c66fdac8
|
7
|
+
data.tar.gz: d83224e032ceffcce72962e50060c5187c74109da26861754716c756d5cee108e009d408cd08f51cd264d4112bce16fecf1755a2fa11e7eb929124fc34c2218c
|
data/Gemfile.lock
CHANGED
@@ -3,15 +3,15 @@
|
|
3
3
|
require 'dotenv/load'
|
4
4
|
|
5
5
|
require 'autodiscover'
|
6
|
-
#require "autodiscover/debug"
|
7
6
|
|
7
|
+
require "autodiscover/debug" if ENV['DEBUG']
|
8
8
|
require 'yaml'
|
9
9
|
require 'nokogiri'
|
10
10
|
require 'tempfile'
|
11
11
|
require 'json'
|
12
12
|
require 'ostruct'
|
13
|
+
require 'shellwords'
|
13
14
|
|
14
|
-
require 'curb'
|
15
15
|
require_relative 'exchange-offline-address-book/parser'
|
16
16
|
require_relative 'exchange-offline-address-book/mspack'
|
17
17
|
|
@@ -25,18 +25,16 @@ class OfflineAddressBook
|
|
25
25
|
@baseurl = baseurl
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
client.password = @password
|
33
|
-
client.perform
|
34
|
-
|
35
|
-
raise client.status unless client.response_code.to_s[0] == '2'
|
36
|
-
|
37
|
-
return client.body_str if target.nil?
|
28
|
+
def path(name)
|
29
|
+
@files ||= {}
|
30
|
+
@files[name] ||= (@cachedir ? File.join(@cachedir, name) : Tempfile.new(name).path)
|
31
|
+
end
|
38
32
|
|
39
|
-
|
33
|
+
def download(name)
|
34
|
+
if !@cachedir || @update || !File.file?(path(name))
|
35
|
+
system "curl --#{ENV['DEBUG'] ? 'verbose' : 'silent'} --ntlm --user #{[@username, @password].join(':').shellescape} #{[baseurl, name].join('').shellescape} -o #{path(name).shellescape}"
|
36
|
+
end
|
37
|
+
return path(name)
|
40
38
|
end
|
41
39
|
|
42
40
|
def baseurl
|
@@ -56,35 +54,26 @@ class OfflineAddressBook
|
|
56
54
|
lzx = File.basename(oab, File.extname(oab)) + '.lzx' if oab
|
57
55
|
end
|
58
56
|
|
59
|
-
lzx ||= Nokogiri::XML(download('oab.xml')).at('//Full').inner_text
|
57
|
+
lzx ||= Nokogiri::XML(open(download('oab.xml'))).at('//Full').inner_text
|
60
58
|
oab = File.basename(lzx, File.extname(lzx)) + '.oab'
|
61
59
|
|
62
|
-
if
|
63
|
-
oab = File.join(@cachedir, oab)
|
64
|
-
else
|
60
|
+
if !File.file?(path(oab))
|
65
61
|
if @cachedir
|
66
62
|
%w{*.oab *.lzx *.yml *.json}.each{|ext|
|
67
63
|
Dir[File.join(@cachedir, ext)].each{|f| File.unlink(f) }
|
68
64
|
}
|
69
|
-
download(lzx, File.join(@cachedir, lzx))
|
70
|
-
lzx = File.join(@cachedir, lzx)
|
71
|
-
@oab = File.join(@cachedir, oab)
|
72
|
-
else
|
73
|
-
_lzx = Tempfile.new('lzx')
|
74
|
-
download(lzx, _lzx.path)
|
75
|
-
lzx = _lzx.path
|
76
|
-
oab = Tempfile.new('oab').path
|
77
65
|
end
|
78
66
|
|
79
|
-
|
67
|
+
download(lzx)
|
68
|
+
LibMsPack.oab_decompress(path(lzx), path(oab))
|
80
69
|
end
|
81
70
|
|
82
|
-
oab
|
71
|
+
path(oab)
|
83
72
|
end
|
84
73
|
end
|
85
74
|
|
86
75
|
def cache
|
87
|
-
@cache ||=
|
76
|
+
@cache ||= path(File.basename(addressbook, File.extname(addressbook)) + '.json')
|
88
77
|
end
|
89
78
|
|
90
79
|
def header
|
@@ -3,6 +3,8 @@ require 'dotenv/load'
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'exchange-offline-address-book'
|
5
5
|
|
6
|
+
ENV['DEBUG'] = 'true'
|
7
|
+
|
6
8
|
class EOABTest < Minitest::Test
|
7
9
|
def test_downlod
|
8
10
|
oab = OfflineAddressBook.new(username: ENV['USERNAME'], password: ENV['PASSWORD'], email: ENV['EMAIL'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exchange-offline-address-book
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emiliano Heyns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|