hop 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/hop/version.rb +1 -1
  2. data/lib/hop.rb +8 -1
  3. metadata +3 -3
data/lib/hop/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hop
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/hop.rb CHANGED
@@ -4,8 +4,10 @@ require 'trollop'
4
4
  class Hop
5
5
  class << self
6
6
  def run
7
+ ARGV[0] = '-h' unless ARGV[0]
7
8
  opts = Trollop::options do
8
9
  opt :add, "Add URL like: apple:http://www.apple.com", :type => String
10
+ opt :delete, "Pass in a key to delete the alias", :type => String
9
11
  opt :force, "Force overwriting of existing keys"
10
12
  opt :list
11
13
  end
@@ -19,7 +21,7 @@ class Hop
19
21
  end
20
22
 
21
23
  if(File.exist?($bookmarks_file))
22
- bookmarks = YAML::load_file($bookmarks_file)
24
+ bookmarks = YAML::load_file($bookmarks_file) || {}
23
25
  end
24
26
 
25
27
  if opts[:add_given]
@@ -32,6 +34,11 @@ class Hop
32
34
  YAML::dump(bookmarks.merge(key => url.join(':')), file)
33
35
  end
34
36
  end
37
+ elsif opts[:delete_given]
38
+ bookmarks.delete(opts[:delete])
39
+ File.open($bookmarks_file, 'w') do |file|
40
+ YAML::dump(bookmarks, file)
41
+ end
35
42
  elsif opts[:list_given]
36
43
  printf("%-16s %s\n", "key", "bookmark")
37
44
  puts "-" * 70
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hop
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacob Atzen