booker 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/booker +1 -4
- data/lib/booker.rb +37 -36
- data/lib/bookmarks.rb +1 -2
- data/lib/config.rb +3 -4
- data/lib/consts.rb +1 -0
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77132e0717914716bdbb9faef9f055fab5356da8
|
4
|
+
data.tar.gz: fc1e922a5f2e5145f1a27d46183e5c5ce04ec81e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2535513f6eb7860b4eb8d64b6a7df73afde2fb54b4f51073cb2d3dfb2a35c7008bc264b05882118669525a469e56a3100463e6e5311969db842a731487cd56ba
|
7
|
+
data.tar.gz: 026fd73d94df38ac6a8bfa405c452f40afa167c281ab8d2a1a13031082ac8dd735b1ffa6d388ab917a9cb6e6cee7f454ff5de62715fbeeebb185a2ae35dcfeb9
|
data/bin/booker
CHANGED
data/lib/booker.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
1
|
# parse booker's command line args
|
2
|
-
|
3
|
-
|
4
|
-
VERSION = "0.5.1"
|
5
|
-
|
6
|
-
|
7
2
|
require 'yaml'
|
8
3
|
require 'find'
|
9
4
|
require 'json'
|
@@ -14,8 +9,13 @@ require_relative 'config'
|
|
14
9
|
require_relative 'consts'
|
15
10
|
|
16
11
|
|
17
|
-
# get
|
12
|
+
# get booker opening command
|
18
13
|
class Booker
|
14
|
+
@version = "0.6.0"
|
15
|
+
class << self
|
16
|
+
attr_reader :version
|
17
|
+
end
|
18
|
+
|
19
19
|
include Browser
|
20
20
|
def initialize(args)
|
21
21
|
parse args
|
@@ -34,11 +34,10 @@ class Booker
|
|
34
34
|
if browsearg.match(/^[0-9]/) # bookmark
|
35
35
|
open_bookmark args
|
36
36
|
elsif domain.match(browsearg) # website
|
37
|
-
puts 'opening website ' + browsearg
|
38
|
-
openweb(
|
37
|
+
puts 'opening website: ' + browsearg
|
38
|
+
openweb(prep(browsearg))
|
39
39
|
else
|
40
|
-
|
41
|
-
open_search allargs
|
40
|
+
open_search(args.join(' '))
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
@@ -52,7 +51,7 @@ class Booker
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def version
|
55
|
-
pexit
|
54
|
+
pexit @version, 0
|
56
55
|
end
|
57
56
|
|
58
57
|
def openweb(url)
|
@@ -72,7 +71,7 @@ class Booker
|
|
72
71
|
def open_search(term)
|
73
72
|
puts 'searching ' + term + '...'
|
74
73
|
search = BConfig.new.searcher
|
75
|
-
openweb(Shellwords.escape(
|
74
|
+
openweb(search + Shellwords.escape(term))
|
76
75
|
end
|
77
76
|
|
78
77
|
# parse and execute any command line options
|
@@ -84,7 +83,7 @@ class Booker
|
|
84
83
|
errormsg = 'Error: '.red + "unrecognized option #{nextarg}"
|
85
84
|
pexit errormsg, 1 if ! (valid_opts.include? nextarg)
|
86
85
|
|
87
|
-
#
|
86
|
+
# forced bookmarking
|
88
87
|
if nextarg == '--bookmark' || nextarg == '-b'
|
89
88
|
if args.first.nil?
|
90
89
|
pexit 'Error: '.red + 'booker --bookmark expects bookmark id', 1
|
@@ -93,14 +92,14 @@ class Booker
|
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
96
|
-
#
|
95
|
+
# autocompletion
|
97
96
|
if nextarg == '--complete' || nextarg == '-c'
|
98
97
|
allargs = args.join(' ')
|
99
98
|
bm = Bookmarks.new(allargs)
|
100
99
|
bm.autocomplete
|
101
100
|
end
|
102
101
|
|
103
|
-
#
|
102
|
+
# installation
|
104
103
|
if nextarg == '--install' || nextarg == '-i'
|
105
104
|
if !args.empty?
|
106
105
|
install(args)
|
@@ -110,7 +109,7 @@ class Booker
|
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
|
-
#
|
112
|
+
# forced searching
|
114
113
|
if nextarg == '--search' || nextarg == '-s'
|
115
114
|
pexit '--search requires an argument', 1 if args.empty?
|
116
115
|
allargs = args.join(' ')
|
@@ -148,8 +147,7 @@ class Booker
|
|
148
147
|
begin
|
149
148
|
fpath = `zsh -c 'echo $fpath'`.split(' ')
|
150
149
|
rescue
|
151
|
-
pexit "Failure: ".red +
|
152
|
-
"zsh is probably not installed, could not find $fpath", 1
|
150
|
+
pexit "Failure: ".red + "zsh is probably not installed, could not find $fpath", 1
|
153
151
|
end
|
154
152
|
|
155
153
|
# determine where to install completion function
|
@@ -157,51 +155,54 @@ class Booker
|
|
157
155
|
begin
|
158
156
|
File.open(fp + "/_booker", 'w') {|f| f.write(COMPLETION) }
|
159
157
|
system "zsh -c 'autoload -U _booker'"
|
160
|
-
puts "Success: ".grn +
|
161
|
-
"installed zsh autocompletion in #{fp}"
|
158
|
+
puts "Success: ".grn + "installed zsh autocompletion in #{fp}"
|
162
159
|
break # if this works, don't try anymore
|
163
160
|
rescue
|
164
|
-
puts "Failure: ".red +
|
165
|
-
"could not write ZSH completion _booker script to $fpath (#{fp})"
|
161
|
+
puts "Failure: ".red + "could not write ZSH completion _booker script to $fpath (#{fp})"
|
166
162
|
end
|
167
163
|
end
|
168
164
|
end
|
169
165
|
|
170
166
|
def install_bookmarks
|
171
167
|
# locate bookmarks file, show user, write to config?
|
172
|
-
puts 'searching for chrome bookmarks...
|
168
|
+
puts 'searching for chrome bookmarks...'
|
173
169
|
begin
|
174
170
|
bms = [] # look for bookmarks
|
175
|
-
|
176
|
-
|
171
|
+
[ '/Library/Application Support/Google/Chrome',
|
172
|
+
'/AppData/Local/Google/Chrome/User Data/Default',
|
173
|
+
'/.config/chromium/Default/',
|
174
|
+
'/.config/google-chrome/Default/',
|
175
|
+
].each do |f|
|
176
|
+
home = File.join(ENV['HOME'], f)
|
177
|
+
next if !FileTest.directory?(home)
|
178
|
+
Find.find(home) do |file|
|
179
|
+
bms << file if /chrom.*bookmarks/i.match file
|
180
|
+
end
|
177
181
|
end
|
178
182
|
|
179
183
|
if bms.empty? # no bookmarks found
|
180
184
|
puts "Failure: ".red + 'bookmarks file could not be found.'
|
181
185
|
raise
|
182
186
|
else # have user select a file
|
183
|
-
puts 'select
|
184
|
-
bms.each_with_index{|bm, i| puts i.to_s.grn + " - " + bm }
|
187
|
+
puts 'select bookmarks file: '
|
188
|
+
bms.each_with_index {|bm, i| puts i.to_s.grn + " - " + bm }
|
185
189
|
selected = bms[gets.chomp.to_i]
|
186
190
|
puts 'Selected: '.yel + selected
|
187
191
|
BConfig.new.write('bookmarks', selected)
|
188
|
-
puts "Success: ".grn +
|
189
|
-
"config file updated with your bookmarks"
|
192
|
+
puts "Success: ".grn + "config file updated with your bookmarks"
|
190
193
|
end
|
191
|
-
rescue
|
192
|
-
|
193
|
-
|
194
|
+
rescue StandardError => e
|
195
|
+
puts e.message
|
196
|
+
pexit "Failure: ".red + "could not add bookmarks to config file ~/.booker", 1
|
194
197
|
end
|
195
198
|
end
|
196
199
|
|
197
200
|
def install_config
|
198
201
|
begin
|
199
202
|
BConfig.new.write
|
200
|
-
puts "Success: ".grn +
|
201
|
-
"example config file written to ~/.booker"
|
203
|
+
puts "Success: ".grn + "example config file written to ~/.booker"
|
202
204
|
rescue
|
203
|
-
pexit "Failure: ".red +
|
204
|
-
"could not write example config file to ~/.booker", 1
|
205
|
+
pexit "Failure: ".red + "could not write example config file to ~/.booker", 1
|
205
206
|
end
|
206
207
|
end
|
207
208
|
end
|
data/lib/bookmarks.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# grab/parse bookmarks from json file on computer
|
2
2
|
|
3
|
-
|
4
3
|
# get int number of columns in half of screen
|
5
4
|
TERMWIDTH = (TermInfo.screen_size[1]/2).floor
|
6
5
|
|
@@ -18,7 +17,7 @@ class String
|
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
|
-
# thx danhassin
|
20
|
+
# thx danhassin/dingbat
|
22
21
|
def colorize(color, mod)
|
23
22
|
"\033[#{mod};#{color};49m#{self}\033[0;0m"
|
24
23
|
end
|
data/lib/config.rb
CHANGED
@@ -25,7 +25,7 @@ module Browser
|
|
25
25
|
# alternatively, start seems to work - probably check if powershell v cygwin?
|
26
26
|
'/cygdrive/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe '
|
27
27
|
elsif OS.mac?
|
28
|
-
'open
|
28
|
+
'open '
|
29
29
|
elsif OS.linux?
|
30
30
|
'xdg-open ' # completely guessing here
|
31
31
|
end
|
@@ -45,8 +45,7 @@ module Browser
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def wrap(url)
|
48
|
-
|
49
|
-
url
|
48
|
+
"\"#{url}\""
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
@@ -85,7 +84,7 @@ class BConfig
|
|
85
84
|
rescue Errno::ENOENT
|
86
85
|
puts "Warning: ".yel +
|
87
86
|
"YAML configuration file couldn't be found. Using defaults."
|
88
|
-
puts "Suggest: ".grn + "
|
87
|
+
puts "Suggest: ".grn + "booker --install config"
|
89
88
|
return false
|
90
89
|
rescue Psych::SyntaxError
|
91
90
|
puts "Warning: ".red +
|
data/lib/consts.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: booker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Warner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-terminfo
|
@@ -36,20 +36,20 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '1
|
39
|
+
version: '2.1'
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 1.
|
42
|
+
version: 2.1.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1
|
49
|
+
version: '2.1'
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 1.
|
52
|
+
version: 2.1.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rspec
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,9 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.6.14
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: CLI parser/selector for google chrome bookmarks
|
118
118
|
test_files: []
|
119
|
-
has_rdoc:
|