ppl 1.23.0 → 1.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +6 -0
  3. data/features/email.feature +38 -1
  4. data/features/phone.feature +21 -0
  5. data/features/step_definitions/ppl_steps.rb +31 -1
  6. data/lib/ppl/adapter/vcard/greencard.rb +8 -2
  7. data/lib/ppl/application/bootstrap.rb +14 -0
  8. data/lib/ppl/command/email.rb +58 -4
  9. data/lib/ppl/command/mutt.rb +2 -2
  10. data/lib/ppl/command/phone.rb +46 -31
  11. data/lib/ppl/entity/email_address.rb +13 -0
  12. data/lib/ppl/entity/phone_number.rb +2 -0
  13. data/lib/ppl/format/address_book/email_addresses.rb +4 -1
  14. data/lib/ppl/format/address_book/mutt_query.rb +1 -1
  15. data/lib/ppl/format/address_book/one_line.rb +10 -1
  16. data/lib/ppl/format/contact/email_addresses.rb +7 -17
  17. data/lib/ppl/format/contact/full.rb +27 -8
  18. data/lib/ppl/format/contact/phone_number.rb +6 -1
  19. data/lib/ppl/format/table.rb +2 -2
  20. data/lib/ppl/service/email_address.rb +37 -0
  21. data/lib/ppl/service/phone_number.rb +40 -0
  22. data/lib/ppl.rb +8 -1
  23. data/ppl.gemspec +2 -2
  24. data/spec/ppl/adapter/vcard/greencard_spec.rb +40 -2
  25. data/spec/ppl/command/email_spec.rb +58 -0
  26. data/spec/ppl/command/mutt_spec.rb +10 -10
  27. data/spec/ppl/command/phone_spec.rb +30 -26
  28. data/spec/ppl/entity/email_address_spec.rb +28 -0
  29. data/spec/ppl/entity/phone_number_spec.rb +6 -0
  30. data/spec/ppl/format/address_book/email_addresses_spec.rb +1 -1
  31. data/spec/ppl/format/address_book/mutt_query_spec.rb +2 -2
  32. data/spec/ppl/format/address_book/one_line_spec.rb +11 -1
  33. data/spec/ppl/format/contact/email_addresses_spec.rb +27 -13
  34. data/spec/ppl/format/contact/full_spec.rb +25 -13
  35. data/spec/ppl/format/contact/phone_number_spec.rb +13 -1
  36. data/spec/ppl/service/email_address_spec.rb +73 -0
  37. data/spec/ppl/service/phone_number_spec.rb +75 -0
  38. metadata +8 -2
@@ -4,7 +4,7 @@ describe Ppl::Format::Contact::PhoneNumber do
4
4
  describe "#initialize" do
5
5
  it "should pass the colors through to the table" do
6
6
  colors = {"number" => "blue"}
7
- Ppl::Format::Table.should_receive(:new).with([:phone_numbers, :type], colors)
7
+ Ppl::Format::Table.should_receive(:new).with([:star, :phone_numbers, :type], colors)
8
8
  format = Ppl::Format::Contact::PhoneNumber.new(colors)
9
9
  end
10
10
  end
@@ -22,6 +22,7 @@ describe Ppl::Format::Contact::PhoneNumber do
22
22
 
23
23
  it "should always include the phone number" do
24
24
  @table.should_receive(:add_row).with({
25
+ :star => " ",
25
26
  :phone_numbers => "01234567890",
26
27
  :type => nil,
27
28
  })
@@ -31,12 +32,23 @@ describe Ppl::Format::Contact::PhoneNumber do
31
32
  it "should put the type in parentheses" do
32
33
  @number.type = "work"
33
34
  @table.should_receive(:add_row).with({
35
+ :star => " ",
34
36
  :phone_numbers => "01234567890",
35
37
  :type => "(work)",
36
38
  })
37
39
  @format.process(@contact)
38
40
  end
39
41
 
42
+ it "should mark preferred numbers with a star" do
43
+ @number.preferred = true
44
+ @table.should_receive(:add_row).with({
45
+ :star => "*",
46
+ :phone_numbers => "01234567890",
47
+ :type => nil,
48
+ })
49
+ @format.process(@contact)
50
+ end
51
+
40
52
  end
41
53
 
42
54
  end
@@ -0,0 +1,73 @@
1
+
2
+ describe Ppl::Service::EmailAddress do
3
+
4
+ before(:each) do
5
+ @service = Ppl::Service::EmailAddress.new
6
+ @contact = Ppl::Entity::Contact.new
7
+ @storage = double(Ppl::Adapter::Storage)
8
+ @storage.stub(:save_contact)
9
+ @service.storage = @storage
10
+ @contact.email_addresses << Ppl::Entity::EmailAddress.new("one@example.org")
11
+ end
12
+
13
+ describe "#add" do
14
+
15
+ it "should add the email address to the contact" do
16
+ @storage.stub(:save_contact) do |contact|
17
+ contact.email_addresses[1].address.should eq "two@example.org"
18
+ end
19
+ @service.add(@contact, "two@example.org", {})
20
+ end
21
+
22
+ it "should set the new address as preferred if asked" do
23
+ @service.add(@contact, "two@example.org", {:preferred => true})
24
+ @contact.email_addresses[1].preferred.should eq true
25
+ end
26
+
27
+ it "should store the contact" do
28
+ @storage.should_receive(:save_contact).with(@contact)
29
+ @service.add(@contact, "", {})
30
+ end
31
+
32
+ end
33
+
34
+ describe "#update" do
35
+ it "should store the updated contact" do
36
+ @storage.should_receive(:save_contact).with(@contact)
37
+ @service.update(@contact, "", {})
38
+ end
39
+
40
+ it "should mark the address as preferred if asked to" do
41
+ @storage.stub(:save_contact) do |contact|
42
+ contact.email_addresses.first.preferred.should eq true
43
+ end
44
+ @service.update(@contact, "one@example.org", {:preferred => true})
45
+ end
46
+
47
+ it "should mark the address as not preferred if asked to" do
48
+ @contact.email_addresses.first.preferred = true
49
+ @storage.stub(:save_contact) do |contact|
50
+ contact.email_addresses.first.preferred.should eq false
51
+ end
52
+ @service.update(@contact, "one@example.org", {:preferred => false})
53
+ end
54
+ end
55
+
56
+ describe "#remove" do
57
+
58
+ it "should remove the email address from the contact" do
59
+ @storage.stub(:save_contact) do |contact|
60
+ contact.email_addresses.length.should eq 0
61
+ end
62
+ @service.remove(@contact, "one@example.org")
63
+ end
64
+
65
+ it "should store the contact" do
66
+ @storage.should_receive(:save_contact).with(@contact)
67
+ @service.remove(@contact, "")
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+
@@ -0,0 +1,75 @@
1
+
2
+ describe Ppl::Service::PhoneNumber do
3
+
4
+ before(:each) do
5
+ @service = Ppl::Service::PhoneNumber.new
6
+ @contact = Ppl::Entity::Contact.new
7
+ @storage = double(Ppl::Adapter::Storage)
8
+ @storage.stub(:save_contact)
9
+ @service.storage = @storage
10
+ @contact.phone_numbers << Ppl::Entity::PhoneNumber.new("01234567890")
11
+ end
12
+
13
+ describe "#add" do
14
+
15
+ it "should add the phone number to the contact" do
16
+ @service.add(@contact, "10987654321", {})
17
+ @contact.phone_numbers[1].number.should eq "10987654321"
18
+ end
19
+
20
+ it "should process the input options against the new contact" do
21
+ @service.add(@contact, "10987654321", {:preferred => true})
22
+ @contact.phone_numbers[1].preferred.should eq true
23
+ end
24
+
25
+ it "should store the contact" do
26
+ @storage.should_receive(:save_contact).with(@contact)
27
+ @service.add(@contact, "", {})
28
+ end
29
+
30
+ end
31
+
32
+ describe "#update" do
33
+
34
+ it "should update the number's type" do
35
+ @service.update(@contact, "01234567890", {:type => "cell"})
36
+ @contact.phone_numbers.first.type.should eq "cell"
37
+ end
38
+
39
+ it "should update the number's preferred status" do
40
+ @contact.phone_numbers << Ppl::Entity::PhoneNumber.new("109876543210")
41
+ @contact.phone_numbers[1].preferred = true
42
+ @service.update(@contact, "01234567890", {:preferred => true})
43
+ @contact.phone_numbers[0].preferred.should eq true
44
+ @contact.phone_numbers[1].preferred.should eq false
45
+ end
46
+
47
+ it "should mark numbers as not preferred" do
48
+ @contact.phone_numbers[0].preferred = true
49
+ @service.update(@contact, "01234567890", {:preferred => false})
50
+ @contact.phone_numbers[0].preferred.should eq false
51
+ end
52
+
53
+ it "should store the contact" do
54
+ @storage.should_receive(:save_contact).with(@contact)
55
+ @service.update(@contact, "", {})
56
+ end
57
+
58
+ end
59
+
60
+ describe "#remove" do
61
+
62
+ it "should remove the phone number from the contact" do
63
+ @service.remove(@contact, "01234567890")
64
+ @contact.phone_numbers.length.should eq 0
65
+ end
66
+
67
+ it "should store the contact" do
68
+ @storage.should_receive(:save_contact).with(@contact)
69
+ @service.remove(@contact, "")
70
+ end
71
+
72
+ end
73
+
74
+ end
75
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.0
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-21 00:00:00.000000000 Z
11
+ date: 2013-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -226,6 +226,7 @@ files:
226
226
  - lib/ppl/command/version.rb
227
227
  - lib/ppl/entity/address_book.rb
228
228
  - lib/ppl/entity/contact.rb
229
+ - lib/ppl/entity/email_address.rb
229
230
  - lib/ppl/entity/phone_number.rb
230
231
  - lib/ppl/entity/postal_address.rb
231
232
  - lib/ppl/error/completion_not_found.rb
@@ -257,6 +258,8 @@ files:
257
258
  - lib/ppl/format/postal_address.rb
258
259
  - lib/ppl/format/postal_address/one_line.rb
259
260
  - lib/ppl/format/table.rb
261
+ - lib/ppl/service/email_address.rb
262
+ - lib/ppl/service/phone_number.rb
260
263
  - ppl.gemspec
261
264
  - spec/ppl/adapter/color/colored_spec.rb
262
265
  - spec/ppl/adapter/color_spec.rb
@@ -301,6 +304,7 @@ files:
301
304
  - spec/ppl/command/version_spec.rb
302
305
  - spec/ppl/entity/address_book_spec.rb
303
306
  - spec/ppl/entity/contact_spec.rb
307
+ - spec/ppl/entity/email_address_spec.rb
304
308
  - spec/ppl/entity/phone_number_spec.rb
305
309
  - spec/ppl/entity/postal_address_spec.rb
306
310
  - spec/ppl/format/address_book/ages_spec.rb
@@ -329,6 +333,8 @@ files:
329
333
  - spec/ppl/format/postal_address/one_line_spec.rb
330
334
  - spec/ppl/format/postal_address_spec.rb
331
335
  - spec/ppl/format/table_spec.rb
336
+ - spec/ppl/service/email_address_spec.rb
337
+ - spec/ppl/service/phone_number_spec.rb
332
338
  - spec/spec_helper.rb
333
339
  homepage: http://ppladdressbook.org
334
340
  licenses: