boom 0.2.4 → 0.3.0
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.
- data/{CHANGELOG.markdown → CHANGELOG.md} +12 -3
- data/Gemfile.lock +3 -5
- data/{LICENSE.markdown → LICENSE.md} +0 -0
- data/{README.markdown → README.md} +14 -11
- data/Rakefile +3 -5
- data/boom.gemspec +14 -26
- data/lib/boom/command.rb +8 -35
- data/lib/boom/item.rb +2 -4
- data/lib/boom/list.rb +1 -1
- data/lib/boom/storage.rb +114 -12
- data/lib/boom.rb +5 -20
- data/test/cli.sh +13 -0
- data/test/examples/data.json +17 -0
- data/test/item.sh +19 -0
- data/test/list.sh +30 -0
- data/test/roundup +307 -0
- data/test/run +8 -0
- metadata +74 -125
- data/lib/boom/config.rb +0 -89
- data/lib/boom/storage/base.rb +0 -81
- data/lib/boom/storage/gist.rb +0 -114
- data/lib/boom/storage/json.rb +0 -69
- data/lib/boom/storage/keychain.rb +0 -135
- data/lib/boom/storage/mongodb.rb +0 -84
- data/lib/boom/storage/redis.rb +0 -72
- data/test/examples/config_json.json +0 -3
- data/test/examples/test_json.json +0 -3
- data/test/examples/urls.json +0 -1
- data/test/helper.rb +0 -24
- data/test/test_color.rb +0 -30
- data/test/test_command.rb +0 -238
- data/test/test_config.rb +0 -25
- data/test/test_item.rb +0 -54
- data/test/test_list.rb +0 -79
- data/test/test_platform.rb +0 -52
data/test/test_command.rb
DELETED
@@ -1,238 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
# Intercept STDOUT and collect it
|
6
|
-
class Boom::Command
|
7
|
-
|
8
|
-
def self.capture_output
|
9
|
-
@output = ''
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.captured_output
|
13
|
-
@output
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.output(s)
|
17
|
-
@output << s
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.save!
|
21
|
-
# no-op
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
class TestCommand < Test::Unit::TestCase
|
27
|
-
|
28
|
-
def setup
|
29
|
-
boom_json :urls
|
30
|
-
end
|
31
|
-
|
32
|
-
def command(cmd)
|
33
|
-
cmd = cmd.split(' ') if cmd
|
34
|
-
Boom::Command.capture_output
|
35
|
-
Boom::Command.execute(*cmd)
|
36
|
-
output = Boom::Command.captured_output
|
37
|
-
output.gsub(/\e\[\d\d?m/, '')
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_overview_for_empty
|
41
|
-
storage = Boom::Storage
|
42
|
-
storage.stubs(:lists).returns([])
|
43
|
-
Boom::Command.stubs(:storage).returns(storage)
|
44
|
-
assert_match /have anything yet!/, command(nil)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_overview
|
48
|
-
assert_equal ' urls (2)', command(nil)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_list_detail
|
52
|
-
assert_match /github/, command('urls')
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_list_all
|
56
|
-
cmd = command('all')
|
57
|
-
assert_match /urls/, cmd
|
58
|
-
assert_match /github/, cmd
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_list_creation
|
62
|
-
assert_match /a new list called newlist/, command('newlist')
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_list_creation_with_item
|
66
|
-
assert_match /a new list called newlist.* item in newlist/, command('newlist item blah')
|
67
|
-
end
|
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
|
-
|
77
|
-
def test_list_creation_with_existing_items_name
|
78
|
-
command('list item foo')
|
79
|
-
assert_match /a new list called item.* key in item is bar/, command('item key bar')
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_item_access
|
83
|
-
IO.stubs(:popen)
|
84
|
-
assert_match /copied https:\/\/github\.com to your clipboard/,
|
85
|
-
command('github')
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_item_access_scoped_by_list
|
89
|
-
IO.stubs(:popen)
|
90
|
-
assert_match /copied https:\/\/github\.com to your clipboard/,
|
91
|
-
command('urls github')
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_item_open_item
|
95
|
-
Boom::Platform.stubs(:system).returns('')
|
96
|
-
assert_match /opened https:\/\/github\.com for you/, command('open github')
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_item_open_specific_item
|
100
|
-
Boom::Platform.stubs(:system).returns('')
|
101
|
-
assert_match /opened https:\/\/github\.com for you/, command('open urls github')
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_item_open_lists
|
105
|
-
Boom::Platform.stubs(:system).returns('')
|
106
|
-
assert_match /opened all of urls for you/, command('open urls')
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_item_creation
|
110
|
-
assert_match /twitter in urls/,
|
111
|
-
command('urls twitter http://twitter.com/holman')
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_item_creation_long_value
|
115
|
-
assert_match /is tanqueray hendricks bombay/,
|
116
|
-
command('urls gins tanqueray hendricks bombay')
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_list_deletion_no
|
120
|
-
STDIN.stubs(:gets).returns('n')
|
121
|
-
assert_match /Just kidding then/, command('urls delete')
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_list_deletion_yes
|
125
|
-
STDIN.stubs(:gets).returns('y')
|
126
|
-
assert_match /Deleted all your urls/, command('urls delete')
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_item_deletion
|
130
|
-
assert_match /github is gone forever/, command('urls github delete')
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_edit
|
134
|
-
Boom::Platform.stubs(:system).returns('')
|
135
|
-
assert_match 'Make your edits', command('edit')
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_help
|
139
|
-
assert_match 'boom help', command('help')
|
140
|
-
assert_match 'boom help', command('-h')
|
141
|
-
assert_match 'boom help', command('--help')
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_noop_options
|
145
|
-
assert_match 'boom help', command('--anything')
|
146
|
-
assert_match 'boom help', command('-d')
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_nonexistent_item_access_scoped_by_list
|
150
|
-
assert_match /twitter not found in urls/, command('urls twitter')
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_echo_item
|
154
|
-
assert_match /https:\/\/github\.com/, command('echo github')
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_echo_item_shorthand
|
158
|
-
assert_match /https:\/\/github\.com/, command('e github')
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_echo_item_does_not_exist
|
162
|
-
assert_match /wrong not found/, command('echo wrong')
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_echo_list_item
|
166
|
-
assert_match /https:\/\/github\.com/, command('echo urls github')
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_echo_list_item_does_not_exist
|
170
|
-
assert_match /wrong not found in urls/, command('echo urls wrong')
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_show_storage
|
174
|
-
Boom::Config.any_instance.stubs(:attributes).returns('backend' => 'json')
|
175
|
-
assert_match /You're currently using json/, command('storage')
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_nonexistant_storage_switch
|
179
|
-
Boom::Config.any_instance.stubs(:save).returns(true)
|
180
|
-
assert_match /couldn't find that storage engine/, command('switch dkdkdk')
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_storage_switch
|
184
|
-
Boom::Config.any_instance.stubs(:save).returns(true)
|
185
|
-
assert_match /We've switched you over to redis/, command('switch redis')
|
186
|
-
end
|
187
|
-
|
188
|
-
def test_version_switch
|
189
|
-
assert_match /#{Boom::VERSION}/, command('-v')
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_version_long
|
193
|
-
assert_match /#{Boom::VERSION}/, command('--version')
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_stdin_pipes
|
197
|
-
stub = Object.new
|
198
|
-
stub.stubs(:stat).returns([1,2])
|
199
|
-
stub.stubs(:read).returns("http://twitter.com")
|
200
|
-
Boom::Command.stubs(:stdin).returns(stub)
|
201
|
-
assert_match /twitter in urls/, command('urls twitter')
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_random
|
205
|
-
Boom::Platform.stubs(:system).returns('')
|
206
|
-
assert_match /opened .+ for you/, command('random')
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_random_from_list
|
210
|
-
Boom::Platform.stubs(:system).returns('')
|
211
|
-
assert_match /(github|zachholman)/, command('random urls')
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_random_list_not_exist
|
215
|
-
Boom::Platform.stubs(:system).returns('')
|
216
|
-
assert_match /couldn't find that list\./, command('random 39jc02jlskjbbac9')
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_delete_item_list_not_exist
|
220
|
-
assert_match /couldn't find that list\./, command('urlz github delete')
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_delete_item_wrong_list
|
224
|
-
command('urlz twitter https://twitter.com/')
|
225
|
-
assert_match /github not found in urlz/, command('urlz github delete')
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_delete_item_different_name
|
229
|
-
command('foo bar baz')
|
230
|
-
assert_match /bar is gone forever/, command('foo bar delete')
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_delete_item_same_name
|
234
|
-
command('duck duck goose')
|
235
|
-
assert_match /duck is gone forever/, command('duck duck delete')
|
236
|
-
end
|
237
|
-
|
238
|
-
end
|
data/test/test_config.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class TestConfig < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
Boom::Config.any_instance.stubs(:file).
|
9
|
-
returns("test/examples/test_json.json")
|
10
|
-
|
11
|
-
@config = Boom::Config.new
|
12
|
-
@config.stubs(:save).returns(true)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_bootstraps_config
|
16
|
-
@config.bootstrap
|
17
|
-
assert_equal ({:backend => 'json'}), @config.attributes
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_attributes
|
21
|
-
@config.attributes[:wu_tang] = 'clan'
|
22
|
-
assert_equal 'clan', @config.attributes[:wu_tang]
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/test/test_item.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class TestItem < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@item = Boom::Item.new('github','https://github.com')
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_name
|
12
|
-
assert_equal 'github', @item.name
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_value
|
16
|
-
assert_equal 'https://github.com', @item.value
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_short_name
|
20
|
-
assert_equal 'github', @item.short_name
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_short_name
|
24
|
-
@item.name = 'github github github lol lol lol'
|
25
|
-
assert_equal 'github github g…', @item.short_name
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_spacer_none
|
29
|
-
@item.name = 'github github github lol lol lol'
|
30
|
-
assert_equal '', @item.spacer
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_spacer_tons
|
34
|
-
assert_equal ' ', @item.spacer
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_to_hash
|
38
|
-
assert_equal 1, @item.to_hash.size
|
39
|
-
end
|
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
|
54
|
-
end
|
data/test/test_list.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
class TestList < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@list = Boom::List.new('urls')
|
9
|
-
@item = Boom::Item.new('github','https://github.com')
|
10
|
-
boom_json :urls
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_name
|
14
|
-
assert_equal 'urls', @list.name
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_add_items
|
18
|
-
assert_equal 0, @list.items.size
|
19
|
-
@list.add_item(@item)
|
20
|
-
assert_equal 1, @list.items.size
|
21
|
-
end
|
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
|
-
|
33
|
-
def test_to_hash
|
34
|
-
assert_equal 0, @list.to_hash[@list.name].size
|
35
|
-
@list.add_item(@item)
|
36
|
-
assert_equal 1, @list.to_hash[@list.name].size
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_find
|
40
|
-
assert_equal 'urls', Boom::List.find('urls').name
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_find_item
|
44
|
-
@list.add_item(@item)
|
45
|
-
assert_equal 'https://github.com', @list.find_item('github').value
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_find_item_long_name
|
49
|
-
@item = Boom::Item.new('long-long-long-name','longname')
|
50
|
-
@list.add_item(@item)
|
51
|
-
assert_equal 'longname', @list.find_item('long-long-long-').value
|
52
|
-
assert_equal 'longname', @list.find_item('long-long-long-…').value
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_delete_success
|
56
|
-
assert_equal 1, Boom.storage.lists.size
|
57
|
-
assert Boom::List.delete('urls')
|
58
|
-
assert_equal 0, Boom.storage.lists.size
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_delete_fail
|
62
|
-
assert_equal 1, Boom.storage.lists.size
|
63
|
-
assert !Boom::List.delete('robocop')
|
64
|
-
assert_equal 1, Boom.storage.lists.size
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_deletes_scoped_to_list
|
68
|
-
@list.add_item(@item)
|
69
|
-
|
70
|
-
@list_2 = Boom::List.new('sexy-companies')
|
71
|
-
@item_2 = Boom::Item.new(@item.name, @item.value)
|
72
|
-
@list_2.add_item(@item_2)
|
73
|
-
|
74
|
-
@list.delete_item(@item.name)
|
75
|
-
assert_equal 0, @list.items.size
|
76
|
-
assert_equal 1, @list_2.items.size
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
data/test/test_platform.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestPlatform < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_darwin
|
10
|
-
assert_equal Boom::Platform.darwin?, RUBY_PLATFORM.include?('darwin')
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_windows
|
14
|
-
assert_equal Boom::Platform.windows?, true if RUBY_PLATFORM =~ /mswin|mingw/
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_open_command_darwin
|
18
|
-
Boom::Platform.stubs(:darwin?).returns(true)
|
19
|
-
assert_equal Boom::Platform.open_command, 'open'
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_open_command_windows
|
23
|
-
Boom::Platform.stubs(:darwin?).returns(false)
|
24
|
-
Boom::Platform.stubs(:windows?).returns(true)
|
25
|
-
assert_equal Boom::Platform.open_command, 'start'
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_open_command_linux
|
29
|
-
Boom::Platform.stubs(:darwin?).returns(false)
|
30
|
-
Boom::Platform.stubs(:windows?).returns(false)
|
31
|
-
assert_equal Boom::Platform.open_command, 'xdg-open'
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_copy_command_darwin
|
35
|
-
Boom::Platform.stubs(:darwin?).returns(true)
|
36
|
-
Boom::Platform.stubs(:windows?).returns(false)
|
37
|
-
assert_equal Boom::Platform.copy_command, 'pbcopy'
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_copy_command_windows
|
41
|
-
Boom::Platform.stubs(:darwin?).returns(false)
|
42
|
-
Boom::Platform.stubs(:windows?).returns(true)
|
43
|
-
assert_equal Boom::Platform.copy_command, 'clip'
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_copy_command_linux
|
47
|
-
Boom::Platform.stubs(:darwin?).returns(false)
|
48
|
-
Boom::Platform.stubs(:windows?).returns(false)
|
49
|
-
assert_equal Boom::Platform.copy_command, 'xclip -selection clipboard'
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|