rack_dav 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e79ae582f10f164cfcd53a6a2b5a48aaad203635
4
+ data.tar.gz: e385c0976e3a93eecac509509c53ca7e304b44b8
5
+ SHA512:
6
+ metadata.gz: 0a3e8849bbed3be0100b1978a52d77510c1ccf4801079a2df9647155de3142dfd51911486f13c00a602cbb4db8fa4a46fbf953dbb091599c958ee1a57b42031c
7
+ data.tar.gz: 01d765203ece91396cf9eb80584c4cfd14f99a8f356d0f5fa1a8fa9539905589d9919ca297a06a08e341a1fb52a96b8959ea1e2291c38cd8516443cb99c5f2ed
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.9.2
@@ -1,25 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack_dav (0.3.0)
4
+ rack_dav (0.3.1)
5
5
  nokogiri
6
- rack (~> 1.4.0)
6
+ rack (>= 1.4.0)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- diff-lcs (1.1.3)
12
- nokogiri (1.5.5)
13
- rack (1.4.1)
14
- rake (0.9.2.2)
15
- rspec (2.11.0)
16
- rspec-core (~> 2.11.0)
17
- rspec-expectations (~> 2.11.0)
18
- rspec-mocks (~> 2.11.0)
19
- rspec-core (2.11.1)
20
- rspec-expectations (2.11.2)
21
- diff-lcs (~> 1.1.3)
22
- rspec-mocks (2.11.1)
11
+ diff-lcs (1.2.1)
12
+ nokogiri (1.5.8)
13
+ nokogiri (1.5.8-java)
14
+ rack (1.5.2)
15
+ rake (10.0.3)
16
+ rspec (2.13.0)
17
+ rspec-core (~> 2.13.0)
18
+ rspec-expectations (~> 2.13.0)
19
+ rspec-mocks (~> 2.13.0)
20
+ rspec-core (2.13.1)
21
+ rspec-expectations (2.13.0)
22
+ diff-lcs (>= 1.1.3, < 2.0)
23
+ rspec-mocks (2.13.0)
23
24
 
24
25
  PLATFORMS
25
26
  java
@@ -27,5 +28,5 @@ PLATFORMS
27
28
 
28
29
  DEPENDENCIES
29
30
  rack_dav!
30
- rake (~> 0.9.0)
31
- rspec (~> 2.11.0)
31
+ rake (>= 0.9.0)
32
+ rspec (>= 2.11.0)
data/README.md CHANGED
@@ -85,7 +85,7 @@ to retrieve and change the resources:
85
85
 
86
86
  * __make\_collection__: Create this resource as collection.
87
87
 
88
- * __lock(token, timeout, scope, type, owner)__: Lock this resource.
88
+ * __lock(locktoken, timeout, lockscope=nil, locktype=nil, owner=nil)__: Lock this resource.
89
89
  If scope, type and owner are nil, refresh the given lock.
90
90
 
91
91
  * __unlock(token)__: Unlock this resource
@@ -13,7 +13,7 @@ module RackDAV
13
13
  @request = request
14
14
  @response = response
15
15
  @options = options
16
- @resource = resource_class.new(url_unescape(request.path_info), @options)
16
+ @resource = resource_class.new(url_unescape(request.path_info), @request, @response, @options)
17
17
  raise Forbidden if request.path_info.include?('../')
18
18
  end
19
19
 
@@ -52,20 +52,20 @@ module RackDAV
52
52
  response['Content-Length'] = resource.content_length.to_s
53
53
  response['Last-Modified'] = resource.last_modified.httpdate
54
54
  map_exceptions do
55
- resource.get(request, response)
55
+ resource.get
56
56
  end
57
57
  end
58
58
 
59
59
  def put
60
60
  raise Forbidden if resource.collection?
61
61
  map_exceptions do
62
- resource.put(request, response)
62
+ resource.put
63
63
  end
64
64
  end
65
65
 
66
66
  def post
67
67
  map_exceptions do
68
- resource.post(request, response)
68
+ resource.post
69
69
  end
70
70
  end
71
71
 
@@ -97,7 +97,7 @@ module RackDAV
97
97
  raise BadGateway if dest_uri.host and dest_uri.host != request.host
98
98
  raise Forbidden if destination == resource.path
99
99
 
100
- dest = resource_class.new(destination, @options)
100
+ dest = resource_class.new(destination, @request, @response, @options)
101
101
  dest = dest.child(resource.name) if dest.collection?
102
102
 
103
103
  dest_existed = dest.exist?
@@ -124,7 +124,7 @@ module RackDAV
124
124
  raise BadGateway if dest_uri.host and dest_uri.host != request.host
125
125
  raise Forbidden if destination == resource.path
126
126
 
127
- dest = resource_class.new(destination, @options)
127
+ dest = resource_class.new(destination, @request, @response, @options)
128
128
  dest = dest.child(resource.name) if dest.collection?
129
129
 
130
130
  dest_existed = dest.exist?
@@ -296,8 +296,13 @@ module RackDAV
296
296
  end
297
297
 
298
298
  def request_document
299
- @request_document ||= Nokogiri::XML(request.body.read) {|config| config.strict }
300
- rescue Nokogiri::XML::SyntaxError
299
+ @request_document ||= if (body = request.body.read).empty?
300
+ Nokogiri::XML::Document.new
301
+ else
302
+ Nokogiri::XML(body, &:strict)
303
+ end
304
+
305
+ rescue Nokogiri::XML::SyntaxError, RuntimeError # Nokogiri raise RuntimeError :-(
301
306
  raise BadRequest
302
307
  end
303
308
 
@@ -68,33 +68,33 @@ module RackDAV
68
68
  # HTTP GET request.
69
69
  #
70
70
  # Write the content of the resource to the response.body.
71
- def get(request, response)
71
+ def get
72
72
  if stat.directory?
73
73
  content = ""
74
- Rack::Directory.new(root).call(request.env)[2].each { |line| content << line }
75
- response.body = [content]
76
- response['Content-Length'] = (content.respond_to?(:bytesize) ? content.bytesize : content.size).to_s
74
+ Rack::Directory.new(root).call(@request.env)[2].each { |line| content << line }
75
+ @response.body = [content]
76
+ @response['Content-Length'] = (content.respond_to?(:bytesize) ? content.bytesize : content.size).to_s
77
77
  else
78
78
  file = File.open(file_path)
79
- response.body = file
79
+ @response.body = file
80
80
  end
81
81
  end
82
82
 
83
83
  # HTTP PUT request.
84
84
  #
85
85
  # Save the content of the request.body.
86
- def put(request, response)
87
- if request.env['HTTP_CONTENT_MD5']
88
- content_md5_pass?(request.env) or raise HTTPStatus::BadRequest.new('Content-MD5 mismatch')
86
+ def put
87
+ if @request.env['HTTP_CONTENT_MD5']
88
+ content_md5_pass?(@request.env) or raise HTTPStatus::BadRequest.new('Content-MD5 mismatch')
89
89
  end
90
90
 
91
- write(request.body)
91
+ write(@request.body)
92
92
  end
93
93
 
94
94
  # HTTP POST request.
95
95
  #
96
96
  # Usually forbidden.
97
- def post(request, response)
97
+ def post
98
98
  raise HTTPStatus::Forbidden
99
99
  end
100
100
 
@@ -4,8 +4,10 @@ module RackDAV
4
4
 
5
5
  attr_reader :path, :options
6
6
 
7
- def initialize(path, options)
7
+ def initialize(path, request, response, options)
8
8
  @path = path
9
+ @request = request
10
+ @response = response
9
11
  @options = options
10
12
  end
11
13
 
@@ -66,21 +68,21 @@ module RackDAV
66
68
  # HTTP GET request.
67
69
  #
68
70
  # Write the content of the resource to the response.body.
69
- def get(request, response)
71
+ def get
70
72
  raise NotImplementedError
71
73
  end
72
74
 
73
75
  # HTTP PUT request.
74
76
  #
75
77
  # Save the content of the request.body.
76
- def put(request, response)
78
+ def put
77
79
  raise NotImplementedError
78
80
  end
79
81
 
80
82
  # HTTP POST request.
81
83
  #
82
84
  # Usually forbidden.
83
- def post(request, response)
85
+ def post
84
86
  raise NotImplementedError
85
87
  end
86
88
 
@@ -126,7 +128,7 @@ module RackDAV
126
128
  end
127
129
 
128
130
  def child(name, option={})
129
- self.class.new(path + '/' + name, options)
131
+ self.class.new(path + '/' + name, @request, @response, options)
130
132
  end
131
133
 
132
134
  def lockable?
@@ -3,8 +3,8 @@ module RackDAV
3
3
  # Holds information about library version.
4
4
  module Version
5
5
  MAJOR = 0
6
- MINOR = 3
7
- PATCH = 1
6
+ MINOR = 4
7
+ PATCH = 0
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join(".")
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://georgi.github.com/rack_dav"
11
11
  s.summary = "WebDAV handler for Rack."
12
12
  s.description = "WebDAV handler for Rack."
13
+ s.license = "MIT"
13
14
 
14
15
  s.files = `git ls-files`.split("\n")
15
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -17,8 +18,8 @@ Gem::Specification.new do |s|
17
18
 
18
19
  s.extra_rdoc_files = ["README.md"]
19
20
 
20
- s.add_dependency("rack", "~> 1.4.0")
21
- s.add_dependency('nokogiri')
22
- s.add_development_dependency("rspec", "~> 2.11.0")
23
- s.add_development_dependency("rake","~> 0.9.0")
21
+ s.add_dependency("rack", "~> 1.4")
22
+ s.add_dependency('nokogiri', "~> 1.5")
23
+ s.add_development_dependency("rspec", "~> 2.11")
24
+ s.add_development_dependency("rake","~> 0.9")
24
25
  end
metadata CHANGED
@@ -1,80 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack_dav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matthias Georgi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 1.4.0
19
+ version: '1.4'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 1.4.0
26
+ version: '1.4'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: nokogiri
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '1.5'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '1.5'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 2.11.0
47
+ version: '2.11'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: 2.11.0
54
+ version: '2.11'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
- version: 0.9.0
61
+ version: '0.9'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: 0.9.0
68
+ version: '0.9'
78
69
  description: WebDAV handler for Rack.
79
70
  email: matti.georgi@gmail.com
80
71
  executables:
@@ -83,7 +74,8 @@ extensions: []
83
74
  extra_rdoc_files:
84
75
  - README.md
85
76
  files:
86
- - .gitignore
77
+ - ".gitignore"
78
+ - ".travis.yml"
87
79
  - CHANGELOG.md
88
80
  - Gemfile
89
81
  - Gemfile.lock
@@ -109,28 +101,27 @@ files:
109
101
  - spec/spec_helper.rb
110
102
  - spec/support/lockable_file_resource.rb
111
103
  homepage: http://georgi.github.com/rack_dav
112
- licenses: []
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
113
107
  post_install_message:
114
108
  rdoc_options: []
115
109
  require_paths:
116
110
  - lib
117
111
  required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
112
  requirements:
120
- - - ! '>='
113
+ - - ">="
121
114
  - !ruby/object:Gem::Version
122
115
  version: '0'
123
116
  required_rubygems_version: !ruby/object:Gem::Requirement
124
- none: false
125
117
  requirements:
126
- - - ! '>='
118
+ - - ">="
127
119
  - !ruby/object:Gem::Version
128
120
  version: '0'
129
121
  requirements: []
130
122
  rubyforge_project:
131
- rubygems_version: 1.8.24
123
+ rubygems_version: 2.4.3
132
124
  signing_key:
133
- specification_version: 3
125
+ specification_version: 4
134
126
  summary: WebDAV handler for Rack.
135
127
  test_files: []
136
- has_rdoc: