ppl 1.14.1 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Gemfile +2 -1
  2. data/Gemfile.lock +3 -1
  3. data/lib/ppl/adapter/color/colored.rb +15 -0
  4. data/lib/ppl/adapter/color.rb +9 -0
  5. data/lib/ppl/application/bootstrap.rb +309 -61
  6. data/lib/ppl/application/configuration.rb +15 -0
  7. data/lib/ppl/command/age.rb +0 -5
  8. data/lib/ppl/command/bday.rb +0 -5
  9. data/lib/ppl/command/email.rb +1 -3
  10. data/lib/ppl/command/ls.rb +0 -5
  11. data/lib/ppl/command/mutt.rb +0 -4
  12. data/lib/ppl/command/name.rb +0 -5
  13. data/lib/ppl/command/nick.rb +1 -3
  14. data/lib/ppl/command/org.rb +1 -3
  15. data/lib/ppl/command/phone.rb +1 -3
  16. data/lib/ppl/command/post.rb +0 -5
  17. data/lib/ppl/command/url.rb +1 -3
  18. data/lib/ppl/format/address_book/ages.rb +2 -4
  19. data/lib/ppl/format/address_book/birthdays.rb +2 -2
  20. data/lib/ppl/format/address_book/email_addresses.rb +3 -3
  21. data/lib/ppl/format/address_book/names.rb +2 -2
  22. data/lib/ppl/format/address_book/nicknames.rb +2 -2
  23. data/lib/ppl/format/address_book/one_line.rb +2 -2
  24. data/lib/ppl/format/address_book/organizations.rb +2 -2
  25. data/lib/ppl/format/address_book/phone_numbers.rb +2 -2
  26. data/lib/ppl/format/address_book/postal_addresses.rb +2 -2
  27. data/lib/ppl/format/address_book/urls.rb +2 -2
  28. data/lib/ppl/format/contact/age.rb +13 -1
  29. data/lib/ppl/format/contact/birthday.rb +11 -0
  30. data/lib/ppl/format/contact/email_addresses.rb +19 -1
  31. data/lib/ppl/format/contact/name.rb +18 -2
  32. data/lib/ppl/format/contact/nicknames.rb +19 -1
  33. data/lib/ppl/format/contact/organization.rb +19 -1
  34. data/lib/ppl/format/contact/phone_number.rb +19 -1
  35. data/lib/ppl/format/contact/urls.rb +19 -1
  36. data/lib/ppl/format/table.rb +15 -6
  37. data/lib/ppl.rb +3 -1
  38. data/ppl.gemspec +4 -2
  39. data/spec/ppl/adapter/color/colored_spec.rb +24 -0
  40. data/spec/ppl/adapter/color_spec.rb +15 -0
  41. data/spec/ppl/application/bootstrap_spec.rb +403 -25
  42. data/spec/ppl/application/configuration_spec.rb +46 -0
  43. data/spec/ppl/command/mutt_spec.rb +4 -0
  44. data/spec/ppl/format/address_book/ages_spec.rb +10 -0
  45. data/spec/ppl/format/address_book/birthdays_spec.rb +10 -0
  46. data/spec/ppl/format/address_book/email_addresses_spec.rb +12 -2
  47. data/spec/ppl/format/address_book/names_spec.rb +10 -0
  48. data/spec/ppl/format/address_book/nicknames_spec.rb +10 -0
  49. data/spec/ppl/format/address_book/one_line_spec.rb +10 -0
  50. data/spec/ppl/format/address_book/organizations_spec.rb +10 -0
  51. data/spec/ppl/format/address_book/phone_numbers_spec.rb +10 -0
  52. data/spec/ppl/format/address_book/postal_addresses_spec.rb +10 -0
  53. data/spec/ppl/format/address_book/urls_spec.rb +10 -0
  54. data/spec/ppl/format/contact/age_spec.rb +10 -0
  55. data/spec/ppl/format/contact/birthday_spec.rb +8 -0
  56. data/spec/ppl/format/contact/email_addresses_spec.rb +8 -0
  57. data/spec/ppl/format/contact/name_spec.rb +8 -0
  58. data/spec/ppl/format/contact/nicknames_spec.rb +8 -0
  59. data/spec/ppl/format/contact/organization_spec.rb +8 -0
  60. data/spec/ppl/format/contact/phone_number_spec.rb +8 -0
  61. data/spec/ppl/format/contact/urls_spec.rb +8 -0
  62. data/spec/ppl/format/table_spec.rb +20 -0
  63. metadata +38 -2
@@ -1,4 +1,14 @@
1
1
 
2
+ describe Ppl::Format::AddressBook::Urls do
3
+ describe "#initialize" do
4
+ it "should pass the colors through to the table" do
5
+ colors = {"id" => "blue"}
6
+ Ppl::Format::Table.should_receive(:new).with([:id, :urls], colors)
7
+ format = Ppl::Format::AddressBook::Urls.new(colors)
8
+ end
9
+ end
10
+ end
11
+
2
12
  describe Ppl::Format::AddressBook::Urls do
3
13
 
4
14
  before(:each) do
@@ -4,11 +4,14 @@ describe Ppl::Format::Contact::Age do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::Age.new
6
6
  @contact = double(Ppl::Entity::Contact)
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
10
12
 
11
13
  it "should return an empty string if the contact lacks a birth date" do
14
+ @color.stub(:colorize)
12
15
  @contact.should_receive(:age).and_return(nil)
13
16
  @format.process(@contact).should eq ""
14
17
  end
@@ -18,6 +21,13 @@ describe Ppl::Format::Contact::Age do
18
21
  @format.process(@contact).should eq "10"
19
22
  end
20
23
 
24
+ it "should colorize the string if configured to do so" do
25
+ @contact.should_receive(:age).and_return(10)
26
+ @format.colors = { "age" => "blue" }
27
+ @color.should_receive(:colorize).and_return("age in blue")
28
+ @format.process(@contact).should eq "age in blue"
29
+ end
30
+
21
31
  end
22
32
 
23
33
  end
@@ -4,6 +4,8 @@ describe Ppl::Format::Contact::Birthday do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::Birthday.new
6
6
  @contact = Ppl::Entity::Contact.new
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
@@ -17,6 +19,12 @@ describe Ppl::Format::Contact::Birthday do
17
19
  @format.process(@contact).should eq "1970-01-01"
18
20
  end
19
21
 
22
+ it "should colorize the string if configured to do so" do
23
+ @format.colors = { "birthday" => "blue" }
24
+ @color.should_receive(:colorize).and_return("birthday in blue")
25
+ @format.process(@contact).should eq "birthday in blue"
26
+ end
27
+
20
28
  end
21
29
 
22
30
  end
@@ -4,6 +4,8 @@ describe Ppl::Format::Contact::EmailAddresses do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::EmailAddresses.new
6
6
  @contact = Ppl::Entity::Contact.new
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
@@ -17,6 +19,12 @@ describe Ppl::Format::Contact::EmailAddresses do
17
19
  @format.process(@contact).should eq "jdoe@example.org"
18
20
  end
19
21
 
22
+ it "should colorize the string if configured to do so" do
23
+ @format.colors = { "email_addresses" => "blue" }
24
+ @color.should_receive(:colorize).and_return("email addresses in blue")
25
+ @format.process(@contact).should eq "email addresses in blue"
26
+ end
27
+
20
28
  end
21
29
 
22
30
  end
@@ -4,6 +4,8 @@ describe Ppl::Format::Contact::Name do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::Name.new
6
6
  @contact = Ppl::Entity::Contact.new
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
@@ -17,6 +19,12 @@ describe Ppl::Format::Contact::Name do
17
19
  @format.process(@contact).should eq "John Doe"
18
20
  end
19
21
 
22
+ it "should colorize the string if configured to do so" do
23
+ @format.colors = { "name" => "blue" }
24
+ @color.should_receive(:colorize).and_return("name in blue")
25
+ @format.process(@contact).should eq "name in blue"
26
+ end
27
+
20
28
  end
21
29
 
22
30
  end
@@ -4,6 +4,8 @@ describe Ppl::Format::Contact::Nicknames do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::Nicknames.new
6
6
  @contact = Ppl::Entity::Contact.new
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
@@ -17,6 +19,12 @@ describe Ppl::Format::Contact::Nicknames do
17
19
  @format.process(@contact).should eq "Dopey"
18
20
  end
19
21
 
22
+ it "should colorize the string if configured to do so" do
23
+ @format.colors = { "nicknames" => "blue" }
24
+ @color.should_receive(:colorize).and_return("nicknames in blue")
25
+ @format.process(@contact).should eq "nicknames in blue"
26
+ end
27
+
20
28
  end
21
29
 
22
30
  end
@@ -4,6 +4,8 @@ describe Ppl::Format::Contact::Organization do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::Organization.new
6
6
  @contact = Ppl::Entity::Contact.new
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
@@ -17,6 +19,12 @@ describe Ppl::Format::Contact::Organization do
17
19
  @format.process(@contact).should eq "Example Ltd"
18
20
  end
19
21
 
22
+ it "should colorize the string if configured to do so" do
23
+ @format.colors = { "organizations" => "blue" }
24
+ @color.should_receive(:colorize).and_return("organizations in blue")
25
+ @format.process(@contact).should eq "organizations in blue"
26
+ end
27
+
20
28
  end
21
29
 
22
30
  end
@@ -4,6 +4,8 @@ describe Ppl::Format::Contact::PhoneNumber do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::PhoneNumber.new
6
6
  @contact = Ppl::Entity::Contact.new
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
@@ -17,6 +19,12 @@ describe Ppl::Format::Contact::PhoneNumber do
17
19
  @format.process(@contact).should eq "0123456789"
18
20
  end
19
21
 
22
+ it "should colorize the string if configured to do so" do
23
+ @format.colors = { "phone_numbers" => "blue" }
24
+ @color.should_receive(:colorize).and_return("phone numbers in blue")
25
+ @format.process(@contact).should eq "phone numbers in blue"
26
+ end
27
+
20
28
  end
21
29
 
22
30
  end
@@ -4,6 +4,8 @@ describe Ppl::Format::Contact::Urls do
4
4
  before(:each) do
5
5
  @format = Ppl::Format::Contact::Urls.new
6
6
  @contact = Ppl::Entity::Contact.new
7
+ @color = double(Ppl::Adapter::Color)
8
+ @format.color_adapter = @color
7
9
  end
8
10
 
9
11
  describe "#process" do
@@ -17,6 +19,12 @@ describe Ppl::Format::Contact::Urls do
17
19
  @format.process(@contact).should eq "http://example.org/~jdoe"
18
20
  end
19
21
 
22
+ it "should colorize the string if configured to do so" do
23
+ @format.colors = { "urls" => "blue" }
24
+ @color.should_receive(:colorize).and_return("urls in blue")
25
+ @format.process(@contact).should eq "urls in blue"
26
+ end
27
+
20
28
  end
21
29
 
22
30
  end
@@ -24,6 +24,12 @@ describe Ppl::Format::Table do
24
24
  ])
25
25
  end
26
26
 
27
+ describe "#colors" do
28
+ it "should be a hash" do
29
+ @table.colors.should be_a(Hash)
30
+ end
31
+ end
32
+
27
33
  describe "#add_row" do
28
34
  it "should accept a hash" do
29
35
  @table.add_row({
@@ -60,6 +66,20 @@ describe Ppl::Format::Table do
60
66
  @table.to_s.should eq "12345\tJohn Doe\tjdoe@example.org"
61
67
  end
62
68
 
69
+ it "should colorize columns if requested" do
70
+ @table.colors = {
71
+ "id" => "red",
72
+ "name" => "yellow",
73
+ "email" => "blue",
74
+ }
75
+ @table.add_row({
76
+ :id => 12345,
77
+ :name => "John Doe",
78
+ :email => "jdoe@example.org",
79
+ })
80
+ @table.to_s.should eq "\e[31m12345 \e[0m\e[33mJohn Doe \e[0m\e[34mjdoe@example.org \e[0m"
81
+ end
82
+
63
83
  it "should align multiple rows into neat columns" do
64
84
  @table.add_row({
65
85
  :id => 12345,
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.14.1
4
+ version: 1.15.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-17 00:00:00.000000000 Z
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colored
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: inifile
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -27,6 +43,22 @@ dependencies:
27
43
  - - '='
28
44
  - !ruby/object:Gem::Version
29
45
  version: 2.0.2
46
+ - !ruby/object:Gem::Dependency
47
+ name: morphine
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.1.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.1
30
62
  - !ruby/object:Gem::Dependency
31
63
  name: rugged
32
64
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +107,8 @@ files:
75
107
  - README.md
76
108
  - bin/ppl
77
109
  - lib/ppl.rb
110
+ - lib/ppl/adapter/color.rb
111
+ - lib/ppl/adapter/color/colored.rb
78
112
  - lib/ppl/adapter/storage.rb
79
113
  - lib/ppl/adapter/storage/disk.rb
80
114
  - lib/ppl/adapter/storage/factory.rb
@@ -142,6 +176,8 @@ files:
142
176
  - lib/ppl/format/postal_address/one_line.rb
143
177
  - lib/ppl/format/table.rb
144
178
  - ppl.gemspec
179
+ - spec/ppl/adapter/color/colored_spec.rb
180
+ - spec/ppl/adapter/color_spec.rb
145
181
  - spec/ppl/adapter/output_spec.rb
146
182
  - spec/ppl/adapter/storage/disk_spec.rb
147
183
  - spec/ppl/adapter/storage/factory_spec.rb