motion-addressbook 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-addressbook (0.0.1)
4
+ motion-addressbook (0.1.0)
5
5
  bubble-wrap
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -20,36 +20,68 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- ### List all people
23
+ ### Instantiating a person object
24
+
25
+ There are 3 ways to instantiate a person object
26
+
27
+ ### To get a new person not yet connected to the iOS Address Book
24
28
 
25
29
  ```ruby
26
- AddressBook::Person.all
27
- # => [#<AddressBook::Person:0x6d55e90 @attributes={:first_name=>"Alex", :last_name=>"Rothenberg", :job_title=>nil, :department=>nil, :organization=>nil} @ab_person=#<__NSCFType:0x6df8bf0>>,
28
- # #<AddressBook::Person:0x6d550a0 @attributes={:first_name=>"Laurent", :last_name=>"Sansonetti", :job_title=>nil, :department=>nil, :organization=>"HipByte"} @ab_person=#<__NSCFType:0x6df97d0>>]
30
+ AddressBook::Person.new
31
+ # => #<AddressBook::Person:0x8c67ca0 @attributes={:first_name=>nil, :last_name=>nil, :job_title=>nil, :department=>nil, :organization=>nil} @new_record=true @ab_person=#<__NSCFType:0x6d832e0>>
29
32
  ```
30
33
 
34
+ ### To get a list of existing people from the iOS Address Book
31
35
 
32
- ### Create a new Contact and save in Contacts app
36
+ Get all people with `.all`
37
+
38
+ ```ruby
39
+ AddressBook::Person.all
40
+ # => [#<AddressBook::Person:0x6d55e90 @attributes={:first_name=>"Alex", :last_name=>"Rothenberg", :job_title=>nil, :department=>nil, :organization=>nil} @ab_person=#<__NSCFType:0x6df8bf0>>,
41
+ # #<AddressBook::Person:0x6d550a0 @attributes={:first_name=>"Laurent", :last_name=>"Sansonetti", :job_title=>nil, :department=>nil, :organization=>"HipByte"} @ab_person=#<__NSCFType:0x6df97d0>>]
42
+ ```
43
+
44
+ Get a list of all people matching one attribute with `.find_all_by_XXX`
45
+
46
+ ```ruby
47
+ AddressBook::Person.find_all_by_email('alex@example.com')
48
+ # => [#<AddressBook::Person:0x6d55e90 @attributes={:first_name=>"Alex", :last_name=>"Rothenberg", :job_title=>nil, :department=>nil, :organization=>nil} @ab_person=#<__NSCFType:0x6df8bf0>>]
49
+ ```
50
+
51
+ Get the first person matching one attribute with `find_by_XXX`
52
+
53
+ ```ruby
54
+ AddressBook::Person.find_by_email('alex@example.com')
55
+ # => #<AddressBook::Person:0x6d55e90 @attributes={:first_name=>"Alex", :last_name=>"Rothenberg", :job_title=>nil, :department=>nil, :organization=>nil} @ab_person=#<__NSCFType:0x6df8bf0>>
56
+ ```
57
+
58
+ Get a list of all people matching several attributes with `.where`
33
59
 
34
60
  ```ruby
35
- alex = AddressBook::Person.new(:first_name => 'Alex', :last_name => 'Rothenberg', :email => 'alex@example.com')
36
- alex.save
61
+ AddressBook::Person.where(:email => 'alex@example.com', :first_name => 'Alex')
62
+ # => [#<AddressBook::Person:0x6d55e90 @attributes={:first_name=>"Alex", :last_name=>"Rothenberg", :job_title=>nil, :department=>nil, :organization=>nil} @ab_person=#<__NSCFType:0x6df8bf0>>]
37
63
  ```
38
64
 
39
- ### Get an existing Contact
65
+ To look for an existing person or get a new one if none is found `find_or_new_by_XXX`
66
+
67
+ ```ruby
68
+ AddressBook::Person.find_or_new_by_email('alex@example.com')
69
+ # => #<AddressBook::Person:0xe4e3a80 @attributes={:first_name=>"Alex", :last_name=>"Rothenberg", :job_title=>nil, :department=>nil, :organization=>nil} @ab_person=#<__NSCFType:0xe4bbef0>>
70
+ ```
71
+
72
+ ### Create a new Contact and save in Contacts app
40
73
 
41
74
  ```ruby
42
- alex = AddressBook::Person.new(:first_name => 'Alex', :email => 'alex@example.com')
43
- alex.last_name
44
- # => 'Rothenberg'
75
+ AddressBook::Person.create(:first_name => 'Alex', :last_name => 'Rothenberg', :email => 'alex@example.com')
76
+ # => #<AddressBook::Person:0xe4e3a80 @attributes={:first_name=>"Alex", :last_name=>"Rothenberg", :job_title=>nil, :department=>nil, :organization=>nil} @ab_person=#<__NSCFType:0xe4bbef0>>
45
77
  ```
46
78
 
47
79
  ### Update existing contact
48
80
 
49
81
  ```ruby
50
- alex = AddressBook::Person.new(:first_name => 'Alex', :email => 'alex@example.com')
51
- alex.job_title = 'RubyMotion Developer'
52
- alex.save
82
+ alex = AddressBook::Person.find_by_email('alex@example.com')
83
+ alex.job_title = 'RubyMotion Developer'
84
+ alex.save
53
85
  ```
54
86
 
55
87
  ## Contributing
@@ -1,5 +1,5 @@
1
1
  module Motion
2
2
  module Addressbook
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,12 +1,12 @@
1
1
  module AddressBook
2
2
  class MultiValue
3
3
  attr_reader :multivalueIdentifier, :ab_multi_values
4
-
4
+
5
5
  def initialize(ab_multi_values=nil)
6
6
  @ab_multi_values = ab_multi_values ? ABMultiValueCreateMutableCopy(ab_multi_values) : ABMultiValueCreateMutable(KABMultiStringPropertyType)
7
7
  # @ab_multi_values = ABMultiValueCreateMutable(KABMultiStringPropertyType)
8
8
  end
9
-
9
+
10
10
  def set(ab_label, value)
11
11
  return if values.include? value #temp because blank? not working
12
12
  if blank?(ab_label)
@@ -22,25 +22,25 @@ module AddressBook
22
22
  set(ab_label, value)
23
23
  end
24
24
  end
25
-
25
+
26
26
  def values
27
27
  ABMultiValueCopyArrayOfAllValues(@ab_multi_values) || []
28
28
  end
29
-
29
+
30
30
  def include? value
31
31
  return false if values.nil?
32
32
  values.include? value
33
33
  end
34
-
34
+
35
35
  private
36
36
  def blank?(ab_label)
37
37
  index_for(ab_label) == -1
38
38
  end
39
-
39
+
40
40
  def index_for(ab_label)
41
41
  return -1 # Keep getting this error :( <ArgumentError: invalid value for Integer: "_$!<Work>!$_">
42
42
  # ABMultiValueGetIndexForIdentifier(@ab_multi_values, ab_label)
43
43
  end
44
-
44
+
45
45
  end
46
46
  end
@@ -2,9 +2,15 @@ module AddressBook
2
2
  class Person
3
3
  attr_reader :attributes, :error, :ab_person
4
4
 
5
- def initialize(attributes, ab_person = nil)
5
+ def initialize(attributes={}, ab_person = nil)
6
6
  @attributes = attributes
7
- load_ab_person(ab_person)
7
+ if ab_person.nil?
8
+ @new_record = true
9
+ else
10
+ @ab_person = ab_person
11
+ load_ab_person
12
+ @new_record = false
13
+ end
8
14
  end
9
15
 
10
16
  def self.all
@@ -24,9 +30,22 @@ module AddressBook
24
30
  ABAddressBookAddRecord(address_book, ab_person, error)
25
31
  ABAddressBookSave(address_book, error )
26
32
  @address_book = nil #force refresh
33
+ @new_record = false
34
+ end
35
+
36
+ def self.where(conditions)
37
+ all.select do |person|
38
+ person.meets? conditions
39
+ end
40
+ end
41
+
42
+ def meets?(conditions)
43
+ conditions.keys.all? do |attribute|
44
+ send(attribute) == conditions[attribute]
45
+ end
27
46
  end
28
47
 
29
- def attribute_map
48
+ def self.attribute_map
30
49
  { :first_name => KABPersonFirstNameProperty,
31
50
  :last_name => KABPersonLastNameProperty,
32
51
  :job_title => KABPersonJobTitleProperty,
@@ -34,22 +53,95 @@ module AddressBook
34
53
  :organization => KABPersonOrganizationProperty
35
54
  }
36
55
  end
56
+ def attribute_map
57
+ self.class.attribute_map
58
+ end
37
59
 
38
60
  def method_missing(name, *args)
39
- name.to_s =~ /^(\w*)(=?)$/
40
- attribute_name = $1.to_sym unless $1.nil?
41
- if attribute_map.include? attribute_name
42
- if $2 == '='
43
- set_field(attribute_map[attribute_name], args.first)
44
- attributes[attribute_name] = args.first
45
- else
46
- attributes[attribute_name] ||= get_field(attribute_map[attribute_name])
47
- end
61
+ if attribute_name = getter?(name)
62
+ get(attribute_name)
63
+ elsif attribute_name = setter?(name)
64
+ set(attribute_name, args.first)
48
65
  else
49
66
  super
50
67
  end
51
68
  end
52
69
 
70
+ def self.method_missing(name, *args)
71
+ if attribute_name = all_finder?(name)
72
+ find_all_by(attribute_name, args.first)
73
+ elsif attribute_name = first_finder?(name)
74
+ find_by(attribute_name, args.first)
75
+ elsif attribute_name = finder_or_new?(name)
76
+ find_or_new_by(attribute_name, args.first)
77
+ else
78
+ super
79
+ end
80
+ end
81
+ def self.is_attribute?(attribute_name)
82
+ return false if attribute_name.nil?
83
+ attribute_map.include?(attribute_name.to_sym) || [:email, :phone_number].include?( attribute_name.to_sym)
84
+ end
85
+
86
+ def getter?(method_name)
87
+ if self.class.is_attribute? method_name
88
+ method_name
89
+ else
90
+ nil
91
+ end
92
+ end
93
+ def setter?(method_name)
94
+ method_name.to_s =~ /^(\w*)=$/
95
+ if self.class.is_attribute? $1
96
+ $1
97
+ else
98
+ nil
99
+ end
100
+ end
101
+ def self.all_finder?(method_name)
102
+ method_name.to_s =~ /^find_all_by_(\w*)$/
103
+ if is_attribute? $1
104
+ $1
105
+ else
106
+ nil
107
+ end
108
+ end
109
+ def self.first_finder?(method_name)
110
+ method_name.to_s =~ /^find_by_(\w*)$/
111
+ if is_attribute? $1
112
+ $1
113
+ else
114
+ nil
115
+ end
116
+ end
117
+ def self.finder_or_new?(method_name)
118
+ method_name.to_s =~ /^find_or_new_by_(\w*)$/
119
+ if is_attribute? $1
120
+ $1
121
+ else
122
+ nil
123
+ end
124
+ end
125
+
126
+ def get(attribute_name)
127
+ attributes[attribute_name.to_sym] ||= get_field(attribute_map[attribute_name])
128
+ end
129
+
130
+ def set(attribute_name, value)
131
+ set_field(attribute_map[attribute_name.to_sym], value)
132
+ attributes[attribute_name.to_sym] = value
133
+ end
134
+
135
+ def self.find_all_by(attribute_name, criteria)
136
+ where({attribute_name.to_sym => criteria})
137
+ end
138
+ def self.find_by(attribute_name, criteria)
139
+ find_all_by(attribute_name, criteria).first
140
+ end
141
+ def self.find_or_new_by(attribute_name, criteria)
142
+ find_by(attribute_name, criteria) || new({attribute_name.to_sym => criteria})
143
+ end
144
+
53
145
  def photo
54
146
  ABPersonCopyImageData(ab_person)
55
147
  end
@@ -74,11 +166,18 @@ module AddressBook
74
166
  def email_values
75
167
  emails.values
76
168
  end
169
+
170
+ # UGH - kinda arbitrary way to deal with multiple values. DO SOMETHING BETTER.
171
+ def email
172
+ @attributes[:email] ||= email_values.first
173
+ end
174
+ def phone_number
175
+ @attributes[:phone_number] ||= phone_number_values.first
176
+ end
77
177
 
78
178
  # private
79
179
 
80
- def load_ab_person(ab_person = nil)
81
- @ab_person = ab_person || find_or_new
180
+ def load_ab_person
82
181
  set_field(KABPersonFirstNameProperty, attributes[:first_name ]) unless attributes[:first_name ].nil?
83
182
  set_field(KABPersonLastNameProperty, attributes[:last_name ]) unless attributes[:last_name ].nil?
84
183
  set_field(KABPersonJobTitleProperty, attributes[:job_title ]) unless attributes[:job_title ].nil?
@@ -104,16 +203,32 @@ module AddressBook
104
203
  MultiValue.new(ABRecordCopyValue(ab_person, field))
105
204
  end
106
205
 
206
+ def ab_person
207
+ if @ab_person.nil?
208
+ @ab_person = new_ab_person
209
+ load_ab_person
210
+ end
211
+ @ab_person
212
+ end
213
+
107
214
  def find_or_new
108
215
  if new_record?
109
- ab_person = ABPersonCreate()
110
- ABAddressBookAddRecord(address_book, ab_person, error )
111
- ab_person
216
+ new_ab_person
112
217
  else
113
218
  existing_record
114
219
  end
115
220
  end
116
221
 
222
+ def new_ab_person
223
+ ab_person = ABPersonCreate()
224
+ # ABAddressBookAddRecord(address_book, ab_person, error )
225
+ ab_person
226
+ end
227
+
228
+ def new_record?
229
+ !!@new_record
230
+ end
231
+
117
232
  def existing_records
118
233
  potential_matches = ABAddressBookCopyPeopleWithName(address_book, attributes[:first_name])
119
234
  potential_matches.select do |record|
@@ -125,9 +240,9 @@ module AddressBook
125
240
  def exists?
126
241
  !new_record?
127
242
  end
128
- def new_record?
129
- existing_record.nil?
130
- end
243
+ # def new_record?
244
+ # existing_record.nil?
245
+ # end
131
246
  def existing_record
132
247
  # what if there are more than one match? email should be unique but ...
133
248
  existing_records.first
@@ -1,4 +1,8 @@
1
+ def unique_email
2
+ "alex_#{Time.now.to_i}@example.com"
3
+ end
1
4
  describe AddressBook::Person do
5
+
2
6
  describe '.all' do
3
7
  before do
4
8
  @person = AddressBook::Person.create({:first_name => 'Alex', :last_name=>'Rothenberg'})
@@ -7,19 +11,94 @@ describe AddressBook::Person do
7
11
  all_names = AddressBook::Person.all.map do |person|
8
12
  [person.first_name, person.last_name]
9
13
  end
10
- all_names.should.include? ['Alex', 'Rothenberg']
14
+ all_names.should.include? ['Alex', 'Rothenberg']
11
15
  end
12
-
13
- it 'should get bigger when we create another' do
16
+
17
+ it 'should get bigger when we create another' do
14
18
  initial_people_count = AddressBook::Person.all.size
15
19
  @person = AddressBook::Person.create({:first_name => 'Alex2', :last_name=>'Rothenberg2'})
16
20
  AddressBook::Person.all.size.should == (initial_people_count + 1)
17
21
  end
18
22
  end
19
23
 
24
+ describe 'ways of creating and finding people' do
25
+ describe 'new' do
26
+ before do
27
+ @alex = AddressBook::Person.new(:first_name => 'Alex', :last_name => 'Testy', :email => 'alex@example.com')
28
+ end
29
+ it 'should create but not save in the address book' do
30
+ @alex.should.be.new_record
31
+ @alex.first_name.should == 'Alex'
32
+ @alex.last_name.should == 'Testy'
33
+ @alex.email_values.should == ['alex@example.com']
34
+ end
35
+ end
36
+
37
+ describe 'existing' do
38
+ before do
39
+ AddressBook::Person.create(:first_name => 'Alex', :last_name => 'Testy', :email => 'alex@example.com')
40
+ end
41
+ describe '.find_by_all_email' do
42
+ it 'should find matches' do
43
+ alexes = AddressBook::Person.find_all_by_email 'alex@example.com'
44
+ alexes.should.not.be.empty
45
+ alexes.each do |alex|
46
+ alex.email.should == 'alex@example.com'
47
+ end
48
+ end
49
+ it 'should give empty list when nothing matches' do
50
+ alexes = AddressBook::Person.find_all_by_email unique_email
51
+ alexes.should == []
52
+ end
53
+ end
54
+ describe '.find_by_email' do
55
+ it 'should find match' do
56
+ alex = AddressBook::Person.find_by_email 'alex@example.com'
57
+ alex.email.should == 'alex@example.com'
58
+ end
59
+ it 'should give empty list when nothing matches' do
60
+ alexes = AddressBook::Person.find_by_email unique_email
61
+ alexes.should.be.nil
62
+ end
63
+ end
64
+ describe '.where' do
65
+ it 'should find matches' do
66
+ alexes = AddressBook::Person.where(:email => 'alex@example.com')
67
+ alexes.should.not.be.empty
68
+ alexes.each do |alex|
69
+ alex.email.should == 'alex@example.com'
70
+ end
71
+ end
72
+ it 'should give empty list when nothing matches' do
73
+ alexes = AddressBook::Person.where(:email => unique_email)
74
+ alexes.should == []
75
+ end
76
+ end
77
+ end
78
+
79
+ # describe 'new or existing' do
80
+ # before do
81
+ # AddressBook::Person.create(:first_name => 'Alex', :last_name => 'Testy', :email => 'alex@example.com')
82
+ # end
83
+ # it 'should find an existing person' do
84
+ # alex = AddressBook::Person.find_or_new_by_email('alex@example.com')
85
+ # alex.should.not.be.new_record
86
+ # alex.email.should == 'alex@example.com'
87
+ # alex.first_name.should == 'Alex'
88
+ # alex.last_name.should == 'Testy'
89
+ # end
90
+ # it 'should return new person when no match found' do
91
+ # never_before_used_email = unique_email
92
+ # alex = AddressBook::Person.find_or_new_by_email(never_before_used_email)
93
+ # alex.should.be.new_record
94
+ # alex.email.should == never_before_used_email
95
+ # alex.first_name.should == nil
96
+ # end
97
+ # end
98
+ end
99
+
20
100
  describe 'save' do
21
101
  before do
22
- unique_email = "alex_#{Time.now.to_i}@example.com"
23
102
  @attributes = {:first_name=>'Alex', :last_name=>'Testy',
24
103
  :job_title => 'Developer', :department => 'Development', :organization => 'The Company',
25
104
  :mobile_phone => '123 456 7890', :office_phone => '987 654 3210',
@@ -73,7 +152,6 @@ describe AddressBook::Person do
73
152
  @ab_person.photo = data
74
153
  UIImagePNGRepresentation(@ab_person.photo).should.equal data
75
154
  end
76
-
77
155
  end
78
156
 
79
157
  it 'should be able to get the phone numbers' do
@@ -100,7 +178,7 @@ describe AddressBook::Person do
100
178
  @attributes[:job_title ] = 'i got promoted'
101
179
  @attributes[:office_phone] = '111 222 3333'
102
180
  # @attributes[:department ] = nil
103
- @ab_person = AddressBook::Person.new(@attributes)
181
+ @ab_person = AddressBook::Person.find_or_new_by_email(@attributes[:email])
104
182
  end
105
183
 
106
184
  it 'should know it is not new' do
@@ -110,23 +188,12 @@ describe AddressBook::Person do
110
188
  end
111
189
 
112
190
  describe 'updating' do
113
- before do
114
- @ab_person.save
115
- @new_ab_person = AddressBook::Person.new :first_name=>@attributes[:first_name], :email => @attributes[:email]
116
- end
117
191
  it 'should be able to get each of the single value fields' do
118
- @new_ab_person.first_name.should.equal @attributes[:first_name ]
119
- @new_ab_person.last_name.should.equal @attributes[:last_name ]
120
- @new_ab_person.job_title.should.equal @attributes[:job_title ]
121
- @new_ab_person.department.should.equal @attributes[:department ]
122
- @new_ab_person.organization.should.equal @attributes[:organization]
123
- end
124
- it 'should be able to get the phone numbers (we never delete and just add - not sure if this is "right")' do
125
- @new_ab_person.phone_number_values.should.equal [@attributes[:mobile_phone], '987 654 3210', @attributes[:office_phone]]
126
- end
127
-
128
- it 'should be able to get the emails' do
129
- @new_ab_person.email_values.should.equal [@attributes[:email] ]
192
+ @ab_person.save
193
+ @new_ab_person = AddressBook::Person.find_by_email @ab_person.email
194
+ @new_ab_person.first_name = 'New First Name'
195
+ @new_ab_person.save
196
+ AddressBook::Person.find_by_email(@ab_person.email).first_name.should == 'New First Name'
130
197
  end
131
198
  end
132
199
 
@@ -134,4 +201,70 @@ describe AddressBook::Person do
134
201
 
135
202
  end
136
203
 
204
+ describe 'method missing magic' do
205
+ before do
206
+ @person = AddressBook::Person.new
207
+ end
208
+ describe 'getters' do
209
+ it 'should have a getter for each attribute' do
210
+ @person.getter?('first_name' ).should.be truthy
211
+ @person.getter?('last_name' ).should.be truthy
212
+ @person.getter?('job_title' ).should.be truthy
213
+ @person.getter?('department' ).should.be truthy
214
+ @person.getter?('organization').should.be truthy
215
+ end
216
+ it 'should know what is not a getter' do
217
+ @person.getter?('nonesense' ).should.be falsey
218
+ @person.getter?('first_name=' ).should.be falsey
219
+ @person.getter?('find_all_by_email').should.be falsey
220
+ @person.getter?('find_by_email' ).should.be falsey
221
+ end
222
+ end
223
+ describe 'setters' do
224
+ it 'should have a setter for each attribute' do
225
+ @person.setter?('first_name=' ).should.be truthy
226
+ @person.setter?('last_name=' ).should.be truthy
227
+ @person.setter?('job_title=' ).should.be truthy
228
+ @person.setter?('department=' ).should.be truthy
229
+ @person.setter?('organization=').should.be truthy
230
+ end
231
+ it 'should know what is not a setter' do
232
+ @person.setter?('nonesense=' ).should.be falsey
233
+ @person.setter?('first_name' ).should.be falsey
234
+ @person.setter?('find_all_by_email').should.be falsey
235
+ @person.setter?('find_by_email' ).should.be falsey
236
+ end
237
+ end
238
+ describe 'all_finders' do
239
+ it 'should have a finder for each attribute' do
240
+ AddressBook::Person.all_finder?('find_all_by_first_name' ).should.be truthy
241
+ AddressBook::Person.all_finder?('find_all_by_last_name' ).should.be truthy
242
+ AddressBook::Person.all_finder?('find_all_by_job_title' ).should.be truthy
243
+ AddressBook::Person.all_finder?('find_all_by_department' ).should.be truthy
244
+ AddressBook::Person.all_finder?('find_all_by_organization').should.be truthy
245
+ end
246
+ it 'should know what is not a finder' do
247
+ AddressBook::Person.all_finder?('nonesense' ).should.be falsey
248
+ AddressBook::Person.all_finder?('first_name' ).should.be falsey
249
+ AddressBook::Person.all_finder?('first_name=' ).should.be falsey
250
+ AddressBook::Person.all_finder?('find_by_email').should.be falsey
251
+ end
252
+ end
253
+ describe 'first_finders' do
254
+ it 'should have a finder for each attribute' do
255
+ AddressBook::Person.first_finder?('find_by_first_name' ).should.be truthy
256
+ AddressBook::Person.first_finder?('find_by_last_name' ).should.be truthy
257
+ AddressBook::Person.first_finder?('find_by_job_title' ).should.be truthy
258
+ AddressBook::Person.first_finder?('find_by_department' ).should.be truthy
259
+ AddressBook::Person.first_finder?('find_by_organization').should.be truthy
260
+ end
261
+ it 'should know what is not a finder' do
262
+ AddressBook::Person.first_finder?('nonesense' ).should.be falsey
263
+ AddressBook::Person.first_finder?('first_name' ).should.be falsey
264
+ AddressBook::Person.first_finder?('first_name=' ).should.be falsey
265
+ AddressBook::Person.first_finder?('find_all_by_email').should.be falsey
266
+ end
267
+ end
268
+ end
269
+
137
270
  end
@@ -0,0 +1,11 @@
1
+ # 1.should.be truthy
2
+ # false.should.not.be truthy
3
+ def truthy()
4
+ lambda { |obj| !!obj }
5
+ end
6
+
7
+ # 1.should.not.be falsey
8
+ # false.should..be falsey
9
+ def falsey()
10
+ lambda { |obj| !obj }
11
+ end
@@ -0,0 +1,5 @@
1
+ def unique_email(email='alex@example.com')
2
+ name, domain = email.split('@')
3
+ "#{name}_#{Time.now.to_i}@#{domain}"
4
+ end
5
+
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: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-23 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bubble-wrap
@@ -79,6 +79,8 @@ files:
79
79
  - motion/address_book/person.rb
80
80
  - spec/address_book/multi_value_spec.rb
81
81
  - spec/address_book/person_spec.rb
82
+ - spec/helpers/bacon_matchers.rb
83
+ - spec/helpers/person_helpers.rb
82
84
  homepage: ''
83
85
  licenses: []
84
86
  post_install_message:
@@ -93,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
95
  version: '0'
94
96
  segments:
95
97
  - 0
96
- hash: -4038011897139577156
98
+ hash: 2222188653506619315
97
99
  required_rubygems_version: !ruby/object:Gem::Requirement
98
100
  none: false
99
101
  requirements:
@@ -102,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  version: '0'
103
105
  segments:
104
106
  - 0
105
- hash: -4038011897139577156
107
+ hash: 2222188653506619315
106
108
  requirements: []
107
109
  rubyforge_project:
108
110
  rubygems_version: 1.8.24
@@ -112,3 +114,5 @@ summary: A RubyMotion wrapper around the iOS Address Book framework
112
114
  test_files:
113
115
  - spec/address_book/multi_value_spec.rb
114
116
  - spec/address_book/person_spec.rb
117
+ - spec/helpers/bacon_matchers.rb
118
+ - spec/helpers/person_helpers.rb