dav4rack_ext 0.0.12 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb8373fe34e17cde3494f38752c00f4c06e8d733
4
- data.tar.gz: 8284a1406a3238aa2855b26a9b444a12fa10269e
3
+ metadata.gz: 22bc67021255d19795f35d47d0e9299ae1db9c91
4
+ data.tar.gz: 3bd4d094d4eab7acae0ab1d1de74bdf4d5647968
5
5
  SHA512:
6
- metadata.gz: e3a5971cb27a3589487f5f12ef45c4d720759dd62c10bc74a40d95c388313611a58ad8d127e5909efc5ca68cc323098e3a78ed35486bd6d3c86d8cdf6e2f8b47
7
- data.tar.gz: bb2146a31439adc84c7dda16e44e7d6d88603a14ebc71428efa9a0534b968be0125456051bed722db47841e9ea3df371f732a4d0776211af10def181da1f58b5
6
+ metadata.gz: 64e22e835a41c7895882f4194e73cc8df9d2748bfc330551821f9354cbd82c471a170fcb3217a3ac9d601bb22fb47cdbc29a3442ceb582c384ab42190c759c43
7
+ data.tar.gz: ff0c650ca6eab05fccff13b2ad2e97f8da925ff9a10b10905e2b8449ae3c93aa13277f32c5c75e29258e19d79ac58dc0c9fd78323de64cf4801f74c56cd05444
data/Gemfile CHANGED
@@ -23,7 +23,7 @@ group(:test) do
23
23
  gem 'virtus'
24
24
 
25
25
  gem 'simplecov'
26
- gem 'guard', '~> 1.5.4'
26
+ gem 'guard', '~> 1.8.3'
27
27
  gem 'rb-fsevent'
28
28
  gem 'growl'
29
29
 
data/README.md CHANGED
@@ -25,8 +25,8 @@ Once the server is started you can connect to it using http://127.0.0.1:3000/u/c
25
25
  (the example has no authentication set up)
26
26
 
27
27
  # Supported clients
28
- - Mac OS X (tested with Mountain Lion )
29
- - iPhone 5.x and 6.x
28
+ - Mac OS X: recently tested on 10.11 (El Capitan)
29
+ - iOS: recently tested on 8 and 9
30
30
 
31
31
  # Setting up development environment
32
32
 
@@ -41,4 +41,3 @@ the tests will run when a file changed, if only want to run all tests once:
41
41
  ```bash
42
42
  $ bundle exec rake
43
43
  ```
44
-
@@ -75,17 +75,22 @@ module DAV4Rack
75
75
 
76
76
  # collect the requested urls
77
77
  hrefs = request_document.css("C|addressbook-multiget D|href", NAMESPACES).map(&:content)
78
-
78
+
79
+
80
+
81
+ children_ids = {}
82
+ hrefs.reject{|_href| resource.is_self?(_href) }.each do |_href|
83
+ path = File.split(URI.parse(_href).path).last
84
+ children_ids[_href] = File.split(path).last
85
+ end
86
+
87
+ children = resource.find_children(children_ids)
88
+
79
89
  multistatus do |xml|
80
90
  hrefs.each do |_href|
81
91
  xml.response do
82
92
  xml.href _href
83
-
84
- path = File.split(URI.parse(_href).path).last
85
- Logger.debug "Creating child w/ ORIG=#{resource.public_path} HREF=#{_href} FILE=#{path}!"
86
-
87
- cur_resource = resource.is_self?(_href) ? resource : resource.find_child(File.split(path).last)
88
-
93
+ cur_resource = resource.is_self?(_href) ? resource : children[_href]
89
94
  if cur_resource && cur_resource.exist?
90
95
  propstats(xml, get_properties(cur_resource, props))
91
96
  else
@@ -120,17 +120,15 @@ module DAV4Rack
120
120
  child(ContactResource, c, @address_book)
121
121
  end
122
122
  end
123
-
124
- def find_child(uid)
125
- uid = File.basename(uid, '.vcf')
126
- c = @address_book.find_contact(uid)
127
- if c
128
- child(ContactResource, c)
129
- else
130
- nil
123
+
124
+ # { href: uid }
125
+ def find_children(ids)
126
+ @address_book.find_contacts(ids).each_with_object({}) do |(href, contact), ret|
127
+ if contact
128
+ ret[href] = child(ContactResource, contact)
129
+ end
131
130
  end
132
131
  end
133
-
134
132
  end
135
133
 
136
134
  end
@@ -33,12 +33,8 @@ module DAV4Rack
33
33
 
34
34
  fields = el[:children].select{|e| e[:name] == 'prop' }.map{|e| e[:attributes]['name'] }
35
35
  data = @contact.vcard.to_s(fields)
36
-
37
- <<-EOS
38
- <C:address-data xmlns:C="#{CARDAV_NS}">
39
- <![CDATA[#{data}]]>
40
- </C:address-data>
41
- EOS
36
+
37
+ %{<C:address-data xmlns:C="#{CARDAV_NS}">#{data}</C:address-data>}
42
38
  end
43
39
  end
44
40
  end
@@ -1,3 +1,3 @@
1
1
  module Dav4rackExt
2
- VERSION = "0.0.12"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -89,6 +89,13 @@ module Testing
89
89
  attribute :path, String
90
90
  attribute :contacts, Array[Contact], default: []
91
91
 
92
+ def find_contacts(ids)
93
+ ids.each_with_object({}) do |(href, path), ret|
94
+ uid = File.basename(path, '.vcf')
95
+ ret[href] = contacts.detect{|c| c.uid == uid.to_s }
96
+ end
97
+ end
98
+
92
99
  def find_contact(uid)
93
100
  contacts.detect{|c| c.uid == uid.to_s }
94
101
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dav4rack_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Ammous
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2017-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dav4rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
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
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: http_router
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: vcard_parser
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.0.8
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.8
55
55
  description: CardDAV / CalDAV implementation
@@ -59,8 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
63
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
64
  - ChangeLog
65
65
  - Gemfile
66
66
  - Guardfile
@@ -105,17 +105,17 @@ require_paths:
105
105
  - lib
106
106
  required_ruby_version: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - '>='
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
117
  rubyforge_project:
118
- rubygems_version: 2.0.3
118
+ rubygems_version: 2.5.1
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: CardDAV / CalDAV implementation.