peanut 0.1 → 0.2
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/README.rdoc +5 -5
- data/lib/peanut/clipboard.rb +2 -2
- data/lib/peanut/command.rb +12 -12
- data/lib/peanut/store.rb +1 -1
- data/lib/peanut/version.rb +2 -2
- data/lib/peanut.rb +4 -0
- data/peanut-0.1.gem +0 -0
- data/test/helper.rb +1 -0
- data/test/test_command.rb +24 -7
- metadata +5 -4
data/README.rdoc
CHANGED
@@ -7,15 +7,15 @@ Peanut is a key/value store kind of similar to BOOM. Instead of managing lists,
|
|
7
7
|
Usage is pretty straight forward:
|
8
8
|
|
9
9
|
peanut help show a quick help overview
|
10
|
-
peanut <key> <value>
|
11
|
-
peanut rm <key>
|
12
|
-
peanut <key>
|
13
|
-
|
10
|
+
peanut <key> <value> adds the key/value pair to your bucket
|
11
|
+
peanut rm <key> removes the key/value pair where key matches
|
12
|
+
peanut <key> copies the value of key to your clipboard
|
13
|
+
peanut <key> v adds the value of your clipboard to key
|
14
14
|
peanut list shows everything currently in your bucket
|
15
15
|
|
16
16
|
== Installation
|
17
17
|
|
18
|
-
gem install
|
18
|
+
gem install peanut
|
19
19
|
|
20
20
|
== Requirements
|
21
21
|
|
data/lib/peanut/clipboard.rb
CHANGED
data/lib/peanut/command.rb
CHANGED
@@ -9,7 +9,7 @@ module Peanut
|
|
9
9
|
return help unless key
|
10
10
|
return send key, value if is_arged_keyword?(key)
|
11
11
|
return send key if is_keyword?(key)
|
12
|
-
return save key, value if key && value
|
12
|
+
return save! key, value if key && value
|
13
13
|
return get key
|
14
14
|
end
|
15
15
|
|
@@ -20,14 +20,14 @@ module Peanut
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def list
|
23
|
-
|
23
|
+
Peanut::output "Your peanut bucket: \n#{'-' * 20}"
|
24
24
|
store.each_pair do |key, value|
|
25
|
-
|
25
|
+
Peanut::output "#{key}: #{value}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def help
|
30
|
-
|
30
|
+
Peanut::output %{
|
31
31
|
#{executable} <key> <value> sets the "key" value to "value"
|
32
32
|
#{executable} <key> copies the value for "key" to the clipboard
|
33
33
|
#{executable} rm <foo> removes the key/value pair where the key = foo
|
@@ -40,17 +40,17 @@ module Peanut
|
|
40
40
|
def get(key)
|
41
41
|
if val = store[key]
|
42
42
|
Clipboard.copy(val)
|
43
|
-
|
43
|
+
Peanut::output "Copied '#{val}' to the clipboard!"
|
44
44
|
else
|
45
|
-
|
45
|
+
Peanut::output "No value stored with key '#{key}'"
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def save(key, val)
|
49
|
+
def save!(key, val)
|
50
50
|
val = Clipboard.paste if val == 'v'
|
51
|
-
store[key.
|
52
|
-
store.save
|
53
|
-
|
51
|
+
store[key.to_sym] = val
|
52
|
+
store.save!
|
53
|
+
Peanut::output "Saved '#{val}' as '#{key}'"
|
54
54
|
end
|
55
55
|
|
56
56
|
def executable
|
@@ -59,8 +59,8 @@ module Peanut
|
|
59
59
|
|
60
60
|
def rm(key)
|
61
61
|
store[key] = nil
|
62
|
-
store.save
|
63
|
-
|
62
|
+
store.save!
|
63
|
+
Peanut::output "Deleted the value with the key '#{key}'"
|
64
64
|
end
|
65
65
|
|
66
66
|
def is_keyword?(word)
|
data/lib/peanut/store.rb
CHANGED
data/lib/peanut/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Peanut
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
2
|
+
VERSION = "0.2"
|
3
|
+
end
|
data/lib/peanut.rb
CHANGED
data/peanut-0.1.gem
ADDED
Binary file
|
data/test/helper.rb
CHANGED
data/test/test_command.rb
CHANGED
@@ -3,13 +3,20 @@ require 'helper'
|
|
3
3
|
# Dont Mind this
|
4
4
|
# Just a little ghetto monkey patching
|
5
5
|
# It lets us grab the STD I/O, and test it
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def
|
10
|
-
@
|
6
|
+
module Peanut
|
7
|
+
|
8
|
+
attr_accessor :outputted_string
|
9
|
+
def self.output(string)
|
10
|
+
@outputted_string << string
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.before_output
|
14
|
+
@outputted_string = ""
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.captured_output
|
18
|
+
@outputted_string
|
11
19
|
end
|
12
|
-
end
|
13
20
|
end
|
14
21
|
|
15
22
|
class TestCommand < Test::Unit::TestCase
|
@@ -20,12 +27,22 @@ class TestCommand < Test::Unit::TestCase
|
|
20
27
|
|
21
28
|
def command(cmd)
|
22
29
|
cmd = cmd.split(' ') if cmd
|
23
|
-
|
30
|
+
Peanut::before_output
|
31
|
+
Peanut::Command.run(*cmd)
|
32
|
+
Peanut::captured_output
|
24
33
|
end
|
25
34
|
|
26
35
|
def test_adding_entry
|
27
36
|
assert_equal "Saved 'testing' as 'test'", command("test testing")
|
28
37
|
end
|
29
38
|
|
39
|
+
def test_removing_entry
|
40
|
+
assert_equal "Deleted the value with the key 'test'", command("rm test")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_list
|
44
|
+
assert_equal "Your peanut bucket: \n--------------------test: testingtest: testing", command("list")
|
45
|
+
end
|
46
|
+
|
30
47
|
end
|
31
48
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peanut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- the_gastropod
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-21 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/peanut/command.rb
|
50
50
|
- lib/peanut/store.rb
|
51
51
|
- lib/peanut/version.rb
|
52
|
+
- peanut-0.1.gem
|
52
53
|
- peanut.gemspec
|
53
54
|
- test/examples/test.json
|
54
55
|
- test/helper.rb
|