ppl 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ppl/adapter/vcard/vpim.rb +16 -0
- data/lib/ppl/application/bootstrap.rb +1 -0
- data/lib/ppl/command/nick.rb +21 -0
- data/lib/ppl/entity/contact.rb +2 -0
- data/lib/ppl/format/address_book/birthdays.rb +1 -4
- data/lib/ppl/format/address_book/email_addresses.rb +3 -10
- data/lib/ppl/format/address_book/nicknames.rb +27 -0
- data/lib/ppl/format/address_book/urls.rb +2 -9
- data/lib/ppl/format/contact/nicknames.rb +9 -0
- data/lib/ppl.rb +4 -1
- data/ppl.gemspec +2 -2
- data/spec/ppl/adapter/vcard/vpim_spec.rb +17 -0
- data/spec/ppl/application/bootstrap_spec.rb +3 -0
- data/spec/ppl/command/nick_spec.rb +15 -0
- data/spec/ppl/entity/contact_spec.rb +6 -0
- data/spec/ppl/format/address_book/email_addresses_spec.rb +3 -3
- data/spec/ppl/format/address_book/nicknames_spec.rb +38 -0
- data/spec/ppl/format/address_book/urls_spec.rb +1 -1
- data/spec/ppl/format/contact/nicknames_spec.rb +23 -0
- metadata +14 -8
@@ -18,6 +18,7 @@ class Ppl::Adapter::Vcard::Vpim
|
|
18
18
|
encode_name(contact, maker)
|
19
19
|
encode_email_addresses(contact, maker)
|
20
20
|
encode_phone_numbers(contact, maker)
|
21
|
+
encode_nicknames(contact, maker)
|
21
22
|
encode_organizations(contact, maker)
|
22
23
|
encode_postal_address(contact, maker)
|
23
24
|
encode_urls(contact, maker)
|
@@ -32,6 +33,7 @@ class Ppl::Adapter::Vcard::Vpim
|
|
32
33
|
decode_email_addresses(vcard, contact)
|
33
34
|
decode_phone_numbers(vcard, contact)
|
34
35
|
decode_postal_address(vcard, contact)
|
36
|
+
decode_nicknames(vcard, contact)
|
35
37
|
decode_organizations(vcard, contact)
|
36
38
|
decode_name(vcard, contact)
|
37
39
|
decode_urls(vcard, contact)
|
@@ -89,6 +91,10 @@ class Ppl::Adapter::Vcard::Vpim
|
|
89
91
|
contact.urls.each { |url| vcard_maker.add_url(url) }
|
90
92
|
end
|
91
93
|
|
94
|
+
def encode_nicknames(contact, vcard_maker)
|
95
|
+
vcard_maker.nickname = contact.nicknames
|
96
|
+
end
|
97
|
+
|
92
98
|
def decode_birthday(vcard, contact)
|
93
99
|
contact.birthday = vcard.birthday unless vcard.birthday.nil?
|
94
100
|
end
|
@@ -132,5 +138,15 @@ class Ppl::Adapter::Vcard::Vpim
|
|
132
138
|
vcard.urls.each { |url| contact.urls.push(url.uri) }
|
133
139
|
end
|
134
140
|
|
141
|
+
def decode_nicknames(vcard, contact)
|
142
|
+
# There appears to be a minor vpim bug here: vpim allows us to save an array
|
143
|
+
# of nicknames but sees it as one big single nickname when decoding. This
|
144
|
+
# code is here to work around that issue by "finishing the job".
|
145
|
+
nicknames = vcard.nicknames.first
|
146
|
+
if !nicknames.nil?
|
147
|
+
nicknames.split(";").each{ |nickname| contact.nicknames.push(nickname) }
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
135
151
|
end
|
136
152
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
class Ppl::Command::Nick < Ppl::Command::Attribute
|
3
|
+
|
4
|
+
name "nick"
|
5
|
+
description "List, show or change nicknames"
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@attribute = :nicknames
|
9
|
+
@show_format = Ppl::Format::Contact::Nicknames.new
|
10
|
+
@list_format = Ppl::Format::AddressBook::Nicknames.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def options(parser, options)
|
14
|
+
parser.banner = "usage: ppl nick <contact> [<nickname>]"
|
15
|
+
parser.on("-d", "--delete", "delete nickname") do
|
16
|
+
options[:delete] = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
data/lib/ppl/entity/contact.rb
CHANGED
@@ -3,6 +3,7 @@ class Ppl::Entity::Contact
|
|
3
3
|
|
4
4
|
attr_accessor :id
|
5
5
|
attr_accessor :name
|
6
|
+
attr_accessor :nicknames
|
6
7
|
attr_accessor :email_addresses
|
7
8
|
attr_accessor :birthday
|
8
9
|
attr_accessor :phone_numbers
|
@@ -12,6 +13,7 @@ class Ppl::Entity::Contact
|
|
12
13
|
|
13
14
|
def initialize
|
14
15
|
@email_addresses = []
|
16
|
+
@nicknames = []
|
15
17
|
@organizations = []
|
16
18
|
@phone_numbers = []
|
17
19
|
@urls = []
|
@@ -16,15 +16,12 @@ class Ppl::Format::AddressBook::Birthdays < Ppl::Format::AddressBook
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def add_row(contact)
|
19
|
-
id = sprintf("%s:", contact.id)
|
20
19
|
birthday = nil
|
21
|
-
|
22
20
|
if !contact.birthday.nil?
|
23
21
|
birthday = contact.birthday.strftime("%Y-%m-%d")
|
24
22
|
end
|
25
|
-
|
26
23
|
@table.add_row({
|
27
|
-
:id => id,
|
24
|
+
:id => sprintf("%s:", contact.id),
|
28
25
|
:birthday => birthday,
|
29
26
|
})
|
30
27
|
end
|
@@ -4,7 +4,7 @@ class Ppl::Format::AddressBook::EmailAddresses < Ppl::Format::AddressBook
|
|
4
4
|
attr_writer :table
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
@table = Ppl::Format::Table.new([:
|
7
|
+
@table = Ppl::Format::Table.new([:contact_id, :email_addresses])
|
8
8
|
end
|
9
9
|
|
10
10
|
def process(address_book)
|
@@ -16,16 +16,9 @@ class Ppl::Format::AddressBook::EmailAddresses < Ppl::Format::AddressBook
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def add_row(contact)
|
19
|
-
id = sprintf("%s:", contact.id)
|
20
|
-
email_addresses = nil
|
21
|
-
|
22
|
-
if !contact.email_addresses.empty?
|
23
|
-
email_addresses = contact.email_addresses.join(", ")
|
24
|
-
end
|
25
|
-
|
26
19
|
@table.add_row({
|
27
|
-
:
|
28
|
-
:email_addresses => email_addresses,
|
20
|
+
:contact_id => sprintf("%s:", contact.id),
|
21
|
+
:email_addresses => contact.email_addresses.join(", "),
|
29
22
|
})
|
30
23
|
end
|
31
24
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
class Ppl::Format::AddressBook::Nicknames < Ppl::Format::AddressBook
|
3
|
+
|
4
|
+
attr_writer :table
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@table = Ppl::Format::Table.new([:id, :nicknames])
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(address_book)
|
11
|
+
address_book.contacts.each { |contact| add_row(contact) }
|
12
|
+
@table.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def add_row(contact)
|
19
|
+
@table.add_row({
|
20
|
+
:id => sprintf("%s:", contact.id),
|
21
|
+
:nicknames => contact.nicknames.join(", "),
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -16,16 +16,9 @@ class Ppl::Format::AddressBook::Urls < Ppl::Format::AddressBook
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def add_row(contact)
|
19
|
-
id = sprintf("%s:", contact.id)
|
20
|
-
urls = nil
|
21
|
-
|
22
|
-
if !contact.urls.empty?
|
23
|
-
urls = contact.urls.join(", ")
|
24
|
-
end
|
25
|
-
|
26
19
|
@table.add_row({
|
27
|
-
:id => id,
|
28
|
-
:urls => urls,
|
20
|
+
:id => sprintf("%s:", contact.id),
|
21
|
+
:urls => contact.urls.join(", "),
|
29
22
|
})
|
30
23
|
end
|
31
24
|
|
data/lib/ppl.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module Ppl
|
3
3
|
|
4
|
-
Version = "1.
|
4
|
+
Version = "1.11.0"
|
5
5
|
|
6
6
|
module Adapter
|
7
7
|
end
|
@@ -50,6 +50,7 @@ require "ppl/command/help"
|
|
50
50
|
require "ppl/command/show"
|
51
51
|
require "ppl/command/mv"
|
52
52
|
require "ppl/command/name"
|
53
|
+
require "ppl/command/nick"
|
53
54
|
require "ppl/command/email"
|
54
55
|
require "ppl/command/org"
|
55
56
|
require "ppl/command/phone"
|
@@ -72,6 +73,7 @@ require "ppl/format/address_book/email_addresses"
|
|
72
73
|
require "ppl/format/address_book/mutt_query"
|
73
74
|
require "ppl/format/address_book/names"
|
74
75
|
require "ppl/format/address_book/one_line"
|
76
|
+
require "ppl/format/address_book/nicknames"
|
75
77
|
require "ppl/format/address_book/organizations"
|
76
78
|
require "ppl/format/address_book/phone_numbers"
|
77
79
|
require "ppl/format/address_book/postal_addresses"
|
@@ -81,6 +83,7 @@ require "ppl/format/contact/birthday"
|
|
81
83
|
require "ppl/format/contact/email_addresses"
|
82
84
|
require "ppl/format/contact/full"
|
83
85
|
require "ppl/format/contact/name"
|
86
|
+
require "ppl/format/contact/nicknames"
|
84
87
|
require "ppl/format/contact/organization"
|
85
88
|
require "ppl/format/contact/phone_number"
|
86
89
|
require "ppl/format/contact/postal_address"
|
data/ppl.gemspec
CHANGED
@@ -73,6 +73,11 @@ describe Ppl::Adapter::Vcard::Vpim, "#encode" do
|
|
73
73
|
@adapter.encode(@contact).should include("URL:http://google.com")
|
74
74
|
end
|
75
75
|
|
76
|
+
it "should encode the contact's nickname" do
|
77
|
+
@contact.nicknames.push "Sleepy"
|
78
|
+
@adapter.encode(@contact).should include("NICKNAME:Sleepy")
|
79
|
+
end
|
80
|
+
|
76
81
|
end
|
77
82
|
|
78
83
|
|
@@ -237,5 +242,17 @@ describe Ppl::Adapter::Vcard::Vpim, "#decode" do
|
|
237
242
|
contact.urls.first.should eq "http://google.com"
|
238
243
|
end
|
239
244
|
|
245
|
+
it "should decode the contact's nickame" do
|
246
|
+
vcard = [
|
247
|
+
"BEGIN:VCARD",
|
248
|
+
"N:,test",
|
249
|
+
"VERSION:3.0",
|
250
|
+
"NICKNAME:Happy;Cheerful",
|
251
|
+
"END:VCARD",
|
252
|
+
].join("\n")
|
253
|
+
contact = @adapter.decode(vcard)
|
254
|
+
contact.nicknames.first.should eq "Happy"
|
255
|
+
end
|
256
|
+
|
240
257
|
end
|
241
258
|
|
@@ -57,6 +57,9 @@ describe Ppl::Application::Bootstrap do
|
|
57
57
|
it "should contain the 'name' command" do
|
58
58
|
@bootstrap.command_suite.find_command("name").should_not be nil
|
59
59
|
end
|
60
|
+
it "should contain the 'nick' command" do
|
61
|
+
@bootstrap.command_suite.find_command("nick").should_not be nil
|
62
|
+
end
|
60
63
|
it "should contain the 'org' command" do
|
61
64
|
@bootstrap.command_suite.find_command("org").should_not be nil
|
62
65
|
end
|
@@ -52,6 +52,12 @@ describe Ppl::Entity::Contact do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
describe "#nicknames" do
|
56
|
+
it "should return an array" do
|
57
|
+
@contact.nicknames.should be_a(Array)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
55
61
|
describe "#organizations" do
|
56
62
|
it "should return an array" do
|
57
63
|
@contact.organizations.should be_a(Array)
|
@@ -17,8 +17,8 @@ describe Ppl::Format::AddressBook::EmailAddresses do
|
|
17
17
|
|
18
18
|
it "should at least show the contact's id" do
|
19
19
|
@table.should_receive(:add_row).with({
|
20
|
-
:
|
21
|
-
:email_addresses =>
|
20
|
+
:contact_id => "test:",
|
21
|
+
:email_addresses => "",
|
22
22
|
})
|
23
23
|
@format.process(@address_book)
|
24
24
|
end
|
@@ -26,7 +26,7 @@ describe Ppl::Format::AddressBook::EmailAddresses do
|
|
26
26
|
it "should show an email address if it's available" do
|
27
27
|
@contact.email_addresses.push "jdoe@example.org"
|
28
28
|
@table.should_receive(:add_row).with({
|
29
|
-
:
|
29
|
+
:contact_id => "test:",
|
30
30
|
:email_addresses => "jdoe@example.org",
|
31
31
|
})
|
32
32
|
@format.process(@address_book)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::AddressBook::Nicknames do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::AddressBook::Nicknames.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.contacts.push(@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
|
+
:nicknames => "",
|
22
|
+
})
|
23
|
+
@format.process(@address_book)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should show a nickname if it's available" do
|
27
|
+
@contact.nicknames.push("Stupid")
|
28
|
+
@table.should_receive(:add_row).with({
|
29
|
+
:id => "test:",
|
30
|
+
:nicknames => "Stupid",
|
31
|
+
})
|
32
|
+
@format.process(@address_book)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::Nicknames do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::Nicknames.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 nickname" do
|
12
|
+
@format.process(Ppl::Entity::Contact.new).should eq ""
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return the contact's nickname if one is set" do
|
16
|
+
@contact.nicknames.push("Dopey")
|
17
|
+
@format.process(@contact).should eq "Dopey"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
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: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: inifile
|
16
|
-
requirement: &
|
16
|
+
requirement: &12830980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.0.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *12830980
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rugged
|
27
|
-
requirement: &
|
27
|
+
requirement: &12830520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.17.0.b6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *12830520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: vpim
|
38
|
-
requirement: &
|
38
|
+
requirement: &12830060 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - =
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0.695'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *12830060
|
47
47
|
description: CLI Address Book
|
48
48
|
email: henry@henrysmith.org
|
49
49
|
executables:
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/ppl/command/mutt.rb
|
85
85
|
- lib/ppl/command/mv.rb
|
86
86
|
- lib/ppl/command/name.rb
|
87
|
+
- lib/ppl/command/nick.rb
|
87
88
|
- lib/ppl/command/org.rb
|
88
89
|
- lib/ppl/command/phone.rb
|
89
90
|
- lib/ppl/command/post.rb
|
@@ -102,6 +103,7 @@ files:
|
|
102
103
|
- lib/ppl/format/address_book/email_addresses.rb
|
103
104
|
- lib/ppl/format/address_book/mutt_query.rb
|
104
105
|
- lib/ppl/format/address_book/names.rb
|
106
|
+
- lib/ppl/format/address_book/nicknames.rb
|
105
107
|
- lib/ppl/format/address_book/one_line.rb
|
106
108
|
- lib/ppl/format/address_book/organizations.rb
|
107
109
|
- lib/ppl/format/address_book/phone_numbers.rb
|
@@ -112,6 +114,7 @@ files:
|
|
112
114
|
- lib/ppl/format/contact/email_addresses.rb
|
113
115
|
- lib/ppl/format/contact/full.rb
|
114
116
|
- lib/ppl/format/contact/name.rb
|
117
|
+
- lib/ppl/format/contact/nicknames.rb
|
115
118
|
- lib/ppl/format/contact/organization.rb
|
116
119
|
- lib/ppl/format/contact/phone_number.rb
|
117
120
|
- lib/ppl/format/contact/postal_address.rb
|
@@ -144,6 +147,7 @@ files:
|
|
144
147
|
- spec/ppl/command/mutt_spec.rb
|
145
148
|
- spec/ppl/command/mv_spec.rb
|
146
149
|
- spec/ppl/command/name_spec.rb
|
150
|
+
- spec/ppl/command/nick_spec.rb
|
147
151
|
- spec/ppl/command/org_spec.rb
|
148
152
|
- spec/ppl/command/phone_spec.rb
|
149
153
|
- spec/ppl/command/post_spec.rb
|
@@ -159,6 +163,7 @@ files:
|
|
159
163
|
- spec/ppl/format/address_book/email_addresses_spec.rb
|
160
164
|
- spec/ppl/format/address_book/mutt_query_spec.rb
|
161
165
|
- spec/ppl/format/address_book/names_spec.rb
|
166
|
+
- spec/ppl/format/address_book/nicknames_spec.rb
|
162
167
|
- spec/ppl/format/address_book/one_line_spec.rb
|
163
168
|
- spec/ppl/format/address_book/organizations_spec.rb
|
164
169
|
- spec/ppl/format/address_book/phone_numbers_spec.rb
|
@@ -169,6 +174,7 @@ files:
|
|
169
174
|
- spec/ppl/format/contact/email_addresses_spec.rb
|
170
175
|
- spec/ppl/format/contact/full_spec.rb
|
171
176
|
- spec/ppl/format/contact/name_spec.rb
|
177
|
+
- spec/ppl/format/contact/nicknames_spec.rb
|
172
178
|
- spec/ppl/format/contact/organization_spec.rb
|
173
179
|
- spec/ppl/format/contact/phone_number_spec.rb
|
174
180
|
- spec/ppl/format/contact/postal_address_spec.rb
|