boom 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +9 -0
- data/README.markdown +20 -0
- data/boom.gemspec +5 -3
- data/completion/boom.bash +23 -0
- data/completion/boom.zsh +18 -0
- data/lib/boom/command.rb +44 -5
- data/lib/boom/item.rb +8 -0
- data/lib/boom/list.rb +3 -1
- data/lib/boom/platform.rb +54 -0
- data/lib/boom.rb +2 -2
- data/test/test_command.rb +37 -0
- data/test/test_item.rb +13 -0
- data/test/test_list.rb +10 -0
- metadata +7 -5
- data/lib/boom/clipboard.rb +0 -29
data/CHANGELOG.markdown
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# boom changes
|
2
2
|
|
3
3
|
## head
|
4
|
+
- `boom open` will open the Item's URL in a browser, or it'll open all the URLs
|
5
|
+
in a List for you. Thanks [lwe](https://github.com/lwe).
|
6
|
+
- Values for item creation can have spaces, and then they get concat'ed as one
|
7
|
+
value. Thanks [lwe](https://github.com/lwe).
|
8
|
+
- Replacing an item no longer dupes the item; it'll just replace the value.
|
9
|
+
Thank god, finally. Thanks [thbishop](https://github.com/thbishop).
|
10
|
+
- Also started `completion/`, a place to drop in scripts to set up completion
|
11
|
+
support for boom. Starting out with [thbishop](https://github.com/thbishop)'s
|
12
|
+
bash script, but if anyone has something for zsh I'd kiss them a bit.
|
4
13
|
|
5
14
|
## 0.0.9
|
6
15
|
- Backport `Symbol#to_proc` for 1.8.6 support (thanks
|
data/README.markdown
CHANGED
@@ -81,6 +81,26 @@ can have multiple lists.
|
|
81
81
|
blog: http://zachholman.com
|
82
82
|
github: https://github.com
|
83
83
|
|
84
|
+
** Open in browser **
|
85
|
+
|
86
|
+
$ boom open facebook-stalking
|
87
|
+
Boom! We just opened all of "shoes" for you.
|
88
|
+
|
89
|
+
In other words, this will open all the links in `facebook-stalking` in your
|
90
|
+
browser. You creep. You can also just open up one:
|
91
|
+
|
92
|
+
$ boom open twitter
|
93
|
+
Boom! We just opened http://twitter.com for you.
|
94
|
+
|
95
|
+
** Echo an item**
|
96
|
+
|
97
|
+
# boom echo <list> <name>
|
98
|
+
# boom echo <name>
|
99
|
+
$ git clone $(boom echo github)holman/boom
|
100
|
+
Cloning into boom...
|
101
|
+
|
102
|
+
Impossible... no. It's silly, but not impossible.
|
103
|
+
|
84
104
|
** Help **
|
85
105
|
|
86
106
|
$ boom help
|
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.0.
|
17
|
-
s.date = '2011-01-
|
16
|
+
s.version = '0.0.10'
|
17
|
+
s.date = '2011-01-26'
|
18
18
|
s.rubyforge_project = 'boom'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -71,12 +71,14 @@ Gem::Specification.new do |s|
|
|
71
71
|
Rakefile
|
72
72
|
bin/boom
|
73
73
|
boom.gemspec
|
74
|
+
completion/boom.bash
|
75
|
+
completion/boom.zsh
|
74
76
|
lib/boom.rb
|
75
|
-
lib/boom/clipboard.rb
|
76
77
|
lib/boom/command.rb
|
77
78
|
lib/boom/core_ext/symbol.rb
|
78
79
|
lib/boom/item.rb
|
79
80
|
lib/boom/list.rb
|
81
|
+
lib/boom/platform.rb
|
80
82
|
lib/boom/storage.rb
|
81
83
|
test/examples/urls.json
|
82
84
|
test/helper.rb
|
@@ -0,0 +1,23 @@
|
|
1
|
+
_boom_complete() {
|
2
|
+
local cur prev lists
|
3
|
+
COMPREPLY=()
|
4
|
+
cur="${COMP_WORDS[COMP_CWORD]}"
|
5
|
+
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
6
|
+
|
7
|
+
lists=`boom | awk '{print $1}'`
|
8
|
+
|
9
|
+
case "${prev}" in
|
10
|
+
boom)
|
11
|
+
COMPREPLY=( $(compgen -W "${lists}" -- ${cur}) )
|
12
|
+
return 0
|
13
|
+
;;
|
14
|
+
*)
|
15
|
+
for ((i = 0; i < ${#lists}; i++)); do
|
16
|
+
local items=`boom $prev | awk '{print $1}' | sed -e 's/://'`
|
17
|
+
COMPREPLY=( $(compgen -W "${items}" -- ${cur}))
|
18
|
+
return 0
|
19
|
+
done
|
20
|
+
;;
|
21
|
+
esac
|
22
|
+
}
|
23
|
+
complete -F _boom_complete boom
|
data/completion/boom.zsh
ADDED
data/lib/boom/command.rb
CHANGED
@@ -24,9 +24,9 @@ module Boom
|
|
24
24
|
# args - The actual commands to operate on. Can be as few as zero
|
25
25
|
# arguments or as many as three.
|
26
26
|
def execute(*args)
|
27
|
-
command = args
|
28
|
-
major = args
|
29
|
-
minor = args
|
27
|
+
command = args.shift
|
28
|
+
major = args.shift
|
29
|
+
minor = args.empty? ? nil : args.join(' ')
|
30
30
|
|
31
31
|
return overview unless command
|
32
32
|
delegate(command, major, minor)
|
@@ -73,6 +73,8 @@ module Boom
|
|
73
73
|
return edit if command == 'edit'
|
74
74
|
return help if command == 'help'
|
75
75
|
return help if command[0] == 45 || command[0] == '-' # any - dash options are pleas for help
|
76
|
+
return echo(major,minor) if command == 'echo' || command == 'e'
|
77
|
+
return open(major,minor) if command == 'open'
|
76
78
|
|
77
79
|
# if we're operating on a List
|
78
80
|
if storage.list_exists?(command)
|
@@ -105,6 +107,39 @@ module Boom
|
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
110
|
+
# Public: opens the Item.
|
111
|
+
#
|
112
|
+
# Returns nothing.
|
113
|
+
def open(major, minor)
|
114
|
+
if storage.list_exists?(major)
|
115
|
+
list = List.find(major)
|
116
|
+
list.items.each { |item| Platform.open(item) }
|
117
|
+
output "Boom! We just opened all of \"#{major}\" for you."
|
118
|
+
else
|
119
|
+
item = storage.items.detect { |item| item.name == major }
|
120
|
+
output Platform.open(item)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Public: echoes only the Item's value without copying
|
125
|
+
#
|
126
|
+
# item_name - the String term to search for in all Item names
|
127
|
+
#
|
128
|
+
# Returns nothing
|
129
|
+
def echo(major, minor)
|
130
|
+
unless minor
|
131
|
+
item = storage.items.detect do |item|
|
132
|
+
item.name == major
|
133
|
+
end
|
134
|
+
return output "\"#{major}\" not found" unless item
|
135
|
+
else
|
136
|
+
list = List.find(major)
|
137
|
+
item = list.find_item(minor)
|
138
|
+
return output "\"#{minor}\" not found in \"#{major}\"" unless item
|
139
|
+
end
|
140
|
+
output item.value
|
141
|
+
end
|
142
|
+
|
108
143
|
# Public: add a new List.
|
109
144
|
#
|
110
145
|
# name - the String name of the List.
|
@@ -187,7 +222,7 @@ module Boom
|
|
187
222
|
item.name == name
|
188
223
|
end
|
189
224
|
|
190
|
-
output
|
225
|
+
output Platform.copy(item)
|
191
226
|
end
|
192
227
|
|
193
228
|
# Public: search for an Item in a particular list by name. Drops the
|
@@ -202,7 +237,7 @@ module Boom
|
|
202
237
|
item = list.find_item(item_name)
|
203
238
|
|
204
239
|
if item
|
205
|
-
output
|
240
|
+
output Platform.copy(item)
|
206
241
|
else
|
207
242
|
output "\"#{item_name}\" not found in \"#{list_name}\""
|
208
243
|
end
|
@@ -243,6 +278,10 @@ module Boom
|
|
243
278
|
boom <list> <name> <value> create a new list item
|
244
279
|
boom <name> copy item's value to clipboard
|
245
280
|
boom <list> <name> copy item's value to clipboard
|
281
|
+
boom open <name> open item's url in browser
|
282
|
+
boom open <list> <name> open all item's url in browser for a list
|
283
|
+
boom echo <name> echo the item's value without copying
|
284
|
+
boom echo <list> <name> echo the item's value without copying
|
246
285
|
boom <list> <name> delete deletes an item
|
247
286
|
|
248
287
|
all other documentation is located at:
|
data/lib/boom/item.rb
CHANGED
@@ -53,6 +53,14 @@ module Boom
|
|
53
53
|
name.length > 15 ? '' : ' '*(15-name.length+1)
|
54
54
|
end
|
55
55
|
|
56
|
+
# Public: only return url part of value - if no url has been
|
57
|
+
# detected returns value.
|
58
|
+
#
|
59
|
+
# Returns a String which preferably is a URL.
|
60
|
+
def url
|
61
|
+
@url ||= value.split(/\s+/).detect { |v| v =~ %r{\A[a-z0-9]+:\S+}i } || value
|
62
|
+
end
|
63
|
+
|
56
64
|
# Public: creates a Hash for this Item.
|
57
65
|
#
|
58
66
|
# Returns a Hash of its data.
|
data/lib/boom/list.rb
CHANGED
@@ -34,12 +34,14 @@ module Boom
|
|
34
34
|
# Returns the String name.
|
35
35
|
attr_accessor :name
|
36
36
|
|
37
|
-
# Public: associates an Item with this List.
|
37
|
+
# Public: associates an Item with this List. If the item name is already
|
38
|
+
# defined, then the value will be replaced
|
38
39
|
#
|
39
40
|
# item - the Item object to associate with this List.
|
40
41
|
#
|
41
42
|
# Returns the current set of items.
|
42
43
|
def add_item(item)
|
44
|
+
delete_item(item.name) if find_item(item.name)
|
43
45
|
@items << item
|
44
46
|
end
|
45
47
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# Platform is a centralized point to shell out platform specific functionality
|
4
|
+
# like clipboard access or commands to open URLs.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Clipboard is a centralized point to shell out to each individual platform's
|
8
|
+
# clipboard, pasteboard, or whatever they decide to call it.
|
9
|
+
#
|
10
|
+
module Boom
|
11
|
+
class Platform
|
12
|
+
class << self
|
13
|
+
|
14
|
+
# Public: tests if currently running on darwin.
|
15
|
+
#
|
16
|
+
# Returns true if running on darwin (MacOS X), else false
|
17
|
+
def darwin?
|
18
|
+
!!(RUBY_PLATFORM =~ /darwin/)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Public: returns the command used to open a file or URL
|
22
|
+
# for the current platform.
|
23
|
+
#
|
24
|
+
# Currently only supports MacOS X and Linux with `xdg-open`.
|
25
|
+
#
|
26
|
+
# Returns a String with the bin
|
27
|
+
def open_command
|
28
|
+
darwin? ? 'open' : 'xdg-open'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Public: opens a given Item's value in the browser. This
|
32
|
+
# method is designed to handle multiple platforms.
|
33
|
+
#
|
34
|
+
# Returns a String explaining what was done
|
35
|
+
def open(item)
|
36
|
+
`#{open_command} '#{item.url.gsub("\'","\\'")}'`
|
37
|
+
|
38
|
+
"Boom! We just opened #{item.value} for you."
|
39
|
+
end
|
40
|
+
|
41
|
+
# Public: copies a given Item's value to the clipboard. This method is
|
42
|
+
# designed to handle multiple platforms.
|
43
|
+
#
|
44
|
+
# Returns a String explaining what was done
|
45
|
+
def copy(item)
|
46
|
+
copy_command = darwin? ? "pbcopy" : "xclip -selection clipboard"
|
47
|
+
|
48
|
+
`echo '#{item.value.gsub("\'","\\'")}' | tr -d "\n" | #{copy_command}`
|
49
|
+
|
50
|
+
"Boom! We just copied #{item.value} to your clipboard."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/boom.rb
CHANGED
@@ -10,7 +10,7 @@ require 'yajl'
|
|
10
10
|
|
11
11
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
12
12
|
|
13
|
-
require 'boom/
|
13
|
+
require 'boom/platform'
|
14
14
|
require 'boom/command'
|
15
15
|
require 'boom/item'
|
16
16
|
require 'boom/list'
|
@@ -19,7 +19,7 @@ require 'boom/storage'
|
|
19
19
|
require 'boom/core_ext/symbol'
|
20
20
|
|
21
21
|
module Boom
|
22
|
-
VERSION = '0.0.
|
22
|
+
VERSION = '0.0.10'
|
23
23
|
|
24
24
|
def self.storage
|
25
25
|
@storage ||= Boom::Storage.new
|
data/test/test_command.rb
CHANGED
@@ -63,12 +63,29 @@ class TestCommand < Test::Unit::TestCase
|
|
63
63
|
assert_match /copied https:\/\/github\.com to your clipboard/,
|
64
64
|
command('urls github')
|
65
65
|
end
|
66
|
+
|
67
|
+
def test_item_open_url
|
68
|
+
Boom::Platform.stubs(:open_command).returns("echo")
|
69
|
+
assert_match /opened https:\/\/github\.com for you/,
|
70
|
+
command('open github')
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_item_open_lists
|
74
|
+
Boom::Platform.stubs(:open_command).returns("echo")
|
75
|
+
assert_match /opened all of \"urls\" for you/,
|
76
|
+
command('open urls')
|
77
|
+
end
|
66
78
|
|
67
79
|
def test_item_creation
|
68
80
|
assert_match /"twitter" in "urls"/,
|
69
81
|
command('urls twitter http://twitter.com/holman')
|
70
82
|
end
|
71
83
|
|
84
|
+
def test_item_creation_long_value
|
85
|
+
assert_match /is "tanqueray hendricks bombay"/,
|
86
|
+
command('urls gins tanqueray hendricks bombay')
|
87
|
+
end
|
88
|
+
|
72
89
|
def test_list_deletion_no
|
73
90
|
STDIN.stubs(:gets).returns('n')
|
74
91
|
assert_match /Just kidding then/, command('urls delete')
|
@@ -102,4 +119,24 @@ class TestCommand < Test::Unit::TestCase
|
|
102
119
|
def test_nonexistent_item_access_scoped_by_list
|
103
120
|
assert_match /"twitter" not found in "urls"/, command('urls twitter')
|
104
121
|
end
|
122
|
+
|
123
|
+
def test_echo_item
|
124
|
+
assert_match /https:\/\/github\.com/, command('echo github')
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_echo_item_shorthand
|
128
|
+
assert_match /https:\/\/github\.com/, command('e github')
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_echo_item_does_not_exist
|
132
|
+
assert_match /"wrong" not found/, command('echo wrong')
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_echo_list_item
|
136
|
+
assert_match /https:\/\/github\.com/, command('echo urls github')
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_echo_list_item_does_not_exist
|
140
|
+
assert_match /"wrong" not found in "urls"/, command('echo urls wrong')
|
141
|
+
end
|
105
142
|
end
|
data/test/test_item.rb
CHANGED
@@ -38,4 +38,17 @@ class TestItem < Test::Unit::TestCase
|
|
38
38
|
assert_equal 1, @item.to_hash.size
|
39
39
|
end
|
40
40
|
|
41
|
+
def test_url
|
42
|
+
assert_equal 'https://github.com', @item.url
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_url_with_additional_description
|
46
|
+
@item = Boom::Item.new('github', 'social coding https://github.com')
|
47
|
+
assert_equal 'https://github.com', @item.url
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_url_without_url
|
51
|
+
@item = Boom::Item.new('didum', 'dadam lol omg')
|
52
|
+
assert_equal 'dadam lol omg', @item.url
|
53
|
+
end
|
41
54
|
end
|
data/test/test_list.rb
CHANGED
@@ -20,6 +20,16 @@ class TestList < Test::Unit::TestCase
|
|
20
20
|
assert_equal 1, @list.items.size
|
21
21
|
end
|
22
22
|
|
23
|
+
def test_add_item_with_duplicate_name
|
24
|
+
@list.add_item(@item)
|
25
|
+
assert_equal 1, @list.items.size
|
26
|
+
assert_equal 'https://github.com', @list.find_item('github').value
|
27
|
+
@diff_item = Boom::Item.new('github', 'https://github.com/home')
|
28
|
+
@list.add_item(@diff_item)
|
29
|
+
assert_equal 1, @list.items.size
|
30
|
+
assert_equal 'https://github.com/home', @list.find_item('github').value
|
31
|
+
end
|
32
|
+
|
23
33
|
def test_to_hash
|
24
34
|
assert_equal 0, @list.to_hash[@list.name].size
|
25
35
|
@list.add_item(@item)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zach Holman
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-26 00:00:00 -08:00
|
19
19
|
default_executable: boom
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -73,12 +73,14 @@ files:
|
|
73
73
|
- Rakefile
|
74
74
|
- bin/boom
|
75
75
|
- boom.gemspec
|
76
|
+
- completion/boom.bash
|
77
|
+
- completion/boom.zsh
|
76
78
|
- lib/boom.rb
|
77
|
-
- lib/boom/clipboard.rb
|
78
79
|
- lib/boom/command.rb
|
79
80
|
- lib/boom/core_ext/symbol.rb
|
80
81
|
- lib/boom/item.rb
|
81
82
|
- lib/boom/list.rb
|
83
|
+
- lib/boom/platform.rb
|
82
84
|
- lib/boom/storage.rb
|
83
85
|
- test/examples/urls.json
|
84
86
|
- test/helper.rb
|
data/lib/boom/clipboard.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
# Clipboard is a centralized point to shell out to each individual platform's
|
4
|
-
# clipboard, pasteboard, or whatever they decide to call it.
|
5
|
-
#
|
6
|
-
module Boom
|
7
|
-
class Clipboard
|
8
|
-
class << self
|
9
|
-
|
10
|
-
# Public: copies a given Item's value to the clipboard. This method is
|
11
|
-
# designed to handle multiple platforms.
|
12
|
-
#
|
13
|
-
# Returns nothing.
|
14
|
-
def copy(item)
|
15
|
-
copy_command =
|
16
|
-
if RUBY_PLATFORM =~ /darwin/
|
17
|
-
"pbcopy"
|
18
|
-
else
|
19
|
-
"xclip -selection clipboard"
|
20
|
-
end
|
21
|
-
|
22
|
-
`echo '#{item.value.gsub("\'","\\'")}' | tr -d "\n" | #{copy_command}`
|
23
|
-
|
24
|
-
"Boom! We just copied #{item.value} to your clipboard."
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|