ppl 1.1.0 → 1.2.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.
- data/lib/ppl/adapter/vcard/vpim.rb +33 -0
- data/lib/ppl/application/bootstrap.rb +1 -0
- data/lib/ppl/command/post.rb +87 -0
- data/lib/ppl/entity/contact.rb +8 -0
- data/lib/ppl/entity/postal_address.rb +12 -0
- data/lib/ppl/format/address_book/postal_addresses.rb +42 -0
- data/lib/ppl/format/contact/full.rb +11 -0
- data/lib/ppl/format/contact/postal_address.rb +33 -0
- data/lib/ppl.rb +5 -1
- data/ppl.gemspec +2 -2
- data/spec/ppl/adapter/vcard/vpim_spec.rb +108 -0
- data/spec/ppl/application/bootstrap_spec.rb +3 -0
- data/spec/ppl/command/post_spec.rb +111 -0
- data/spec/ppl/entity/contact_spec.rb +6 -0
- data/spec/ppl/entity/postal_address_spec.rb +15 -0
- data/spec/ppl/format/address_book/postal_addresses_spec.rb +40 -0
- data/spec/ppl/format/contact/full_spec.rb +10 -0
- data/spec/ppl/format/contact/postal_address_spec.rb +27 -0
- metadata +16 -8
@@ -27,6 +27,29 @@ class Ppl::Adapter::Vcard::Vpim
|
|
27
27
|
maker.org=(contact.organization)
|
28
28
|
end
|
29
29
|
|
30
|
+
if !contact.postal_address.nil?
|
31
|
+
maker.add_addr do |address|
|
32
|
+
if !contact.postal_address.street.nil?
|
33
|
+
address.street = contact.postal_address.street
|
34
|
+
end
|
35
|
+
if !contact.postal_address.postal_code.nil?
|
36
|
+
address.postalcode = contact.postal_address.postal_code
|
37
|
+
end
|
38
|
+
if !contact.postal_address.po_box.nil?
|
39
|
+
address.pobox = contact.postal_address.po_box
|
40
|
+
end
|
41
|
+
if !contact.postal_address.country.nil?
|
42
|
+
address.country = contact.postal_address.country
|
43
|
+
end
|
44
|
+
if !contact.postal_address.region.nil?
|
45
|
+
address.region = contact.postal_address.region
|
46
|
+
end
|
47
|
+
if !contact.postal_address.locality.nil?
|
48
|
+
address.locality = contact.postal_address.locality
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
30
53
|
end
|
31
54
|
|
32
55
|
return vcard.to_s
|
@@ -48,6 +71,16 @@ class Ppl::Adapter::Vcard::Vpim
|
|
48
71
|
contact.phone_number = vcard.telephones.first
|
49
72
|
end
|
50
73
|
|
74
|
+
if !vcard.address.nil?
|
75
|
+
contact.postal_address = Ppl::Entity::PostalAddress.new
|
76
|
+
contact.postal_address.street = vcard.address.street
|
77
|
+
contact.postal_address.postal_code = vcard.address.postalcode
|
78
|
+
contact.postal_address.po_box = vcard.address.pobox
|
79
|
+
contact.postal_address.locality = vcard.address.locality
|
80
|
+
contact.postal_address.region = vcard.address.region
|
81
|
+
contact.postal_address.country = vcard.address.country
|
82
|
+
end
|
83
|
+
|
51
84
|
if !vcard.org.nil?
|
52
85
|
contact.organization = vcard.org.first
|
53
86
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
|
2
|
+
class Ppl::Command::Post < Ppl::Application::Command
|
3
|
+
|
4
|
+
attr_writer :show_format
|
5
|
+
attr_writer :list_format
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@name = "post"
|
9
|
+
@description = "Show or change a contact's postal address"
|
10
|
+
@show_format = Ppl::Format::Contact::PostalAddress.new
|
11
|
+
@list_format = Ppl::Format::AddressBook::PostalAddresses.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def options(parser, options)
|
15
|
+
parser.banner = "usage: ppl post <contact> [address]"
|
16
|
+
|
17
|
+
parser.on("-s", "--street <street-address>") do |street|
|
18
|
+
options[:street] = street
|
19
|
+
end
|
20
|
+
parser.on("-z", "--postal-code <postal-code>") do |postal_code|
|
21
|
+
options[:postal_code] = postal_code
|
22
|
+
end
|
23
|
+
parser.on("-p", "--po-box <po-box>") do |po_box|
|
24
|
+
options[:po_box] = po_box
|
25
|
+
end
|
26
|
+
parser.on("-l", "--locality <locality>") do |locality|
|
27
|
+
options[:locality] = locality
|
28
|
+
end
|
29
|
+
parser.on("-r", "--region <region>") do |region|
|
30
|
+
options[:region] = region
|
31
|
+
end
|
32
|
+
parser.on("-c", "--country <country>") do |country|
|
33
|
+
options[:country] = country
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(input, output)
|
39
|
+
action = determine_action(input)
|
40
|
+
send(action, input, output)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def determine_action(input)
|
47
|
+
if input.arguments[0].nil?
|
48
|
+
:list_postal_addresses
|
49
|
+
elsif input.options.empty?
|
50
|
+
:show_postal_address
|
51
|
+
else
|
52
|
+
:set_postal_address
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def list_postal_addresses(input, output)
|
57
|
+
address_book = @storage.load_address_book
|
58
|
+
address_list = @list_format.process(address_book)
|
59
|
+
output.line(address_list)
|
60
|
+
end
|
61
|
+
|
62
|
+
def show_postal_address(input, output)
|
63
|
+
contact = @storage.require_contact(input.arguments[0])
|
64
|
+
address = @show_format.process(contact)
|
65
|
+
if address != ""
|
66
|
+
output.line(address)
|
67
|
+
true
|
68
|
+
else
|
69
|
+
false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_postal_address(input, output)
|
74
|
+
contact = @storage.require_contact(input.arguments[0])
|
75
|
+
contact.set_postal_address do |address|
|
76
|
+
address.country = input.options[:country] unless input.options[:country].nil?
|
77
|
+
address.locality = input.options[:locality] unless input.options[:locality].nil?
|
78
|
+
address.region = input.options[:region] unless input.options[:region].nil?
|
79
|
+
address.po_box = input.options[:po_box] unless input.options[:po_box].nil?
|
80
|
+
address.postal_code = input.options[:postal_code] unless input.options[:postal_code].nil?
|
81
|
+
address.street = input.options[:street] unless input.options[:street].nil?
|
82
|
+
end
|
83
|
+
@storage.save_contact(contact)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
data/lib/ppl/entity/contact.rb
CHANGED
@@ -7,6 +7,14 @@ class Ppl::Entity::Contact
|
|
7
7
|
attr_accessor :birthday
|
8
8
|
attr_accessor :phone_number
|
9
9
|
attr_accessor :organization
|
10
|
+
attr_accessor :postal_address
|
11
|
+
|
12
|
+
def set_postal_address
|
13
|
+
if @postal_address.nil?
|
14
|
+
@postal_address = Ppl::Entity::PostalAddress.new
|
15
|
+
end
|
16
|
+
yield @postal_address
|
17
|
+
end
|
10
18
|
|
11
19
|
end
|
12
20
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
class Ppl::Format::AddressBook::PostalAddresses < Ppl::Format::AddressBook
|
3
|
+
|
4
|
+
attr_writer :table
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@table = Ppl::Format::Table.new([:id, :postal_address])
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(address_book)
|
11
|
+
address_book.each { |contact| add_row(contact) }
|
12
|
+
@table.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def add_row(contact)
|
19
|
+
id = sprintf("%s:", contact.id)
|
20
|
+
postal_address = nil
|
21
|
+
|
22
|
+
if !contact.postal_address.nil?
|
23
|
+
pieces = [
|
24
|
+
contact.postal_address.street,
|
25
|
+
contact.postal_address.locality,
|
26
|
+
contact.postal_address.region,
|
27
|
+
contact.postal_address.country,
|
28
|
+
contact.postal_address.postal_code,
|
29
|
+
contact.postal_address.po_box,
|
30
|
+
].select { |property| property != "" && !property.nil? }
|
31
|
+
postal_address = pieces.join(", ")
|
32
|
+
end
|
33
|
+
|
34
|
+
@table.add_row({
|
35
|
+
:id => id,
|
36
|
+
:postal_address => postal_address,
|
37
|
+
})
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -1,6 +1,12 @@
|
|
1
1
|
|
2
2
|
class Ppl::Format::Contact::Full < Ppl::Format::Contact
|
3
3
|
|
4
|
+
attr_writer :postal_address_format
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@postal_address_format = Ppl::Format::Contact::PostalAddress.new
|
8
|
+
end
|
9
|
+
|
4
10
|
def process(contact)
|
5
11
|
lines = []
|
6
12
|
|
@@ -17,6 +23,11 @@ class Ppl::Format::Contact::Full < Ppl::Format::Contact
|
|
17
23
|
lines.push("")
|
18
24
|
end
|
19
25
|
|
26
|
+
if !contact.postal_address.nil?
|
27
|
+
lines.push("Postal Address:")
|
28
|
+
lines.push(@postal_address_format.process(contact))
|
29
|
+
end
|
30
|
+
|
20
31
|
return lines.join("\n")
|
21
32
|
end
|
22
33
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
class Ppl::Format::Contact::PostalAddress < Ppl::Format::Contact
|
3
|
+
|
4
|
+
attr_writer :table
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@table = Ppl::Format::Table.new([:label, :value])
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(contact)
|
11
|
+
address = contact.postal_address
|
12
|
+
|
13
|
+
{
|
14
|
+
:street => "Street",
|
15
|
+
:postal_code => "Postal Code",
|
16
|
+
:po_box => "PO box",
|
17
|
+
:locality => "Locality",
|
18
|
+
:region => "Region",
|
19
|
+
:country => "Country",
|
20
|
+
}.each do |property, name|
|
21
|
+
value = address.send(property)
|
22
|
+
next if value.nil? || value == ""
|
23
|
+
@table.add_row({
|
24
|
+
:label => sprintf("%s:", name),
|
25
|
+
:value => address.send(property)
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
return @table.to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
data/lib/ppl.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module Ppl
|
3
3
|
|
4
|
-
Version = "1.
|
4
|
+
Version = "1.2.0"
|
5
5
|
|
6
6
|
module Adapter
|
7
7
|
end
|
@@ -53,9 +53,11 @@ require "ppl/command/email"
|
|
53
53
|
require "ppl/command/org"
|
54
54
|
require "ppl/command/phone"
|
55
55
|
require "ppl/command/mutt"
|
56
|
+
require "ppl/command/post"
|
56
57
|
|
57
58
|
require "ppl/entity/address_book"
|
58
59
|
require "ppl/entity/contact"
|
60
|
+
require "ppl/entity/postal_address"
|
59
61
|
|
60
62
|
require "ppl/error/contact_not_found"
|
61
63
|
require "ppl/error/incorrect_usage"
|
@@ -68,6 +70,7 @@ require "ppl/format/address_book/names"
|
|
68
70
|
require "ppl/format/address_book/one_line"
|
69
71
|
require "ppl/format/address_book/organizations"
|
70
72
|
require "ppl/format/address_book/phone_numbers"
|
73
|
+
require "ppl/format/address_book/postal_addresses"
|
71
74
|
require "ppl/format/contact"
|
72
75
|
require "ppl/format/contact/birthday"
|
73
76
|
require "ppl/format/contact/email_address"
|
@@ -75,6 +78,7 @@ require "ppl/format/contact/full"
|
|
75
78
|
require "ppl/format/contact/name"
|
76
79
|
require "ppl/format/contact/organization"
|
77
80
|
require "ppl/format/contact/phone_number"
|
81
|
+
require "ppl/format/contact/postal_address"
|
78
82
|
require "ppl/format/table"
|
79
83
|
|
80
84
|
class String
|
data/ppl.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
|
4
4
|
spec.name = "ppl"
|
5
|
-
spec.version = "1.
|
5
|
+
spec.version = "1.2.0"
|
6
6
|
spec.date = "2012-12-20"
|
7
7
|
|
8
8
|
spec.required_ruby_version = ">= 1.9.3"
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.files = `git ls-files`.split("\n")
|
24
24
|
spec.require_path = "lib"
|
25
|
-
spec.homepage = "
|
25
|
+
spec.homepage = "http://ppladdressbook.org"
|
26
26
|
|
27
27
|
end
|
28
28
|
|
@@ -32,6 +32,42 @@ describe Ppl::Adapter::Vcard::Vpim, "#encode" do
|
|
32
32
|
@adapter.encode(@contact).should include("ORG:Example Ltd")
|
33
33
|
end
|
34
34
|
|
35
|
+
it "should encode the contact's street address" do
|
36
|
+
@contact.postal_address = Ppl::Entity::PostalAddress.new
|
37
|
+
@contact.postal_address.street = "1 Testing Road"
|
38
|
+
@adapter.encode(@contact).should include("ADR:;;1 Testing Road;;;;")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should encode the contact's postal code" do
|
42
|
+
@contact.postal_address = Ppl::Entity::PostalAddress.new
|
43
|
+
@contact.postal_address.postal_code = "L7 8AA"
|
44
|
+
@adapter.encode(@contact).should include("ADR:;;;;;L7 8AA;")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should encode the contact's po box" do
|
48
|
+
@contact.postal_address = Ppl::Entity::PostalAddress.new
|
49
|
+
@contact.postal_address.po_box = "123456"
|
50
|
+
@adapter.encode(@contact).should include("ADR:123456;;;;;;")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should encode the contact's locality" do
|
54
|
+
@contact.postal_address = Ppl::Entity::PostalAddress.new
|
55
|
+
@contact.postal_address.locality = "Liverpool"
|
56
|
+
@adapter.encode(@contact).should include("ADR:;;;Liverpool;;;")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should encode the contact's country" do
|
60
|
+
@contact.postal_address = Ppl::Entity::PostalAddress.new
|
61
|
+
@contact.postal_address.country = "UK"
|
62
|
+
@adapter.encode(@contact).should include("ADR:;;;;;;UK")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should encode the contact's region" do
|
66
|
+
@contact.postal_address = Ppl::Entity::PostalAddress.new
|
67
|
+
@contact.postal_address.region = "South West"
|
68
|
+
@adapter.encode(@contact).should include("ADR:;;;;South West;;")
|
69
|
+
end
|
70
|
+
|
35
71
|
end
|
36
72
|
|
37
73
|
|
@@ -112,5 +148,77 @@ describe Ppl::Adapter::Vcard::Vpim, "#decode" do
|
|
112
148
|
contact.organization.should eq "Example Ltd"
|
113
149
|
end
|
114
150
|
|
151
|
+
it "should decode the contact's street address" do
|
152
|
+
vcard = [
|
153
|
+
"BEGIN:VCARD",
|
154
|
+
"N:,test",
|
155
|
+
"VERSION:3.0",
|
156
|
+
"ADR:;;1 Testing Road;;;;",
|
157
|
+
"END:VCARD",
|
158
|
+
].join("\n")
|
159
|
+
contact = @adapter.decode(vcard)
|
160
|
+
contact.postal_address.street.should eq "1 Testing Road"
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should decode the contact's postal code" do
|
164
|
+
vcard = [
|
165
|
+
"BEGIN:VCARD",
|
166
|
+
"N:,test",
|
167
|
+
"VERSION:3.0",
|
168
|
+
"ADR:;;;;;L7 8AA;",
|
169
|
+
"END:VCARD",
|
170
|
+
].join("\n")
|
171
|
+
contact = @adapter.decode(vcard)
|
172
|
+
contact.postal_address.postal_code.should eq "L7 8AA"
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should decode the contact's po box" do
|
176
|
+
vcard = [
|
177
|
+
"BEGIN:VCARD",
|
178
|
+
"N:,test",
|
179
|
+
"VERSION:3.0",
|
180
|
+
"ADR:123456;;;;;;",
|
181
|
+
"END:VCARD",
|
182
|
+
].join("\n")
|
183
|
+
contact = @adapter.decode(vcard)
|
184
|
+
contact.postal_address.po_box.should eq "123456"
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should decode the contact's locality" do
|
188
|
+
vcard = [
|
189
|
+
"BEGIN:VCARD",
|
190
|
+
"N:,test",
|
191
|
+
"VERSION:3.0",
|
192
|
+
"ADR:;;;Liverpool;;;",
|
193
|
+
"END:VCARD",
|
194
|
+
].join("\n")
|
195
|
+
contact = @adapter.decode(vcard)
|
196
|
+
contact.postal_address.locality.should eq "Liverpool"
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should decode the contact's region" do
|
200
|
+
vcard = [
|
201
|
+
"BEGIN:VCARD",
|
202
|
+
"N:,test",
|
203
|
+
"VERSION:3.0",
|
204
|
+
"ADR:;;;;South West;;",
|
205
|
+
"END:VCARD",
|
206
|
+
].join("\n")
|
207
|
+
contact = @adapter.decode(vcard)
|
208
|
+
contact.postal_address.region.should eq "South West"
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should decode the contact's country" do
|
212
|
+
vcard = [
|
213
|
+
"BEGIN:VCARD",
|
214
|
+
"N:,test",
|
215
|
+
"VERSION:3.0",
|
216
|
+
"ADR:;;;;;;UK",
|
217
|
+
"END:VCARD",
|
218
|
+
].join("\n")
|
219
|
+
contact = @adapter.decode(vcard)
|
220
|
+
contact.postal_address.country.should eq "UK"
|
221
|
+
end
|
222
|
+
|
115
223
|
end
|
116
224
|
|
@@ -63,6 +63,9 @@ describe Ppl::Application::Bootstrap do
|
|
63
63
|
it "should contain the 'phone' command" do
|
64
64
|
@bootstrap.command_suite.find_command("phone").should_not be nil
|
65
65
|
end
|
66
|
+
it "should contain the 'post' command" do
|
67
|
+
@bootstrap.command_suite.find_command("post").should_not be nil
|
68
|
+
end
|
66
69
|
it "should contain the 'rm' command" do
|
67
70
|
@bootstrap.command_suite.find_command("rm").should_not be nil
|
68
71
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Command::Post 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::Post.new
|
9
|
+
@storage = double(Ppl::Adapter::Storage)
|
10
|
+
|
11
|
+
@list_format = double(Ppl::Format::Contact)
|
12
|
+
@show_format = double(Ppl::Format::Contact)
|
13
|
+
|
14
|
+
@command.storage = @storage
|
15
|
+
@command.show_format = @show_format
|
16
|
+
@command.list_format = @list_format
|
17
|
+
@contact.id = "jim"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#name" do
|
21
|
+
it "should be 'post'" do
|
22
|
+
@command.name.should eq "post"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#execute" do
|
27
|
+
|
28
|
+
it "should list all postal addresses if no contact ID is given" do
|
29
|
+
@storage.should_receive(:load_address_book).and_return(@address_book)
|
30
|
+
@list_format.should_receive(:process).and_return("all the postal addresses")
|
31
|
+
@output.should_receive(:line).with("all the postal addresses")
|
32
|
+
@input.arguments = []
|
33
|
+
@command.execute(@input, @output)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should show the current address if no new address is given" do
|
37
|
+
@storage.should_receive(:require_contact).and_return(@contact)
|
38
|
+
@show_format.should_receive(:process).and_return("1 Test Road")
|
39
|
+
@output.should_receive(:line).with("1 Test Road")
|
40
|
+
@input.arguments = ["jim"]
|
41
|
+
@command.execute(@input, @output).should eq true
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not output anything if there's nothing to show" do
|
45
|
+
@storage.should_receive(:require_contact).and_return(@contact)
|
46
|
+
@show_format.should_receive(:process).and_return("")
|
47
|
+
@input.arguments = ["jim"]
|
48
|
+
@command.execute(@input, @output).should eq false
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#execute" do
|
54
|
+
|
55
|
+
before(:each) do
|
56
|
+
@input.arguments = ["jim"]
|
57
|
+
@storage.should_receive(:require_contact).and_return(@contact)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should change the contact's street address if it's given" do
|
61
|
+
@input.options = {:street => "1 Test Road"}
|
62
|
+
@storage.should_receive(:save_contact) do |contact|
|
63
|
+
contact.postal_address.street.should eq "1 Test Road"
|
64
|
+
end
|
65
|
+
@command.execute(@input, @output)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should change the contact's postal code if it's given" do
|
69
|
+
@input.options = {:postal_code => "L7 8AA"}
|
70
|
+
@storage.should_receive(:save_contact) do |contact|
|
71
|
+
contact.postal_address.postal_code.should eq "L7 8AA"
|
72
|
+
end
|
73
|
+
@command.execute(@input, @output)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should change the contact's po box if it's given" do
|
77
|
+
@input.options = {:po_box => "124578"}
|
78
|
+
@storage.should_receive(:save_contact) do |contact|
|
79
|
+
contact.postal_address.po_box.should eq "124578"
|
80
|
+
end
|
81
|
+
@command.execute(@input, @output)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should change the contact's country if it's given" do
|
85
|
+
@input.options = {:country => "UK"}
|
86
|
+
@storage.should_receive(:save_contact) do |contact|
|
87
|
+
contact.postal_address.country.should eq "UK"
|
88
|
+
end
|
89
|
+
@command.execute(@input, @output)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should change the contact's locality if it's given" do
|
93
|
+
@input.options = {:locality => "Liverpool"}
|
94
|
+
@storage.should_receive(:save_contact) do |contact|
|
95
|
+
contact.postal_address.locality.should eq "Liverpool"
|
96
|
+
end
|
97
|
+
@command.execute(@input, @output)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should change the contact's region if it's given" do
|
101
|
+
@input.options = {:region => "North West"}
|
102
|
+
@storage.should_receive(:save_contact) do |contact|
|
103
|
+
contact.postal_address.region.should eq "North West"
|
104
|
+
end
|
105
|
+
@command.execute(@input, @output)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::AddressBook::PostalAddresses do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::AddressBook::PostalAddresses.new
|
6
|
+
@address_book = Ppl::Entity::AddressBook.new
|
7
|
+
@contact = Ppl::Entity::Contact.new
|
8
|
+
@address = Ppl::Entity::PostalAddress.new
|
9
|
+
@table = double(Ppl::Format::Table)
|
10
|
+
|
11
|
+
@contact.id = "test"
|
12
|
+
@contact.postal_address = @address
|
13
|
+
@format.table = @table
|
14
|
+
|
15
|
+
@address_book.add_contact(@contact)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#process" do
|
19
|
+
|
20
|
+
it "should at least show the contact's id" do
|
21
|
+
@table.should_receive(:add_row).with({
|
22
|
+
:id => "test:",
|
23
|
+
:postal_address => "",
|
24
|
+
})
|
25
|
+
@format.process(@address_book)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should show the postal address if it's available" do
|
29
|
+
@address.street = "1 Test Road"
|
30
|
+
@table.should_receive(:add_row).with({
|
31
|
+
:id => "test:",
|
32
|
+
:postal_address => "1 Test Road",
|
33
|
+
})
|
34
|
+
@format.process(@address_book)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
@@ -4,6 +4,10 @@ describe Ppl::Format::Contact::Full do
|
|
4
4
|
before(:each) do
|
5
5
|
@format = Ppl::Format::Contact::Full.new
|
6
6
|
@contact = Ppl::Entity::Contact.new
|
7
|
+
@address = Ppl::Entity::PostalAddress.new
|
8
|
+
|
9
|
+
@postal_address_format = double(Ppl::Format::Contact)
|
10
|
+
@format.postal_address_format = @postal_address_format
|
7
11
|
end
|
8
12
|
|
9
13
|
describe "#process" do
|
@@ -38,6 +42,12 @@ describe Ppl::Format::Contact::Full do
|
|
38
42
|
@format.process(@contact).should include "Example Ltd"
|
39
43
|
end
|
40
44
|
|
45
|
+
it "should show their postal address if available" do
|
46
|
+
@contact.postal_address = @address
|
47
|
+
@postal_address_format.should_receive(:process).with(@contact)
|
48
|
+
@format.process(@contact)
|
49
|
+
end
|
50
|
+
|
41
51
|
end
|
42
52
|
|
43
53
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
describe Ppl::Format::Contact::PostalAddress do
|
3
|
+
|
4
|
+
before(:each) do
|
5
|
+
@format = Ppl::Format::Contact::PostalAddress.new
|
6
|
+
@contact = Ppl::Entity::Contact.new
|
7
|
+
@address = Ppl::Entity::PostalAddress.new
|
8
|
+
@table = double(Ppl::Format::Table)
|
9
|
+
@contact.postal_address = @address
|
10
|
+
@format.table = @table
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#process" do
|
14
|
+
|
15
|
+
it "should return the contact's street address if it is set" do
|
16
|
+
@address.street = "1 Test Road"
|
17
|
+
@table.should_receive(:add_row).with({
|
18
|
+
:label => "Street:",
|
19
|
+
:value => "1 Test Road",
|
20
|
+
})
|
21
|
+
@format.process(@contact)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
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.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-12-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: inifile
|
16
|
-
requirement: &
|
16
|
+
requirement: &16562220 !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: *16562220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rugged
|
27
|
-
requirement: &
|
27
|
+
requirement: &16560900 !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: *16560900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: vpim
|
38
|
-
requirement: &
|
38
|
+
requirement: &16560140 !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: *16560140
|
47
47
|
description: CLI Address Book
|
48
48
|
email: henry@henrysmith.org
|
49
49
|
executables:
|
@@ -85,10 +85,12 @@ files:
|
|
85
85
|
- lib/ppl/command/name.rb
|
86
86
|
- lib/ppl/command/org.rb
|
87
87
|
- lib/ppl/command/phone.rb
|
88
|
+
- lib/ppl/command/post.rb
|
88
89
|
- lib/ppl/command/rm.rb
|
89
90
|
- lib/ppl/command/show.rb
|
90
91
|
- lib/ppl/entity/address_book.rb
|
91
92
|
- lib/ppl/entity/contact.rb
|
93
|
+
- lib/ppl/entity/postal_address.rb
|
92
94
|
- lib/ppl/error/contact_not_found.rb
|
93
95
|
- lib/ppl/error/incorrect_usage.rb
|
94
96
|
- lib/ppl/format/address_book.rb
|
@@ -99,6 +101,7 @@ files:
|
|
99
101
|
- lib/ppl/format/address_book/one_line.rb
|
100
102
|
- lib/ppl/format/address_book/organizations.rb
|
101
103
|
- lib/ppl/format/address_book/phone_numbers.rb
|
104
|
+
- lib/ppl/format/address_book/postal_addresses.rb
|
102
105
|
- lib/ppl/format/contact.rb
|
103
106
|
- lib/ppl/format/contact/birthday.rb
|
104
107
|
- lib/ppl/format/contact/email_address.rb
|
@@ -106,6 +109,7 @@ files:
|
|
106
109
|
- lib/ppl/format/contact/name.rb
|
107
110
|
- lib/ppl/format/contact/organization.rb
|
108
111
|
- lib/ppl/format/contact/phone_number.rb
|
112
|
+
- lib/ppl/format/contact/postal_address.rb
|
109
113
|
- lib/ppl/format/table.rb
|
110
114
|
- ppl.gemspec
|
111
115
|
- spec/ppl/adapter/output_spec.rb
|
@@ -133,10 +137,12 @@ files:
|
|
133
137
|
- spec/ppl/command/name_spec.rb
|
134
138
|
- spec/ppl/command/org_spec.rb
|
135
139
|
- spec/ppl/command/phone_spec.rb
|
140
|
+
- spec/ppl/command/post_spec.rb
|
136
141
|
- spec/ppl/command/rm_spec.rb
|
137
142
|
- spec/ppl/command/show_spec.rb
|
138
143
|
- spec/ppl/entity/address_book_spec.rb
|
139
144
|
- spec/ppl/entity/contact_spec.rb
|
145
|
+
- spec/ppl/entity/postal_address_spec.rb
|
140
146
|
- spec/ppl/format/address_book/birthdays_spec.rb
|
141
147
|
- spec/ppl/format/address_book/email_addresses_spec.rb
|
142
148
|
- spec/ppl/format/address_book/mutt_query_spec.rb
|
@@ -144,6 +150,7 @@ files:
|
|
144
150
|
- spec/ppl/format/address_book/one_line_spec.rb
|
145
151
|
- spec/ppl/format/address_book/organizations_spec.rb
|
146
152
|
- spec/ppl/format/address_book/phone_numbers_spec.rb
|
153
|
+
- spec/ppl/format/address_book/postal_addresses_spec.rb
|
147
154
|
- spec/ppl/format/address_book_spec.rb
|
148
155
|
- spec/ppl/format/contact/birthday_spec.rb
|
149
156
|
- spec/ppl/format/contact/email_address_spec.rb
|
@@ -151,10 +158,11 @@ files:
|
|
151
158
|
- spec/ppl/format/contact/name_spec.rb
|
152
159
|
- spec/ppl/format/contact/organization_spec.rb
|
153
160
|
- spec/ppl/format/contact/phone_number_spec.rb
|
161
|
+
- spec/ppl/format/contact/postal_address_spec.rb
|
154
162
|
- spec/ppl/format/contact_spec.rb
|
155
163
|
- spec/ppl/format/table_spec.rb
|
156
164
|
- spec/spec_helper.rb
|
157
|
-
homepage:
|
165
|
+
homepage: http://ppladdressbook.org
|
158
166
|
licenses:
|
159
167
|
- GPL-2
|
160
168
|
post_install_message:
|