ppl 1.5.3 → 1.6.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 +0 -1
- data/lib/ppl/command/email.rb +16 -1
- data/lib/ppl.rb +1 -1
- data/ppl.gemspec +2 -2
- data/spec/ppl/command/email_spec.rb +21 -0
- metadata +8 -8
data/lib/ppl/command/email.rb
CHANGED
@@ -14,6 +14,10 @@ class Ppl::Command::Email < Ppl::Application::Command
|
|
14
14
|
|
15
15
|
def options(parser, options)
|
16
16
|
parser.banner = "usage: ppl email <contact> [<email-address>]"
|
17
|
+
|
18
|
+
parser.on("-d", "--delete", "delete email address") do
|
19
|
+
options[:delete] = true
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def execute(input, output)
|
@@ -29,6 +33,8 @@ class Ppl::Command::Email < Ppl::Application::Command
|
|
29
33
|
:list_email_addresses
|
30
34
|
elsif input.arguments[1].nil?
|
31
35
|
:show_email_addresses
|
36
|
+
elsif input.options[:delete]
|
37
|
+
:delete_email_address
|
32
38
|
else
|
33
39
|
:set_email_address
|
34
40
|
end
|
@@ -51,10 +57,19 @@ class Ppl::Command::Email < Ppl::Application::Command
|
|
51
57
|
end
|
52
58
|
end
|
53
59
|
|
54
|
-
def
|
60
|
+
def delete_email_address(input, output)
|
55
61
|
contact = @storage.require_contact(input.arguments[0])
|
56
62
|
email_address = input.arguments[1].dup
|
63
|
+
contact.email_addresses.delete(email_address) do
|
64
|
+
message = sprintf("%s has no such email address %s", contact.id, email_address)
|
65
|
+
raise Ppl::Error::IncorrectUsage, message
|
66
|
+
end
|
67
|
+
@storage.save_contact(contact)
|
68
|
+
end
|
57
69
|
|
70
|
+
def set_email_address(input, output)
|
71
|
+
contact = @storage.require_contact(input.arguments[0])
|
72
|
+
email_address = input.arguments[1].dup
|
58
73
|
if contact.has_email_address?(email_address)
|
59
74
|
message = sprintf("%s already has email address %s", contact.id, email_address)
|
60
75
|
raise Ppl::Error::IncorrectUsage, message
|
data/lib/ppl.rb
CHANGED
data/ppl.gemspec
CHANGED
@@ -48,6 +48,27 @@ describe Ppl::Command::Email do
|
|
48
48
|
@command.execute(@input, @output).should eq false
|
49
49
|
end
|
50
50
|
|
51
|
+
it "should delete the given address to the contact if requested" do
|
52
|
+
@contact.email_addresses.push("jim@example.org")
|
53
|
+
@contact.email_addresses.push("jim@example.com")
|
54
|
+
@storage.should_receive(:require_contact).and_return(@contact)
|
55
|
+
@storage.should_receive(:save_contact) do |contact|
|
56
|
+
contact.email_addresses.should eq ["jim@example.com"]
|
57
|
+
end
|
58
|
+
@input.arguments = ["jim", "jim@example.org"]
|
59
|
+
@input.options = { :delete => true }
|
60
|
+
@command.execute(@input, @output)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should raise an error when deleting a non-existent email address" do
|
64
|
+
@contact.email_addresses.push("jim@example.org")
|
65
|
+
@contact.email_addresses.push("jim@example.com")
|
66
|
+
@storage.should_receive(:require_contact).and_return(@contact)
|
67
|
+
@input.arguments = ["jim", "jim@example.net"]
|
68
|
+
@input.options = { :delete => true }
|
69
|
+
expect{@command.execute(@input, nil)}.to raise_error(Ppl::Error::IncorrectUsage)
|
70
|
+
end
|
71
|
+
|
51
72
|
it "should add the given address to the contact if it's new" do
|
52
73
|
@storage.should_receive(:require_contact).and_return(@contact)
|
53
74
|
@storage.should_receive(:save_contact) do |contact|
|
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.6.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: 2012-12-
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: inifile
|
16
|
-
requirement: &
|
16
|
+
requirement: &17793580 !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: *17793580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rugged
|
27
|
-
requirement: &
|
27
|
+
requirement: &17792360 !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: *17792360
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: vpim
|
38
|
-
requirement: &
|
38
|
+
requirement: &17791520 !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: *17791520
|
47
47
|
description: CLI Address Book
|
48
48
|
email: henry@henrysmith.org
|
49
49
|
executables:
|