bulkippt 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Bulkippt
2
2
 
3
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jboursiquot/bulkippt)
4
+
3
5
  Allows you to upload your bookmarks to kippt.com in bulk. You'll need a kippt.com account (of course) from which you'll obtain your API token along with your username. From there, all you need is a CSV file with url, title and description headers and the loader will push those links to kippt.com on your behalf.
4
6
 
5
7
  ## Installation
data/lib/bulkippt.rb CHANGED
@@ -30,7 +30,25 @@ module Bulkippt
30
30
  def extract_bookmarks(file_path)
31
31
  begin
32
32
  validate_file_path file_path
33
+ rescue => e
34
+ @logger.error e.message
35
+ return []
36
+ end
37
+
38
+ begin
33
39
  @csv = CSV.read(file_path, {headers: true})
40
+ rescue ArgumentError => e
41
+ @logger.warn e.message + " | Forcing UTF-8..."
42
+ begin
43
+ data = IO.read(file_path).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
44
+ @csv = CSV.parse(data, {headers: true})
45
+ rescue => e
46
+ @logger.error "Failed to force UTF-8 | " + e.message
47
+ return []
48
+ end
49
+ end
50
+
51
+ begin
34
52
  validate_headers(normalize_headers(@csv.headers))
35
53
  parse_csv(@csv)
36
54
  rescue => e
@@ -70,6 +88,10 @@ module Bulkippt
70
88
  result
71
89
  end
72
90
 
91
+ def parse_file(file_path)
92
+ IO.read(file_path).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
93
+ end
94
+
73
95
  def normalize_headers(headers)
74
96
  headers.map(&:downcase)
75
97
  end
@@ -1,3 +1,3 @@
1
1
  module Bulkippt
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1 @@
1
+ URL,Title,Description,Folder
@@ -44,6 +44,10 @@ describe "Bulkippt" do
44
44
  File.expand_path './spec/data/good.csv'
45
45
  end
46
46
 
47
+ let :non_utf8_csv do
48
+ File.expand_path './spec/data/non-utf8.csv'
49
+ end
50
+
47
51
  let :loader do
48
52
  Bulkippt::Loader.new(Bulkippt::FakeService.new('valid','valid'), Logger.new('/dev/null'))
49
53
  end
@@ -54,6 +58,12 @@ describe "Bulkippt" do
54
58
  clips.size.should >= 3
55
59
  end
56
60
 
61
+ it "should handle non-UTF-8 CSVs and still find all the bookmarks" do
62
+ clips = loader.extract_bookmarks non_utf8_csv
63
+ clips.class.should == Array
64
+ clips.size.should >= 2
65
+ end
66
+
57
67
  it "should use the service to submit the bookmarks" do
58
68
  bookmarks = loader.extract_bookmarks good_csv
59
69
  saved = loader.submit_bookmarks bookmarks
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulkippt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: kippt
@@ -126,6 +126,7 @@ files:
126
126
  - lib/bulkippt/version.rb
127
127
  - spec/data/empty.csv
128
128
  - spec/data/good.csv
129
+ - spec/data/non-utf8.csv
129
130
  - spec/lib/bulkippt_spec.rb
130
131
  - spec/spec_helper.rb
131
132
  homepage: https://github.com/jboursiquot/bulkippt
@@ -155,5 +156,6 @@ summary: Imports bookmarks (url, title, etc) into your kippt.com account in bulk
155
156
  test_files:
156
157
  - spec/data/empty.csv
157
158
  - spec/data/good.csv
159
+ - spec/data/non-utf8.csv
158
160
  - spec/lib/bulkippt_spec.rb
159
161
  - spec/spec_helper.rb