kaboom 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+
3
+ require 'helper'
4
+ require 'output_interceptor'
5
+
6
+ class TestConfig < Test::Unit::TestCase
7
+
8
+ def setup
9
+ Boom::Config.any_instance.stubs(:file).
10
+ returns("test/examples/test_json.json")
11
+
12
+ @config = Boom::Config.new
13
+ @config.stubs(:save).returns(true)
14
+ end
15
+
16
+ def test_bootstraps_config
17
+ @config.bootstrap
18
+ assert_equal ({:backend => 'json'}), @config.attributes
19
+ end
20
+
21
+ def test_attributes
22
+ @config.attributes[:wu_tang] = 'clan'
23
+ assert_equal 'clan', @config.attributes[:wu_tang]
24
+ end
25
+
26
+
27
+ end
@@ -0,0 +1,54 @@
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
@@ -0,0 +1,79 @@
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
@@ -0,0 +1,52 @@
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
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ require 'helper'
4
+ require 'output_interceptor'
5
+
6
+ class TestRemote < Test::Unit::TestCase
7
+ def dummy type
8
+ m = stub 'storage_type', :class => type
9
+ end
10
+
11
+ def test_remote
12
+ Boom.use_remote false
13
+ Boom::Output.capture_output
14
+
15
+ local = [Boom::Storage::Json, Boom::Storage::Keychain ]
16
+
17
+
18
+ remote = [Boom::Storage::Gist, Boom::Storage::Mongodb, Boom::Storage::Redis]
19
+
20
+ (local + remote).all? do |type|
21
+ assert Boom::Remote.allowed? dummy(type)
22
+ end
23
+
24
+ Boom.use_remote true
25
+
26
+ Boom::Remote.stubs(:output)
27
+ remote.all? { |t| assert Boom::Remote.allowed?(dummy(t)), "#{t} should be allowed" }
28
+ local.all? { |t| refute Boom::Remote.allowed?(dummy(t)), "#{t} should not be allowed"}
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kaboom
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Zach Holman
9
+ - Mark Burns
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-03-17 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: multi_json
17
+ requirement: &70094413093860 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70094413093860
26
+ - !ruby/object:Gem::Dependency
27
+ name: json_pure
28
+ requirement: &70094413093400 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *70094413093400
37
+ - !ruby/object:Gem::Dependency
38
+ name: mocha
39
+ requirement: &70094413092800 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 0.9.9
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70094413092800
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: &70094413092140 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 0.9.2
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70094413092140
59
+ description: ! "God it's about every day where I think to myself, gadzooks,\n I keep
60
+ typing *REPETITIVE_BORING_TASK* over and over. Wouldn't it be great if\n I had
61
+ something like boom to store all these commonly-used text snippets for\n me? Then
62
+ I realized that was a worthless idea since boom hadn't been created\n yet and I
63
+ had no idea what that statement meant. At some point I found the\n code for boom
64
+ in a dark alleyway and released it under my own name because I\n wanted to look
65
+ smart."
66
+ email: markthedeveloper@gmail.com
67
+ executables:
68
+ - boom
69
+ - kaboom
70
+ extensions: []
71
+ extra_rdoc_files:
72
+ - README.markdown
73
+ - LICENSE.markdown
74
+ files:
75
+ - CHANGELOG.markdown
76
+ - Gemfile
77
+ - Gemfile.lock
78
+ - LICENSE.markdown
79
+ - README.markdown
80
+ - Rakefile
81
+ - bin/boom
82
+ - bin/kaboom
83
+ - completion/README.md
84
+ - completion/boom.bash
85
+ - completion/boom.zsh
86
+ - kaboom.gemspec
87
+ - lib/kaboom.rb
88
+ - lib/kaboom/color.rb
89
+ - lib/kaboom/command.rb
90
+ - lib/kaboom/config.rb
91
+ - lib/kaboom/core_ext/symbol.rb
92
+ - lib/kaboom/item.rb
93
+ - lib/kaboom/list.rb
94
+ - lib/kaboom/output.rb
95
+ - lib/kaboom/platform.rb
96
+ - lib/kaboom/remote.rb
97
+ - lib/kaboom/storage.rb
98
+ - lib/kaboom/storage/base.rb
99
+ - lib/kaboom/storage/gist.rb
100
+ - lib/kaboom/storage/json.rb
101
+ - lib/kaboom/storage/keychain.rb
102
+ - lib/kaboom/storage/mongodb.rb
103
+ - lib/kaboom/storage/redis.rb
104
+ - test/examples/config_json.json
105
+ - test/examples/test_json.json
106
+ - test/examples/urls.json
107
+ - test/helper.rb
108
+ - test/output_interceptor.rb
109
+ - test/test_color.rb
110
+ - test/test_command.rb
111
+ - test/test_config.rb
112
+ - test/test_item.rb
113
+ - test/test_list.rb
114
+ - test/test_platform.rb
115
+ - test/test_remote.rb
116
+ homepage: https://github.com/markburns/kaboom
117
+ licenses: []
118
+ post_install_message:
119
+ rdoc_options:
120
+ - --charset=UTF-8
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ segments:
130
+ - 0
131
+ hash: 3545507400932762145
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project: boom
140
+ rubygems_version: 1.8.17
141
+ signing_key:
142
+ specification_version: 2
143
+ summary: boom lets you access text snippets over your command line.
144
+ test_files:
145
+ - test/test_color.rb
146
+ - test/test_command.rb
147
+ - test/test_config.rb
148
+ - test/test_item.rb
149
+ - test/test_list.rb
150
+ - test/test_platform.rb
151
+ - test/test_remote.rb