boom 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## head
4
4
 
5
+ ## 0.0.6
6
+ - Searching for an item that doesn't exist doesn't murder puppies anymore
7
+ (thanks [jimmycuadra](https://github.com/jimmycuadra)).
8
+ - Output is a bit cleaner with a constrained `name` column.
9
+ - Adds items from stdin (thanks
10
+ [MichaelXavier](https://github.com/MichaelXavier)).
11
+
5
12
  ## 0.0.5
6
13
  - Item deletes are now scoped by list rather than GLOBAL DESTRUCTION! (thanks
7
14
  [natebean](https://github.com/natebean)).
data/README.markdown CHANGED
@@ -45,6 +45,9 @@ can have multiple lists.
45
45
  $ boom urls github https://github.com
46
46
  Boom! "github" in "urls" is "https://github.com". Got it.
47
47
 
48
+ # boom <list> <name> with stdin
49
+ $ boom journal january < ~/Desktop/01-secret-journal.markdown
50
+
48
51
  ** Copy an item's value to your clipboard **
49
52
 
50
53
  $ boom github
@@ -110,14 +113,18 @@ important business information (say, a carefully cultivated list of animated
110
113
  .gifs), you'd be sitting pretty if you made a backup of `~/.boom` every now and
111
114
  then, just in case. We're living on the edge, baby.
112
115
 
113
- Also, don't mistype anything. Everything should be 100% perfect if you type all
114
- the commands correctly. If you don't, it'll probably ungracefully error out and
115
- a puppy in Kansas will probably be murdered. You should be fine, though. As
116
- long as you don't have butter fingers.
117
-
118
116
  Soon enough, though, this'll be stable to the point where I can truthfully tell
119
117
  myself that this time baby, `boom` will be, bulletttttttttttttproof ♫.
120
118
 
119
+ ## Contribute
120
+
121
+ I'd love to include your contributions, friend. Make sure your methods are
122
+ [TomDoc](http://tomdoc.org)'d properly, that existing tests pass (`rake`), and
123
+ that any new functionality includes appropriate tests. Bonus points if you're
124
+ not updating the gemspec or bumping boom's version.
125
+
126
+ All good? Cool! Then [send me a pull request](https://github.com/holman/boom/pull/new/master)!
127
+
121
128
  ## I love you
122
129
 
123
130
  [Zach Holman](http://zachholman.com) made this. Ping me on Twitter —
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.5'
17
- s.date = '2010-12-22'
16
+ s.version = '0.0.6'
17
+ s.date = '2011-01-05'
18
18
  s.rubyforge_project = 'boom'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -50,7 +50,7 @@ Gem::Specification.new do |s|
50
50
  ## Specify any RDoc options here. You'll want to add your README and
51
51
  ## LICENSE files to the extra_rdoc_files list.
52
52
  s.rdoc_options = ["--charset=UTF-8"]
53
- s.extra_rdoc_files = %w[readme.markdown license.markdown]
53
+ s.extra_rdoc_files = %w[README.markdown LICENSE.markdown]
54
54
 
55
55
  ## List your runtime dependencies here. Runtime dependencies are those
56
56
  ## that are needed for an end user to actually USE your code.
@@ -17,7 +17,7 @@ module Boom
17
17
  "xclip -selection clipboard"
18
18
  end
19
19
 
20
- `echo '#{item.value}' | tr -d "\n" | #{copy_command}`
20
+ `echo '#{item.value.gsub("\'","\\'")}' | tr -d "\n" | #{copy_command}`
21
21
 
22
22
  "Boom! We just copied #{item.value} to your clipboard."
23
23
  end
data/lib/boom/command.rb CHANGED
@@ -58,7 +58,7 @@ module Boom
58
58
  storage.lists.each do |list|
59
59
  output " #{list.name}"
60
60
  list.items.each do |item|
61
- output " #{item.name}: #{item.value}"
61
+ output " #{item.short_name}:#{item.spacer} #{item.value}"
62
62
  end
63
63
  end
64
64
  end
@@ -77,7 +77,8 @@ module Boom
77
77
  return delete_list(command) if major == 'delete'
78
78
  return detail_list(command) unless major
79
79
  unless minor == 'delete'
80
- return add_item(command,major,minor) if minor
80
+ minor ||= $stdin.read
81
+ return add_item(command,major,minor) if minor.to_s.length > 0
81
82
  return search_list_for_item(command, major)
82
83
  end
83
84
  end
@@ -99,7 +100,7 @@ module Boom
99
100
  def detail_list(name)
100
101
  list = List.find(name)
101
102
  list.items.sort{ |x,y| x.name <=> y.name }.each do |item|
102
- output " #{item.name}: #{item.value}"
103
+ output " #{item.short_name}:#{item.spacer} #{item.value}"
103
104
  end
104
105
  end
105
106
 
@@ -189,17 +190,21 @@ module Boom
189
190
  end
190
191
 
191
192
  # Public: search for an Item in a particular list by name. Drops the
192
- # corresponding entry into your clipboard.
193
+ # corresponding entry into your clipboard if found.
193
194
  #
194
195
  # list_name - the String name of the List in which to scope the search
195
196
  # item_name - the String term to search for in all Item names
196
197
  #
197
- # Returns the matching Item.
198
+ # Returns the matching Item if found.
198
199
  def search_list_for_item(list_name, item_name)
199
200
  list = List.find(list_name)
200
- item = list.items.first { |item| item.name == item_name }
201
+ item = list.find_item(item_name)
201
202
 
202
- output Clipboard.copy(item)
203
+ if item
204
+ output Clipboard.copy(item)
205
+ else
206
+ output "\"#{item_name}\" not found in \"#{list_name}\""
207
+ end
203
208
  end
204
209
 
205
210
  # Public: save in-memory data to disk.
data/lib/boom/item.rb CHANGED
@@ -18,7 +18,7 @@ module Boom
18
18
  #
19
19
  # Examples
20
20
  #
21
- # Item.new("github", "http://github.com")
21
+ # Item.new("github", "https://github.com")
22
22
  #
23
23
  # Returns the newly initialized Item.
24
24
  def initialize(name,value)
@@ -26,6 +26,31 @@ module Boom
26
26
  @value = value
27
27
  end
28
28
 
29
+ # Public: the shortened String name of the Item. Truncates with ellipses if
30
+ # larger.
31
+ #
32
+ # Examples
33
+ #
34
+ # item = Item.new("github's home page","https://github.com")
35
+ # item.short_name
36
+ # # => 'github's home p…'
37
+ #
38
+ # item = Item.new("github","https://github.com")
39
+ # item.short_name
40
+ # # => 'github'
41
+ #
42
+ # Returns the shortened name.
43
+ def short_name
44
+ name.length > 15 ? "#{name[0..14]}…" : name[0..14]
45
+ end
46
+
47
+ # Public: the amount of consistent spaces to pad based on Item#short_name.
48
+ #
49
+ # Returns a String of spaces.
50
+ def spacer
51
+ name.length > 15 ? '' : ' '*(15-name.length+1)
52
+ end
53
+
29
54
  # Public: creates a Hash for this Item.
30
55
  #
31
56
  # Returns a Hash of its data.
data/lib/boom/list.rb CHANGED
@@ -72,6 +72,19 @@ module Boom
72
72
  previous != items.size
73
73
  end
74
74
 
75
+ # Public: finds an Item by name. If the name is typically truncated, also
76
+ # allow a search based on that truncated name.
77
+ #
78
+ # name - String name of the Item to find
79
+ #
80
+ # Returns the found item
81
+ def find_item(name)
82
+ items.find do |item|
83
+ item.name == name ||
84
+ item.short_name.gsub('…','') == name.gsub('…','')
85
+ end
86
+ end
87
+
75
88
  # Public: a Hash representation of this List.
76
89
  #
77
90
  # Returns a Hash of its own data and its child Items.
data/lib/boom.rb CHANGED
@@ -15,7 +15,7 @@ require 'boom/list'
15
15
  require 'boom/storage'
16
16
 
17
17
  module Boom
18
- VERSION = '0.0.5'
18
+ VERSION = '0.0.6'
19
19
 
20
20
  def self.storage
21
21
  @storage ||= Boom::Storage.new
data/test/test_command.rb CHANGED
@@ -96,4 +96,8 @@ class TestCommand < Test::Unit::TestCase
96
96
  assert_match 'boom help', command('--anything')
97
97
  assert_match 'boom help', command('-d')
98
98
  end
99
+
100
+ def test_nonexistent_item_access_scoped_by_list
101
+ assert_match /"twitter" not found in "urls"/, command('urls twitter')
102
+ end
99
103
  end
data/test/test_item.rb CHANGED
@@ -14,6 +14,24 @@ class TestItem < Test::Unit::TestCase
14
14
  assert_equal 'https://github.com', @item.value
15
15
  end
16
16
 
17
+ def test_short_name
18
+ assert_equal 'github', @item.short_name
19
+ end
20
+
21
+ def test_short_name
22
+ @item.name = 'github github github lol lol lol'
23
+ assert_equal 'github github g…', @item.short_name
24
+ end
25
+
26
+ def test_spacer_none
27
+ @item.name = 'github github github lol lol lol'
28
+ assert_equal '', @item.spacer
29
+ end
30
+
31
+ def test_spacer_tons
32
+ assert_equal ' ', @item.spacer
33
+ end
34
+
17
35
  def test_to_hash
18
36
  assert_equal 1, @item.to_hash.size
19
37
  end
data/test/test_list.rb CHANGED
@@ -28,6 +28,18 @@ class TestList < Test::Unit::TestCase
28
28
  assert_equal 'urls', Boom::List.find('urls').name
29
29
  end
30
30
 
31
+ def test_find_item
32
+ @list.add_item(@item)
33
+ assert_equal 'https://github.com', @list.find_item('github').value
34
+ end
35
+
36
+ def test_find_item_long_name
37
+ @item = Boom::Item.new('long-long-long-name','longname')
38
+ @list.add_item(@item)
39
+ assert_equal 'longname', @list.find_item('long-long-long-').value
40
+ assert_equal 'longname', @list.find_item('long-long-long-…').value
41
+ end
42
+
31
43
  def test_delete_success
32
44
  assert_equal 1, Boom.storage.lists.size
33
45
  assert Boom::List.delete('urls')
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
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: 2010-12-22 00:00:00 -06:00
18
+ date: 2011-01-05 00:00:00 -08:00
19
19
  default_executable: boom
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -64,8 +64,8 @@ executables:
64
64
  extensions: []
65
65
 
66
66
  extra_rdoc_files:
67
- - readme.markdown
68
- - license.markdown
67
+ - README.markdown
68
+ - LICENSE.markdown
69
69
  files:
70
70
  - CHANGELOG.markdown
71
71
  - LICENSE.markdown
@@ -84,8 +84,6 @@ files:
84
84
  - test/test_command.rb
85
85
  - test/test_item.rb
86
86
  - test/test_list.rb
87
- - readme.markdown
88
- - license.markdown
89
87
  has_rdoc: true
90
88
  homepage: https://github.com/holman/boom
91
89
  licenses: []
data/license.markdown DELETED
@@ -1,21 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) Zach Holman, http://zachholman.com
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/readme.markdown DELETED
@@ -1,127 +0,0 @@
1
- # B O O M
2
-
3
- See? Look, a tiny explosion: \*
4
-
5
- ## What's a boom?
6
-
7
- boom lets you access text snippets over your command line. I'm personally
8
- aiming for exactly two use cases, but I'm almost positive there are thirteen
9
- more. Here's a couple examples:
10
-
11
- - **Your own [del.icio.us](http://delicious.com)-esque URL tracker.** When I
12
- make [clever animated
13
- gifs](http://github.com/holman/dotfiles/blob/master/bin/gifme) of my
14
- coworkers, I tend to lose the URL, which is a total bummer since I want to
15
- repeatedly repost these images well past their funny expiration date. boom
16
- lets me easily access the good stuff for years to come.
17
- - **Commonly-used email replies.** Everyone's got those stock replies in their
18
- pocket for a few common use cases. Rather than keep some files strewn about
19
- with the responses, boom gives me them on my ever-present command line.
20
- - **Simple todos.** You can super-quickly drop items into lists and remove them
21
- when finished. I'm a big fan of simple, straightforward stuff. Plus, it's a
22
- Dropbox away from simple cloud syncing. Someone get Cultured Code on the line
23
- THIS MAY BE RELEVANT TO THEIR INTERESTS!
24
-
25
- We store everything in one JSON file in your home directory: `~/.boom`. The
26
- structure is simple, too. Each individual item is tossed on a `list`, and you
27
- can have multiple lists.
28
-
29
- ## Show me the boom
30
-
31
- ** Overview **
32
-
33
- $ boom
34
- gifs (5)
35
- email (4)
36
-
37
- ** Create a list **
38
-
39
- $ boom urls
40
- Boom! Created a new list called "urls".
41
-
42
- ** Add an item **
43
-
44
- # boom <list> <name> <value>
45
- $ boom urls github https://github.com
46
- Boom! "github" in "urls" is "https://github.com". Got it.
47
-
48
- ** Copy an item's value to your clipboard **
49
-
50
- $ boom github
51
- Boom! Just copied https://github.com to your clipboard.
52
-
53
- $ boom urls github
54
- Boom! Just copied https://github.com to your clipboard.
55
-
56
- ** List items in a list **
57
-
58
- $ boom urls
59
- blog http://zachholman.com
60
- github http://github.com
61
-
62
- ** Delete a list **
63
-
64
- $ boom urls delete
65
- You sure you want to delete everything in "urls"? (y/n): y
66
- Boom! Deleted all your urls.
67
-
68
- ** Delete an item **
69
-
70
- # boom urls github delete
71
- Boom! "github" is gone forever.
72
-
73
- ** List everything **
74
-
75
- $ boom all
76
- enemies
77
- @kneath: he's got dreamy eyes. he must die.
78
- @rtomayko: i must murder him for his mac and cheese recipe.
79
- @luckiestmonkey: she hates recycling.
80
- urls
81
- blog: http://zachholman.com
82
- github: https://github.com
83
-
84
- ** Help **
85
-
86
- $ boom help
87
-
88
- ** Manual edit **
89
-
90
- If you want to edit the underlying JSON directly, make sure your `$EDITOR`
91
- environment variable is set, and run:
92
-
93
- $ boom edit
94
-
95
- ** It's just the command line, silly **
96
-
97
- So don't forget all your other favorites are there to help you, too:
98
-
99
- $ boom all | grep @luckiestmonkey
100
- @luckiestmonkey: she hates recycling.
101
-
102
- ## Install
103
-
104
- gem install boom
105
-
106
- ## Current Status
107
-
108
- Precarious. I'm starting to use this a bunch now, but if you're tossing in
109
- important business information (say, a carefully cultivated list of animated
110
- .gifs), you'd be sitting pretty if you made a backup of `~/.boom` every now and
111
- then, just in case. We're living on the edge, baby.
112
-
113
- Also, don't mistype anything. Everything should be 100% perfect if you type all
114
- the commands correctly. If you don't, it'll probably ungracefully error out and
115
- a puppy in Kansas will probably be murdered. You should be fine, though. As
116
- long as you don't have butter fingers.
117
-
118
- Soon enough, though, this'll be stable to the point where I can truthfully tell
119
- myself that this time baby, `boom` will be, bulletttttttttttttproof ♫.
120
-
121
- ## I love you
122
-
123
- [Zach Holman](http://zachholman.com) made this. Ping me on Twitter —
124
- [@holman](http://twitter.com/holman) — if you're having issues, want me to
125
- merge in your pull request, or are using boom in a cool way. I'm kind of hoping
126
- this is generic enough that people do some fun things with it. First one to use
127
- `boom` to calculate their tax liability wins.