booker 0.2.1 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/booker.rb +24 -11
  3. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1532762ef0daee4451bf6edc98b8383ffe7efb0b
4
- data.tar.gz: 04935d5ae99fa9ae66dd5ff6a242cdb1825b4375
3
+ metadata.gz: 66eee15b03131060b83845037e2d8379db8fec53
4
+ data.tar.gz: ee81fcf16d0a652e6bd8283b0ae73f4a12924fcb
5
5
  SHA512:
6
- metadata.gz: fc05ede43930fcc9632b8e1cc4f7648eb181d157e791f34983f2892f122205b1d6283b68d3e1f977bc396a2b9b698ae62ef8210353bca09fe5530ad82916ea8b
7
- data.tar.gz: 746db64651cde56e9f52ccabec68403197af8dc9588fdc66ad5fb177d82e9c8dee90242ce0ae7f405b32295f86afa339471193ab2925491224a51ea8b847f426
6
+ metadata.gz: e17594d0e0f5e70c1825a299f82ca2410014f35098095461bbd2550aa30c8828f7db401c6d84abc0df4771215c5e72733cc6a5c5ae1d1aeb2a5df4c9977f4320
7
+ data.tar.gz: c207c0b6389922960bbf3df2974980ecdb20f281697ee7c7a24afa5779f3bceed127ae36de4afee429ecdc48c1065d20bfd79934e26c96ad75e1cfae99b13129
data/lib/booker.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # parse web's command line args
2
2
 
3
3
 
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
 
6
6
 
7
7
  require 'yaml'
8
+ require 'find'
8
9
  require 'json'
9
10
  require_relative 'bookmarks'
10
11
  require_relative 'config'
@@ -131,23 +132,35 @@ class Booker
131
132
  exit 0 if target.nil?
132
133
 
133
134
  if /comp/i.match(target) # completion installation
135
+ # check if zsh is even installed for this user
134
136
  begin
135
- # determine where to install function
136
- fpath = `zsh -c 'echo $fpath'`.split(' ')[0]
137
- File.open(fpath + "/_web", 'w') {|f| f.write(COMPLETION) }
138
- loaded = `zsh -c 'autoload -U _web'`
139
- puts "Success: ".grn +
140
- "installed zsh autocompletion in #{fpath}"
137
+ fpath = `zsh -c 'echo $fpath'`.split(' ')
141
138
  rescue
142
139
  pexit "Failure: ".red +
143
- "could not write ZSH completion _web script to $fpath", 1
140
+ "zsh is probably not installed, could not find $fpath", 1
141
+ end
142
+ # determine where to install completion function
143
+ fpath.each do |fp|
144
+ begin
145
+ File.open(fp + "/_web", 'w') {|f| f.write(COMPLETION) }
146
+ break # if this works, don't try anymore
147
+ rescue
148
+ puts "Failure: ".red +
149
+ "could not write ZSH completion _web script to $fpath"
150
+ end
144
151
  end
152
+ exec "zsh -c 'autoload -U _web'"
153
+ puts "Success: ".grn +
154
+ "installed zsh autocompletion in #{fpath}"
145
155
 
146
- elsif /bookmark/i.match(target) # bookmarks installation
156
+ elsif /book/i.match(target) # bookmarks installation
147
157
  # locate bookmarks file, show user, write to config?
148
- puts 'searching for chrome bookmarks...(takes time)'
158
+ puts 'searching for chrome bookmarks... (takes some time)'
149
159
  begin
150
- bms = `find ~ -iname '*bookmarks' | grep -i chrom`.split("\n")
160
+ bms = []
161
+ Find.find(ENV["HOME"]) do |path|
162
+ bms << path if /chrom.*bookmarks/i.match path
163
+ end
151
164
  puts 'select your bookmarks file: '
152
165
  bms.each_with_index{|bm, i| puts i.to_s.grn + " - " + bm }
153
166
  selected = bms[gets.chomp.to_i]
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.2.1
4
+ version: 0.2.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-17 00:00:00.000000000 Z
11
+ date: 2015-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -73,8 +73,9 @@ licenses:
73
73
  metadata: {}
74
74
  post_install_message: |2
75
75
  Thank you for installing booker!
76
- To set bookmarks location, run `web --install bookmarks`
77
- To add zsh completion, run `web --install completion`
76
+ To set bookmarks location, run `web -i bookmarks`
77
+ To add zsh completion, run `web -i completion`
78
+ To see more help, run `web --help`
78
79
  rdoc_options: []
79
80
  require_paths:
80
81
  - lib