restful-sharepoint 0.2.2 → 0.2.6

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
  SHA256:
3
- metadata.gz: 676e57e07950be0b111e91a9675056ab7f9b3d90c39319dc1e9ac619476e7cec
4
- data.tar.gz: 717a90610e1a58b0895eed3fe018f3d99faae5f7947ce1b81797c0e8cf9fe6c1
3
+ metadata.gz: c2e6bddfc8e8eb4afad9644e4fceb24043d312e04341485462de992153c49cdc
4
+ data.tar.gz: d476fd5cee073d7b86a966716898ffbd0dd510bca811997d9f93c8d46a45d53e
5
5
  SHA512:
6
- metadata.gz: e448c10bb59bee93d58725f109f2c5ce8f55ed0b2bae7f27944ae865ec9352f1f133947a948f5fadce119b67c614a844f7f6c1435ac31cab6fafff9c7134a472
7
- data.tar.gz: dd7afb07ce1d26484e3f48a070c8dfe28c67de1a52c02481b5a13d70f90d15e0e35ae91a4e4d545c98669402a02b20513dc6c43d7a35c59e1a6dd4cf637ea332
6
+ metadata.gz: d51978834840b49ea49236b599393d6199a1292ea04eb32e3931a9f69c9d8c645cb50e6776306f70ed3db08297989ce0bd2426ab018f8798422d2d9f81a5674e
7
+ data.tar.gz: b668f5b57dad92a36aad569443216783d061fb34750ecafe9afe7524b306e65bbf55d7116882a14e7ae9a4c982c1876334ac146ff54636e12a4b3b08c25f1fdf
data/Gemfile CHANGED
File without changes
data/README.md CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -9,6 +9,10 @@ module RestfulSharePoint
9
9
  @username = username
10
10
  @password = password
11
11
  @debug = debug
12
+
13
+ @httpclient = HTTPClient.new
14
+ @httpclient.set_auth(nil, @username, @password) if @username
15
+ @httpclient.ssl_config.set_default_paths
12
16
  end
13
17
 
14
18
  attr_reader :site_url
@@ -23,22 +27,22 @@ module RestfulSharePoint
23
27
 
24
28
  # Path can be either relative to the site URL, or a complete URL itself.
25
29
  # Takes an optional `options` hash which are any number of valid OData query options (dollar sign prefix is added automatically)
26
- # Also takes an optional block that is provided the HTTPI::Request instance, allowing customisation of the request.
27
30
  def request(path, method, options: {}, body: nil)
28
31
  url = URI.parse(path).is_a?(URI::HTTP) ? path : "#{@site_url}#{path}"
29
32
  options_str = options.map { |k,v| "$#{k}=#{CGI.escape v.to_s}" }.join('&')
30
33
  url += "?#{options_str}"
31
- req = HTTPI::Request.new(url: url, headers: {'accept' => 'application/json; odata=verbose'})
32
- req.auth.ntlm(@username, @password) if @username
34
+
35
+ headers = {'accept' => 'application/json; odata=verbose'}
33
36
  if body
34
- req.body = JSON.dump(body).gsub('/', '\\/') # SharePoint requires forward slashes be escaped in JSON (WTF!!!)
35
- req.headers['Content-Type'] = 'application/json'
36
- req.headers['X-HTTP-Method'] = 'MERGE' # TODO: Extend logic to support all operations
37
- req.headers['If-Match'] = '*'
37
+ body = JSON.dump(body).gsub('/', '\\/') # SharePoint requires forward slashes be escaped in JSON (WTF!!!)
38
+ headers['Content-Type'] = 'application/json'
39
+ headers['X-HTTP-Method'] = 'MERGE' # TODO: Extend logic to support all operations
40
+ headers['If-Match'] = '*'
38
41
  end
39
- yield(req) if block_given?
40
- LOG.info "Making HTTP request to: #{req.url.to_s}"
41
- response = HTTPI.request(method, req)
42
+
43
+ LOG.info "Making HTTP request to: #{url}"
44
+ response = @httpclient.request(method, url, nil, body, headers)
45
+
42
46
  if response.body.empty?
43
47
  if response.code >= 300
44
48
  raise RestError, "Server returned HTTP status #{response.code} with no message body."
@@ -77,7 +81,6 @@ module RestfulSharePoint
77
81
 
78
82
  def parse(str)
79
83
  data = JSON.load(str)
80
- ::File.write('parsed.json', JSON.dump(data))
81
84
  raise RestError, "(#{data['error']['code']}): #{data['error']['message']['value']}" if data['error']
82
85
  parse_tree(data['d'])
83
86
  end
@@ -85,7 +88,7 @@ module RestfulSharePoint
85
88
  def parse_tree(tree)
86
89
  indices = tree.respond_to?(:keys) ? tree.keys : 0...tree.length
87
90
  indices.each do |i|
88
- if tree[i].respond_to?(:=~) && tree[i] =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$/
91
+ if tree[i].is_a?(String) && tree[i] =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$/
89
92
  tree[i] = DateTime.parse(tree[i]).new_offset(DateTime.now.offset)
90
93
  elsif tree[i].respond_to?(:gsub!)
91
94
  # Convert relative paths to absolute URL's.
File without changes
File without changes
@@ -3,7 +3,7 @@ module RestfulSharePoint
3
3
 
4
4
  def endpoint
5
5
  url = URI.parse(connection.site_url)
6
- url.path = URI.encode(@properties['ServerRelativeUrl'])
6
+ url.path = Addressable::URI.encode(@properties['ServerRelativeUrl'])
7
7
  url.to_s
8
8
  end
9
9
  end
@@ -11,7 +11,7 @@ module RestfulSharePoint
11
11
 
12
12
  def url
13
13
  url = URI.parse(connection.site_url)
14
- url.path = URI.encode(self['ServerRelativeUrl'])
14
+ url.path = Addressable::URI.encode(self['ServerRelativeUrl'])
15
15
  url.to_s
16
16
  end
17
17
 
File without changes
@@ -3,7 +3,7 @@ module RestfulSharePoint
3
3
 
4
4
  def self.from_title(title, connection)
5
5
  new(connection: connection).tap do |list|
6
- list.define_singleton_method(:endpoint) { "/_api/web/lists/getbytitle('#{URI.encode title}')" }
6
+ list.define_singleton_method(:endpoint) { "/_api/web/lists/getbytitle('#{Addressable::URI.encode title}')" }
7
7
  end
8
8
  end
9
9
 
File without changes
@@ -1,3 +1,3 @@
1
1
  module RestfulSharePoint
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.6'
3
3
  end
@@ -1,10 +1,10 @@
1
1
  require 'json'
2
- require 'httpi'
3
- require 'curb'
2
+ require 'httpclient'
3
+ require 'addressable'
4
+ require 'rubyntlm'
4
5
  require 'cgi'
5
6
  require 'logger'
6
-
7
- HTTPI.adapter = :curb
7
+ require 'forwardable'
8
8
 
9
9
  module RestfulSharePoint
10
10
  OBJECT_MAP = {
@@ -9,10 +9,10 @@ Gem::Specification.new 'restful-sharepoint', RestfulSharePoint::VERSION do |s|
9
9
  s.homepage = 'https://github.com/Wardrop/restful-sharepoint'
10
10
  s.license = 'MIT'
11
11
  s.files = Dir.glob(`git ls-files`.split("\n") - %w[.gitignore])
12
- s.has_rdoc = 'yard'
13
12
 
14
13
  s.required_ruby_version = '>= 2.0.0'
15
14
 
16
- s.add_dependency 'httpi', '~> 2.4'
17
- s.add_dependency 'curb', '~> 0.9'
15
+ s.add_dependency 'httpclient', '~> 2.8'
16
+ s.add_dependency 'rubyntlm', '~> 0.6'
17
+ s.add_dependency 'addressable', '~> 2.8'
18
18
  end
@@ -23,13 +23,13 @@ module RestfulSharePoint
23
23
  end
24
24
 
25
25
  it "can work with an object" do
26
- list = Object.new(connection: c, properties: c.get("/_api/web/lists/getbytitle('#{URI.encode CONFIG[:test_list_title]}')"))
26
+ list = Object.new(connection: c, properties: c.get("/_api/web/lists/getbytitle('#{Addressable::URI.encode CONFIG[:test_list_title]}')"))
27
27
  expect(list['Title']).to eq(CONFIG[:test_list_title])
28
28
  end
29
29
 
30
30
  it "can automatically get an object or collection" do
31
31
  lists = c.get_as_object('/_api/web/lists/')
32
- list = c.get_as_object("/_api/web/lists/getbytitle('#{URI.encode CONFIG[:test_list_title]}')")
32
+ list = c.get_as_object("/_api/web/lists/getbytitle('#{Addressable::URI.encode CONFIG[:test_list_title]}')")
33
33
  expect(lists).to be_a(Collection)
34
34
  expect(list).to be_a(Object)
35
35
  end
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful-sharepoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.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-08-01 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httpi
14
+ name: httpclient
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: '2.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.4'
26
+ version: '2.8'
27
27
  - !ruby/object:Gem::Dependency
28
- name: curb
28
+ name: rubyntlm
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.9'
33
+ version: '0.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.9'
40
+ version: '0.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: addressable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.8'
41
55
  description: Provides a convenient object model to the OData REST API of SharePoint
42
56
  2013 and newer.
43
57
  email: tomw@msc.qld.gov.au
@@ -85,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
99
  - !ruby/object:Gem::Version
86
100
  version: '0'
87
101
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.7.3
102
+ rubygems_version: 3.1.2
90
103
  signing_key:
91
104
  specification_version: 4
92
105
  summary: Provides a convenient object model to the OData REST API of SharePoint 2013