restful-sharepoint 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restful-sharepoint.rb +3 -0
- data/lib/restful-sharepoint/connection.rb +17 -2
- data/lib/restful-sharepoint/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 412f20755aa500a89583d5dd54b276297fe1a1b8c98f3e98d8b34d5d4e2c18eb
|
4
|
+
data.tar.gz: fcd75c378e15090ed40fdfcd0ffd49faa72718b332f3d9727d3d1dd97bd6628e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c67523e73f23fb0b61118686b0462fbf7c14407e6a0413171659c7660749b05328d79d39594560629d528ef2a67e5ea648dfbd1e79d9e5437a799701d572640
|
7
|
+
data.tar.gz: 3189b842eea420ea716fae68cde51a884c70db74fd8f03ba8a8ff1d499e86adbb60f487b232b8558fe707c81a3d23e13ad5514ebfd61950a1508b30b779a2b49
|
data/lib/restful-sharepoint.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'httpi'
|
3
3
|
require 'curb'
|
4
4
|
require 'cgi'
|
5
|
+
require 'logger'
|
5
6
|
|
6
7
|
HTTPI.adapter = :curb
|
7
8
|
|
@@ -20,6 +21,8 @@ module RestfulSharePoint
|
|
20
21
|
/SP\.Data\..*Item/ => :ListItems,
|
21
22
|
"SP.Attachment" => :Attachments
|
22
23
|
}
|
24
|
+
|
25
|
+
LOG = Logger.new('restful-sharepoint.log')
|
23
26
|
end
|
24
27
|
|
25
28
|
require_relative './restful-sharepoint/version.rb'
|
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'uri'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
module RestfulSharePoint
|
5
6
|
class Connection
|
6
|
-
def initialize(site_url, username = nil, password = nil)
|
7
|
+
def initialize(site_url, username = nil, password = nil, debug: false)
|
7
8
|
@site_url = site_url
|
8
9
|
@username = username
|
9
10
|
@password = password
|
11
|
+
@debug = debug
|
10
12
|
end
|
11
13
|
|
12
14
|
attr_reader :site_url
|
@@ -30,8 +32,21 @@ module RestfulSharePoint
|
|
30
32
|
req.headers['X-HTTP-Method'] = 'MERGE' # TODO: Extend logic to support all operations
|
31
33
|
req.headers['If-Match'] = '*'
|
32
34
|
end
|
33
|
-
yield(
|
35
|
+
yield(req) if block_given?
|
36
|
+
LOG.info "Making HTTP request to: #{req.url.to_s}"
|
34
37
|
response = HTTPI.request(method, req)
|
38
|
+
# Log each request to file
|
39
|
+
if @debug
|
40
|
+
request_name = req.url.to_s.gsub(/[^\w.]/, '_')
|
41
|
+
filepath = ::File.join(@debug, "#{DateTime.now.strftime('%FT%R')}_#{request_name}.log")
|
42
|
+
FileUtils.mkdir_p @debug
|
43
|
+
::File.open(filepath, 'w+') do |file|
|
44
|
+
file.puts response.code
|
45
|
+
response.headers.each { |k,v| file.puts "#{k}: #{v}" }
|
46
|
+
file.puts '----------'
|
47
|
+
file.puts response.body
|
48
|
+
end
|
49
|
+
end
|
35
50
|
if response.body.empty?
|
36
51
|
if response.code >= 300
|
37
52
|
raise RestError, "Server returned HTTP status #{response.code} with no message body."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful-sharepoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Wardrop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|