ppl 2.3.0 → 2.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6751b47fc16bbbe1cf3f04a8c314f3c6fb54ff6
4
- data.tar.gz: c44d7945c8b6994f0adfc8aadb59936e2a8bb5c3
3
+ metadata.gz: de5c3bfa9ec90c3aad5dace9f52e3ac33a24d53c
4
+ data.tar.gz: 0c3ecacd962b11facb97e41d8ec59b3b64350554
5
5
  SHA512:
6
- metadata.gz: 0683f92143ecfbcb291ad7d8c341cf946652f74f563d765b738ae6a703aae324bf6818d5e20db394b5ed9cab89187d195e4842b3cd79246d3b1b05211b1bde4c
7
- data.tar.gz: 56a3e71bfde3fbf4affbc1865239e84fd7a20b2767b83dcc4b776c3afd6d5f2f9b1c220785c9543bfde8c75bc074d3a37be229336fdaad846657b4855ae7119f
6
+ metadata.gz: 40fc44570b1d55fcd8fe915798ed6913cdfa932a00bf785288b5bbae76b5afcb85d39eb81d0b69c2b7e6d81983f7ef4edab9a0058f15b5c37b845cc4e548f763
7
+ data.tar.gz: 5eb285ac6574d192cb79f9a873c621b5f66ace980c6248703644d10ccb1d9d30df26d4cfa81f3e00870da9368355a07340390919fecdd8e714ec7bfa7ddb11ca
data/README.md CHANGED
@@ -14,6 +14,7 @@ ppl if:
14
14
 
15
15
  [![Build Status](https://secure.travis-ci.org/h2s/ppl.png)](http://travis-ci.org/h2s/ppl)
16
16
  [![Code Climate](https://codeclimate.com/github/h2s/ppl.png)](https://codeclimate.com/github/h2s/ppl)
17
+ [![Coverage Status](https://coveralls.io/repos/h2s/ppl/badge.png?branch=master)](https://coveralls.io/r/h2s/ppl?branch=master)
17
18
 
18
19
  Installation
19
20
  ------------
data/lib/ppl.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Ppl
3
3
 
4
- Version = "2.2.0"
4
+ Version = "2.3.1"
5
5
 
6
6
  module Adapter
7
7
  end
@@ -81,6 +81,7 @@ require "ppl/entity/postal_address"
81
81
  require "ppl/error/completion_not_found"
82
82
  require "ppl/error/contact_not_found"
83
83
  require "ppl/error/incorrect_usage"
84
+ require "ppl/error/invalid_vcard"
84
85
  require "ppl/error/postal_address_not_found"
85
86
 
86
87
  require "ppl/format/address_book"
@@ -1,4 +1,3 @@
1
-
2
1
  require "rugged"
3
2
  require "socket"
4
3
 
@@ -40,17 +39,11 @@ class Ppl::Adapter::Storage::Git < Ppl::Adapter::Storage
40
39
  end
41
40
 
42
41
  def load_contact(id)
43
- filename = id + ".vcf"
44
- target = @repository.head.target
45
- vcard = @repository.file_at(target, filename)
46
- contact = nil
47
-
48
- if !vcard.nil?
49
- contact = @vcard_adapter.decode(vcard)
50
- contact.id = id
42
+ begin
43
+ read_contact_from_disk id
44
+ rescue GreenCard::InvalidEncodingError
45
+ raise Ppl::Error::InvalidVcard, "#{id}.vcf contains invalid data"
51
46
  end
52
-
53
- return contact
54
47
  end
55
48
 
56
49
  def save_contact(contact)
@@ -117,5 +110,20 @@ class Ppl::Adapter::Storage::Git < Ppl::Adapter::Storage
117
110
  @disk.path
118
111
  end
119
112
 
120
- end
113
+ private
121
114
 
115
+ def read_contact_from_disk(id)
116
+ filename = id + ".vcf"
117
+ target = @repository.head.target
118
+ vcard = @repository.file_at(target, filename)
119
+ contact = nil
120
+
121
+ if !vcard.nil?
122
+ contact = @vcard_adapter.decode(vcard)
123
+ contact.id = id
124
+ end
125
+
126
+ return contact
127
+ end
128
+
129
+ end
@@ -0,0 +1,2 @@
1
+ class Ppl::Error::InvalidVcard < StandardError
2
+ end
@@ -46,7 +46,9 @@ class Ppl::Format::Table
46
46
 
47
47
  def format_row(row)
48
48
  string = ""
49
- @columns.each { |column| string += format_cell(row, column) }
49
+ @columns.each do |column|
50
+ string += format_cell(row, column).force_encoding("UTF-8")
51
+ end
50
52
  return string
51
53
  end
52
54
 
data/ppl.gemspec CHANGED
@@ -2,8 +2,8 @@
2
2
  Gem::Specification.new do |spec|
3
3
 
4
4
  spec.name = "ppl"
5
- spec.version = "2.3.0"
6
- spec.date = "2013-10-12"
5
+ spec.version = "2.3.1"
6
+ spec.date = "2014-03-30"
7
7
 
8
8
  spec.required_ruby_version = ">= 1.9.3"
9
9
 
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.add_dependency("rugged", "0.17.0.b6")
19
19
  spec.add_dependency("greencard", "0.0.5")
20
20
 
21
+ spec.add_development_dependency("coveralls")
21
22
  spec.add_development_dependency("cucumber")
22
23
  spec.add_development_dependency("rspec")
23
24
  spec.add_development_dependency("rake")
@@ -93,6 +93,16 @@ describe Ppl::Adapter::Storage::Git do
93
93
  contact = @git.load_contact("test")
94
94
  end
95
95
 
96
+ it "handles encoding errors gracefully" do
97
+ head = OpenStruct.new
98
+ head.target = "asdfg"
99
+
100
+ @repo.should_receive(:head).and_return(head)
101
+ @repo.should_receive(:file_at).and_return("vcard contents")
102
+ @vcard.should_receive(:decode).and_raise(GreenCard::InvalidEncodingError)
103
+ expect{ @git.load_contact("test") }.to raise_error(Ppl::Error::InvalidVcard)
104
+ end
105
+
96
106
  end
97
107
 
98
108
  describe "#save_contact" do
@@ -96,6 +96,16 @@ describe Ppl::Format::Table do
96
96
  @table.to_s.should include "123 Luis Ignacio Lula da Silva lula@planalto.biz"
97
97
  end
98
98
 
99
+ it "copes with mixed encodings" do
100
+ @table.add_row({
101
+ :id => "franz_viehböck".force_encoding("ASCII-8BIT"),
102
+ :name => "Franz Viehböck",
103
+ :email => "fv@example.org",
104
+ })
105
+ expect{ @table.to_s }.not_to raise_error()
106
+ @table.to_s.should include "franz_viehböck Franz Viehböck fv@example.org"
107
+ end
108
+
99
109
  end
100
110
 
101
111
  describe "#disable_colors!" do
data/spec/spec_helper.rb CHANGED
@@ -5,5 +5,10 @@ require "pathname"
5
5
  bin_file = Pathname.new(__FILE__).realpath
6
6
  $:.unshift File.expand_path("../../lib", bin_file)
7
7
 
8
+ if ENV['CI']
9
+ require "coveralls"
10
+ Coveralls.wear!
11
+ end
12
+
8
13
  require "ppl"
9
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ppl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-12 00:00:00.000000000 Z
11
+ date: 2014-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.0.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: cucumber
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -236,6 +250,7 @@ files:
236
250
  - lib/ppl/error/completion_not_found.rb
237
251
  - lib/ppl/error/contact_not_found.rb
238
252
  - lib/ppl/error/incorrect_usage.rb
253
+ - lib/ppl/error/invalid_vcard.rb
239
254
  - lib/ppl/error/postal_address_not_found.rb
240
255
  - lib/ppl/format/address_book.rb
241
256
  - lib/ppl/format/address_book/ages.rb