boombera 0.0.0 → 0.1.0
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/.autotest +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +19 -0
- data/VERSION +1 -1
- data/bin/boombera +26 -0
- data/boombera.gemspec +22 -2
- data/lib/boombera.rb +77 -0
- data/lib/boombera/content_item.rb +33 -0
- data/spec/bin/boombera_spec.rb +121 -0
- data/spec/lib/boombera/content_item_spec.rb +63 -0
- data/spec/lib/boombera_spec.rb +131 -0
- metadata +68 -18
data/.autotest
ADDED
data/Gemfile
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'couchrest', '~> 1.0.2'
|
4
|
+
|
2
5
|
group :development do
|
3
6
|
gem "rspec", "~> 2.3.0"
|
4
7
|
gem "bundler", "~> 1.0.0"
|
@@ -6,4 +9,7 @@ group :development do
|
|
6
9
|
gem "rcov", ">= 0"
|
7
10
|
gem "reek", "~> 1.2.8"
|
8
11
|
gem "rdoc", "~> 3.6.1"
|
12
|
+
gem 'autotest', '~> 4.4.6'
|
13
|
+
gem 'autotest-growl', '~> 0.2.9'
|
14
|
+
gem 'autotest-fsevent', '~> 0.2.5'
|
9
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -10,8 +10,20 @@ GIT
|
|
10
10
|
GEM
|
11
11
|
remote: http://rubygems.org/
|
12
12
|
specs:
|
13
|
+
ZenTest (4.5.0)
|
14
|
+
autotest (4.4.6)
|
15
|
+
ZenTest (>= 4.4.1)
|
16
|
+
autotest-fsevent (0.2.5)
|
17
|
+
sys-uname
|
18
|
+
autotest-growl (0.2.9)
|
19
|
+
couchrest (1.0.2)
|
20
|
+
json (~> 1.5.1)
|
21
|
+
mime-types (~> 1.15)
|
22
|
+
rest-client (~> 1.6.1)
|
13
23
|
diff-lcs (1.1.2)
|
14
24
|
git (1.2.5)
|
25
|
+
json (1.5.1)
|
26
|
+
mime-types (1.16)
|
15
27
|
rake (0.9.0)
|
16
28
|
rcov (0.9.9)
|
17
29
|
rdoc (3.6.1)
|
@@ -19,6 +31,8 @@ GEM
|
|
19
31
|
ruby2ruby (~> 1.2)
|
20
32
|
ruby_parser (~> 2.0)
|
21
33
|
sexp_processor (~> 3.0)
|
34
|
+
rest-client (1.6.1)
|
35
|
+
mime-types (>= 1.16)
|
22
36
|
rspec (2.3.0)
|
23
37
|
rspec-core (~> 2.3.0)
|
24
38
|
rspec-expectations (~> 2.3.0)
|
@@ -33,12 +47,17 @@ GEM
|
|
33
47
|
ruby_parser (2.0.6)
|
34
48
|
sexp_processor (~> 3.0)
|
35
49
|
sexp_processor (3.0.5)
|
50
|
+
sys-uname (0.8.5)
|
36
51
|
|
37
52
|
PLATFORMS
|
38
53
|
ruby
|
39
54
|
|
40
55
|
DEPENDENCIES
|
56
|
+
autotest (~> 4.4.6)
|
57
|
+
autotest-fsevent (~> 0.2.5)
|
58
|
+
autotest-growl (~> 0.2.9)
|
41
59
|
bundler (~> 1.0.0)
|
60
|
+
couchrest (~> 1.0.2)
|
42
61
|
jeweler!
|
43
62
|
rcov
|
44
63
|
rdoc (~> 3.6.1)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/bin/boombera
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
|
3
|
+
require 'boombera'
|
4
|
+
|
5
|
+
command, database, path, body = ARGV[0..3]
|
6
|
+
|
7
|
+
begin
|
8
|
+
case command
|
9
|
+
when 'install'
|
10
|
+
Boombera.install_design_doc!(database)
|
11
|
+
puts "The CouchDB Boombera application has been updated to version #{Boombera.version}"
|
12
|
+
when 'put'
|
13
|
+
db = Boombera.new(database)
|
14
|
+
result = db.put(path, body)
|
15
|
+
puts "Content Saved: #{path}"
|
16
|
+
when 'get'
|
17
|
+
db = Boombera.new(database)
|
18
|
+
result = db.get(path)
|
19
|
+
puts result.body
|
20
|
+
end
|
21
|
+
rescue Boombera::VersionMismatch => e
|
22
|
+
puts e.message
|
23
|
+
puts "You may need to run 'boombera install #{database}' to update the"
|
24
|
+
puts "CouchDB Boombera application."
|
25
|
+
exit(1)
|
26
|
+
end
|
data/boombera.gemspec
CHANGED
@@ -5,18 +5,21 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{boombera}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Wilger"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-30}
|
13
|
+
s.default_executable = %q{boombera}
|
13
14
|
s.description = %q{CouchDB-backed content repository for multi-tenant, multi-stage applications}
|
14
15
|
s.email = %q{johnwilger@gmail.com}
|
16
|
+
s.executables = ["boombera"]
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE.txt",
|
17
19
|
"README.rdoc"
|
18
20
|
]
|
19
21
|
s.files = [
|
22
|
+
".autotest",
|
20
23
|
".document",
|
21
24
|
".rspec",
|
22
25
|
".rvmrc",
|
@@ -26,8 +29,13 @@ Gem::Specification.new do |s|
|
|
26
29
|
"README.rdoc",
|
27
30
|
"Rakefile",
|
28
31
|
"VERSION",
|
32
|
+
"bin/boombera",
|
29
33
|
"boombera.gemspec",
|
30
34
|
"lib/boombera.rb",
|
35
|
+
"lib/boombera/content_item.rb",
|
36
|
+
"spec/bin/boombera_spec.rb",
|
37
|
+
"spec/lib/boombera/content_item_spec.rb",
|
38
|
+
"spec/lib/boombera_spec.rb",
|
31
39
|
"spec/spec_helper.rb"
|
32
40
|
]
|
33
41
|
s.homepage = %q{http://github.com/jwilger/boombera}
|
@@ -40,27 +48,39 @@ Gem::Specification.new do |s|
|
|
40
48
|
s.specification_version = 3
|
41
49
|
|
42
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_runtime_dependency(%q<couchrest>, ["~> 1.0.2"])
|
43
52
|
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
44
53
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
45
54
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
46
55
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
47
56
|
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
48
57
|
s.add_development_dependency(%q<rdoc>, ["~> 3.6.1"])
|
58
|
+
s.add_development_dependency(%q<autotest>, ["~> 4.4.6"])
|
59
|
+
s.add_development_dependency(%q<autotest-growl>, ["~> 0.2.9"])
|
60
|
+
s.add_development_dependency(%q<autotest-fsevent>, ["~> 0.2.5"])
|
49
61
|
else
|
62
|
+
s.add_dependency(%q<couchrest>, ["~> 1.0.2"])
|
50
63
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
51
64
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
52
65
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
53
66
|
s.add_dependency(%q<rcov>, [">= 0"])
|
54
67
|
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
55
68
|
s.add_dependency(%q<rdoc>, ["~> 3.6.1"])
|
69
|
+
s.add_dependency(%q<autotest>, ["~> 4.4.6"])
|
70
|
+
s.add_dependency(%q<autotest-growl>, ["~> 0.2.9"])
|
71
|
+
s.add_dependency(%q<autotest-fsevent>, ["~> 0.2.5"])
|
56
72
|
end
|
57
73
|
else
|
74
|
+
s.add_dependency(%q<couchrest>, ["~> 1.0.2"])
|
58
75
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
59
76
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
77
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
61
78
|
s.add_dependency(%q<rcov>, [">= 0"])
|
62
79
|
s.add_dependency(%q<reek>, ["~> 1.2.8"])
|
63
80
|
s.add_dependency(%q<rdoc>, ["~> 3.6.1"])
|
81
|
+
s.add_dependency(%q<autotest>, ["~> 4.4.6"])
|
82
|
+
s.add_dependency(%q<autotest-growl>, ["~> 0.2.9"])
|
83
|
+
s.add_dependency(%q<autotest-fsevent>, ["~> 0.2.5"])
|
64
84
|
end
|
65
85
|
end
|
66
86
|
|
data/lib/boombera.rb
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
$:.unshift(File.expand_path(File.dirname(__FILE__)))
|
2
|
+
require 'couchrest'
|
3
|
+
require 'boombera/content_item'
|
4
|
+
|
5
|
+
class Boombera
|
6
|
+
VersionMismatch = Class.new(StandardError)
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def version
|
10
|
+
File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', 'VERSION')))
|
11
|
+
end
|
12
|
+
|
13
|
+
def database_version(db)
|
14
|
+
db.get('_design/boombera')['gem_version']
|
15
|
+
rescue RestClient::ResourceNotFound
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def install_design_doc!(database)
|
20
|
+
db = CouchRest.database!(database)
|
21
|
+
design = design_doc
|
22
|
+
existing = db.documents(:key => '_design/boombera')['rows'].first
|
23
|
+
design['_rev'] = existing['value']['rev'] unless existing.nil?
|
24
|
+
db.save_doc(design)
|
25
|
+
end
|
26
|
+
|
27
|
+
def design_doc
|
28
|
+
{
|
29
|
+
'_id' => '_design/boombera',
|
30
|
+
'language' => 'javascript',
|
31
|
+
'gem_version' => version,
|
32
|
+
'views' => {
|
33
|
+
'content_map' => {
|
34
|
+
'map' => <<-EOF
|
35
|
+
function(doc) {
|
36
|
+
if (doc['path']) {
|
37
|
+
emit(doc.path, doc.path);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
EOF
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
attr_reader :db
|
48
|
+
|
49
|
+
def initialize(database_name)
|
50
|
+
@db = CouchRest.database!(database_name)
|
51
|
+
check_database_version!
|
52
|
+
end
|
53
|
+
|
54
|
+
def put(path, body)
|
55
|
+
content_item = get(path) || ContentItem.new(:path => path, :database => db)
|
56
|
+
content_item.body = body
|
57
|
+
content_item.save
|
58
|
+
end
|
59
|
+
|
60
|
+
def get(path)
|
61
|
+
ContentItem.get(path, db)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def check_database_version!
|
67
|
+
database_version ||= Boombera.database_version(db)
|
68
|
+
unless Boombera.version == database_version
|
69
|
+
msg = if database_version.nil?
|
70
|
+
"Database does not specify a Boombera version"
|
71
|
+
else
|
72
|
+
"Database expects Boombera #{database_version}"
|
73
|
+
end
|
74
|
+
raise VersionMismatch, msg
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Boombera
|
2
|
+
class ContentItem < CouchRest::Document
|
3
|
+
class << self
|
4
|
+
def get(path, database)
|
5
|
+
rows = database.view('boombera/content_map', :key => path)['rows']
|
6
|
+
return nil if rows.empty?
|
7
|
+
id = rows.first['id']
|
8
|
+
new(database.get(id))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(pkeys = {})
|
13
|
+
@database = if pkeys.respond_to?(:database)
|
14
|
+
pkeys.database
|
15
|
+
else
|
16
|
+
pkeys.delete(:database)
|
17
|
+
end
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def path
|
22
|
+
self[:path]
|
23
|
+
end
|
24
|
+
|
25
|
+
def body
|
26
|
+
self[:body]
|
27
|
+
end
|
28
|
+
|
29
|
+
def body=(new_body)
|
30
|
+
self[:body] = new_body
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe "The boombera CLI" do
|
4
|
+
BOOMBERA_CLI = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'boombera')
|
5
|
+
|
6
|
+
let(:db) { CouchRest.database!('boombera_test') }
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
db.delete!
|
10
|
+
Boombera.install_design_doc!('boombera_test')
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "put command" do
|
14
|
+
context "when putting a new content item via argument string" do
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
@output = `#{BOOMBERA_CLI} put boombera_test /foo "some content"`
|
18
|
+
@exit_status = $?.exitstatus
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'exits with a status code of 0' do
|
22
|
+
@exit_status.should == 0
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'outputs a message indicating that the content was saved' do
|
26
|
+
@output.should == "Content Saved: /foo\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'creates the content in the couchdb server' do
|
30
|
+
result = db.view('boombera/content_map', :key => '/foo')['rows'].first
|
31
|
+
result.should_not be_nil
|
32
|
+
document = db.get(result['id'])
|
33
|
+
document['path'].should == '/foo'
|
34
|
+
document['body'].should == 'some content'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when updating an existing content item via argument string" do
|
39
|
+
before(:each) do
|
40
|
+
db.save_doc({:path => '/bar', :body => 'original content'})
|
41
|
+
@output = `#{BOOMBERA_CLI} put boombera_test /bar "new content"`
|
42
|
+
@exit_status = $?.exitstatus
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'exits with a status code of 0' do
|
46
|
+
@exit_status.should == 0
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'outputs a message indicating that the content was saved' do
|
50
|
+
@output.should == "Content Saved: /bar\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'updates the content in the couchdb server' do
|
54
|
+
rows = db.view('boombera/content_map', :key => '/bar')['rows']
|
55
|
+
rows.length.should == 1
|
56
|
+
result = rows.first
|
57
|
+
result.should_not be_nil
|
58
|
+
document = db.get(result['id'])
|
59
|
+
document['path'].should == '/bar'
|
60
|
+
document['body'].should == 'new content'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'get command' do
|
66
|
+
context 'the requested content exists' do
|
67
|
+
before(:each) do
|
68
|
+
`#{BOOMBERA_CLI} put boombera_test /foo "some content"`
|
69
|
+
@output = `#{BOOMBERA_CLI} get boombera_test /foo`
|
70
|
+
@exit_status = $?.exitstatus
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'exits with a status code of 0' do
|
74
|
+
@exit_status.should == 0
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'outputs the document body to STDOUT' do
|
78
|
+
@output.should == "some content\n"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "install command" do
|
84
|
+
before(:each) do
|
85
|
+
db.delete!
|
86
|
+
@output = `#{BOOMBERA_CLI} install boombera_test`
|
87
|
+
@exit_status = $?.exitstatus
|
88
|
+
end
|
89
|
+
|
90
|
+
shared_examples_for :a_successful_instalation do
|
91
|
+
it 'exits with a status code of 0' do
|
92
|
+
@exit_status.should == 0
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'outputs a message indicating that the CouchDB portion of the Boombera application was installed' do
|
96
|
+
@output.should == "The CouchDB Boombera application has been updated to " \
|
97
|
+
+ "version #{Boombera.version}\n"
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'installs the boombera design document on the CouchDB instance' do
|
101
|
+
design_doc = db.get('_design/boombera')
|
102
|
+
expected = Boombera.design_doc
|
103
|
+
design_doc['gem_version'].should == expected['gem_version']
|
104
|
+
design_doc['views'].should == expected['views']
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when run for the first time' do
|
109
|
+
it_should_behave_like :a_successful_instalation
|
110
|
+
end
|
111
|
+
|
112
|
+
context 'when run more than once' do
|
113
|
+
before(:each) do
|
114
|
+
@output = `#{BOOMBERA_CLI} install boombera_test`
|
115
|
+
@exit_status = $?.exitstatus
|
116
|
+
end
|
117
|
+
|
118
|
+
it_should_behave_like :a_successful_instalation
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Boombera::ContentItem do
|
4
|
+
describe '.get' do
|
5
|
+
context 'with an existing content item' do
|
6
|
+
it 'returns a ContentItem instance for the found document' do
|
7
|
+
view_result = {'rows' => [{'id' => '123'}]}
|
8
|
+
db = mock(CouchRest::Database)
|
9
|
+
db.should_receive(:view) \
|
10
|
+
.with('boombera/content_map', :key => '/foo') \
|
11
|
+
.and_return(view_result)
|
12
|
+
db.should_receive(:get) \
|
13
|
+
.with('123') \
|
14
|
+
.and_return({'path' => '/foo', 'body' => 'bar'})
|
15
|
+
result = Boombera::ContentItem.get('/foo', db)
|
16
|
+
result.path.should == '/foo'
|
17
|
+
result.body.should == 'bar'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.new' do
|
23
|
+
context 'when passed a plain hash' do
|
24
|
+
it 'sets the database from the params hash' do
|
25
|
+
content_item = Boombera::ContentItem.new(:path => '/foo',
|
26
|
+
:body => 'bar',
|
27
|
+
:database => :the_database)
|
28
|
+
content_item.database.should == :the_database
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when passed a CouchRest::Document instance' do
|
33
|
+
it 'sets the database as the document database' do
|
34
|
+
doc = CouchRest::Document.new(:path => '/foo', :body => 'bar')
|
35
|
+
doc.stub!(:database => :the_document_database)
|
36
|
+
content_item = Boombera::ContentItem.new(doc)
|
37
|
+
content_item.database.should == :the_document_database
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#path' do
|
43
|
+
it 'returns the path from the associated document' do
|
44
|
+
content = Boombera::ContentItem.new('path' => '/index.html')
|
45
|
+
content.path.should == '/index.html'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#body' do
|
50
|
+
it 'returns the body from the associated document' do
|
51
|
+
content = Boombera::ContentItem.new('body' => 'foo bar baz')
|
52
|
+
content.body.should == 'foo bar baz'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#body=' do
|
57
|
+
it 'overwrites the current contents of the document body' do
|
58
|
+
content = Boombera::ContentItem.new('body' => 'foo')
|
59
|
+
content.body = 'bar'
|
60
|
+
content.body.should == 'bar'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe Boombera do
|
4
|
+
let(:db) do
|
5
|
+
db = stub(CouchRest::Database)
|
6
|
+
CouchRest.stub!(:database! => db)
|
7
|
+
db
|
8
|
+
end
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
Boombera.stub!(:version => '1.2.3')
|
12
|
+
Boombera.stub!(:database_version => '1.2.3')
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.new' do
|
16
|
+
it 'connects to the specified database on the local couchdb server' do
|
17
|
+
CouchRest.should_receive(:database!) \
|
18
|
+
.with("my_db") \
|
19
|
+
.and_return(db)
|
20
|
+
boombera = Boombera.new('my_db')
|
21
|
+
boombera.db.should == db
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'raises a VersionMismatch error with expected version if the database does not match VERSION' do
|
25
|
+
Boombera.stub!(:version => '1.2.2')
|
26
|
+
lambda { Boombera.new('boombera_test') }.should \
|
27
|
+
raise_error(Boombera::VersionMismatch, "Database expects Boombera 1.2.3")
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'raises a VersionMismatch error if the database does not have a boombera_version document' do
|
31
|
+
Boombera.stub!(:database_version => nil)
|
32
|
+
lambda { Boombera.new('boombera_test') }.should \
|
33
|
+
raise_error(Boombera::VersionMismatch, "Database does not specify a Boombera version")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#put' do
|
38
|
+
let(:content_item) { mock(Boombera::ContentItem) }
|
39
|
+
let(:content_item_save_expectations) do
|
40
|
+
lambda {
|
41
|
+
content_item.should_receive(:body=).with('bar')
|
42
|
+
content_item.should_receive(:save).and_return(true)
|
43
|
+
boombera = Boombera.new('boombera_test')
|
44
|
+
boombera.put('/foo', 'bar').should == true
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
context "to an existing path" do
|
49
|
+
it 'updates and saves the existing content item' do
|
50
|
+
Boombera::ContentItem.should_receive(:get).with('/foo', db).and_return(content_item)
|
51
|
+
content_item_save_expectations.call
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "to a new path" do
|
56
|
+
it 'creates and saves the existing content item' do
|
57
|
+
Boombera::ContentItem.stub!(:get => nil)
|
58
|
+
Boombera::ContentItem.should_receive(:new) \
|
59
|
+
.with(:path => '/foo', :database => db) \
|
60
|
+
.and_return(content_item)
|
61
|
+
content_item_save_expectations.call
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#get' do
|
67
|
+
it 'gets the content item at the specified path from the current database' do
|
68
|
+
db.as_null_object
|
69
|
+
Boombera::ContentItem.should_receive(:get).with('/foo', db)
|
70
|
+
boombera = Boombera.new('boombera_test')
|
71
|
+
boombera.get('/foo')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '.install_design_doc!' do
|
76
|
+
context 'when the design doc does not yet exist' do
|
77
|
+
it 'creates the design doc on the specified database' do
|
78
|
+
CouchRest.should_receive(:database!) \
|
79
|
+
.with('boombera_test') \
|
80
|
+
.and_return(db)
|
81
|
+
db.should_receive(:documents) \
|
82
|
+
.with(:key => '_design/boombera') \
|
83
|
+
.and_return({'rows' => []})
|
84
|
+
db.should_receive(:save_doc).with(Boombera.design_doc)
|
85
|
+
Boombera.install_design_doc!('boombera_test')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when the design doc already exists' do
|
90
|
+
it 'updates the design doc on the specified database' do
|
91
|
+
CouchRest.should_receive(:database!) \
|
92
|
+
.with('boombera_test') \
|
93
|
+
.and_return(db)
|
94
|
+
db.should_receive(:documents) \
|
95
|
+
.with(:key => '_design/boombera') \
|
96
|
+
.and_return({'rows' => [{'value' => {'rev' => '123'}}]})
|
97
|
+
db.should_receive(:save_doc).with(Boombera.design_doc.merge('_rev' => '123'))
|
98
|
+
Boombera.install_design_doc!('boombera_test')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# This is set up as a seperate describe block, because we obviously can't stub
|
105
|
+
# out .version and .database_version when those are the methods being tested.
|
106
|
+
describe Boombera do
|
107
|
+
describe '.version' do
|
108
|
+
it 'returns the current version as specified in the VERSION file' do
|
109
|
+
File.should_receive(:read) \
|
110
|
+
.with(File.expand_path(File.join(File.dirname(__FILE__), '..', '..',
|
111
|
+
'VERSION'))) \
|
112
|
+
.and_return('1.2.3')
|
113
|
+
Boombera.version.should == '1.2.3'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '.database_version' do
|
118
|
+
let(:db) { stub(CouchRest::Database) }
|
119
|
+
|
120
|
+
it 'returns the version of Boombera that the database expects to be working with' do
|
121
|
+
db.should_receive(:get).with('_design/boombera') \
|
122
|
+
.and_return({'gem_version' => '1.2.3'})
|
123
|
+
Boombera.database_version(db).should == '1.2.3'
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'returns nil if no version is specified in the database' do
|
127
|
+
db.stub!(:get).and_raise(RestClient::ResourceNotFound)
|
128
|
+
Boombera.database_version(db).should be_nil
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: boombera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Wilger
|
@@ -10,12 +10,23 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-05-30 00:00:00 -07:00
|
14
|
+
default_executable: boombera
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: couchrest
|
18
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.2
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
19
30
|
none: false
|
20
31
|
requirements:
|
21
32
|
- - ~>
|
@@ -23,10 +34,10 @@ dependencies:
|
|
23
34
|
version: 2.3.0
|
24
35
|
type: :development
|
25
36
|
prerelease: false
|
26
|
-
version_requirements: *
|
37
|
+
version_requirements: *id002
|
27
38
|
- !ruby/object:Gem::Dependency
|
28
39
|
name: bundler
|
29
|
-
requirement: &
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
30
41
|
none: false
|
31
42
|
requirements:
|
32
43
|
- - ~>
|
@@ -34,10 +45,10 @@ dependencies:
|
|
34
45
|
version: 1.0.0
|
35
46
|
type: :development
|
36
47
|
prerelease: false
|
37
|
-
version_requirements: *
|
48
|
+
version_requirements: *id003
|
38
49
|
- !ruby/object:Gem::Dependency
|
39
50
|
name: jeweler
|
40
|
-
requirement: &
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
41
52
|
none: false
|
42
53
|
requirements:
|
43
54
|
- - ">="
|
@@ -45,10 +56,10 @@ dependencies:
|
|
45
56
|
version: "0"
|
46
57
|
type: :development
|
47
58
|
prerelease: false
|
48
|
-
version_requirements: *
|
59
|
+
version_requirements: *id004
|
49
60
|
- !ruby/object:Gem::Dependency
|
50
61
|
name: rcov
|
51
|
-
requirement: &
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
52
63
|
none: false
|
53
64
|
requirements:
|
54
65
|
- - ">="
|
@@ -56,10 +67,10 @@ dependencies:
|
|
56
67
|
version: "0"
|
57
68
|
type: :development
|
58
69
|
prerelease: false
|
59
|
-
version_requirements: *
|
70
|
+
version_requirements: *id005
|
60
71
|
- !ruby/object:Gem::Dependency
|
61
72
|
name: reek
|
62
|
-
requirement: &
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
63
74
|
none: false
|
64
75
|
requirements:
|
65
76
|
- - ~>
|
@@ -67,10 +78,10 @@ dependencies:
|
|
67
78
|
version: 1.2.8
|
68
79
|
type: :development
|
69
80
|
prerelease: false
|
70
|
-
version_requirements: *
|
81
|
+
version_requirements: *id006
|
71
82
|
- !ruby/object:Gem::Dependency
|
72
83
|
name: rdoc
|
73
|
-
requirement: &
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
74
85
|
none: false
|
75
86
|
requirements:
|
76
87
|
- - ~>
|
@@ -78,17 +89,51 @@ dependencies:
|
|
78
89
|
version: 3.6.1
|
79
90
|
type: :development
|
80
91
|
prerelease: false
|
81
|
-
version_requirements: *
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: autotest
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ~>
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 4.4.6
|
101
|
+
type: :development
|
102
|
+
prerelease: false
|
103
|
+
version_requirements: *id008
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: autotest-growl
|
106
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 0.2.9
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: *id009
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: autotest-fsevent
|
117
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ~>
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.2.5
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *id010
|
82
126
|
description: CouchDB-backed content repository for multi-tenant, multi-stage applications
|
83
127
|
email: johnwilger@gmail.com
|
84
|
-
executables:
|
85
|
-
|
128
|
+
executables:
|
129
|
+
- boombera
|
86
130
|
extensions: []
|
87
131
|
|
88
132
|
extra_rdoc_files:
|
89
133
|
- LICENSE.txt
|
90
134
|
- README.rdoc
|
91
135
|
files:
|
136
|
+
- .autotest
|
92
137
|
- .document
|
93
138
|
- .rspec
|
94
139
|
- .rvmrc
|
@@ -98,8 +143,13 @@ files:
|
|
98
143
|
- README.rdoc
|
99
144
|
- Rakefile
|
100
145
|
- VERSION
|
146
|
+
- bin/boombera
|
101
147
|
- boombera.gemspec
|
102
148
|
- lib/boombera.rb
|
149
|
+
- lib/boombera/content_item.rb
|
150
|
+
- spec/bin/boombera_spec.rb
|
151
|
+
- spec/lib/boombera/content_item_spec.rb
|
152
|
+
- spec/lib/boombera_spec.rb
|
103
153
|
- spec/spec_helper.rb
|
104
154
|
has_rdoc: true
|
105
155
|
homepage: http://github.com/jwilger/boombera
|
@@ -115,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
165
|
requirements:
|
116
166
|
- - ">="
|
117
167
|
- !ruby/object:Gem::Version
|
118
|
-
hash:
|
168
|
+
hash: -1122201151572776858
|
119
169
|
segments:
|
120
170
|
- 0
|
121
171
|
version: "0"
|