boom 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +8 -0
- data/boom.gemspec +3 -2
- data/lib/boom/command.rb +28 -2
- data/lib/boom/storage/gist/json_parser.rb +8 -0
- data/lib/boom/storage/gist.rb +12 -16
- data/lib/boom.rb +1 -1
- data/test/test_command.rb +30 -1
- metadata +5 -4
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## head
|
4
4
|
|
5
|
+
## 0.2.3
|
6
|
+
- [@culvr](https://github.com/culvr) added `boom random <list>` that lets you
|
7
|
+
quickly pull a random item.
|
8
|
+
- Fixed so that opening a specific item (`boom open urls github`) will only
|
9
|
+
open that item.
|
10
|
+
- [@culvr](https://github.com/culvr) fixed STDIN list+item creation.
|
11
|
+
- HTTParty should only be a soft dependency. (#46)
|
12
|
+
|
5
13
|
## 0.2.2 (July 29, 2011)
|
6
14
|
- [@jimmycuadra](https://github.com/jimmycuadra) went to town on this beast and
|
7
15
|
hooked up a Gist backend to boom. Killer.
|
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.2.
|
17
|
-
s.date = '2011-
|
16
|
+
s.version = '0.2.3'
|
17
|
+
s.date = '2011-09-06'
|
18
18
|
s.rubyforge_project = 'boom'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -89,6 +89,7 @@ Gem::Specification.new do |s|
|
|
89
89
|
lib/boom/storage.rb
|
90
90
|
lib/boom/storage/base.rb
|
91
91
|
lib/boom/storage/gist.rb
|
92
|
+
lib/boom/storage/gist/json_parser.rb
|
92
93
|
lib/boom/storage/json.rb
|
93
94
|
lib/boom/storage/keychain.rb
|
94
95
|
lib/boom/storage/mongodb.rb
|
data/lib/boom/command.rb
CHANGED
@@ -95,6 +95,7 @@ module Boom
|
|
95
95
|
return help if command[0] == 45 || command[0] == '-' # any - dash options are pleas for help
|
96
96
|
return echo(major,minor) if command == 'echo' || command == 'e'
|
97
97
|
return open(major,minor) if command == 'open' || command == 'o'
|
98
|
+
return random(major) if command == 'random' || command == 'rand' || command == 'r'
|
98
99
|
|
99
100
|
# if we're operating on a List
|
100
101
|
if storage.list_exists?(command)
|
@@ -113,6 +114,7 @@ module Boom
|
|
113
114
|
return delete_item(command, major)
|
114
115
|
end
|
115
116
|
|
117
|
+
return create_list(command, major, stdin.read) if !minor && stdin.stat.size > 0
|
116
118
|
return create_list(command, major, minor)
|
117
119
|
end
|
118
120
|
|
@@ -153,14 +155,36 @@ module Boom
|
|
153
155
|
def open(major, minor)
|
154
156
|
if storage.list_exists?(major)
|
155
157
|
list = List.find(major)
|
156
|
-
|
157
|
-
|
158
|
+
if minor
|
159
|
+
item = storage.items.detect { |item| item.name == minor }
|
160
|
+
output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
|
161
|
+
else
|
162
|
+
list.items.each { |item| Platform.open(item) }
|
163
|
+
output "#{cyan("Boom!")} We just opened all of #{yellow(major)} for you."
|
164
|
+
end
|
158
165
|
else
|
159
166
|
item = storage.items.detect { |item| item.name == major }
|
160
167
|
output "#{cyan("Boom!")} We just opened #{yellow(Platform.open(item))} for you."
|
161
168
|
end
|
162
169
|
end
|
163
170
|
|
171
|
+
# Public: Opens a random item
|
172
|
+
#
|
173
|
+
# Returns nothing.
|
174
|
+
def random(major)
|
175
|
+
if major.nil?
|
176
|
+
index = rand(storage.items.size)
|
177
|
+
item = storage.items[index]
|
178
|
+
elsif storage.list_exists?(major)
|
179
|
+
list = List.find(major)
|
180
|
+
index = rand(list.items.size)
|
181
|
+
item = list.items[index]
|
182
|
+
else
|
183
|
+
output "We couldn't find that list."
|
184
|
+
end
|
185
|
+
open(item.name, nil) unless item.nil?
|
186
|
+
end
|
187
|
+
|
164
188
|
# Public: echoes only the Item's value without copying
|
165
189
|
#
|
166
190
|
# item_name - the String term to search for in all Item names
|
@@ -331,6 +355,8 @@ module Boom
|
|
331
355
|
boom <list> <name> copy item's value to clipboard
|
332
356
|
boom open <name> open item's url in browser
|
333
357
|
boom open <list> <name> open all item's url in browser for a list
|
358
|
+
boom random open a random item's url in browser
|
359
|
+
boom random <list> open a random item's url for a list in browser
|
334
360
|
boom echo <name> echo the item's value without copying
|
335
361
|
boom echo <list> <name> echo the item's value without copying
|
336
362
|
boom <list> <name> delete deletes an item
|
data/lib/boom/storage/gist.rb
CHANGED
@@ -21,28 +21,24 @@
|
|
21
21
|
# any value other than boolean true will make
|
22
22
|
# the Gist private.
|
23
23
|
#
|
24
|
-
begin
|
25
|
-
require "httparty"
|
26
|
-
rescue LoadError
|
27
|
-
puts "The Gist backend requires HTTParty: gem install httparty"
|
28
|
-
exit
|
29
|
-
end
|
30
|
-
|
31
|
-
# Crack's parsing is no bueno. Use the MultiJson instead.
|
32
|
-
class JsonParser < HTTParty::Parser
|
33
|
-
def json
|
34
|
-
MultiJson.decode(body)
|
35
|
-
end
|
36
|
-
end
|
37
24
|
|
38
25
|
module Boom
|
39
26
|
module Storage
|
40
27
|
class Gist < Base
|
41
|
-
include HTTParty
|
42
|
-
parser JsonParser
|
43
|
-
base_uri "https://api.github.com"
|
44
28
|
|
45
29
|
def bootstrap
|
30
|
+
begin
|
31
|
+
require "httparty"
|
32
|
+
require "boom/storage/gist/json_parser"
|
33
|
+
|
34
|
+
self.class.send(:include, HTTParty)
|
35
|
+
self.class.parser JsonParser
|
36
|
+
self.class.base_uri "https://api.github.com"
|
37
|
+
rescue LoadError
|
38
|
+
puts "The Gist backend requires HTTParty: gem install httparty"
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
46
42
|
unless Boom.config.attributes["gist"]
|
47
43
|
puts 'A "gist" data structure must be defined in ~/.boom.conf'
|
48
44
|
exit
|
data/lib/boom.rb
CHANGED
data/test/test_command.rb
CHANGED
@@ -66,6 +66,14 @@ class TestCommand < Test::Unit::TestCase
|
|
66
66
|
assert_match /a new list called newlist.* item in newlist/, command('newlist item blah')
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_list_creation_with_item_stdin
|
70
|
+
STDIN.stubs(:read).returns('blah')
|
71
|
+
STDIN.stubs(:stat)
|
72
|
+
STDIN.stat.stubs(:size).returns(4)
|
73
|
+
|
74
|
+
assert_match /a new list called newlist.* item in newlist is blah/, command('newlist item')
|
75
|
+
end
|
76
|
+
|
69
77
|
def test_item_access
|
70
78
|
assert_match /copied https:\/\/github\.com to your clipboard/,
|
71
79
|
command('github')
|
@@ -76,11 +84,16 @@ class TestCommand < Test::Unit::TestCase
|
|
76
84
|
command('urls github')
|
77
85
|
end
|
78
86
|
|
79
|
-
def
|
87
|
+
def test_item_open_item
|
80
88
|
Boom::Platform.stubs(:system).returns('')
|
81
89
|
assert_match /opened https:\/\/github\.com for you/, command('open github')
|
82
90
|
end
|
83
91
|
|
92
|
+
def test_item_open_specific_item
|
93
|
+
Boom::Platform.stubs(:system).returns('')
|
94
|
+
assert_match /opened https:\/\/github\.com for you/, command('open urls github')
|
95
|
+
end
|
96
|
+
|
84
97
|
def test_item_open_lists
|
85
98
|
Boom::Platform.stubs(:system).returns('')
|
86
99
|
assert_match /opened all of urls for you/, command('open urls')
|
@@ -180,4 +193,20 @@ class TestCommand < Test::Unit::TestCase
|
|
180
193
|
Boom::Command.stubs(:stdin).returns(stub)
|
181
194
|
assert_match /twitter in urls/, command('urls twitter')
|
182
195
|
end
|
196
|
+
|
197
|
+
def test_random
|
198
|
+
Boom::Platform.stubs(:system).returns('')
|
199
|
+
assert_match /opened .+ for you/, command('random')
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_random_from_list
|
203
|
+
Boom::Platform.stubs(:system).returns('')
|
204
|
+
assert_match /(github|zachholman)/, command('random urls')
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_random_list_not_exist
|
208
|
+
Boom::Platform.stubs(:system).returns('')
|
209
|
+
assert_match /couldn't find that list\./, command('random 39jc02jlskjbbac9')
|
210
|
+
end
|
211
|
+
|
183
212
|
end
|
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: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
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-
|
18
|
+
date: 2011-09-06 00:00:00 -07:00
|
19
19
|
default_executable: boom
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/boom/storage.rb
|
122
122
|
- lib/boom/storage/base.rb
|
123
123
|
- lib/boom/storage/gist.rb
|
124
|
+
- lib/boom/storage/gist/json_parser.rb
|
124
125
|
- lib/boom/storage/json.rb
|
125
126
|
- lib/boom/storage/keychain.rb
|
126
127
|
- lib/boom/storage/mongodb.rb
|