motion-addressbook 1.7.2 → 1.7.4
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 +4 -4
- data/Gemfile +0 -3
- data/README.md +25 -10
- data/Rakefile +2 -7
- data/app/app_delegate.rb +4 -2
- data/lib/motion-addressbook.rb +13 -25
- data/lib/motion-addressbook/version.rb +1 -1
- data/motion-addressbook.gemspec +0 -2
- data/motion/address_book.rb +3 -3
- data/motion/address_book/ios/addr_book.rb +1 -1
- data/motion/address_book/ios/person.rb +4 -2
- data/motion/address_book/ios/picker.rb +12 -1
- data/motion/address_book/osx/addr_book.rb +3 -2
- data/spec/ios/address_book/multi_valued_spec.rb +1 -1
- data/spec/ios/address_book/person_spec.rb +4 -4
- data/spec/ios/address_book/picker_spec.rb +17 -7
- data/spec/ios/helpers/spec_helper.rb +2 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e8cc5964dc93254dd6daa37e210928a6ee4b881
|
4
|
+
data.tar.gz: fa6ba42ab41a6b365185aca1e30517791639bebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bbc20f804a6de90d9b79b93f6421c58d5dbb32de68454465e8da3ba7fb6a7dd0fbcbaa04190d5bba855d5f0c21666340e150a36829e5befa30df40c41bdbb91
|
7
|
+
data.tar.gz: a65a9af3fe0b5a258d4dcf5643076637654f6bafea5b57db0b98336e6163ea03c4a1d5901ee1fc930aecb510fdb6cfac5a79617cb43e531e0e0f125832a95a0b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -15,23 +15,30 @@ or for [OSX](https://developer.apple.com/library/mac/#documentation/userexperien
|
|
15
15
|
|
16
16
|
Add these lines to your application's `Rakefile`:
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
```ruby
|
19
|
+
require 'bundler'
|
20
|
+
Bundler.require
|
21
|
+
```
|
20
22
|
|
21
23
|
Add this line to your application's `Gemfile`:
|
22
24
|
|
23
|
-
|
25
|
+
```ruby
|
26
|
+
gem 'motion-addressbook'
|
27
|
+
```
|
24
28
|
|
25
29
|
And then execute:
|
26
30
|
|
27
|
-
|
31
|
+
```bash
|
32
|
+
$ bundle
|
33
|
+
```
|
28
34
|
|
29
35
|
### Manually without bundler
|
30
36
|
|
31
|
-
Or install it yourself
|
37
|
+
Or install it yourself as:
|
32
38
|
|
33
|
-
|
34
|
-
|
39
|
+
```bash
|
40
|
+
$ gem install motion-addressbook
|
41
|
+
```
|
35
42
|
|
36
43
|
## Usage
|
37
44
|
|
@@ -72,10 +79,13 @@ end
|
|
72
79
|
|
73
80
|
```ruby
|
74
81
|
# ask the user to authorize us
|
75
|
-
|
82
|
+
AddressBook.request_authorization do |granted|
|
76
83
|
# this block is invoked sometime later
|
77
84
|
if granted
|
78
|
-
|
85
|
+
Dispatch::Queue.main.sync do
|
86
|
+
# do something now that the user has said "yes"
|
87
|
+
# This has to be done on the main thread.
|
88
|
+
end
|
79
89
|
else
|
80
90
|
# do something now that the user has said "no"
|
81
91
|
end
|
@@ -89,7 +99,8 @@ simulator does.
|
|
89
99
|
### Showing the ABPeoplePickerNavigationController
|
90
100
|
|
91
101
|
```ruby
|
92
|
-
AddressBook.
|
102
|
+
address_book = AddressBook::AddrBook.new
|
103
|
+
address_book.picker do |person|
|
93
104
|
if person
|
94
105
|
# person is an AddressBook::Person object
|
95
106
|
else
|
@@ -218,6 +229,10 @@ notification.
|
|
218
229
|
```ruby
|
219
230
|
ab.observe!
|
220
231
|
|
232
|
+
proc = Proc.new {|notification| NSLog "Address Book was changed!" }
|
233
|
+
NSNotificationCenter.defaultCenter.addObserverForName(:addressbook_updated, object:nil, queue:NSOperationQueue.mainQueue, usingBlock:proc)
|
234
|
+
|
235
|
+
# Or if you're using BubbleWrap:
|
221
236
|
App.notification_center.observe :addressbook_updated do |notification|
|
222
237
|
NSLog "Address Book was changed!"
|
223
238
|
end
|
data/Rakefile
CHANGED
@@ -10,21 +10,16 @@ end
|
|
10
10
|
Bundler.setup
|
11
11
|
Bundler.require
|
12
12
|
|
13
|
-
require 'bubble-wrap/reactor'
|
14
|
-
|
15
13
|
Motion::Project::App.setup do |app|
|
16
14
|
# Use `rake config' to see complete project settings.
|
17
15
|
app.name = 'AddressBook'
|
18
16
|
|
19
|
-
if
|
17
|
+
if ENV['osx']
|
20
18
|
app.specs_dir = "./spec/osx"
|
19
|
+
app.info_plist['LSUIElement'] = true
|
21
20
|
else
|
22
21
|
app.specs_dir = "./spec/ios"
|
23
22
|
end
|
24
|
-
|
25
|
-
if ENV['osx']
|
26
|
-
app.info_plist['LSUIElement'] = true
|
27
|
-
end
|
28
23
|
end
|
29
24
|
|
30
25
|
# The test suite may interfere with contacts already created in the
|
data/app/app_delegate.rb
CHANGED
@@ -15,9 +15,11 @@ class AppDelegate
|
|
15
15
|
AddressBook::AddrBook.new do |ab|
|
16
16
|
case command
|
17
17
|
when 'people'
|
18
|
-
|
18
|
+
people = ab.people.map(&:attributes)
|
19
|
+
puts NSJSONSerialization.dataWithJSONObject(people, options:0, error:nil).to_str
|
19
20
|
when 'groups'
|
20
|
-
|
21
|
+
groups = ab.groups.map { |g| {name: g.name, members: g.members.map(&:uid) }}
|
22
|
+
puts NSJSONSerialization.dataWithJSONObject(groups, options:0, error:nil).to_str
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
data/lib/motion-addressbook.rb
CHANGED
@@ -13,30 +13,18 @@ gem 'motion-addressbook', '<= 1.5.0'
|
|
13
13
|
EOT
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
file('motion/address_book/ios/picker.rb').uses_framework('AddressBookUI')
|
16
|
+
lib_dir_path = File.dirname(File.expand_path(__FILE__))
|
17
|
+
Motion::Project::App.setup do |app|
|
18
|
+
|
19
|
+
app.frameworks += ['AddressBook']
|
20
|
+
app.files.unshift(Dir.glob(File.join(lib_dir_path, "../motion/address_book.rb")))
|
21
|
+
|
22
|
+
if app.respond_to?(:template) && app.template == :osx
|
23
|
+
# We have an OS X project
|
24
|
+
app.files.unshift(Dir.glob(File.join(lib_dir_path, "../motion/address_book/osx/**.rb")))
|
25
|
+
else
|
26
|
+
# We have an iOS project
|
27
|
+
app.frameworks += ['AddressBookUI']
|
28
|
+
app.files.unshift(Dir.glob(File.join(lib_dir_path, "../motion/address_book/ios/**.rb")))
|
30
29
|
end
|
31
|
-
BW.require 'motion/address_book/ios/creator.rb' do
|
32
|
-
file('motion/address_book/ios/creator.rb').uses_framework('AddressBookUI')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
BubbleWrap.require_osx do
|
37
|
-
BW.require 'motion/address_book/osx/addr_book.rb'
|
38
|
-
BW.require 'motion/address_book/osx/person.rb'
|
39
|
-
BW.require 'motion/address_book/osx/group.rb'
|
40
|
-
BW.require 'motion/address_book/osx/multi_valued.rb'
|
41
|
-
BW.require 'motion/address_book/osx/source.rb'
|
42
30
|
end
|
data/motion-addressbook.gemspec
CHANGED
@@ -17,8 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency 'bubble-wrap', '~> 1.3'
|
21
|
-
|
22
20
|
gem.add_development_dependency 'rake'
|
23
21
|
gem.add_development_dependency 'rspec'
|
24
22
|
end
|
data/motion/address_book.rb
CHANGED
@@ -2,10 +2,10 @@ module AddressBook
|
|
2
2
|
module_function
|
3
3
|
|
4
4
|
def address_book
|
5
|
-
if
|
5
|
+
if Kernel.const_defined?(:NSApplication)
|
6
6
|
ABAddressBook.addressBook
|
7
7
|
else # iOS
|
8
|
-
if
|
8
|
+
if UIDevice.currentDevice.systemVersion =~ /5/
|
9
9
|
ios5_create
|
10
10
|
else
|
11
11
|
ios6_create
|
@@ -18,7 +18,7 @@ module AddressBook
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def count
|
21
|
-
if
|
21
|
+
if Kernel.const_defined?(:UIApplication)
|
22
22
|
# ABAddressBookGetPersonCount(address_book)
|
23
23
|
instance.count
|
24
24
|
else
|
@@ -37,7 +37,7 @@ module AddressBook
|
|
37
37
|
|
38
38
|
def observe!
|
39
39
|
@notifier = Proc.new do |ab_instance, always_nil, context|
|
40
|
-
|
40
|
+
NSNotificationCenter.defaultCenter.postNotificationName(:addressbook_updated, object: self, userInfo: nil)
|
41
41
|
end
|
42
42
|
ab.register_callback(@notifier)
|
43
43
|
end
|
@@ -54,6 +54,8 @@ module AddressBook
|
|
54
54
|
case attribute
|
55
55
|
when :email
|
56
56
|
emails.map {|rec| rec[:value]}.any? {|v| v == conditions[attribute]}
|
57
|
+
when :phone
|
58
|
+
phones.map {|rec| rec[:value]}.any? {|v| v == conditions[attribute]}
|
57
59
|
else
|
58
60
|
send(attribute) == conditions[attribute]
|
59
61
|
end
|
@@ -189,11 +191,11 @@ module AddressBook
|
|
189
191
|
end
|
190
192
|
|
191
193
|
def photo_image
|
192
|
-
UIImage.alloc.initWithData(photo)
|
194
|
+
ABPersonHasImageData(ab_person) ? UIImage.alloc.initWithData(photo) : nil
|
193
195
|
end
|
194
196
|
|
195
197
|
def photo
|
196
|
-
ABPersonCopyImageData(ab_person)
|
198
|
+
ABPersonHasImageData(ab_person) ? ABPersonCopyImageData(ab_person) : nil
|
197
199
|
end
|
198
200
|
|
199
201
|
def photo=(photo_data)
|
@@ -39,16 +39,27 @@ module AddressBook
|
|
39
39
|
end)
|
40
40
|
end
|
41
41
|
|
42
|
+
# iOS 8+
|
43
|
+
def peoplePickerNavigationController(people_picker, didSelectPerson: ab_person)
|
44
|
+
hide(ab_person)
|
45
|
+
end
|
46
|
+
|
47
|
+
def peoplePickerNavigationController(people_picker, didSelectPerson: ab_person, property:_, identifier:_)
|
48
|
+
hide(ab_person)
|
49
|
+
end
|
50
|
+
|
51
|
+
# iOS 7 and below - deprecated in iOS 8+
|
42
52
|
def peoplePickerNavigationController(people_picker, shouldContinueAfterSelectingPerson:ab_person)
|
43
53
|
hide(ab_person)
|
44
54
|
false
|
45
55
|
end
|
46
56
|
|
47
|
-
def peoplePickerNavigationController(people_picker, shouldContinueAfterSelectingPerson:ab_person, property:
|
57
|
+
def peoplePickerNavigationController(people_picker, shouldContinueAfterSelectingPerson:ab_person, property:_, identifier:_)
|
48
58
|
hide(ab_person)
|
49
59
|
false
|
50
60
|
end
|
51
61
|
|
62
|
+
# iOS 2+
|
52
63
|
def peoplePickerNavigationControllerDidCancel(people_picker)
|
53
64
|
hide
|
54
65
|
end
|
@@ -60,9 +60,10 @@ module AddressBook
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def observe!
|
63
|
-
|
64
|
-
|
63
|
+
proc = Proc.new do |notification|
|
64
|
+
NSNotificationCenter.defaultCenter.postNotificationName(:addressbook_updated, object: self, userInfo: nil)
|
65
65
|
end
|
66
|
+
NSNotificationCenter.defaultCenter.addObserverForName(KABDatabaseChangedExternallyNotification, object:nil, queue:NSOperationQueue.mainQueue, usingBlock:proc)
|
66
67
|
end
|
67
68
|
|
68
69
|
def inspect
|
@@ -162,7 +162,7 @@ describe AddressBook::Person do
|
|
162
162
|
{:label => 'home', :city => 'Dogpatch', :state => 'KY'}
|
163
163
|
],
|
164
164
|
:urls => [
|
165
|
-
{ :label => 'home
|
165
|
+
{ :label => 'home-page', :value => "http://www.mysite.com/" },
|
166
166
|
{ :label => 'work', :value => 'http://dept.bigco.com/' },
|
167
167
|
{ :label => 'school', :value => 'http://state.edu/college' }
|
168
168
|
],
|
@@ -530,9 +530,9 @@ describe AddressBook::Person do
|
|
530
530
|
@ab1.observe!
|
531
531
|
@ab2.observe!
|
532
532
|
@notifications = 0
|
533
|
-
|
534
|
-
|
535
|
-
|
533
|
+
|
534
|
+
proc = Proc.new{|notification| @notifications += 1 }
|
535
|
+
NSNotificationCenter.defaultCenter.addObserverForName(:addressbook_updated, object:nil, queue:NSOperationQueue.mainQueue, usingBlock:proc)
|
536
536
|
end
|
537
537
|
|
538
538
|
# should see a single notification for each change to the AB database:
|
@@ -7,30 +7,40 @@ describe AddressBook::Picker do
|
|
7
7
|
@selected_person = nil
|
8
8
|
@picker = @ab.picker(animated: false) do |person|
|
9
9
|
@selected_person = person
|
10
|
+
resume
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
after do
|
14
15
|
@colin.delete!
|
16
|
+
@picker.hide(animated: false)
|
15
17
|
end
|
16
18
|
|
17
19
|
it 'should yield the selected person' do
|
18
|
-
@picker.peoplePickerNavigationController(@picker_nav_controller, shouldContinueAfterSelectingPerson: @ab_person)
|
19
|
-
@
|
20
|
-
|
20
|
+
@picker.peoplePickerNavigationController(@picker_nav_controller, shouldContinueAfterSelectingPerson: @ab_person) if UIDevice.currentDevice.systemVersion < "8.0"
|
21
|
+
@picker.peoplePickerNavigationController(@picker_nav_controller, didSelectPerson: @ab_person) if UIDevice.currentDevice.systemVersion >= "8.0"
|
22
|
+
wait 5 {
|
23
|
+
@selected_person.should.not == nil
|
24
|
+
@selected_person.first_name.should == 'Colin'
|
25
|
+
}
|
21
26
|
end
|
22
27
|
|
23
28
|
it 'should yield the selected person' do
|
24
29
|
property = :some_property
|
25
30
|
id = :some_id
|
26
|
-
@picker.peoplePickerNavigationController(@picker_nav_controller, shouldContinueAfterSelectingPerson: @ab_person, property:property, identifier:id)
|
27
|
-
@
|
28
|
-
|
31
|
+
@picker.peoplePickerNavigationController(@picker_nav_controller, shouldContinueAfterSelectingPerson: @ab_person, property:property, identifier:id) if UIDevice.currentDevice.systemVersion < "8.0"
|
32
|
+
@picker.peoplePickerNavigationController(@picker_nav_controller, didSelectPerson: @ab_person, property:property, identifier:id) if UIDevice.currentDevice.systemVersion >= "8.0"
|
33
|
+
wait 5 {
|
34
|
+
@selected_person.should.not == nil
|
35
|
+
@selected_person.first_name.should == 'Colin'
|
36
|
+
}
|
29
37
|
end
|
30
38
|
|
31
39
|
it 'should yield nil when cancelled' do
|
32
40
|
@picker.peoplePickerNavigationControllerDidCancel(@picker_nav_controller)
|
33
|
-
|
41
|
+
wait 5 {
|
42
|
+
@selected_person.should == nil
|
43
|
+
}
|
34
44
|
end
|
35
45
|
end
|
36
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-addressbook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rothenberg
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: bubble-wrap
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.3'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '1.3'
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: rake
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
102
|
version: '0'
|
117
103
|
requirements: []
|
118
104
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.4.3
|
120
106
|
signing_key:
|
121
107
|
specification_version: 4
|
122
108
|
summary: A RubyMotion wrapper around the iOS & OSX Address Book frameworks
|