boom 0.1.1 → 0.1.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/CHANGELOG.markdown +11 -1
- data/boom.gemspec +3 -2
- data/completion/README.md +7 -0
- data/completion/boom.zsh +29 -18
- data/lib/boom/config.rb +1 -1
- data/lib/boom/platform.rb +1 -1
- data/lib/boom/storage/mongodb.rb +53 -107
- data/lib/boom.rb +1 -1
- data/test/test_config.rb +1 -1
- metadata +5 -4
data/CHANGELOG.markdown
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# boom changes
|
2
2
|
|
3
|
-
##
|
3
|
+
## head
|
4
|
+
|
5
|
+
## 0.1.2
|
6
|
+
- Copy to clipboard doesn't hang anymore. Sweet. Thanks,
|
7
|
+
[mcollina](https://github.com/mcollina).
|
8
|
+
- Holy hell, [brettbuddin](https://github.com/brettbuddin) added completion for
|
9
|
+
zsh. Pretty awesome too.
|
10
|
+
- [antonlindstrom](https://github.com/antonlindstrom) fixed up the MongoDB
|
11
|
+
backend.
|
12
|
+
|
13
|
+
## 0.1.1
|
4
14
|
- Don't force Redis on everyone.
|
5
15
|
|
6
16
|
## 0.1.0
|
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.1.
|
17
|
-
s.date = '2011-
|
16
|
+
s.version = '0.1.2'
|
17
|
+
s.date = '2011-03-11'
|
18
18
|
s.rubyforge_project = 'boom'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -71,6 +71,7 @@ Gem::Specification.new do |s|
|
|
71
71
|
Rakefile
|
72
72
|
bin/boom
|
73
73
|
boom.gemspec
|
74
|
+
completion/README.md
|
74
75
|
completion/boom.bash
|
75
76
|
completion/boom.zsh
|
76
77
|
lib/boom.rb
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# boom completion
|
2
|
+
|
3
|
+
To add autocompletion to your shell, look in this directory and grab the script
|
4
|
+
that matches your corresponding shell.
|
5
|
+
|
6
|
+
I use the Z shell, so hey, I picked `boom.zsh`. And trust me: after a couple minutes of
|
7
|
+
playing with it, you'll never look back. NEVER!
|
data/completion/boom.zsh
CHANGED
@@ -1,18 +1,29 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
#compdef boom
|
2
|
+
|
3
|
+
local state line cmds ret=1
|
4
|
+
|
5
|
+
_arguments -C '1: :->cmds' '*: :->args'
|
6
|
+
|
7
|
+
case $state in
|
8
|
+
cmds)
|
9
|
+
local -a cmds
|
10
|
+
cmds=(
|
11
|
+
'all:show all items in all lists'
|
12
|
+
'edit:edit the boom JSON file in $EDITOR'
|
13
|
+
'help:help text'
|
14
|
+
)
|
15
|
+
_describe -t commands 'boom command' cmds && ret=0
|
16
|
+
_values 'lists' $(boom | awk '{print $1}')
|
17
|
+
;;
|
18
|
+
args)
|
19
|
+
case $line[1] in
|
20
|
+
(boom|all|edit|help)
|
21
|
+
;;
|
22
|
+
*)
|
23
|
+
_values 'items' `boom $line[1] | awk '{print $1}' | sed -e 's/://'` 2>/dev/null && ret=0
|
24
|
+
;;
|
25
|
+
esac
|
26
|
+
;;
|
27
|
+
esac
|
28
|
+
|
29
|
+
return ret
|
data/lib/boom/config.rb
CHANGED
data/lib/boom/platform.rb
CHANGED
@@ -45,7 +45,7 @@ module Boom
|
|
45
45
|
def copy(item)
|
46
46
|
copy_command = darwin? ? "pbcopy" : "xclip -selection clipboard"
|
47
47
|
|
48
|
-
|
48
|
+
Kernel.system("echo '#{item.value.gsub("\'","\\'")}' | tr -d \"\n\" | #{copy_command}")
|
49
49
|
|
50
50
|
"Boom! We just copied #{item.value} to your clipboard."
|
51
51
|
end
|
data/lib/boom/storage/mongodb.rb
CHANGED
@@ -1,67 +1,57 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
# Storage adapter that saves data from boom to MongoDB instead of JSON file.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
begin
|
5
|
+
require 'mongo'
|
6
|
+
require 'json/pure' # Will be here for now See Issue#21
|
7
|
+
rescue LoadError
|
8
|
+
end
|
9
9
|
|
10
10
|
module Boom
|
11
11
|
module Storage
|
12
|
-
class
|
12
|
+
class Mongodb < Base
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
# Public: the path to the JSON Mongo config file, userdata.
|
17
|
-
#
|
18
|
-
# Returns the String path of boom's MongoDB userdata
|
19
|
-
def mongo_cfg
|
20
|
-
MONGO_CFG
|
21
|
-
end
|
22
|
-
|
23
|
-
# Public: initializes a Storage instance by loading in your persisted data.
|
14
|
+
# Public: Initialize MongoDB connection and check dep.
|
24
15
|
#
|
25
|
-
# Returns
|
26
|
-
def
|
27
|
-
|
16
|
+
# Returns Mongo connection
|
17
|
+
def mongo
|
18
|
+
@mongo ||= ::Mongo::Connection.new(
|
19
|
+
Boom.config.attributes["mongodb"]["host"],
|
20
|
+
Boom.config.attributes["mongodb"]["port"]
|
21
|
+
).db(Boom.config.attributes["mongodb"]["database"])
|
28
22
|
|
29
|
-
@
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
@mongo.authenticate(
|
24
|
+
Boom.config.attributes['mongodb']['username'],
|
25
|
+
Boom.config.attributes['mongodb']['password']
|
26
|
+
)
|
27
|
+
|
28
|
+
# Return connection
|
29
|
+
@mongo
|
30
|
+
rescue NameError => e
|
31
|
+
puts "You don't have the Mongo gem installed yet:\n gem install mongo"
|
32
|
+
exit
|
33
33
|
end
|
34
|
-
|
35
|
-
# Public:
|
34
|
+
|
35
|
+
# Public: The MongoDB collection
|
36
36
|
#
|
37
|
-
# Returns
|
38
|
-
def
|
39
|
-
@
|
37
|
+
# Returns the MongoDB collection
|
38
|
+
def collection
|
39
|
+
@collection ||= mongo.collection(Boom.config.attributes["mongodb"]["collection"])
|
40
40
|
end
|
41
|
-
|
42
|
-
# Public:
|
43
|
-
#
|
44
|
-
# lists_json - the list to be saved in JSON format
|
41
|
+
|
42
|
+
# Public: Bootstrap
|
45
43
|
#
|
46
|
-
# Returns
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
# INTERNAL METHODS ##########################################################
|
44
|
+
# Returns
|
45
|
+
def bootstrap
|
46
|
+
collection.insert("boom" => '{"lists": [{}]}') if collection.find_one.nil?
|
47
|
+
end
|
53
48
|
|
54
|
-
#
|
55
|
-
# Lists and Items for the given Storage instance.
|
49
|
+
# Public: Populates the memory list from MongoDB
|
56
50
|
#
|
57
|
-
# Returns nothing
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
storage = Yajl::Parser.new.parse(s)
|
62
|
-
|
63
|
-
return if storage['lists'].nil?
|
64
|
-
|
51
|
+
# Returns nothing
|
52
|
+
def populate
|
53
|
+
storage = JSON.parse(collection.find_one['boom']) || []
|
54
|
+
|
65
55
|
storage['lists'].each do |lists|
|
66
56
|
lists.each do |list_name, items|
|
67
57
|
@lists << list = List.new(list_name)
|
@@ -72,68 +62,24 @@ module Boom
|
|
72
62
|
end
|
73
63
|
end
|
74
64
|
end
|
75
|
-
end
|
65
|
+
end
|
76
66
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
# Initialize MongoDB and set data in memory
|
81
|
-
#
|
82
|
-
# config_file - The MongoDB config_file path defined
|
83
|
-
#
|
84
|
-
# Returns database obj.
|
85
|
-
def mongo_initialize(config_file)
|
86
|
-
bootstrap_config(config_file) unless File.exists?(config_file)
|
87
|
-
config = parse_mongo_cfg(config_file)
|
88
|
-
|
89
|
-
db = Mongo::Connection.new(config['host'], config['port']).db(config['database'])
|
90
|
-
auth = db.authenticate(config['username'], config['password'])
|
91
|
-
|
92
|
-
# Get collection collection;
|
93
|
-
@mongo_coll = db.collection(config['collection'])
|
94
|
-
|
95
|
-
@mongo_coll.insert("boom" => '{"lists": [{}]}') if @mongo_coll.find_one.nil?
|
96
|
-
|
97
|
-
return @mongo_coll
|
98
|
-
end
|
99
|
-
|
100
|
-
# Parse Mongo JSON Config
|
101
|
-
#
|
102
|
-
# config_file - The MongoDB config_file path defined
|
67
|
+
|
68
|
+
# Public: Save to MongoDB
|
103
69
|
#
|
104
|
-
# Returns
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
config = Yajl::Parser.new.parse(File.open(config_file, 'r'))
|
109
|
-
|
110
|
-
config.each_pair do |type, data|
|
111
|
-
mongod[type] = data
|
112
|
-
end
|
113
|
-
return mongod
|
70
|
+
# Returns Mongo ID
|
71
|
+
def save
|
72
|
+
doc = collection.find_one()
|
73
|
+
collection.update({"_id" => doc["_id"]}, {'boom' => to_json})
|
114
74
|
end
|
115
|
-
|
116
|
-
#
|
117
|
-
#
|
118
|
-
# config_file - The MongoDB config_file path defined
|
75
|
+
|
76
|
+
# Public: Convert to JSON
|
119
77
|
#
|
120
|
-
# Returns
|
121
|
-
def
|
122
|
-
|
123
|
-
|
124
|
-
config['host'] = 'localhost'
|
125
|
-
config['port'] = '27017'
|
126
|
-
config['database'] = 'boom'
|
127
|
-
config['username'] = 'boom'
|
128
|
-
config['password'] = 's3cr3t'
|
129
|
-
config['collection'] = 'boom'
|
130
|
-
|
131
|
-
# Write to CFG
|
132
|
-
json_cfg = Yajl::Encoder.encode(config, :pretty => true)
|
133
|
-
File.open(config_file, 'w') {|f| f.write(json_cfg) }
|
78
|
+
# Returns
|
79
|
+
def to_json
|
80
|
+
JSON.generate(to_hash)
|
134
81
|
end
|
135
|
-
|
136
|
-
|
82
|
+
|
137
83
|
end
|
138
84
|
end
|
139
|
-
end
|
85
|
+
end
|
data/lib/boom.rb
CHANGED
data/test/test_config.rb
CHANGED
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: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
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-03-11 00:00:00 -08:00
|
19
19
|
default_executable: boom
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- Rakefile
|
74
74
|
- bin/boom
|
75
75
|
- boom.gemspec
|
76
|
+
- completion/README.md
|
76
77
|
- completion/boom.bash
|
77
78
|
- completion/boom.zsh
|
78
79
|
- lib/boom.rb
|