booker 0.1 → 0.2

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: 7e03cf87b4d4677e8ee2cd82e676e2c37e328c53
4
- data.tar.gz: 67c4a45af1cd4f92b9cf47c01e368bc0a3de5aff
3
+ metadata.gz: 12ce5c6cd017aa992b6dd70db7b7cf2f71731789
4
+ data.tar.gz: a14a6a224145a45ef3b1df81ec657560aee47f5a
5
5
  SHA512:
6
- metadata.gz: e3b1ff12d26bd927a4cfbccd737f9cc9b3ede569ec955529ac5b4a729aafe2a29be87597f291765e6a9a1216f3c57a89118999d16df99cda6a98ffdab38b868e
7
- data.tar.gz: cebe4d14c2d95831891035056d5e9567e4435c0e3ed70eeffdedc30ca24777b1dede6146b75ae6d1d62e11df4f8eedc7fe8cedaeff15ede44e033ad1eb5d532d
6
+ metadata.gz: 8855af77d02586e4ff62f1643c41b8ddcab97107e01fc22fb7c1d4bab5ec837493c3a26f0a591313d5611930457623a3ce39beab8ba4f305e8ca735b613b9998
7
+ data.tar.gz: 56ebded687f7e7f757e048a363e787f99fbb6454c41416e4b306ed4f8e2b49e444e1d0c9e85bbc2a97119bfeb3060852985b6f47363f5716c29f2ce0f0b5fe2c
data/bin/web CHANGED
@@ -9,15 +9,4 @@ require_relative "../lib/booker"
9
9
  # also show and/or open up google chrome bookmarks
10
10
 
11
11
 
12
- VERSION = "0.1"
13
- HELP_BANNER = <<-EOS
14
- Open browser:
15
- $ web [options]
16
- Options:
17
- --bookmark, -b: explicity open bookmark
18
- --search, -s: explicity open search
19
- --complete: show completions
20
- EOS
21
-
22
-
23
12
  Booker.new(ARGV)
@@ -1,8 +1,14 @@
1
- # parse command line args
1
+ # parse web's command line args
2
2
 
3
3
 
4
+ VERSION = "0.2"
5
+
6
+
7
+ require 'yaml'
8
+ require 'json'
4
9
  require_relative 'bookmarks'
5
- require_relative 'browser'
10
+ require_relative 'config'
11
+ require_relative 'consts'
6
12
 
7
13
 
8
14
  # get web opening command
@@ -12,41 +18,21 @@ class Booker
12
18
  parse args
13
19
  end
14
20
 
15
- def parse(args)
16
- if args.none? # no args given, show help
17
- puts HELP_BANNER
18
- exit 1
19
- end
20
-
21
- # doing autocompletion
22
- if args[0] == "--complete"
23
- args.shift # remove flag
24
- allargs = args.join(' ')
25
- bm = Bookmarks.new(allargs)
26
- bm.autocomplete
27
- exit 0
28
- end
29
-
30
-
31
- # doing forced bookmarking
32
- if args[0] == "--bookmark" or args[0] == "-b"
33
- bm = Bookmarks.new('')
34
- bookmark = bm.bookmark_id(args[1])
35
- url = bm.bookmark_url(bookmark)
36
- puts 'opening ' + url + '...'
37
- exec browse << wrap(url)
38
- exit 0
39
- end
21
+ def helper
22
+ pexit HELP_BANNER, 1
23
+ end
40
24
 
25
+ def pexit(msg, sig)
26
+ puts msg
27
+ exit sig
28
+ end
41
29
 
42
- # doing forced searching
43
- if args[0] == "--search" or args[0] == "-s"
44
- args.shift # remove flag
45
- puts 'searching ' + allargs + '...'
46
- exec browse << search << allargs
47
- exit 0
48
- end
30
+ def parse(args)
31
+ # no args given, show help
32
+ helper if args.none?
49
33
 
34
+ # if arg starts with hyphen, parse option
35
+ parse_opt args if /^-.*/.match(args[0])
50
36
 
51
37
  # interpret
52
38
  while args do
@@ -66,10 +52,130 @@ class Booker
66
52
 
67
53
  else # just search for these arguments
68
54
  puts 'searching ' + allargs + '...'
55
+ search = BConfig.new.searcher
69
56
  exec browse << search << allargs
70
57
 
71
58
  end
72
59
  end
73
60
  end
74
- end
75
61
 
62
+ def parse_opt(args)
63
+ valid_opts = %w{--version -v --install -i --help -h
64
+ --complete -c --bookmark -b --search -s}
65
+
66
+ nextarg = args[0]
67
+ errormsg = "Error: ".red + "unrecognized option #{nextarg}"
68
+ pexit errormsg, 1 if ! (valid_opts.include? nextarg)
69
+
70
+ # doing forced bookmarking
71
+ if args[0] == "--bookmark" or args[0] == "-b"
72
+ bm = Bookmarks.new('')
73
+ id = args[1]
74
+ if id
75
+ url = bm.bookmark_url(id)
76
+ puts 'opening ' + url + '...'
77
+ exec browse << wrap(url)
78
+ exit 0
79
+ else
80
+ pexit ' Error: '.red +
81
+ 'web --bookmark expects bookmark id', 1
82
+ end
83
+ end
84
+
85
+ # doing autocompletion
86
+ if args[0] == "--complete" or args[0] == "-c"
87
+ args.shift # remove flag
88
+ allargs = args.join(' ')
89
+ bm = Bookmarks.new(allargs)
90
+ bm.autocomplete
91
+ exit 0
92
+ end
93
+
94
+ # doing installation
95
+ if args[0] == "--install" or args[0] == "-i"
96
+ args.shift # remove flag
97
+ if args.length > 0
98
+ install(args)
99
+ else
100
+ pexit ' Error: '.red +
101
+ "web --install expects arguments: [completion, bookmarks, config]", 1
102
+ end
103
+ end
104
+
105
+ # needs some help
106
+ if args[0] == "--help" or args[0] == "-h"
107
+ helper
108
+ end
109
+
110
+ # doing forced searching
111
+ if args[0] == "--search" or args[0] == "-s"
112
+ args.shift # remove flag
113
+ allargs = args.join(' ')
114
+ if allargs == ""
115
+ pexit "--search requires an argument", 1
116
+ else
117
+ puts 'searching ' + allargs + '...'
118
+ search = BConfig.new.searcher
119
+ exec browse << search << allargs
120
+ exit 0
121
+ end
122
+ end
123
+
124
+ # print version information
125
+ if args[0] == "--version" or args[0] == "-v"
126
+ pexit VERSION, 0
127
+ end
128
+ end
129
+
130
+ def install(args)
131
+ target = args.shift
132
+ exit 0 if target.nil?
133
+
134
+ if /comp/i.match(target) # completion installation
135
+ begin
136
+ # determine where to install function
137
+ fpath = `zsh -c 'echo $fpath'`.split(' ')[0]
138
+ File.open(fpath + "/_web", 'w') {|f| f.write(COMPLETION) }
139
+ loaded = `zsh -c 'autoload -U _web'`
140
+ puts "Success: ".grn +
141
+ "installed zsh autocompletion in #{fpath}"
142
+ rescue
143
+ pexit "Failure: ".red +
144
+ "could not write ZSH completion _web script to $fpath", 1
145
+ end
146
+
147
+ elsif /bookmark/i.match(target) # bookmarks installation
148
+ # locate bookmarks file, show user, write to config?
149
+ puts 'searching for chrome bookmarks...(takes time)'
150
+ begin
151
+ bms = `find ~ -iname '*bookmarks' | grep -i chrom`.split("\n")
152
+ puts 'select your bookmarks file: '
153
+ bms.each_with_index{|bm, i| puts i.to_s.grn + " - " + bm }
154
+ selected = bms[gets.chomp.to_i]
155
+ puts 'Selected: '.yel + selected
156
+ BConfig.new.write('bookmarks', selected)
157
+ puts "Success: ".grn +
158
+ "config file updated with your bookmarks"
159
+ rescue
160
+ puts "Failure: ".red +
161
+ "could not add bookmarks to config file ~/.booker"
162
+ end
163
+
164
+ elsif /config/i.match(target) # default config file generation
165
+ begin
166
+ BConfig.new.write
167
+ puts "Success: ".grn +
168
+ "config file written to ~/.booker"
169
+ rescue
170
+ puts "Failure: ".red +
171
+ "could not write config file ~/.booker"
172
+ end
173
+
174
+ else # unknown argument passed into install
175
+ pexit "Failure: ".red +
176
+ "unknown installation option (#{target})", 1
177
+ end
178
+
179
+ install(args) # recurse til done
180
+ end
181
+ end
@@ -1,22 +1,11 @@
1
- # grab bookmarks from json file on computer - this may need to be changed based
2
- # on operating system as well
1
+ # grab/parse bookmarks from json file on computer
3
2
 
4
3
 
5
- require "rubygems"
6
- require "json"
7
- require_relative "folder"
4
+ TERMWIDTH = 80
8
5
 
9
6
 
10
- # get the width of the current terminal # [columns, lines]
11
- #require "highline"
12
- #COLWIDTH = HighLine::SystemExtensions.terminal_size[0]
13
-
14
7
  # thx danhassin
15
8
  class String
16
- def colorize(color, mod)
17
- "\033[#{mod};#{color};49m#{self}\033[0;0m"
18
- end
19
-
20
9
  def window(width)
21
10
  if self.length >= width
22
11
  self[0..width-1]
@@ -25,67 +14,73 @@ class String
25
14
  end
26
15
  end
27
16
 
17
+ def colorize(color, mod)
18
+ "\033[#{mod};#{color};49m#{self}\033[0;0m"
19
+ end
20
+
28
21
  def reset() colorize(0,0) end
29
- def white() colorize(37,1) end
30
- def green() colorize(32,0) end
31
- def blue() colorize(34,0) end
22
+ def blu() colorize(34,0) end
23
+ def yel() colorize(33,0) end
24
+ def grn() colorize(32,0) end
25
+ def red() colorize(31,0) end
32
26
  end
33
27
 
34
28
 
35
29
  class Bookmarks
36
- LOCAL_BOOKMARKS = "/Library/Application Support/Google/Chrome/Profile 1/bookmarks"
37
- RAW_JSON_BOOKMARKS = JSON.parse(open(ENV['HOME'] + LOCAL_BOOKMARKS).read)
38
- CHROME_BOOKMARKS = RAW_JSON_BOOKMARKS['roots']['bookmark_bar']['children']
39
-
30
+ # try to read bookmarks
40
31
  def initialize(search_term)
32
+ @conf = BConfig.new
33
+ begin
34
+ local_bookmarks = JSON.parse(open(@conf.bookmarks).read)
35
+ @chrome_bookmarks = local_bookmarks['roots']['bookmark_bar']['children']
36
+ rescue
37
+ puts "Warning: ".yel +
38
+ "Chrome JSON Bookmarks not found."
39
+ puts "Suggest: ".grn +
40
+ "web --install bookmarks"
41
+ @chrome_bookmarks = {}
42
+ end
43
+
44
+ # clean search term, set urls
41
45
  @searching = /#{search_term}/i
42
46
  @allurls = []
43
47
  parse
44
48
  end
45
49
 
50
+
46
51
  # output for zsh
47
52
  def autocomplete
48
- width = 80
49
53
  @allurls.each do |url|
50
54
  # delete anything not allowed in linktitle
51
- dirty_t = url.title.gsub(/[^a-z0-9\-\/_]/i, '')
52
- dirty_t = url.folder + dirty_t
53
- dirty_t = dirty_t.gsub(/\-+/, '-')
54
- dirty_t = dirty_t.gsub(/ /,'')
55
- name = dirty_t.window(width)
55
+ name = url.folder + url.title.gsub(/[^a-z0-9\-\/_]/i, '')
56
+ name.gsub!(/\-+/, '-')
57
+ name.gsub!(/ /,'')
58
+ name = name.window(TERMWIDTH)
56
59
 
57
60
  # remove strange things from any linkurls
58
- dirty_u = url.url.gsub(/[,'"&?].*/, '')
59
- dirty_u = dirty_u.gsub(/.*:\/+/,'')
60
- dirty_u = dirty_u.gsub(/ /,'')
61
- #right = [url.url.length, COLWIDTH-titlewidth].max
62
- #link = dirty_u[0..right-1]
63
- link = dirty_u[0..width]
61
+ link = url.url.gsub(/[,'"&?].*/, '')
62
+ link.gsub!(/.*:\/+/,'')
63
+ link.gsub!(/ /,'')
64
+ link = link[0..TERMWIDTH]
64
65
 
65
66
  # print out title and cleaned url, for autocompetion
66
67
  puts url.id + ":" + name + ":" + link
67
68
  end
68
69
  end
69
70
 
70
-
71
- # parse a bookmark's id from tab completed form
72
- def bookmark_id(url)
73
- url[0..5].gsub(/[^0-9]/, '')
74
- end
75
-
76
71
  # get link (from id number)
77
72
  def bookmark_url(id)
78
- bm_url = ''
79
73
  @allurls.each do |url|
80
- bm_url = url.url if id == url.id
74
+ if id == url.id
75
+ return url.url
76
+ end
81
77
  end
82
- bm_url
83
78
  end
84
79
 
85
80
  # recursively parse gc bookmarks
86
81
  def parse(root=nil)
87
82
  # root - parent folder in ruby
88
- root = Folder.new CHROME_BOOKMARKS if root.nil?
83
+ root = Folder.new @chrome_bookmarks if root.nil?
89
84
 
90
85
  # all current urls, to hash
91
86
  root.json.each {|x| parse_link root.title, x }
@@ -112,11 +107,25 @@ class Bookmarks
112
107
  parse(subdir)
113
108
  end
114
109
  end
110
+ end # close bookmarks class
111
+
112
+
113
+ # for recursively parsing bookmarks
114
+ class Folder
115
+ include Enumerable
116
+ def initialize(title='/', json)
117
+ @title = title.gsub(/[: ,'"]/, '-').downcase
118
+ @json = json
119
+ end
120
+
121
+ def json() @json end
122
+ def title() @title end
123
+ def each() @json.each end
115
124
  end
116
125
 
117
- # just hold data
126
+
127
+ # clean bookmark title, set attrs
118
128
  class Bookmark
119
- # clean bookmark title, set attrs
120
129
  def initialize(f, t, u, id)
121
130
  @title = t.gsub(/[: ,'"+\-]/, '_').downcase
122
131
  @folder = f
@@ -124,19 +133,8 @@ class Bookmark
124
133
  @id = id
125
134
  end
126
135
 
127
- def folder
128
- @folder
129
- end
130
-
131
- def title
132
- @title
133
- end
134
-
135
- def id
136
- @id
137
- end
138
-
139
- def url
140
- @url
141
- end
136
+ def folder() @folder end
137
+ def title() @title end
138
+ def url() @url end
139
+ def id() @id end
142
140
  end
@@ -0,0 +1,104 @@
1
+ # configuation - get where bookmarks are
2
+
3
+
4
+ # detect operating system
5
+ module OS
6
+ def OS.windows?
7
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
8
+ end
9
+
10
+ def OS.mac?
11
+ (/darwin/ =~ RUBY_PLATFORM) != nil
12
+ end
13
+
14
+ def OS.linux?
15
+ not (OS.windows? or OS.mac?)
16
+ end
17
+ end
18
+
19
+
20
+ # return browser (chrome) opening command
21
+ module Browser
22
+ extend OS
23
+ def browse
24
+ if OS.windows?
25
+ '/cygdrive/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe '
26
+ elsif OS.mac?
27
+ 'open -a "Google Chrome" '
28
+ elsif OS.linux?
29
+ 'xdg-open ' # completely guessing here
30
+ end
31
+ end
32
+
33
+ def domain
34
+ /.*(io|com|web|net|org|gov|edu)$/i
35
+ end
36
+
37
+ # helper methods
38
+ def prep(url)
39
+ if /^http/.match(url)
40
+ url
41
+ else
42
+ 'http://' << url
43
+ end
44
+ end
45
+
46
+ def wrap(url)
47
+ "'" + url + "'"
48
+ end
49
+ end
50
+
51
+
52
+ # high level configuration
53
+ class BConfig
54
+ YAMLCONF = ENV['HOME'] + '/.booker.yml'
55
+
56
+ def initialize
57
+ # config defaults (for osx, default chrome profile)
58
+ @config = {
59
+ :searcher => "https://duckduckgo.com/?q=",
60
+ :bookmarks => ENV['HOME'] +
61
+ "/Library/Application Support/Google/Chrome/Profile 1/Bookmarks",
62
+ }
63
+
64
+ # configure through users yaml config file
65
+ @config = read(YAMLCONF)
66
+
67
+ valid = @config.keys
68
+ @config.each do |k,v|
69
+ @config[k.to_sym] = v if valid.include? k.to_sym
70
+ end
71
+ end
72
+
73
+ def read(file)
74
+ begin
75
+ @config = YAML::load(IO.read(file))
76
+ rescue Errno::ENOENT
77
+ puts "Warning: ".yel +
78
+ "YAML configuration file couldn't be found. Using defaults."
79
+ puts "Suggest: ".grn +
80
+ "web --install config"
81
+ rescue Psych::SyntaxError
82
+ puts "Warning: ".red +
83
+ "YAML configuration file contains invalid syntax. Using defaults."
84
+ end
85
+ @config
86
+ end
87
+
88
+ def write(k=nil, v=nil)
89
+ if k.nil? or v.nil?
90
+ File.open(YAMLCONF, 'w') {|f| f.write(@config.to_yaml) }
91
+ else
92
+ @config[k] = v
93
+ File.open(YAMLCONF, 'w+') {|f| f.write(@config.to_yaml) }
94
+ end
95
+ end
96
+
97
+ def bookmarks
98
+ @config['bookmarks']
99
+ end
100
+
101
+ def searcher
102
+ @config['searcher']
103
+ end
104
+ end
@@ -0,0 +1,101 @@
1
+ # file for large constant strings
2
+
3
+
4
+ HELP_BANNER = <<-EOS
5
+ Open browser:
6
+ $ web [option] [arguments]
7
+
8
+ Main options:
9
+ --bookmark, -b: explicity open bookmark
10
+ --install, -i: install [bookmarks, completion, config]
11
+ --search, -s: explicity search arguments
12
+
13
+ Others:
14
+ --complete, -c: show tab completions
15
+ --version, -v: print version
16
+ --help, -h: show help
17
+ EOS
18
+
19
+
20
+ DEF_CONFIG = <<-EOS
21
+ bookmarks: null
22
+ searcher: https://duckduckgo.com/?q=
23
+ EOS
24
+
25
+
26
+ COMPLETION = <<-EOS
27
+ #compdef web
28
+ #autoload
29
+
30
+
31
+ _web_bookmarks() {
32
+ #http://zsh.sourceforge.net/Guide/zshguide06.html#l147
33
+ setopt glob bareglobqual nullglob rcexpandparam extendedglob automenu
34
+ unsetopt allexport aliases errexit octalzeroes ksharrays cshnullglob
35
+
36
+ #get chrome bookmarks
37
+ local -a bookmarks sites search
38
+
39
+ #grab all CLI args, remove 'web' from start
40
+ search=`echo $@ | sed -e '/^web /d'`
41
+ sites=`web --complete $search`
42
+ bookmarks=("${(f)${sites}}")
43
+
44
+ #terminal colors
45
+ BLUE=`echo -e "\033[4;34m"`
46
+ RESET=`echo -e "\033[0;0m"`
47
+
48
+ #parse parts, color
49
+ local -a ids links
50
+ for bookmark in ${bookmarks[@]}; do
51
+ local -a split
52
+ split=("${(@s/:/)bookmark}")
53
+ ids+=( $split[1] )
54
+ links+=("$split[2] $BLUE$split[3]$RESET")
55
+ done
56
+
57
+ #finally, add completions
58
+ compstate[insert]=menu
59
+ compadd -U -l -X 'found chrome bookmarks:' -d links -a ids
60
+ }
61
+
62
+
63
+ _web() {
64
+ compstate[insert]=menu
65
+ local curcontext state line
66
+ typeset -A opt_args
67
+ _arguments\
68
+ '(-b)-b[do bookmark completion]'\
69
+ '(--bookmark)--bookmark[do bookmark completion]'\
70
+ '(-c)-c[show bookmark completions]'\
71
+ '(--complete)--complete[show bookmark completions]'\
72
+ '(-i)-i[perform installations (bookmarks, completion, config)]'\
73
+ '(--install)--install[perform installations (bookmarks, completion, config)]'\
74
+ '(-s)-s[search google for...]'\
75
+ '(--search)--search[search google for...]'\
76
+ '(-h)-h[show web help]'\
77
+ '(--help)--help[show web help]'\
78
+ '(-v)-v[show version]'\
79
+ '(--version)--version[show version]'\
80
+ '*::bookmarks:->bookmarks' && return 0
81
+
82
+ _web_bookmarks $words
83
+ }
84
+
85
+
86
+ _web
87
+ EOS
88
+
89
+
90
+ ZSH_SCRIPT = <<-EOS
91
+ # load zsh web completions
92
+ install_loc=~/.oh-my-zsh/completions
93
+ script=_web
94
+
95
+ install:
96
+ mkdir -vp $(install_loc)
97
+ cp -v $(script) $(install_loc)/
98
+
99
+ uninstall:
100
+ rm -v $(install_loc)/$(script)
101
+ EOS
metadata CHANGED
@@ -1,32 +1,62 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: booker
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Warner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.8.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.1
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: rspec
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.3'
17
40
  - - ">="
18
41
  - !ruby/object:Gem::Version
19
- version: '0'
42
+ version: 3.3.2
20
43
  type: :development
21
44
  prerelease: false
22
45
  version_requirements: !ruby/object:Gem::Requirement
23
46
  requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.3'
24
50
  - - ">="
25
51
  - !ruby/object:Gem::Version
26
- version: '0'
27
- description: Select your bookmarks from the command line.
28
- email:
29
- - jeremywrnr@gmail.com
52
+ version: 3.3.2
53
+ description: |2
54
+ Select your bookmarks from the command line, by their bookmark id number.
55
+ ZSH users will be able to tab complete through their matches, similar to
56
+ how the autocompletion for `kill` works. If no bookmark is provided, web
57
+ will check if the argument is a website and visit it, or search duckduckgo
58
+ for the string argument.
59
+ email: jeremywrnr@gmail.com
30
60
  executables:
31
61
  - web
32
62
  extensions: []
@@ -35,13 +65,16 @@ files:
35
65
  - bin/web
36
66
  - lib/booker.rb
37
67
  - lib/bookmarks.rb
38
- - lib/browser.rb
39
- - lib/folder.rb
40
- homepage: http://rubygems.org/gems/booker
68
+ - lib/config.rb
69
+ - lib/consts.rb
70
+ homepage: http://github.com/jeremywrnr/booker
41
71
  licenses:
42
72
  - MIT
43
73
  metadata: {}
44
- post_install_message:
74
+ post_install_message: |2
75
+ Thank you for installing booker!
76
+ To set bookmarks location, run `web --install bookmarks`
77
+ To add zsh completion, run `web --install completion`
45
78
  rdoc_options: []
46
79
  require_paths:
47
80
  - lib
@@ -60,5 +93,5 @@ rubyforge_project:
60
93
  rubygems_version: 2.4.8
61
94
  signing_key:
62
95
  specification_version: 4
63
- summary: CLI parser for google chrome bookmarks
96
+ summary: CLI parser/selector for google chrome bookmarks
64
97
  test_files: []
@@ -1,55 +0,0 @@
1
- # detect operating system
2
-
3
- module OS
4
- def OS.windows?
5
- (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
6
- end
7
-
8
- def OS.mac?
9
- (/darwin/ =~ RUBY_PLATFORM) != nil
10
- end
11
-
12
- def OS.linux?
13
- not (OS.windows? or OS.mac?)
14
- end
15
- end
16
-
17
-
18
- # return browser (chrome) opening command
19
-
20
- module Browser
21
- extend OS
22
- def browse
23
- if OS.windows?
24
- '/cygdrive/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe '
25
- elsif OS.mac?
26
- 'open -a "Google Chrome" '
27
- elsif OS.linix?
28
- 'xdg-open ' # completely guessing here
29
- end
30
- end
31
-
32
- def domain
33
- /.*(io|com|web|net|org|gov|edu)$/i
34
- end
35
-
36
- def search
37
- #"https://www.google.com/search?q="
38
- #"http://www.bing.com/search?q=" #lol
39
- "https://duckduckgo.com/?q="
40
- end
41
-
42
- # helper methods
43
-
44
- def prep(url)
45
- if /^http/.match(url)
46
- url
47
- else
48
- 'http://' << url
49
- end
50
- end
51
-
52
- def wrap(url)
53
- "'" + url + "'"
54
- end
55
- end
@@ -1,21 +0,0 @@
1
- # basic folder class, for parsing bookmarks
2
-
3
- class Folder
4
- include Enumerable
5
- def initialize(title='/', json)
6
- @title = title.gsub(/[: ,'"]/, '-').downcase
7
- @json = json
8
- end
9
-
10
- def title
11
- @title
12
- end
13
-
14
- def json
15
- @json
16
- end
17
-
18
- def each
19
- @json.each
20
- end
21
- end