bulkippt-cli 0.0.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.
- data/.gitignore +21 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +8 -0
- data/bin/bulkippt +5 -0
- data/bulkippt.gemspec +30 -0
- data/lib/bulkippt.rb +50 -0
- data/lib/bulkippt/version.rb +3 -0
- data/spec/data/empty.csv +0 -0
- data/spec/data/good.csv +1 -0
- data/spec/lib/bulkippt/bulkippt_spec.rb +77 -0
- data/spec/spec_helper.rb +1 -0
- metadata +197 -0
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
.rvmrc
|
7
|
+
.rspec
|
8
|
+
Gemfile.lock
|
9
|
+
InstalledFiles
|
10
|
+
_yardoc
|
11
|
+
coverage
|
12
|
+
doc/
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
config/my_kippt_creds.yml
|
21
|
+
Guardfile
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Johnny Boursiquot
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Bulkippt CLI
|
2
|
+
|
3
|
+
BulkipptCLI offers a command line interface alternative to using the Bulkippt gem (https://github.com/jboursiquot/bulkippt) in your application. If you just need to import your bookmarks from a CSV into your kippt.com account with a single one-liner from your shell, this is your tool.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install bulkippt-cli
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Upon installation, the bulkippt command should be available to you in the terminal. Running the command without any arguments will list the available tasks you can perform. The built-in help can also assist you with invocation parameters like so:
|
12
|
+
|
13
|
+
$ bulkippt help submit
|
14
|
+
|
15
|
+
To invoke the submit task (in test mode):
|
16
|
+
|
17
|
+
$ bulkippt submit ~/path/to/my/bookmarks.csv -u kippt_username -t kippt_token
|
18
|
+
|
19
|
+
The above command will submit the bookmarks you've listed in your CSV using your kippt.com username and token passed in through the -u and -t flags. See developers.kippt.com for that information.
|
20
|
+
|
21
|
+
Your bookmarks CSV is expected to have the following columns: url, title, description.
|
22
|
+
|
23
|
+
The result of running the command successfully will be something like this:
|
24
|
+
|
25
|
+
I, [2012-11-14T01:40:55.938107 #66997] INFO -- : SUCCESS: Kippt http://www.kippt.com
|
26
|
+
I, [2012-11-14T01:40:55.938230 #66997] INFO -- : SUCCESS: Pinboard http://pinboard.in
|
27
|
+
I, [2012-11-14T01:40:55.938288 #66997] INFO -- : SUCCESS: Delicious http://delicious.com
|
28
|
+
3 bookmarks submitted
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes with tests (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/bulkippt
ADDED
data/bulkippt.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bulkippt/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "bulkippt-cli"
|
8
|
+
gem.version = Bulkippt::VERSION
|
9
|
+
gem.authors = ["Johnny Boursiquot"]
|
10
|
+
gem.email = ["jboursiquot@gmail.com"]
|
11
|
+
gem.description = %q{BulkipptCLI offers a command line interface alternative to using the Bulkippt gem in your application. If you just need to import your bookmarks from a CSV into your kippt.com account with a single one-liner from your shell, this is your tool.}
|
12
|
+
gem.summary = %q{BulkipptCLI offers a command line interface alternative to using the Bulkippt gem in your application. If you just need to import your bookmarks from a CSV into your kippt.com account with a single one-liner from your shell, this is your tool.}
|
13
|
+
gem.homepage = "https://github.com/jboursiquot/bulkippt-cli"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'kippt','~> 1.1.0'
|
21
|
+
gem.add_runtime_dependency 'bulkippt','~> 0.0.3'
|
22
|
+
gem.add_runtime_dependency 'thor'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'rake','~> 0.9'
|
25
|
+
gem.add_development_dependency 'rspec','~> 2.11'
|
26
|
+
gem.add_development_dependency 'fivemat', '~> 1.1'
|
27
|
+
gem.add_development_dependency 'pry'
|
28
|
+
gem.add_development_dependency 'pry-debugger'
|
29
|
+
|
30
|
+
end
|
data/lib/bulkippt.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'logger'
|
3
|
+
require 'bulkippt'
|
4
|
+
require 'kippt'
|
5
|
+
|
6
|
+
module Bulkippt
|
7
|
+
|
8
|
+
class CLI < Thor
|
9
|
+
|
10
|
+
desc 'submit CSV', 'Submits bookmarks from CSV to kippt.com'
|
11
|
+
method_option :username, aliases: '-u', desc: 'Your kippt.com username'
|
12
|
+
method_option :token, aliases: '-t', desc: 'Your kippt.com token'
|
13
|
+
method_option :environment, aliases: '-e', default: 'production', desc: 'Running environment of tool. When set to test, it will not submit to Kippt.com.'
|
14
|
+
def submit(csv)
|
15
|
+
begin
|
16
|
+
initialize_credentials options['username'], options['token']
|
17
|
+
initialize_bulkippt options['environment']
|
18
|
+
|
19
|
+
csv_path = File.expand_path(csv, __FILE__)
|
20
|
+
raise "File not found: #{csv}" unless File.exists?(csv_path)
|
21
|
+
|
22
|
+
bookmarks = @bulkippt.extract_bookmarks csv_path
|
23
|
+
submitted = @bulkippt.submit_bookmarks bookmarks
|
24
|
+
$stdout.puts "#{submitted.length} bookmarks submitted"
|
25
|
+
|
26
|
+
rescue => e
|
27
|
+
$stderr.puts e.message
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def initialize_credentials(username, token)
|
34
|
+
raise 'Missing username argument' if username.nil? || username == 'username'
|
35
|
+
raise 'Missing token argument' if token.nil? || token == 'token'
|
36
|
+
@username = username
|
37
|
+
@token = token
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize_bulkippt(env)
|
42
|
+
kippt = env == 'test' ? Bulkippt::FakeService.new(@username, @token) : Kippt::Client.new(username: @username, token: @token)
|
43
|
+
@bulkippt = Bulkippt::Loader.new(kippt)
|
44
|
+
raise 'Invalid username and/or token' unless @bulkippt.credentials_valid?
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/spec/data/empty.csv
ADDED
File without changes
|
data/spec/data/good.csv
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
URL,Title,Description,Folder
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe 'Bulkippt CLI' do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@username = 'valid'
|
7
|
+
@token = 'valid'
|
8
|
+
@invalid_username = 'invalid'
|
9
|
+
@invalid_token = 'invalid'
|
10
|
+
@empty_csv = File.expand_path('../../../data/empty.csv',__FILE__)
|
11
|
+
@good_csv = File.expand_path('../../../data/good.csv',__FILE__)
|
12
|
+
@bad_csv = '/does/not/exist'
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when invoked without any parameters' do
|
16
|
+
|
17
|
+
it 'should respond with a task list' do
|
18
|
+
output = `./bin/bulkippt`
|
19
|
+
output.should include 'Tasks:'
|
20
|
+
output.should include 'bulkippt submit CSV'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when submit task is invoked with missing or invalid paramters' do
|
26
|
+
|
27
|
+
it "should respond with 'bulkippt submit requires at least 1 argument...' if the csv passed in is invalid" do
|
28
|
+
output = `./bin/bulkippt submit -e test 2>&1`
|
29
|
+
output.should include 'bulkippt submit requires at least 1 argument'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should respond with a missing username argument error if the -u|-username parameter is not provided' do
|
33
|
+
output = `./bin/bulkippt submit #{@empty_csv} -e test 2>&1`
|
34
|
+
output.should include 'Missing username argument'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should respond with a missing username argument error if the -u|-username parameter is blank' do
|
38
|
+
output = `./bin/bulkippt submit #{@empty_csv} -u -e test 2>&1`
|
39
|
+
output.should include 'Missing username argument'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should respond with a missing token argument error if the -t|-token parameter is not provided' do
|
43
|
+
output = `./bin/bulkippt submit #{@empty_csv} -u #{@username} -e test 2>&1`
|
44
|
+
output.should include 'Missing token argument'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should respond with a missing token argument error if the -t|-token parameter is blank' do
|
48
|
+
output = `./bin/bulkippt submit #{@empty_csv} -u #{@username} -t -e test 2>&1`
|
49
|
+
output.should include 'Missing token argument'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should respond with invalid username and/or token if validation of username/token fails' do
|
53
|
+
output = `./bin/bulkippt submit #{@good_csv} -u #{@invalid_username} -t #{@invalid_token} -e test 2>&1`
|
54
|
+
output.should include 'Invalid username and/or token'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should respond with an invalid CSV error if the expected columns are not found in the CSV' do
|
58
|
+
output = `./bin/bulkippt submit #{@empty_csv} -u #{@username} -t #{@token} -e test 2>&1`
|
59
|
+
output.should include "Missing 'url' column"
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should respond with an invalid CSV error if the CSV cannot be found' do
|
63
|
+
output = `./bin/bulkippt submit #{@bad_csv} -u #{@username} -t #{@token} -e test 2>&1`
|
64
|
+
output.should include "File not found: #{@bad_csv}"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when successfully parsing and submitting bookmarks' do
|
70
|
+
|
71
|
+
it 'should respond with at least 3 SUCCESS messages when bookmarks are successfully processed' do
|
72
|
+
output = `./bin/bulkippt submit #{@good_csv} -u #{@username} -t #{@token} -e test 2>&1`
|
73
|
+
output.should include 'SUCCESS'
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
%w{yaml pry}.each{ |lib| require lib}
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bulkippt-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Johnny Boursiquot
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: kippt
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.0
|
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.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bulkippt
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.0.3
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.0.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
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'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.9'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.9'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.11'
|
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: '2.11'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: fivemat
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.1'
|
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: '1.1'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pry
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: pry-debugger
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: BulkipptCLI offers a command line interface alternative to using the
|
143
|
+
Bulkippt gem in your application. If you just need to import your bookmarks from
|
144
|
+
a CSV into your kippt.com account with a single one-liner from your shell, this
|
145
|
+
is your tool.
|
146
|
+
email:
|
147
|
+
- jboursiquot@gmail.com
|
148
|
+
executables:
|
149
|
+
- bulkippt
|
150
|
+
extensions: []
|
151
|
+
extra_rdoc_files: []
|
152
|
+
files:
|
153
|
+
- .gitignore
|
154
|
+
- Gemfile
|
155
|
+
- LICENSE.txt
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- bin/bulkippt
|
159
|
+
- bulkippt.gemspec
|
160
|
+
- lib/bulkippt.rb
|
161
|
+
- lib/bulkippt/version.rb
|
162
|
+
- spec/data/empty.csv
|
163
|
+
- spec/data/good.csv
|
164
|
+
- spec/lib/bulkippt/bulkippt_spec.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
homepage: https://github.com/jboursiquot/bulkippt-cli
|
167
|
+
licenses: []
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
175
|
+
- - ! '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
none: false
|
180
|
+
requirements:
|
181
|
+
- - ! '>='
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 1.8.24
|
187
|
+
signing_key:
|
188
|
+
specification_version: 3
|
189
|
+
summary: BulkipptCLI offers a command line interface alternative to using the Bulkippt
|
190
|
+
gem in your application. If you just need to import your bookmarks from a CSV into
|
191
|
+
your kippt.com account with a single one-liner from your shell, this is your tool.
|
192
|
+
test_files:
|
193
|
+
- spec/data/empty.csv
|
194
|
+
- spec/data/good.csv
|
195
|
+
- spec/lib/bulkippt/bulkippt_spec.rb
|
196
|
+
- spec/spec_helper.rb
|
197
|
+
has_rdoc:
|