motion-addressbook 1.7.2 → 1.7.4

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
  SHA1:
3
- metadata.gz: 686d48dc6904f9b9a55304536a80a6a54ba98609
4
- data.tar.gz: a8c743b34dc3ec02f54d5bcc80110eba64b698bf
3
+ metadata.gz: 7e8cc5964dc93254dd6daa37e210928a6ee4b881
4
+ data.tar.gz: fa6ba42ab41a6b365185aca1e30517791639bebd
5
5
  SHA512:
6
- metadata.gz: 5b62d28e2ac4e801430d98ebb9dcd77f48dd4ce193d6966eb668ae6fa25effa893b3eba5c3c33db4da5b2fde48eabc24d22ce9f92507a5cc9c55a0567b3c6d66
7
- data.tar.gz: 028c26080e06d2da83637864311c1130ea4b0399e378df4eb724b60c3097a061ecea3ba4bc2620338fe19ca652d682f73545c447254ab88bdf99204c7057faa4
6
+ metadata.gz: 8bbc20f804a6de90d9b79b93f6421c58d5dbb32de68454465e8da3ba7fb6a7dd0fbcbaa04190d5bba855d5f0c21666340e150a36829e5befa30df40c41bdbb91
7
+ data.tar.gz: a65a9af3fe0b5a258d4dcf5643076637654f6bafea5b57db0b98336e6163ea03c4a1d5901ee1fc930aecb510fdb6cfac5a79617cb43e531e0e0f125832a95a0b
data/Gemfile CHANGED
@@ -1,7 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # need to do this here as alphabetically "bubble-wrap" comes after "address_book" and require fails otherwise
4
- gem 'bubble-wrap', '~> 1.3'
5
-
6
3
  # Specify your gem's dependencies in motion-addressbook.gemspec
7
4
  gemspec
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
- require 'bundler'
19
- Bundler.require
18
+ ```ruby
19
+ require 'bundler'
20
+ Bundler.require
21
+ ```
20
22
 
21
23
  Add this line to your application's `Gemfile`:
22
24
 
23
- gem 'motion-addressbook'
25
+ ```ruby
26
+ gem 'motion-addressbook'
27
+ ```
24
28
 
25
29
  And then execute:
26
30
 
27
- $ bundle
31
+ ```bash
32
+ $ bundle
33
+ ```
28
34
 
29
35
  ### Manually without bundler
30
36
 
31
- Or install it yourself (remember to add the bubble-wrap dependency) as:
37
+ Or install it yourself as:
32
38
 
33
- $ gem install bubble-wrap
34
- $ gem install motion-addressbook
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
- if AddressBook.request_authorization do |granted|
82
+ AddressBook.request_authorization do |granted|
76
83
  # this block is invoked sometime later
77
84
  if granted
78
- # do something now that the user has said "yes"
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.pick do |person|
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 Motion::Project::App.osx?
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
- puts BW::JSON.generate(ab.people.map(&:attributes))
18
+ people = ab.people.map(&:attributes)
19
+ puts NSJSONSerialization.dataWithJSONObject(people, options:0, error:nil).to_str
19
20
  when 'groups'
20
- puts BW::JSON.generate(ab.groups.map { |g| {name: g.name, members: g.members.map(&:uid) }})
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
@@ -13,30 +13,18 @@ gem 'motion-addressbook', '<= 1.5.0'
13
13
  EOT
14
14
  end
15
15
 
16
- BubbleWrap.require 'motion/address_book.rb' do
17
- file('motion/address_book.rb').uses_framework('AddressBook')
18
- end
19
-
20
- BubbleWrap.require_ios do
21
- # BW.require 'motion/address_book/multi_value.rb'
22
- BW.require 'motion/address_book/ios/addr_book.rb'
23
- BW.require 'motion/address_book/ios/person.rb'
24
- BW.require 'motion/address_book/ios/group.rb'
25
- BW.require 'motion/address_book/ios/multi_valued.rb'
26
- BW.require 'motion/address_book/ios/source.rb'
27
-
28
- BW.require 'motion/address_book/ios/picker.rb' do
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
@@ -1,5 +1,5 @@
1
1
  module Motion
2
2
  module Addressbook
3
- VERSION = "1.7.2"
3
+ VERSION = "1.7.4"
4
4
  end
5
5
  end
@@ -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
@@ -2,10 +2,10 @@ module AddressBook
2
2
  module_function
3
3
 
4
4
  def address_book
5
- if App.osx?
5
+ if Kernel.const_defined?(:NSApplication)
6
6
  ABAddressBook.addressBook
7
7
  else # iOS
8
- if Device.ios_version =~ /5/
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 App.ios?
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
- App.notification_center.post :addressbook_updated, self
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:property, identifier:id)
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
- App.notification_center.observe KABDatabaseChangedExternallyNotification do |notification|
64
- App.notification_center.post :addressbook_updated, self
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
@@ -17,7 +17,7 @@ describe AddressBook::MultiValued do
17
17
  before do
18
18
  @attributes = [
19
19
  {
20
- :label => 'home page',
20
+ :label => 'home-page',
21
21
  :value => "http://www.mysite.com/"
22
22
  }, {
23
23
  :label => 'work',
@@ -162,7 +162,7 @@ describe AddressBook::Person do
162
162
  {:label => 'home', :city => 'Dogpatch', :state => 'KY'}
163
163
  ],
164
164
  :urls => [
165
- { :label => 'home page', :value => "http://www.mysite.com/" },
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
- App.notification_center.observe :addressbook_updated do |notification|
534
- @notifications += 1
535
- end
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
- @selected_person.should.not == nil
20
- @selected_person.first_name.should == 'Colin'
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
- @selected_person.should.not == nil
28
- @selected_person.first_name.should == 'Colin'
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
- @selected_person.should == nil
41
+ wait 5 {
42
+ @selected_person.should == nil
43
+ }
34
44
  end
35
45
  end
36
46
  end
@@ -6,9 +6,10 @@ module Bacon
6
6
  def ab_connect
7
7
  AddressBook::AddrBook.new do |ab|
8
8
  if ab
9
- EM.schedule_on_main do
9
+ cb = proc do
10
10
  Bacon.run
11
11
  end
12
+ Dispatch::Queue.main.async &cb
12
13
  else
13
14
  warn "ACCESS DENIED - ABORTING"
14
15
  exit
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.2
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: 2014-04-14 00:00:00.000000000 Z
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.2.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