boom 0.2.1 → 0.2.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 +5 -0
- data/Gemfile.lock +7 -3
- data/boom.gemspec +6 -3
- data/lib/boom/config.rb +2 -2
- data/lib/boom/platform.rb +1 -1
- data/lib/boom/storage/gist.rb +120 -0
- data/lib/boom/storage/json.rb +2 -2
- data/lib/boom/storage/mongodb.rb +2 -2
- data/lib/boom.rb +3 -2
- data/test/test_platform.rb +1 -1
- metadata +44 -11
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## head
|
4
4
|
|
5
|
+
## 0.2.2 (July 29, 2011)
|
6
|
+
- [@jimmycuadra](https://github.com/jimmycuadra) went to town on this beast and
|
7
|
+
hooked up a Gist backend to boom. Killer.
|
8
|
+
- Small Windows fix.
|
9
|
+
|
5
10
|
## 0.2.1 (July 16, 2011)
|
6
11
|
- boom displays colors thanks to [@dandorman](https://github.com/dandorman).
|
7
12
|
- Windows support, brah. [@tombell](https://github.com/tombell).
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
boom (0.2.
|
5
|
-
json_pure (~> 1.5.
|
4
|
+
boom (0.2.1)
|
5
|
+
json_pure (~> 1.5.3)
|
6
|
+
multi_json (~> 1.0.3)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: http://rubygems.org/
|
9
10
|
specs:
|
10
|
-
json_pure (1.5.
|
11
|
+
json_pure (1.5.3)
|
11
12
|
mocha (0.9.12)
|
13
|
+
multi_json (1.0.3)
|
14
|
+
rake (0.9.2)
|
12
15
|
|
13
16
|
PLATFORMS
|
14
17
|
ruby
|
@@ -16,3 +19,4 @@ PLATFORMS
|
|
16
19
|
DEPENDENCIES
|
17
20
|
boom!
|
18
21
|
mocha (~> 0.9.9)
|
22
|
+
rake (~> 0.9.2)
|
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.2.
|
17
|
-
s.date = '2011-07-
|
16
|
+
s.version = '0.2.2'
|
17
|
+
s.date = '2011-07-29'
|
18
18
|
s.rubyforge_project = 'boom'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -54,11 +54,13 @@ Gem::Specification.new do |s|
|
|
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.
|
57
|
-
s.add_dependency('
|
57
|
+
s.add_dependency('multi_json', "~> 1.0.3")
|
58
|
+
s.add_dependency('json_pure', "~> 1.5.3")
|
58
59
|
|
59
60
|
## List your development dependencies here. Development dependencies are
|
60
61
|
## those that are only needed during development
|
61
62
|
s.add_development_dependency('mocha', "~> 0.9.9")
|
63
|
+
s.add_development_dependency('rake', "~> 0.9.2")
|
62
64
|
|
63
65
|
## Leave this section as-is. It will be automatically generated from the
|
64
66
|
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
@@ -86,6 +88,7 @@ Gem::Specification.new do |s|
|
|
86
88
|
lib/boom/platform.rb
|
87
89
|
lib/boom/storage.rb
|
88
90
|
lib/boom/storage/base.rb
|
91
|
+
lib/boom/storage/gist.rb
|
89
92
|
lib/boom/storage/json.rb
|
90
93
|
lib/boom/storage/keychain.rb
|
91
94
|
lib/boom/storage/mongodb.rb
|
data/lib/boom/config.rb
CHANGED
@@ -74,14 +74,14 @@ module Boom
|
|
74
74
|
#
|
75
75
|
# Returns nothing.
|
76
76
|
def load_attributes
|
77
|
-
@attributes =
|
77
|
+
@attributes = MultiJson.decode(File.new(file, 'r').read)
|
78
78
|
end
|
79
79
|
|
80
80
|
# Public: writes the in-memory JSON Hash to disk.
|
81
81
|
#
|
82
82
|
# Returns nothing.
|
83
83
|
def save
|
84
|
-
json =
|
84
|
+
json = MultiJson.encode(attributes)
|
85
85
|
File.open(file, 'w') {|f| f.write(json) }
|
86
86
|
end
|
87
87
|
|
data/lib/boom/platform.rb
CHANGED
@@ -0,0 +1,120 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
#
|
3
|
+
# Gist backend for Boom.
|
4
|
+
#
|
5
|
+
# Your .boom.conf file should look like this:
|
6
|
+
#
|
7
|
+
# {
|
8
|
+
# "backend": "gist",
|
9
|
+
# "gist": {
|
10
|
+
# "username": "your_github_username",
|
11
|
+
# "password": "your_github_password"
|
12
|
+
# }
|
13
|
+
# }
|
14
|
+
#
|
15
|
+
# There are two optional keys which can be under "gist":
|
16
|
+
#
|
17
|
+
# gist_id - The ID of an existing Gist to use. If not
|
18
|
+
# present, a Gist will be created the first time
|
19
|
+
# Boom is run and will be persisted to the config.
|
20
|
+
# public - Makes the Gist public. An absent value or
|
21
|
+
# any value other than boolean true will make
|
22
|
+
# the Gist private.
|
23
|
+
#
|
24
|
+
begin
|
25
|
+
require "httparty"
|
26
|
+
rescue LoadError
|
27
|
+
puts "The Gist backend requires HTTParty: gem install httparty"
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
# Crack's parsing is no bueno. Use the MultiJson instead.
|
32
|
+
class JsonParser < HTTParty::Parser
|
33
|
+
def json
|
34
|
+
MultiJson.decode(body)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Boom
|
39
|
+
module Storage
|
40
|
+
class Gist < Base
|
41
|
+
include HTTParty
|
42
|
+
parser JsonParser
|
43
|
+
base_uri "https://api.github.com"
|
44
|
+
|
45
|
+
def bootstrap
|
46
|
+
unless Boom.config.attributes["gist"]
|
47
|
+
puts 'A "gist" data structure must be defined in ~/.boom.conf'
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
|
51
|
+
set_up_auth
|
52
|
+
find_or_create_gist
|
53
|
+
end
|
54
|
+
|
55
|
+
def populate
|
56
|
+
@storage['lists'].each do |lists|
|
57
|
+
lists.each do |list_name, items|
|
58
|
+
@lists << list = List.new(list_name)
|
59
|
+
|
60
|
+
items.each do |item|
|
61
|
+
item.each do |name,value|
|
62
|
+
list.add_item(Item.new(name,value))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def save
|
70
|
+
self.class.post("/gists/#{@gist_id}", request_params)
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def set_up_auth
|
76
|
+
username, password = Boom.config.attributes["gist"]["username"], Boom.config.attributes["gist"]["password"]
|
77
|
+
|
78
|
+
if username and password
|
79
|
+
self.class.basic_auth(username, password)
|
80
|
+
else
|
81
|
+
puts "GitHub username and password must be defined in ~/.boom.conf"
|
82
|
+
exit
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_or_create_gist
|
87
|
+
@gist_id = Boom.config.attributes["gist"]["gist_id"]
|
88
|
+
@public = Boom.config.attributes["gist"]["public"] == true
|
89
|
+
|
90
|
+
if @gist_id.nil? or @gist_id.empty?
|
91
|
+
response = self.class.post("/gists", request_params)
|
92
|
+
else
|
93
|
+
response = self.class.get("/gists/#{@gist_id}", request_params)
|
94
|
+
end
|
95
|
+
|
96
|
+
@storage = MultiJson.decode(response["files"]["boom.json"]["content"]) if response["files"] and response["files"]["boom.json"]
|
97
|
+
|
98
|
+
unless @storage
|
99
|
+
puts "Boom data could not be obtained"
|
100
|
+
exit
|
101
|
+
end
|
102
|
+
|
103
|
+
unless @gist_id
|
104
|
+
Boom.config.attributes["gist"]["gist_id"] = @gist_id = response["id"]
|
105
|
+
Boom.config.save
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def request_params
|
110
|
+
{
|
111
|
+
:body => MultiJson.encode({
|
112
|
+
:description => "boom!",
|
113
|
+
:public => @public,
|
114
|
+
:files => { "boom.json" => { :content => MultiJson.encode(to_hash) } }
|
115
|
+
})
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
data/lib/boom/storage/json.rb
CHANGED
@@ -32,7 +32,7 @@ module Boom
|
|
32
32
|
#
|
33
33
|
# Returns nothing.
|
34
34
|
def populate
|
35
|
-
storage =
|
35
|
+
storage = MultiJson.decode(File.new(json_file, 'r').read)
|
36
36
|
|
37
37
|
storage['lists'].each do |lists|
|
38
38
|
lists.each do |list_name, items|
|
@@ -61,7 +61,7 @@ module Boom
|
|
61
61
|
#
|
62
62
|
# Returns a String Json representation of its Lists and their Items.
|
63
63
|
def to_json
|
64
|
-
|
64
|
+
MultiJson.encode(to_hash)
|
65
65
|
end
|
66
66
|
|
67
67
|
end
|
data/lib/boom/storage/mongodb.rb
CHANGED
@@ -49,7 +49,7 @@ module Boom
|
|
49
49
|
#
|
50
50
|
# Returns nothing
|
51
51
|
def populate
|
52
|
-
storage =
|
52
|
+
storage = MultiJson.decode(collection.find_one['boom']) || []
|
53
53
|
|
54
54
|
storage['lists'].each do |lists|
|
55
55
|
lists.each do |list_name, items|
|
@@ -76,7 +76,7 @@ module Boom
|
|
76
76
|
#
|
77
77
|
# Returns
|
78
78
|
def to_json
|
79
|
-
|
79
|
+
MultiJson.encode(to_hash)
|
80
80
|
end
|
81
81
|
|
82
82
|
end
|
data/lib/boom.rb
CHANGED
@@ -6,7 +6,7 @@ rescue LoadError
|
|
6
6
|
end
|
7
7
|
|
8
8
|
require 'fileutils'
|
9
|
-
require '
|
9
|
+
require 'multi_json'
|
10
10
|
|
11
11
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
12
12
|
|
@@ -23,11 +23,12 @@ require 'boom/storage/json'
|
|
23
23
|
require 'boom/storage/redis'
|
24
24
|
require 'boom/storage/mongodb'
|
25
25
|
require 'boom/storage/keychain'
|
26
|
+
require 'boom/storage/gist'
|
26
27
|
|
27
28
|
require 'boom/core_ext/symbol'
|
28
29
|
|
29
30
|
module Boom
|
30
|
-
VERSION = '0.2.
|
31
|
+
VERSION = '0.2.2'
|
31
32
|
|
32
33
|
extend self
|
33
34
|
|
data/test/test_platform.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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zach Holman
|
@@ -15,29 +15,45 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-29 00:00:00 -07:00
|
19
19
|
default_executable: boom
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: multi_json
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 17
|
30
30
|
segments:
|
31
31
|
- 1
|
32
|
-
-
|
33
|
-
-
|
34
|
-
version: 1.
|
32
|
+
- 0
|
33
|
+
- 3
|
34
|
+
version: 1.0.3
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: json_pure
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 5
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 5
|
49
|
+
- 3
|
50
|
+
version: 1.5.3
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: mocha
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
58
|
requirements:
|
43
59
|
- - ~>
|
@@ -49,7 +65,23 @@ dependencies:
|
|
49
65
|
- 9
|
50
66
|
version: 0.9.9
|
51
67
|
type: :development
|
52
|
-
version_requirements: *
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 63
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 9
|
81
|
+
- 2
|
82
|
+
version: 0.9.2
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
53
85
|
description: |-
|
54
86
|
God it's about every day where I think to myself, gadzooks,
|
55
87
|
I keep typing *REPETITIVE_BORING_TASK* over and over. Wouldn't it be great if
|
@@ -88,6 +120,7 @@ files:
|
|
88
120
|
- lib/boom/platform.rb
|
89
121
|
- lib/boom/storage.rb
|
90
122
|
- lib/boom/storage/base.rb
|
123
|
+
- lib/boom/storage/gist.rb
|
91
124
|
- lib/boom/storage/json.rb
|
92
125
|
- lib/boom/storage/keychain.rb
|
93
126
|
- lib/boom/storage/mongodb.rb
|