boom 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # boom changes
2
2
  ## head
3
3
 
4
+ ## 0.4.0
5
+ - Returns an error if you try to `open` something that doesn't exist.
6
+ ([@romainberger](https://github.com/romainberger), #90).
7
+ - Removes `--delete` in favor of going to `boom delete x`
8
+ ([@eugeneius](https://github.com/holman/boom/pull/89), #89).
9
+
4
10
  ## 0.3.0
5
11
  - 0.3 removes all the Storage nonsense in favor of clean and easy JSON. Less
6
12
  code is best code.
data/README.md CHANGED
@@ -24,6 +24,9 @@ For more details about what boom is and how it works, check out
24
24
  $ boom shirt
25
25
  Boom! Just copied http://cl.ly/NwCS/shirt.gif to your clipboard.
26
26
 
27
+ $ boom delete gifs shirt
28
+ Boom! shirt is gone forever.
29
+
27
30
  And that's just a taste! I know, you're salivating, I can hear you from here.
28
31
  (Why your saliva is noisy is beyond me.) Check out the [full list of
29
32
  commands](https://github.com/holman/boom/wiki/Commands).
@@ -51,4 +54,4 @@ All good? Cool! Then [send me a pull request](https://github.com/holman/boom/pul
51
54
  [@holman](http://twitter.com/holman) — if you're having issues, want me to
52
55
  merge in your pull request, or are using boom in a cool way. I'm kind of hoping
53
56
  this is generic enough that people do some fun things with it. First one to use
54
- `boom` to calculate their tax liability wins.
57
+ `boom` to calculate their tax liability wins.
data/Rakefile CHANGED
@@ -75,9 +75,9 @@ task :release => :build do
75
75
  puts "You must be on the master branch to release!"
76
76
  exit!
77
77
  end
78
- sh "git commit --allow-empty -a -m 'Release #{version}'"
79
- sh "git tag v#{version}"
80
- sh "git push origin master"
78
+ # sh "git commit --allow-empty -a -m 'Release #{version}'"
79
+ # sh "git tag v#{version}"
80
+ # sh "git push origin master"
81
81
  sh "git push origin v#{version}"
82
82
  sh "gem push pkg/#{name}-#{version}.gem"
83
83
  end
data/boom.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'boom'
16
- s.version = '0.3.0'
17
- s.date = '2013-03-29'
16
+ s.version = '0.4.0'
17
+ s.date = '2013-08-18'
18
18
  s.rubyforge_project = 'boom'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
data/lib/boom/command.rb CHANGED
@@ -92,22 +92,24 @@ module Boom
92
92
  return help if command == 'help'
93
93
  return help if command[0] == 45 || command[0] == '-' # any - dash options are pleas for help
94
94
  return echo(major,minor) if command == 'echo' || command == 'e'
95
+ return copy(major,minor) if command == 'copy' || command == 'c'
95
96
  return open(major,minor) if command == 'open' || command == 'o'
96
97
  return random(major) if command == 'random' || command == 'rand' || command == 'r'
97
98
 
98
- # if we're operating on a List
99
- if storage.list_exists?(command)
100
- return delete_list(command) if major == '--delete'
101
- return detail_list(command) unless major
102
- unless minor == '--delete'
103
- return add_item(command,major,minor) if minor
104
- return add_item(command,major,stdin.read) if stdin.stat.size > 0
105
- return search_list_for_item(command, major)
99
+ if command == 'delete' || command == 'd'
100
+ if minor
101
+ return delete_item(major, minor)
102
+ else
103
+ return delete_list(major)
106
104
  end
107
105
  end
108
106
 
109
- if minor == '--delete' and storage.item_exists?(major)
110
- return delete_item(command, major)
107
+ # if we're operating on a List
108
+ if storage.list_exists?(command)
109
+ return detail_list(command) unless major
110
+ return add_item(command,major,minor) if minor
111
+ return add_item(command,major,stdin.read) if stdin.stat.size > 0
112
+ return search_list_for_item(command, major)
111
113
  end
112
114
 
113
115
  return search_items(command) if storage.item_exists?(command) and !major
@@ -136,17 +138,25 @@ module Boom
136
138
  list = List.find(major)
137
139
  if minor
138
140
  item = storage.items.detect { |item| item.name == minor }
139
- output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
141
+ if item
142
+ output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
143
+ else
144
+ output "Couldn't find #{yellow(minor)}."
145
+ end
140
146
  else
141
147
  list.items.each { |item| Platform.open(item) }
142
148
  output "#{cyan("Boom!")} We just opened all of #{yellow(major)} for you."
143
149
  end
144
150
  else
145
151
  item = storage.items.detect { |item| item.name == major }
146
- output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
152
+ if item
153
+ output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
154
+ else
155
+ output "Couldn't find #{yellow(major)}."
156
+ end
147
157
  end
148
158
  end
149
-
159
+
150
160
  # Public: Opens a random item
151
161
  #
152
162
  # Returns nothing.
@@ -161,9 +171,9 @@ module Boom
161
171
  else
162
172
  output "We couldn't find that list."
163
173
  end
164
- open(item.name, nil) unless item.nil?
174
+ open(item.name, nil) unless item.nil?
165
175
  end
166
-
176
+
167
177
  # Public: echoes only the Item's value without copying
168
178
  #
169
179
  # item_name - the String term to search for in all Item names
@@ -183,6 +193,23 @@ module Boom
183
193
  output item.value
184
194
  end
185
195
 
196
+ # Public: Copies to clipboard the Item's value without printing to screen
197
+ #
198
+ # Returns nothing
199
+ def copy(major, minor)
200
+ unless minor
201
+ item = storage.items.detect do |item|
202
+ item.name == major
203
+ end
204
+ return output "#{yellow(major)} #{red("not found")}" unless item
205
+ else
206
+ list = List.find(major)
207
+ item = list.find_item(minor)
208
+ return output "#{yellow(minor)} #{red("not found in")} #{yellow(major)}" unless item
209
+ end
210
+ Platform.copy(item)
211
+ end
212
+
186
213
  # Public: add a new List.
187
214
  #
188
215
  # name - the String name of the List.
@@ -265,7 +292,7 @@ module Boom
265
292
  end
266
293
  end
267
294
 
268
- # Public: search for an Item in all lists by name. Drops the
295
+ # Public: search for an Item in all lists by name. Drops the
269
296
  # corresponding entry into your clipboard.
270
297
  #
271
298
  # name - the String term to search for in all Item names
@@ -279,7 +306,7 @@ module Boom
279
306
  output "#{cyan("Boom!")} We just copied #{yellow(Platform.copy(item))} to your clipboard."
280
307
  end
281
308
 
282
- # Public: search for an Item in a particular list by name. Drops the
309
+ # Public: search for an Item in a particular list by name. Drops the
283
310
  # corresponding entry into your clipboard if found.
284
311
  #
285
312
  # list_name - the String name of the List in which to scope the search
@@ -329,10 +356,10 @@ module Boom
329
356
  boom all show all items in all lists
330
357
  boom edit edit the boom JSON file in $EDITOR
331
358
  boom help this help text
332
-
359
+
333
360
  boom <list> create a new list
334
361
  boom <list> show items for a list
335
- boom <list> --delete deletes a list
362
+ boom delete <list> deletes a list
336
363
 
337
364
  boom <list> <name> <value> create a new list item
338
365
  boom <name> copy item's value to clipboard
@@ -343,7 +370,9 @@ module Boom
343
370
  boom random <list> open a random item's url for a list in browser
344
371
  boom echo <name> echo the item's value without copying
345
372
  boom echo <list> <name> echo the item's value without copying
346
- boom <list> <name> --delete deletes an item
373
+ boom copy <name> copy the item's value without echo
374
+ boom copy <list> <name> copy the item's value without echo
375
+ boom delete <list> <name> deletes an item
347
376
 
348
377
  all other documentation is located at:
349
378
  https://github.com/holman/boom
data/lib/boom/platform.rb CHANGED
@@ -14,7 +14,7 @@ module Boom
14
14
  #
15
15
  # Returns true if running on darwin (MacOS X), else false
16
16
  def darwin?
17
- !!(RUBY_PLATFORM =~ /darwin/)
17
+ !!(RbConfig::CONFIG['host_os'] =~ /darwin/)
18
18
  end
19
19
 
20
20
  # Public: tests if currently running on windows.
@@ -23,7 +23,7 @@ module Boom
23
23
  #
24
24
  # Returns true if running on windows (win32/mingw32), else false
25
25
  def windows?
26
- !!(RUBY_PLATFORM =~ /mswin|mingw/)
26
+ !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
27
27
  end
28
28
 
29
29
  # Public: returns the command used to open a file or URL
@@ -35,7 +35,7 @@ module Boom
35
35
  def open_command
36
36
  if darwin?
37
37
  'open'
38
- elsif windows?
38
+ elsif windows?
39
39
  'start'
40
40
  else
41
41
  'xdg-open'
@@ -69,14 +69,20 @@ module Boom
69
69
  'xclip -selection clipboard'
70
70
  end
71
71
  end
72
-
72
+
73
73
  # Public: copies a given Item's value to the clipboard. This method is
74
74
  # designed to handle multiple platforms.
75
75
  #
76
76
  # Returns the String value of the Item.
77
77
  def copy(item)
78
- IO.popen(copy_command,"w") {|cc| cc.write(item.value)}
79
- item.value
78
+ begin
79
+ IO.popen(copy_command,"w") {|cc| cc.write(item.value)}
80
+ item.value
81
+ rescue Errno::ENOENT
82
+ puts item.value
83
+ puts "Please install #{copy_command[0..5]} to copy this item to your clipboard"
84
+ exit
85
+ end
80
86
  end
81
87
 
82
88
  # Public: opens the JSON file in an editor for you to edit. Uses the
@@ -86,7 +92,7 @@ module Boom
86
92
  #
87
93
  # Returns a String with a helpful message.
88
94
  def edit(json_file)
89
- unless $EDITOR.nil?
95
+ unless ENV['EDITOR'].nil?
90
96
  unless windows?
91
97
  system("`echo $EDITOR` #{json_file} &")
92
98
  else
data/lib/boom.rb CHANGED
@@ -20,9 +20,9 @@ require 'boom/storage'
20
20
  require 'boom/core_ext/symbol'
21
21
 
22
22
  module Boom
23
- VERSION = '0.3.0'
23
+ VERSION = '0.4.0'
24
24
 
25
25
  def self.storage
26
26
  @storage ||= Storage.new
27
27
  end
28
- end
28
+ end
data/test/item.sh CHANGED
@@ -10,10 +10,14 @@ it_adds_an_item() {
10
10
  }
11
11
 
12
12
  it_deletes_an_item() {
13
- yes | $boom urls google --delete | grep 'gone forever'
13
+ yes | $boom delete urls google | grep 'gone forever'
14
14
  $boom urls google | grep 'not found'
15
15
  }
16
16
 
17
17
  it_echos_an_item() {
18
18
  $boom echo site | grep 'zachholman.com'
19
- }
19
+ }
20
+
21
+ it_handles_open_on_nonexistent_item() {
22
+ $boom open nadda | grep "nadda"
23
+ }
data/test/list.sh CHANGED
@@ -25,6 +25,6 @@ it_shows_a_list() {
25
25
 
26
26
  it_deletes_a_list() {
27
27
  $boom | grep "enemies"
28
- yes | $boom enemies --delete | grep "Deleted"
28
+ yes | $boom delete enemies | grep "Deleted"
29
29
  ! $boom | grep "enemies"
30
30
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-08-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby