bulkippt 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/bulkippt.gemspec CHANGED
@@ -22,4 +22,6 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'rake','~> 0.9'
23
23
  gem.add_development_dependency 'rspec','~> 2.11'
24
24
  gem.add_development_dependency 'fivemat', '~> 1.1'
25
+ gem.add_development_dependency 'pry'
26
+ gem.add_development_dependency 'pry-debugger'
25
27
  end
@@ -1,4 +1,5 @@
1
1
  require 'ostruct'
2
+ require 'json'
2
3
 
3
4
  module Bulkippt
4
5
 
@@ -1,3 +1,3 @@
1
1
  module Bulkippt
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/bulkippt.rb CHANGED
@@ -35,6 +35,7 @@ module Bulkippt
35
35
  parse_csv(@csv)
36
36
  rescue => e
37
37
  @logger.error e.message
38
+ []
38
39
  end
39
40
  end
40
41
 
@@ -53,6 +54,7 @@ module Bulkippt
53
54
  submitted
54
55
  rescue => e
55
56
  @logger.error e.message
57
+ []
56
58
  end
57
59
  end
58
60
 
@@ -73,13 +75,13 @@ module Bulkippt
73
75
  end
74
76
 
75
77
  def validate_file_path(file_path)
76
- raise Exception, "CSV not found: #{file_path}" if !File.exists?(file_path)
78
+ raise "File not found: #{file_path}" if !File.exists?(file_path)
77
79
  end
78
80
 
79
81
  def validate_headers(headers)
80
82
  #url and title are required, description and folder are not
81
- raise Exception, "Missing 'url' column" unless headers.include? 'url'
82
- raise Exception, "Missing 'title' column" unless headers.include? 'title'
83
+ raise "Missing 'url' column" unless headers.include? 'url'
84
+ raise "Missing 'title' column" unless headers.include? 'title'
83
85
  end
84
86
 
85
87
  def bookmark_instance(url, title, desc, folder)
@@ -5,11 +5,11 @@ describe "Bulkippt" do
5
5
  context "when asked to verify credentials" do
6
6
 
7
7
  it "should detect that a given set of credentials is incorrect" do
8
- Bulkippt::Loader.new(Bulkippt::FakeService.new('invalid', 'invalid')).credentials_valid?.should be_false
8
+ Bulkippt::Loader.new(Bulkippt::FakeService.new('invalid', 'invalid'), Logger.new('/dev/null')).credentials_valid?.should be_false
9
9
  end
10
10
 
11
11
  it "should detect that a given set of credentials is correct" do
12
- Bulkippt::Loader.new(Bulkippt::FakeService.new('valid', 'valid')).credentials_valid?.should be_true
12
+ Bulkippt::Loader.new(Bulkippt::FakeService.new('valid', 'valid'), Logger.new('/dev/null')).credentials_valid?.should be_true
13
13
  end
14
14
 
15
15
  end
@@ -20,14 +20,20 @@ describe "Bulkippt" do
20
20
  File.expand_path './spec/data/empty.csv'
21
21
  end
22
22
 
23
- it "should raise an error when it can't find the file specified" do
24
- loader = Bulkippt::Loader.new(Bulkippt::FakeService.new('valid','valid'))
25
- expect {loader.extract_bookmarks('/does/not/exist.csv')}.to raise_error
23
+ let :loader do
24
+ Bulkippt::Loader.new(Bulkippt::FakeService.new('valid','valid'), Logger.new('/dev/null'))
25
+ end
26
+
27
+ it "should fail to extract bookmarks when CSV's not found" do
28
+ result = loader.extract_bookmarks('/does/not/exist.csv')
29
+ result.should be_an_instance_of Array
30
+ result.size.should == 0
26
31
  end
27
32
 
28
33
  it "should raise an error when missing the require url and title columns" do
29
- loader = Bulkippt::Loader.new(Bulkippt::FakeService.new('valid', 'valid'))
30
- expect { loader.extract_bookmarks bad_csv }.to raise_error
34
+ result = loader.extract_bookmarks(bad_csv)
35
+ result.should be_an_instance_of Array
36
+ result.size.should == 0
31
37
  end
32
38
 
33
39
  end
@@ -38,15 +44,17 @@ describe "Bulkippt" do
38
44
  File.expand_path './spec/data/good.csv'
39
45
  end
40
46
 
47
+ let :loader do
48
+ Bulkippt::Loader.new(Bulkippt::FakeService.new('valid','valid'), Logger.new('/dev/null'))
49
+ end
50
+
41
51
  it "should find all the bookmarks" do
42
- loader = Bulkippt::Loader.new(Bulkippt::FakeService.new('valid', 'valid'))
43
52
  clips = loader.extract_bookmarks good_csv
44
53
  clips.class.should == Array
45
54
  clips.size.should >= 3
46
55
  end
47
56
 
48
57
  it "should use the service to submit the bookmarks" do
49
- loader = Bulkippt::Loader.new(Bulkippt::FakeService.new('valid', 'valid'))
50
58
  bookmarks = loader.extract_bookmarks good_csv
51
59
  saved = loader.submit_bookmarks bookmarks
52
60
  saved.class.should == Array
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,2 @@
1
- %w{kippt json}.each{ |lib| require lib}
2
- %w{bulkippt}.each { |file| require File.join(File.dirname(__FILE__),"../lib", file)}
1
+ %w{kippt json pry}.each{ |lib| require lib }
2
+ %w{bulkippt}.each { |file| require File.join(File.dirname(__FILE__),"../lib", file) }
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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -75,6 +75,38 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: '1.1'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: pry-debugger
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
78
110
  description: Imports bookmarks (url, title, etc) into your kippt.com account in bulk
79
111
  email:
80
112
  - jboursiquot@gmail.com