ppl 0.3.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +4 -0
- data/README.md +1 -3
- data/lib/ppl/adapter/storage/disk.rb +27 -7
- data/lib/ppl/adapter/storage/factory.rb +26 -0
- data/lib/ppl/adapter/storage/git.rb +101 -0
- data/lib/ppl/adapter/storage.rb +4 -0
- data/lib/ppl/adapter/vcard/vpim.rb +16 -0
- data/lib/ppl/application/bootstrap.rb +23 -10
- data/lib/ppl/application/command.rb +3 -0
- data/lib/ppl/application/command_suite.rb +8 -0
- data/lib/ppl/application/configuration.rb +50 -0
- data/lib/ppl/application/output.rb +1 -0
- data/lib/ppl/application/shell.rb +21 -0
- data/lib/ppl/command/add.rb +34 -0
- data/lib/ppl/command/bday.rb +72 -0
- data/lib/ppl/command/email.rb +55 -0
- data/lib/ppl/command/help.rb +43 -0
- data/lib/ppl/command/init.rb +26 -0
- data/lib/ppl/command/ls.rb +26 -0
- data/lib/ppl/command/mv.rb +42 -0
- data/lib/ppl/command/name.rb +54 -0
- data/lib/ppl/command/org.rb +55 -0
- data/lib/ppl/command/phone.rb +55 -0
- data/lib/ppl/command/rm.rb +26 -0
- data/lib/ppl/command/show.rb +31 -0
- data/lib/ppl/entity/contact.rb +2 -0
- data/lib/ppl/format/address_book/birthdays.rb +34 -0
- data/lib/ppl/format/address_book/email_addresses.rb +34 -0
- data/lib/ppl/format/address_book/names.rb +34 -0
- data/lib/ppl/format/address_book/one_line.rb +34 -0
- data/lib/ppl/format/address_book/organizations.rb +34 -0
- data/lib/ppl/format/address_book/phone_numbers.rb +34 -0
- data/lib/ppl/format/address_book.rb +9 -0
- data/lib/ppl/format/contact/birthday.rb +13 -0
- data/lib/ppl/format/contact/email_address.rb +13 -0
- data/lib/ppl/format/contact/full.rb +55 -0
- data/lib/ppl/format/contact/name.rb +15 -0
- data/lib/ppl/format/contact/organization.rb +13 -0
- data/lib/ppl/format/contact/phone_number.rb +13 -0
- data/lib/ppl/format/contact.rb +9 -0
- data/lib/ppl/format/table.rb +48 -0
- data/lib/ppl.rb +33 -11
- data/ppl.gemspec +1 -1
- data/spec/ppl/adapter/storage/disk_spec.rb +57 -10
- data/spec/ppl/adapter/storage/factory_spec.rb +34 -0
- data/spec/ppl/adapter/storage/git_spec.rb +114 -0
- data/spec/ppl/adapter/storage_spec.rb +6 -0
- data/spec/ppl/adapter/vcard/vpim_spec.rb +34 -0
- data/spec/ppl/application/bootstrap_spec.rb +42 -4
- data/spec/ppl/application/command_suite_spec.rb +8 -0
- data/spec/ppl/application/configuration_spec.rb +32 -0
- data/spec/ppl/application/shell_spec.rb +4 -0
- data/spec/ppl/command/{contact_add_spec.rb → add_spec.rb} +2 -2
- data/spec/ppl/command/bday_spec.rb +56 -0
- data/spec/ppl/command/email_spec.rb +56 -0
- data/spec/ppl/command/help_spec.rb +79 -0
- data/spec/ppl/command/init_spec.rb +40 -0
- data/spec/ppl/command/ls_spec.rb +32 -0
- data/spec/ppl/command/mv_spec.rb +62 -0
- data/spec/ppl/command/name_spec.rb +59 -0
- data/spec/ppl/command/org_spec.rb +57 -0
- data/spec/ppl/command/phone_spec.rb +55 -0
- data/spec/ppl/command/{contact_delete_spec.rb → rm_spec.rb} +8 -2
- data/spec/ppl/command/{contact_show_spec.rb → show_spec.rb} +12 -6
- data/spec/ppl/format/address_book/birthdays_spec.rb +38 -0
- data/spec/ppl/format/address_book/email_addresses_spec.rb +38 -0
- data/spec/ppl/format/address_book/names_spec.rb +38 -0
- data/spec/ppl/format/address_book/one_line_spec.rb +41 -0
- data/spec/ppl/format/address_book/organizations_spec.rb +38 -0
- data/spec/ppl/format/address_book/phone_numbers_spec.rb +38 -0
- data/spec/ppl/format/address_book_spec.rb +18 -0
- data/spec/ppl/format/contact/birthday_spec.rb +23 -0
- data/spec/ppl/format/contact/email_address_spec.rb +23 -0
- data/spec/ppl/format/contact/full_spec.rb +44 -0
- data/spec/ppl/format/contact/name_spec.rb +23 -0
- data/spec/ppl/format/contact/organization_spec.rb +23 -0
- data/spec/ppl/format/contact/phone_number_spec.rb +23 -0
- data/spec/ppl/format/contact_spec.rb +17 -0
- data/spec/ppl/format/table_spec.rb +72 -0
- metadata +61 -19
- data/lib/ppl/command/command_list.rb +0 -21
- data/lib/ppl/command/contact_add.rb +0 -26
- data/lib/ppl/command/contact_delete.rb +0 -16
- data/lib/ppl/command/contact_list.rb +0 -24
- data/lib/ppl/command/contact_rename.rb +0 -23
- data/lib/ppl/command/contact_show.rb +0 -20
- data/lib/ppl/command/set_birthday.rb +0 -30
- data/lib/ppl/command/set_email.rb +0 -23
- data/lib/ppl/command/set_name.rb +0 -28
- data/spec/ppl/command/command_list_spec.rb +0 -37
- data/spec/ppl/command/contact_list_spec.rb +0 -15
- data/spec/ppl/command/contact_rename_spec.rb +0 -42
- data/spec/ppl/command/set_birthday_spec.rb +0 -50
- data/spec/ppl/command/set_email_spec.rb +0 -38
- data/spec/ppl/command/set_name_spec.rb +0 -45
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::AddressBook::Organizations do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::AddressBook::Organizations.new
|
6
|
+
@address_book = Ppl::Entity::AddressBook.new
|
7
|
+
@contact = Ppl::Entity::Contact.new
|
8
|
+
@table = double(Ppl::Format::Table)
|
9
|
+
|
10
|
+
@contact.id = "test"
|
11
|
+
@format.table = @table
|
12
|
+
|
13
|
+
@address_book.add_contact(@contact)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#process" do
|
17
|
+
|
18
|
+
it "should at least show the contact's id" do
|
19
|
+
@table.should_receive(:add_row).with({
|
20
|
+
:id => "test:",
|
21
|
+
:organization => nil,
|
22
|
+
})
|
23
|
+
@format.process(@address_book)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should show the organization if it's available" do
|
27
|
+
@contact.organization = "Example Ltd"
|
28
|
+
@table.should_receive(:add_row).with({
|
29
|
+
:id => "test:",
|
30
|
+
:organization => "Example Ltd",
|
31
|
+
})
|
32
|
+
@format.process(@address_book)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::AddressBook::PhoneNumbers do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::AddressBook::PhoneNumbers.new
|
6
|
+
@address_book = Ppl::Entity::AddressBook.new
|
7
|
+
@contact = Ppl::Entity::Contact.new
|
8
|
+
@table = double(Ppl::Format::Table)
|
9
|
+
|
10
|
+
@contact.id = "test"
|
11
|
+
@format.table = @table
|
12
|
+
|
13
|
+
@address_book.add_contact(@contact)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#process" do
|
17
|
+
|
18
|
+
it "should at least show the contact's id" do
|
19
|
+
@table.should_receive(:add_row).with({
|
20
|
+
:id => "test:",
|
21
|
+
:phone_number => nil,
|
22
|
+
})
|
23
|
+
@format.process(@address_book)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should show the phone number if it's available" do
|
27
|
+
@contact.phone_number = "01234567890"
|
28
|
+
@table.should_receive(:add_row).with({
|
29
|
+
:id => "test:",
|
30
|
+
:phone_number => "01234567890",
|
31
|
+
})
|
32
|
+
@format.process(@address_book)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::AddressBook do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::AddressBook.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#process" do
|
9
|
+
|
10
|
+
it "should raise a NotImplementedError" do
|
11
|
+
expect{@format.process(nil)}.to raise_error(NotImplementedError)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::Birthday do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::Birthday.new
|
6
|
+
@contact = Ppl::Entity::Contact.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#process" do
|
10
|
+
|
11
|
+
it "should return an empty string if the contact lacks a birthday" do
|
12
|
+
@format.process(Ppl::Entity::Contact.new).should eq ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the contact's birthday if it is set" do
|
16
|
+
@contact.birthday = Date.parse("1970-01-01")
|
17
|
+
@format.process(@contact).should eq "1970-01-01"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::EmailAddress do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::EmailAddress.new
|
6
|
+
@contact = Ppl::Entity::Contact.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#process" do
|
10
|
+
|
11
|
+
it "should return an empty string if the contact lacks an email address" do
|
12
|
+
@format.process(Ppl::Entity::Contact.new).should eq ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the contact's email address if it is set" do
|
16
|
+
@contact.email_address = "jdoe@example.org"
|
17
|
+
@format.process(@contact).should eq "jdoe@example.org"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::Full do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::Full.new
|
6
|
+
@contact = Ppl::Entity::Contact.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#process" do
|
10
|
+
|
11
|
+
it "should return an empty string if the contact lacks any properties" do
|
12
|
+
@format.process(Ppl::Entity::Contact.new).should eq ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should start with the contact's name" do
|
16
|
+
@contact.name = "John Doe"
|
17
|
+
@format.process(@contact).should eq "John Doe"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should include their email address in brackets" do
|
21
|
+
@contact.name = "John Doe"
|
22
|
+
@contact.email_address = "john@example.org"
|
23
|
+
@format.process(@contact).should eq "John Doe <john@example.org>"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should show their birthday if available" do
|
27
|
+
@contact.birthday = Date.parse("1980-01-01")
|
28
|
+
@format.process(@contact).should include "1980-01-01"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should show their phone number if available" do
|
32
|
+
@contact.phone_number = "01234567890"
|
33
|
+
@format.process(@contact).should include "01234567890"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should show their organization if available" do
|
37
|
+
@contact.organization = "Example Ltd"
|
38
|
+
@format.process(@contact).should include "Example Ltd"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::Name do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::Name.new
|
6
|
+
@contact = Ppl::Entity::Contact.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#process" do
|
10
|
+
|
11
|
+
it "should return an empty string if the contact lacks a name" do
|
12
|
+
@format.process(Ppl::Entity::Contact.new).should eq ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the contact's name if it is set" do
|
16
|
+
@contact.name = "John Doe"
|
17
|
+
@format.process(@contact).should eq "John Doe"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::Organization do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::Organization.new
|
6
|
+
@contact = Ppl::Entity::Contact.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#process" do
|
10
|
+
|
11
|
+
it "should return an empty string if the contact lacks an organization" do
|
12
|
+
@format.process(Ppl::Entity::Contact.new).should eq ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the contact's organization if it is set" do
|
16
|
+
@contact.organization = "Example Ltd"
|
17
|
+
@format.process(@contact).should eq "Example Ltd"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::PhoneNumber do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::PhoneNumber.new
|
6
|
+
@contact = Ppl::Entity::Contact.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#process" do
|
10
|
+
|
11
|
+
it "should return an empty string if the contact lacks a phone number" do
|
12
|
+
@format.process(Ppl::Entity::Contact.new).should eq ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the contact's phone number if it is set" do
|
16
|
+
@contact.phone_number = "0123456789"
|
17
|
+
@format.process(@contact).should eq "0123456789"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#process" do
|
9
|
+
|
10
|
+
it "should raise a NotImplementedError" do
|
11
|
+
expect{@format.process(nil)}.to raise_error(NotImplementedError)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Table do
|
3
|
+
|
4
|
+
describe "#initialize" do
|
5
|
+
it "should accept an array of columns" do
|
6
|
+
@table = Ppl::Format::Table.new([
|
7
|
+
:id,
|
8
|
+
:name,
|
9
|
+
:email,
|
10
|
+
])
|
11
|
+
@table.columns.length.should eq 3
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe Ppl::Format::Table do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@table = Ppl::Format::Table.new([
|
21
|
+
:id,
|
22
|
+
:name,
|
23
|
+
:email,
|
24
|
+
])
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#add_row" do
|
28
|
+
it "should accept a hash" do
|
29
|
+
@table.add_row({
|
30
|
+
:id => 12345,
|
31
|
+
:name => "John Doe",
|
32
|
+
:email => "jdoe@example.org",
|
33
|
+
})
|
34
|
+
@table.rows.length.should eq 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#to_s" do
|
39
|
+
|
40
|
+
it "should return an empty string if the table is empty" do
|
41
|
+
@table.to_s.should eq ""
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return a string represenation of its rows" do
|
45
|
+
@table.add_row({
|
46
|
+
:id => 12345,
|
47
|
+
:name => "John Doe",
|
48
|
+
:email => "jdoe@example.org",
|
49
|
+
})
|
50
|
+
@table.to_s.should eq "12345 John Doe jdoe@example.org"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should align multiple rows into neat columns" do
|
54
|
+
@table.add_row({
|
55
|
+
:id => 12345,
|
56
|
+
:name => "John Doe",
|
57
|
+
:email => "jdoe@example.org",
|
58
|
+
})
|
59
|
+
@table.add_row({
|
60
|
+
:id => 123,
|
61
|
+
:name => "Luis Ignacio Lula da Silva",
|
62
|
+
:email => "lula@planalto.biz",
|
63
|
+
})
|
64
|
+
|
65
|
+
@table.to_s.should include "12345 John Doe jdoe@example.org"
|
66
|
+
@table.to_s.should include "123 Luis Ignacio Lula da Silva lula@planalto.biz"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -29,51 +29,93 @@ files:
|
|
29
29
|
- lib/ppl.rb
|
30
30
|
- lib/ppl/adapter/storage.rb
|
31
31
|
- lib/ppl/adapter/storage/disk.rb
|
32
|
+
- lib/ppl/adapter/storage/factory.rb
|
33
|
+
- lib/ppl/adapter/storage/git.rb
|
32
34
|
- lib/ppl/adapter/vcard.rb
|
33
35
|
- lib/ppl/adapter/vcard/vpim.rb
|
34
36
|
- lib/ppl/application/bootstrap.rb
|
35
37
|
- lib/ppl/application/command.rb
|
36
38
|
- lib/ppl/application/command_suite.rb
|
39
|
+
- lib/ppl/application/configuration.rb
|
37
40
|
- lib/ppl/application/input.rb
|
38
41
|
- lib/ppl/application/output.rb
|
39
42
|
- lib/ppl/application/router.rb
|
40
43
|
- lib/ppl/application/shell.rb
|
41
|
-
- lib/ppl/command/
|
42
|
-
- lib/ppl/command/
|
43
|
-
- lib/ppl/command/
|
44
|
-
- lib/ppl/command/
|
45
|
-
- lib/ppl/command/
|
46
|
-
- lib/ppl/command/
|
47
|
-
- lib/ppl/command/
|
48
|
-
- lib/ppl/command/
|
49
|
-
- lib/ppl/command/
|
44
|
+
- lib/ppl/command/add.rb
|
45
|
+
- lib/ppl/command/bday.rb
|
46
|
+
- lib/ppl/command/email.rb
|
47
|
+
- lib/ppl/command/help.rb
|
48
|
+
- lib/ppl/command/init.rb
|
49
|
+
- lib/ppl/command/ls.rb
|
50
|
+
- lib/ppl/command/mv.rb
|
51
|
+
- lib/ppl/command/name.rb
|
52
|
+
- lib/ppl/command/org.rb
|
53
|
+
- lib/ppl/command/phone.rb
|
54
|
+
- lib/ppl/command/rm.rb
|
55
|
+
- lib/ppl/command/show.rb
|
50
56
|
- lib/ppl/entity/address_book.rb
|
51
57
|
- lib/ppl/entity/contact.rb
|
52
58
|
- lib/ppl/error/contact_not_found.rb
|
53
59
|
- lib/ppl/error/incorrect_usage.rb
|
60
|
+
- lib/ppl/format/address_book.rb
|
61
|
+
- lib/ppl/format/address_book/birthdays.rb
|
62
|
+
- lib/ppl/format/address_book/email_addresses.rb
|
63
|
+
- lib/ppl/format/address_book/names.rb
|
64
|
+
- lib/ppl/format/address_book/one_line.rb
|
65
|
+
- lib/ppl/format/address_book/organizations.rb
|
66
|
+
- lib/ppl/format/address_book/phone_numbers.rb
|
67
|
+
- lib/ppl/format/contact.rb
|
68
|
+
- lib/ppl/format/contact/birthday.rb
|
69
|
+
- lib/ppl/format/contact/email_address.rb
|
70
|
+
- lib/ppl/format/contact/full.rb
|
71
|
+
- lib/ppl/format/contact/name.rb
|
72
|
+
- lib/ppl/format/contact/organization.rb
|
73
|
+
- lib/ppl/format/contact/phone_number.rb
|
74
|
+
- lib/ppl/format/table.rb
|
54
75
|
- ppl.gemspec
|
55
76
|
- spec/ppl/adapter/output_spec.rb
|
56
77
|
- spec/ppl/adapter/storage/disk_spec.rb
|
78
|
+
- spec/ppl/adapter/storage/factory_spec.rb
|
79
|
+
- spec/ppl/adapter/storage/git_spec.rb
|
57
80
|
- spec/ppl/adapter/storage_spec.rb
|
58
81
|
- spec/ppl/adapter/vcard/vpim_spec.rb
|
59
82
|
- spec/ppl/adapter/vcard_spec.rb
|
60
83
|
- spec/ppl/application/bootstrap_spec.rb
|
61
84
|
- spec/ppl/application/command_spec.rb
|
62
85
|
- spec/ppl/application/command_suite_spec.rb
|
86
|
+
- spec/ppl/application/configuration_spec.rb
|
63
87
|
- spec/ppl/application/input_spec.rb
|
64
88
|
- spec/ppl/application/router_spec.rb
|
65
89
|
- spec/ppl/application/shell_spec.rb
|
66
|
-
- spec/ppl/command/
|
67
|
-
- spec/ppl/command/
|
68
|
-
- spec/ppl/command/
|
69
|
-
- spec/ppl/command/
|
70
|
-
- spec/ppl/command/
|
71
|
-
- spec/ppl/command/
|
72
|
-
- spec/ppl/command/
|
73
|
-
- spec/ppl/command/
|
74
|
-
- spec/ppl/command/
|
90
|
+
- spec/ppl/command/add_spec.rb
|
91
|
+
- spec/ppl/command/bday_spec.rb
|
92
|
+
- spec/ppl/command/email_spec.rb
|
93
|
+
- spec/ppl/command/help_spec.rb
|
94
|
+
- spec/ppl/command/init_spec.rb
|
95
|
+
- spec/ppl/command/ls_spec.rb
|
96
|
+
- spec/ppl/command/mv_spec.rb
|
97
|
+
- spec/ppl/command/name_spec.rb
|
98
|
+
- spec/ppl/command/org_spec.rb
|
99
|
+
- spec/ppl/command/phone_spec.rb
|
100
|
+
- spec/ppl/command/rm_spec.rb
|
101
|
+
- spec/ppl/command/show_spec.rb
|
75
102
|
- spec/ppl/entity/address_book_spec.rb
|
76
103
|
- spec/ppl/entity/contact_spec.rb
|
104
|
+
- spec/ppl/format/address_book/birthdays_spec.rb
|
105
|
+
- spec/ppl/format/address_book/email_addresses_spec.rb
|
106
|
+
- spec/ppl/format/address_book/names_spec.rb
|
107
|
+
- spec/ppl/format/address_book/one_line_spec.rb
|
108
|
+
- spec/ppl/format/address_book/organizations_spec.rb
|
109
|
+
- spec/ppl/format/address_book/phone_numbers_spec.rb
|
110
|
+
- spec/ppl/format/address_book_spec.rb
|
111
|
+
- spec/ppl/format/contact/birthday_spec.rb
|
112
|
+
- spec/ppl/format/contact/email_address_spec.rb
|
113
|
+
- spec/ppl/format/contact/full_spec.rb
|
114
|
+
- spec/ppl/format/contact/name_spec.rb
|
115
|
+
- spec/ppl/format/contact/organization_spec.rb
|
116
|
+
- spec/ppl/format/contact/phone_number_spec.rb
|
117
|
+
- spec/ppl/format/contact_spec.rb
|
118
|
+
- spec/ppl/format/table_spec.rb
|
77
119
|
- spec/spec_helper.rb
|
78
120
|
homepage: https://github.com/h2s/ppl
|
79
121
|
licenses:
|
@@ -1,21 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::CommandList < Ppl::Application::Command
|
3
|
-
|
4
|
-
attr_accessor :command_suite
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@name = "help"
|
8
|
-
@description = "Show a list of commands"
|
9
|
-
end
|
10
|
-
|
11
|
-
def execute(input, output)
|
12
|
-
@command_suite.each do |command|
|
13
|
-
name = command.name
|
14
|
-
description = command.description
|
15
|
-
output.line("#{name}: #{description}")
|
16
|
-
end
|
17
|
-
return true
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::ContactAdd < Ppl::Application::Command
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@name = "add"
|
6
|
-
@description = "Add a new contact"
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(input, output)
|
10
|
-
contact_id = input.arguments.shift
|
11
|
-
contact_name = input.arguments.shift
|
12
|
-
|
13
|
-
if contact_id.nil? || contact_name.nil?
|
14
|
-
raise Ppl::Error::IncorrectUsage
|
15
|
-
end
|
16
|
-
|
17
|
-
contact = Ppl::Entity::Contact.new
|
18
|
-
contact.id = contact_id
|
19
|
-
contact.name = contact_name
|
20
|
-
|
21
|
-
@storage.save_contact(contact)
|
22
|
-
return true
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::ContactDelete < Ppl::Application::Command
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@name = "rm"
|
6
|
-
@description = "Delete a contact"
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(input, output)
|
10
|
-
contact_id = input.arguments.first
|
11
|
-
contact = @storage.require_contact(contact_id)
|
12
|
-
@storage.delete_contact(contact)
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::ContactList < Ppl::Application::Command
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@name = "ls"
|
6
|
-
@description = "List all contacts"
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(input, output)
|
10
|
-
address_book = @storage.load_address_book
|
11
|
-
|
12
|
-
address_book.each do |contact|
|
13
|
-
line = sprintf("%s: %s",
|
14
|
-
contact.id,
|
15
|
-
contact.email_address
|
16
|
-
)
|
17
|
-
output.line(line)
|
18
|
-
end
|
19
|
-
|
20
|
-
return true
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::ContactRename < Ppl::Application::Command
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@name = "mv"
|
6
|
-
@description = "Rename a contact"
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(input, output)
|
10
|
-
old_id = input.arguments.shift
|
11
|
-
new_id = input.arguments.shift
|
12
|
-
contact = @storage.require_contact(old_id)
|
13
|
-
|
14
|
-
@storage.delete_contact(contact)
|
15
|
-
|
16
|
-
contact.id = new_id
|
17
|
-
@storage.save_contact(contact)
|
18
|
-
|
19
|
-
return true
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::ContactShow < Ppl::Application::Command
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@name = "show"
|
6
|
-
@description = "Display the full details of a contact"
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(input, output)
|
10
|
-
contact_id = input.arguments.shift
|
11
|
-
contact = @storage.require_contact(contact_id)
|
12
|
-
|
13
|
-
output.line(contact.name)
|
14
|
-
output.line(contact.email_address)
|
15
|
-
|
16
|
-
return true
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::SetBirthday < Ppl::Application::Command
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@name = "birthday"
|
6
|
-
@description = "Change a contact's birthday"
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(input, output)
|
10
|
-
|
11
|
-
contact_id = input.arguments.shift
|
12
|
-
birthday = input.arguments.shift
|
13
|
-
|
14
|
-
if contact_id.nil? || birthday.nil?
|
15
|
-
raise Ppl::Error::IncorrectUsage
|
16
|
-
end
|
17
|
-
|
18
|
-
birthday = Date.parse birthday
|
19
|
-
|
20
|
-
contact = @storage.require_contact(contact_id)
|
21
|
-
|
22
|
-
contact.birthday = birthday
|
23
|
-
|
24
|
-
storage.save_contact(contact)
|
25
|
-
|
26
|
-
return true
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
@@ -1,23 +0,0 @@
|
|
1
|
-
|
2
|
-
class Ppl::Command::SetEmail < Ppl::Application::Command
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@name = "email"
|
6
|
-
@description = "Change a contact's email address"
|
7
|
-
end
|
8
|
-
|
9
|
-
def execute(input, output)
|
10
|
-
|
11
|
-
contact_id = input.arguments.shift
|
12
|
-
email_address = input.arguments.shift
|
13
|
-
|
14
|
-
contact = @storage.require_contact(contact_id)
|
15
|
-
contact.email_address = email_address
|
16
|
-
|
17
|
-
storage.save_contact(contact)
|
18
|
-
|
19
|
-
return true
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|