ppl 0.3.0 → 0.9.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.
Files changed (97) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +4 -0
  4. data/README.md +1 -3
  5. data/lib/ppl/adapter/storage/disk.rb +27 -7
  6. data/lib/ppl/adapter/storage/factory.rb +26 -0
  7. data/lib/ppl/adapter/storage/git.rb +101 -0
  8. data/lib/ppl/adapter/storage.rb +4 -0
  9. data/lib/ppl/adapter/vcard/vpim.rb +16 -0
  10. data/lib/ppl/application/bootstrap.rb +23 -10
  11. data/lib/ppl/application/command.rb +3 -0
  12. data/lib/ppl/application/command_suite.rb +8 -0
  13. data/lib/ppl/application/configuration.rb +50 -0
  14. data/lib/ppl/application/output.rb +1 -0
  15. data/lib/ppl/application/shell.rb +21 -0
  16. data/lib/ppl/command/add.rb +34 -0
  17. data/lib/ppl/command/bday.rb +72 -0
  18. data/lib/ppl/command/email.rb +55 -0
  19. data/lib/ppl/command/help.rb +43 -0
  20. data/lib/ppl/command/init.rb +26 -0
  21. data/lib/ppl/command/ls.rb +26 -0
  22. data/lib/ppl/command/mv.rb +42 -0
  23. data/lib/ppl/command/name.rb +54 -0
  24. data/lib/ppl/command/org.rb +55 -0
  25. data/lib/ppl/command/phone.rb +55 -0
  26. data/lib/ppl/command/rm.rb +26 -0
  27. data/lib/ppl/command/show.rb +31 -0
  28. data/lib/ppl/entity/contact.rb +2 -0
  29. data/lib/ppl/format/address_book/birthdays.rb +34 -0
  30. data/lib/ppl/format/address_book/email_addresses.rb +34 -0
  31. data/lib/ppl/format/address_book/names.rb +34 -0
  32. data/lib/ppl/format/address_book/one_line.rb +34 -0
  33. data/lib/ppl/format/address_book/organizations.rb +34 -0
  34. data/lib/ppl/format/address_book/phone_numbers.rb +34 -0
  35. data/lib/ppl/format/address_book.rb +9 -0
  36. data/lib/ppl/format/contact/birthday.rb +13 -0
  37. data/lib/ppl/format/contact/email_address.rb +13 -0
  38. data/lib/ppl/format/contact/full.rb +55 -0
  39. data/lib/ppl/format/contact/name.rb +15 -0
  40. data/lib/ppl/format/contact/organization.rb +13 -0
  41. data/lib/ppl/format/contact/phone_number.rb +13 -0
  42. data/lib/ppl/format/contact.rb +9 -0
  43. data/lib/ppl/format/table.rb +48 -0
  44. data/lib/ppl.rb +33 -11
  45. data/ppl.gemspec +1 -1
  46. data/spec/ppl/adapter/storage/disk_spec.rb +57 -10
  47. data/spec/ppl/adapter/storage/factory_spec.rb +34 -0
  48. data/spec/ppl/adapter/storage/git_spec.rb +114 -0
  49. data/spec/ppl/adapter/storage_spec.rb +6 -0
  50. data/spec/ppl/adapter/vcard/vpim_spec.rb +34 -0
  51. data/spec/ppl/application/bootstrap_spec.rb +42 -4
  52. data/spec/ppl/application/command_suite_spec.rb +8 -0
  53. data/spec/ppl/application/configuration_spec.rb +32 -0
  54. data/spec/ppl/application/shell_spec.rb +4 -0
  55. data/spec/ppl/command/{contact_add_spec.rb → add_spec.rb} +2 -2
  56. data/spec/ppl/command/bday_spec.rb +56 -0
  57. data/spec/ppl/command/email_spec.rb +56 -0
  58. data/spec/ppl/command/help_spec.rb +79 -0
  59. data/spec/ppl/command/init_spec.rb +40 -0
  60. data/spec/ppl/command/ls_spec.rb +32 -0
  61. data/spec/ppl/command/mv_spec.rb +62 -0
  62. data/spec/ppl/command/name_spec.rb +59 -0
  63. data/spec/ppl/command/org_spec.rb +57 -0
  64. data/spec/ppl/command/phone_spec.rb +55 -0
  65. data/spec/ppl/command/{contact_delete_spec.rb → rm_spec.rb} +8 -2
  66. data/spec/ppl/command/{contact_show_spec.rb → show_spec.rb} +12 -6
  67. data/spec/ppl/format/address_book/birthdays_spec.rb +38 -0
  68. data/spec/ppl/format/address_book/email_addresses_spec.rb +38 -0
  69. data/spec/ppl/format/address_book/names_spec.rb +38 -0
  70. data/spec/ppl/format/address_book/one_line_spec.rb +41 -0
  71. data/spec/ppl/format/address_book/organizations_spec.rb +38 -0
  72. data/spec/ppl/format/address_book/phone_numbers_spec.rb +38 -0
  73. data/spec/ppl/format/address_book_spec.rb +18 -0
  74. data/spec/ppl/format/contact/birthday_spec.rb +23 -0
  75. data/spec/ppl/format/contact/email_address_spec.rb +23 -0
  76. data/spec/ppl/format/contact/full_spec.rb +44 -0
  77. data/spec/ppl/format/contact/name_spec.rb +23 -0
  78. data/spec/ppl/format/contact/organization_spec.rb +23 -0
  79. data/spec/ppl/format/contact/phone_number_spec.rb +23 -0
  80. data/spec/ppl/format/contact_spec.rb +17 -0
  81. data/spec/ppl/format/table_spec.rb +72 -0
  82. metadata +61 -19
  83. data/lib/ppl/command/command_list.rb +0 -21
  84. data/lib/ppl/command/contact_add.rb +0 -26
  85. data/lib/ppl/command/contact_delete.rb +0 -16
  86. data/lib/ppl/command/contact_list.rb +0 -24
  87. data/lib/ppl/command/contact_rename.rb +0 -23
  88. data/lib/ppl/command/contact_show.rb +0 -20
  89. data/lib/ppl/command/set_birthday.rb +0 -30
  90. data/lib/ppl/command/set_email.rb +0 -23
  91. data/lib/ppl/command/set_name.rb +0 -28
  92. data/spec/ppl/command/command_list_spec.rb +0 -37
  93. data/spec/ppl/command/contact_list_spec.rb +0 -15
  94. data/spec/ppl/command/contact_rename_spec.rb +0 -42
  95. data/spec/ppl/command/set_birthday_spec.rb +0 -50
  96. data/spec/ppl/command/set_email_spec.rb +0 -38
  97. data/spec/ppl/command/set_name_spec.rb +0 -45
@@ -1,28 +0,0 @@
1
-
2
- class Ppl::Command::SetName < Ppl::Application::Command
3
-
4
- def initialize
5
- @name = "name"
6
- @description = "Change a contact's name"
7
- end
8
-
9
- def execute(input, output)
10
-
11
- contact_id = input.arguments.shift
12
- name = input.arguments.shift
13
-
14
- if contact_id.nil? || name.nil?
15
- raise Ppl::Error::IncorrectUsage
16
- end
17
-
18
- contact = @storage.require_contact(contact_id)
19
-
20
- contact.name = name.dup
21
-
22
- storage.save_contact(contact)
23
-
24
- return true
25
- end
26
-
27
- end
28
-
@@ -1,37 +0,0 @@
1
-
2
- describe Ppl::Command::CommandList do
3
-
4
- before(:each) do
5
- @command = Ppl::Command::CommandList.new
6
- @output = double(Ppl::Application::Output)
7
- end
8
-
9
- describe "#command_suite=" do
10
- it "should accept a value" do
11
- suite = Object.new
12
- @command.command_suite = suite
13
- @command.command_suite.should be suite
14
- end
15
- end
16
-
17
- describe "#name" do
18
- it "should be 'help'" do
19
- @command.name.should eq "help"
20
- end
21
- end
22
-
23
- describe "#execute" do
24
- it "should list available commands" do
25
- command = double(Ppl::Application::Command)
26
- command.should_receive(:name).and_return("one")
27
- command.should_receive(:description).and_return("The first command")
28
- @command.command_suite = [command]
29
-
30
- @output.should_receive(:line).with("one: The first command")
31
-
32
- @command.execute(nil, @output)
33
- end
34
- end
35
-
36
- end
37
-
@@ -1,15 +0,0 @@
1
-
2
- describe Ppl::Command::ContactList do
3
-
4
- before(:each) do
5
- @command = Ppl::Command::ContactList.new
6
- end
7
-
8
- describe "#name" do
9
- it "should be 'ls'" do
10
- @command.name.should eq "ls"
11
- end
12
- end
13
-
14
- end
15
-
@@ -1,42 +0,0 @@
1
-
2
- describe Ppl::Command::ContactRename do
3
-
4
- before(:each) do
5
- @input = Ppl::Application::Input.new
6
- @output = Ppl::Application::Output.new(nil, nil)
7
- @contact = Ppl::Entity::Contact.new
8
- @command = Ppl::Command::ContactRename.new
9
- @storage = double(Ppl::Adapter::Storage)
10
-
11
- @command.storage = @storage
12
- @contact.id = "old"
13
- end
14
-
15
- describe "#name" do
16
- it "should be 'mv'" do
17
- @command.name.should eq "mv"
18
- end
19
- end
20
-
21
- describe "#execute" do
22
-
23
- it "should rename the given contact" do
24
- @storage.should_receive(:require_contact).and_return(@contact)
25
-
26
- @storage.should_receive(:delete_contact).with(@contact) do |contact|
27
- contact.id.should eq "old"
28
- end
29
-
30
- @storage.should_receive(:save_contact).with(@contact) do |contact|
31
- contact.id.should eq "new"
32
- end
33
-
34
- @input.arguments = ["old", "new"]
35
-
36
- @command.execute(@input, @output)
37
- end
38
-
39
- end
40
-
41
- end
42
-
@@ -1,50 +0,0 @@
1
-
2
- describe Ppl::Command::SetBirthday do
3
-
4
- before(:each) do
5
- @input = Ppl::Application::Input.new
6
- @output = Ppl::Application::Output.new(nil, nil)
7
- @contact = Ppl::Entity::Contact.new
8
- @command = Ppl::Command::SetBirthday.new
9
- @storage = double(Ppl::Adapter::Storage)
10
-
11
- @command.storage = @storage
12
- @contact.id = "jim"
13
- end
14
-
15
- describe "#name" do
16
- it "should be 'birthday'" do
17
- @command.name.should eq "birthday"
18
- end
19
- end
20
-
21
- describe "#execute" do
22
-
23
- it "should change the contact's birthday" do
24
- @storage.should_receive(:require_contact).and_return(@contact)
25
- @storage.should_receive(:save_contact) do |contact|
26
- contact.birthday.strftime.should eq "1980-01-01"
27
- end
28
- @input.arguments = ["jim", "1980-01-01"]
29
- @command.execute(@input, @output)
30
- end
31
-
32
- it "should raise an error if no contact ID is given" do
33
- @input.arguments = [nil, "1980-01-01"]
34
- expect{@command.execute(@input, @output)}.to raise_error(Ppl::Error::IncorrectUsage)
35
- end
36
-
37
- it "should raise an error if no birthday is given" do
38
- @input.arguments = ["jim"]
39
- expect{@command.execute(@input, @output)}.to raise_error(Ppl::Error::IncorrectUsage)
40
- end
41
-
42
- it "should raise an error if the birthday isn't a valid date" do
43
- @input.arguments = ["jim", "poiuytrewq"]
44
- expect{@command.execute(@input, @output)}.to raise_error(ArgumentError)
45
- end
46
-
47
- end
48
-
49
- end
50
-
@@ -1,38 +0,0 @@
1
-
2
- describe Ppl::Command::SetEmail do
3
-
4
- before(:each) do
5
- @input = Ppl::Application::Input.new
6
- @output = Ppl::Application::Output.new(nil, nil)
7
- @contact = Ppl::Entity::Contact.new
8
- @command = Ppl::Command::SetEmail.new
9
- @storage = double(Ppl::Adapter::Storage)
10
-
11
- @command.storage = @storage
12
- @contact.id = "jim"
13
- end
14
-
15
- describe "#name" do
16
- it "should be 'email'" do
17
- @command.name.should eq "email"
18
- end
19
- end
20
-
21
- describe "#execute" do
22
-
23
- it "should change the contact's email address" do
24
-
25
- @storage.should_receive(:require_contact).and_return(@contact)
26
-
27
- @storage.should_receive(:save_contact) do |contact|
28
- contact.email_address.should eq "jim@example.org"
29
- end
30
-
31
- @input.arguments = ["jim", "jim@example.org"]
32
- @command.execute(@input, @output)
33
- end
34
-
35
- end
36
-
37
- end
38
-
@@ -1,45 +0,0 @@
1
-
2
- describe Ppl::Command::SetName do
3
-
4
- before(:each) do
5
- @input = Ppl::Application::Input.new
6
- @output = Ppl::Application::Output.new(nil, nil)
7
- @contact = Ppl::Entity::Contact.new
8
- @command = Ppl::Command::SetName.new
9
- @storage = double(Ppl::Adapter::Storage)
10
-
11
- @command.storage = @storage
12
- @contact.id = "jim"
13
- end
14
-
15
- describe "#name" do
16
- it "should be 'name'" do
17
- @command.name.should eq "name"
18
- end
19
- end
20
-
21
- describe "#execute" do
22
-
23
- it "should change the contact's name" do
24
- @storage.should_receive(:require_contact).and_return(@contact)
25
- @storage.should_receive(:save_contact) do |contact|
26
- contact.name.should eq "Jim Jamieson"
27
- end
28
- @input.arguments = ["jim", "Jim Jamieson"]
29
- @command.execute(@input, @output)
30
- end
31
-
32
- it "should raise an error if no contact ID is given" do
33
- @input.arguments = [nil, "Jim Jamieson"]
34
- expect{@command.execute(@input, @output)}.to raise_error(Ppl::Error::IncorrectUsage)
35
- end
36
-
37
- it "should raise an error if no name is given" do
38
- @input.arguments = ["jim"]
39
- expect{@command.execute(@input, @output)}.to raise_error(Ppl::Error::IncorrectUsage)
40
- end
41
-
42
- end
43
-
44
- end
45
-