ppl 0.9.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,8 +46,13 @@ class Ppl::Command::Bday < Ppl::Application::Command
46
46
  end
47
47
  contact = @storage.require_contact(contact_id)
48
48
 
49
- line = @show_format.process(contact)
50
- output.line(line)
49
+ birthday = @show_format.process(contact)
50
+ if birthday != ""
51
+ output.line(birthday)
52
+ true
53
+ else
54
+ false
55
+ end
51
56
  end
52
57
 
53
58
  def set_birthday(input, output)
@@ -42,7 +42,12 @@ class Ppl::Command::Email < Ppl::Application::Command
42
42
  def show_email_address(input, output)
43
43
  contact = @storage.require_contact(input.arguments[0])
44
44
  email_address = @show_format.process(contact)
45
- output.line(email_address)
45
+ if email_address != ""
46
+ output.line(email_address)
47
+ true
48
+ else
49
+ false
50
+ end
46
51
  end
47
52
 
48
53
  def set_email_address(input, output)
@@ -41,7 +41,12 @@ class Ppl::Command::Name < Ppl::Application::Command
41
41
  def show_name(input, output)
42
42
  contact = @storage.require_contact(input.arguments[0])
43
43
  name = @show_format.process(contact)
44
- output.line(name)
44
+ if name != ""
45
+ output.line(name)
46
+ true
47
+ else
48
+ false
49
+ end
45
50
  end
46
51
 
47
52
  def set_name(input, output)
@@ -42,7 +42,12 @@ class Ppl::Command::Org < Ppl::Application::Command
42
42
  def show_organization(input, output)
43
43
  contact = @storage.require_contact(input.arguments[0])
44
44
  organization = @show_format.process(contact)
45
- output.line(organization)
45
+ if organization != ""
46
+ output.line(organization)
47
+ true
48
+ else
49
+ false
50
+ end
46
51
  end
47
52
 
48
53
  def set_organization(input, output)
@@ -42,7 +42,12 @@ class Ppl::Command::Phone < Ppl::Application::Command
42
42
  def show_phone_number(input, output)
43
43
  contact = @storage.require_contact(input.arguments[0])
44
44
  number = @show_format.process(contact)
45
- output.line(number)
45
+ if number != ""
46
+ output.line(number)
47
+ true
48
+ else
49
+ false
50
+ end
46
51
  end
47
52
 
48
53
  def set_phone_number(input, output)
data/lib/ppl.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Ppl
3
3
 
4
- Version = "0.9.0"
4
+ Version = "1.0.0"
5
5
 
6
6
  module Adapter
7
7
  end
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 = "0.9.0"
5
+ spec.version = "1.0.0"
6
6
  spec.date = "2012-11-23"
7
7
 
8
8
  spec.summary = "CLI Address Book"
@@ -22,23 +22,19 @@ describe Ppl::Command::Bday do
22
22
 
23
23
  describe "#execute" do
24
24
 
25
- it "should list all birthdays if no contact is specified" do
26
- #@input.arguments = []
27
- #@command.execute(@input, @output)
28
- end
29
-
30
- it "should raise an error if the date given isn't a valid date" do
31
- @storage.should_receive(:require_contact).and_return(@contact)
32
- @input.arguments = ["jim", "poiuytrewq"]
33
- expect{@command.execute(@input, @output)}.to raise_error(Ppl::Error::IncorrectUsage)
34
- end
35
-
36
25
  it "should show the contact's birthday if no date is given" do
37
26
  @storage.should_receive(:require_contact).and_return(@contact)
38
27
  @show_format.should_receive(:process).and_return("1970-01-01")
39
28
  @output.should_receive(:line).with("1970-01-01")
40
29
  @input.arguments = ["jim"]
41
- @command.execute(@input, @output)
30
+ @command.execute(@input, @output).should eq true
31
+ end
32
+
33
+ it "should not output anything if there's no birthday to show" do
34
+ @storage.should_receive(:require_contact).and_return(@contact)
35
+ @show_format.should_receive(:process).and_return("")
36
+ @input.arguments = ["jim"]
37
+ @command.execute(@input, @output).should eq false
42
38
  end
43
39
 
44
40
  it "should change the contact's birthday if a date is given" do
@@ -38,7 +38,14 @@ describe Ppl::Command::Email do
38
38
  @show_format.should_receive(:process).and_return("jdoe@example.org")
39
39
  @output.should_receive(:line).with("jdoe@example.org")
40
40
  @input.arguments = ["jim"]
41
- @command.execute(@input, @output)
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
42
49
  end
43
50
 
44
51
  it "should change the contact's email address if an address is given" do
@@ -41,7 +41,14 @@ describe Ppl::Command::Name do
41
41
  @show_format.should_receive(:process).and_return("John Doe")
42
42
  @output.should_receive(:line).with("John Doe")
43
43
  @input.arguments = ["jim"]
44
- @command.execute(@input, @output)
44
+ @command.execute(@input, @output).should eq true
45
+ end
46
+
47
+ it "should not output anything if there's nothing to show" do
48
+ @storage.should_receive(:require_contact).and_return(@contact)
49
+ @show_format.should_receive(:process).and_return("")
50
+ @input.arguments = ["jim"]
51
+ @command.execute(@input, @output).should eq false
45
52
  end
46
53
 
47
54
  it "should change the contact's name if a name is given" do
@@ -39,7 +39,14 @@ describe Ppl::Command::Org do
39
39
  @show_format.should_receive(:process).and_return("Example Ltd")
40
40
  @output.should_receive(:line).with("Example Ltd")
41
41
  @input.arguments = ["jim"]
42
- @command.execute(@input, @output)
42
+ @command.execute(@input, @output).should eq true
43
+ end
44
+
45
+ it "should not output anything if there's nothing to show" do
46
+ @storage.should_receive(:require_contact).and_return(@contact)
47
+ @show_format.should_receive(:process).and_return("")
48
+ @input.arguments = ["jim"]
49
+ @command.execute(@input, @output).should eq false
43
50
  end
44
51
 
45
52
  it "should change the contact's organization if one is given" do
@@ -37,7 +37,14 @@ describe Ppl::Command::Phone do
37
37
  @show_format.should_receive(:process).and_return("0123456789")
38
38
  @output.should_receive(:line).with("0123456789")
39
39
  @input.arguments = ["jim"]
40
- @command.execute(@input, @output)
40
+ @command.execute(@input, @output).should eq true
41
+ end
42
+
43
+ it "should not output anything if there's nothing to show" do
44
+ @storage.should_receive(:require_contact).and_return(@contact)
45
+ @show_format.should_receive(:process).and_return("")
46
+ @input.arguments = ["jim"]
47
+ @command.execute(@input, @output).should eq false
41
48
  end
42
49
 
43
50
  it "should change the contact's phone number if a number is given" do
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.9.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: