Fix merge conflict
This commit is contained in:
commit
c78be51e8f
2
Gemfile
2
Gemfile
@ -2,8 +2,8 @@ source "http://rubygems.org"
|
||||
|
||||
gem "sinatra"
|
||||
gem "sinatra-contrib"
|
||||
gem "activesupport"
|
||||
gem "riak-client"
|
||||
gem "airbrake"
|
||||
|
||||
group :test do
|
||||
gem 'rake'
|
||||
|
31
Gemfile.lock
31
Gemfile.lock
@ -1,16 +1,13 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
activesupport (3.2.2)
|
||||
i18n (~> 0.6)
|
||||
activesupport (3.2.13)
|
||||
i18n (= 0.6.1)
|
||||
multi_json (~> 1.0)
|
||||
airbrake (3.0.9)
|
||||
activesupport
|
||||
builder
|
||||
backports (2.3.0)
|
||||
backports (3.3.0)
|
||||
beefcake (0.3.7)
|
||||
builder (3.1.3)
|
||||
eventmachine (0.12.10)
|
||||
eventmachine (1.0.3)
|
||||
i18n (0.6.1)
|
||||
kgio (2.7.4)
|
||||
m (1.2.1)
|
||||
@ -22,9 +19,9 @@ GEM
|
||||
purdytest (1.0.0)
|
||||
minitest (~> 2.2)
|
||||
rack (1.5.2)
|
||||
rack-protection (1.1.4)
|
||||
rack-protection (1.5.0)
|
||||
rack
|
||||
rack-test (0.6.1)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
raindrops (0.10.0)
|
||||
rake (0.9.2.2)
|
||||
@ -33,18 +30,18 @@ GEM
|
||||
builder (>= 2.1.2)
|
||||
i18n (>= 0.4.0)
|
||||
multi_json (~> 1.0)
|
||||
sinatra (1.3.1)
|
||||
rack (~> 1.3, >= 1.3.4)
|
||||
rack-protection (~> 1.1, >= 1.1.2)
|
||||
tilt (~> 1.3, >= 1.3.3)
|
||||
sinatra-contrib (1.3.1)
|
||||
sinatra (1.4.2)
|
||||
rack (~> 1.5, >= 1.5.2)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (~> 1.3, >= 1.3.4)
|
||||
sinatra-contrib (1.4.0)
|
||||
backports (>= 2.0)
|
||||
eventmachine
|
||||
rack-protection
|
||||
rack-test
|
||||
sinatra (~> 1.3.0)
|
||||
sinatra (~> 1.4.2)
|
||||
tilt (~> 1.3)
|
||||
tilt (1.3.3)
|
||||
tilt (1.3.7)
|
||||
unicorn (4.3.1)
|
||||
kgio (~> 2.6)
|
||||
rack
|
||||
@ -54,7 +51,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
airbrake
|
||||
activesupport
|
||||
m
|
||||
purdytest
|
||||
rake
|
||||
|
@ -1,25 +1,26 @@
|
||||
defaults: &defaults
|
||||
development: &defaults
|
||||
riak:
|
||||
host: localhost
|
||||
http_port: 8098
|
||||
buckets:
|
||||
data: "user_data"
|
||||
directories: "rs_directories"
|
||||
binaries: "rs_binaries"
|
||||
authorizations: "authorizations"
|
||||
info: "rs_info"
|
||||
|
||||
development:
|
||||
<<: *defaults
|
||||
buckets:
|
||||
data: rs_data
|
||||
directories: rs_directories
|
||||
binaries: rs_binaries
|
||||
authorizations: rs_authorizations
|
||||
opslog: rs_opslog
|
||||
|
||||
test:
|
||||
<<: *defaults
|
||||
buckets:
|
||||
data: "user_data_test"
|
||||
directories: "rs_directories_test"
|
||||
binaries: "rs_binaries_test"
|
||||
authorizations: "authorizations_test"
|
||||
info: "rs_info_test"
|
||||
riak:
|
||||
buckets:
|
||||
data: rs_data_test
|
||||
directories: rs_directories_test
|
||||
binaries: rs_binaries_test
|
||||
authorizations: rs_authorizations_test
|
||||
opslog: rs_opslog_test
|
||||
|
||||
staging:
|
||||
<<: *defaults
|
||||
|
||||
production:
|
||||
<<: *defaults
|
||||
|
@ -1,6 +1,8 @@
|
||||
require "riak"
|
||||
require "json"
|
||||
require "cgi"
|
||||
require "active_support/core_ext/time/conversions"
|
||||
require "active_support/core_ext/numeric/time"
|
||||
|
||||
module RemoteStorage
|
||||
module Riak
|
||||
@ -8,23 +10,24 @@ module RemoteStorage
|
||||
::Riak.url_decoding = true
|
||||
|
||||
def client
|
||||
@client ||= ::Riak::Client.new(LiquorCabinet.config['riak'].symbolize_keys)
|
||||
@client ||= ::Riak::Client.new(:host => settings.riak['host'],
|
||||
:http_port => settings.riak['http_port'])
|
||||
end
|
||||
|
||||
def data_bucket
|
||||
@data_bucket ||= client.bucket(LiquorCabinet.config['buckets']['data'])
|
||||
@data_bucket ||= client.bucket(settings.riak['buckets']['data'])
|
||||
end
|
||||
|
||||
def directory_bucket
|
||||
@directory_bucket ||= client.bucket(LiquorCabinet.config['buckets']['directories'])
|
||||
@directory_bucket ||= client.bucket(settings.riak['buckets']['directories'])
|
||||
end
|
||||
|
||||
def auth_bucket
|
||||
@auth_bucket ||= client.bucket(LiquorCabinet.config['buckets']['authorizations'])
|
||||
@auth_bucket ||= client.bucket(settings.riak['buckets']['authorizations'])
|
||||
end
|
||||
|
||||
def binary_bucket
|
||||
@binary_bucket ||= client.bucket(LiquorCabinet.config['buckets']['binaries'])
|
||||
@binary_bucket ||= client.bucket(settings.riak['buckets']['binaries'])
|
||||
end
|
||||
|
||||
def info_bucket
|
||||
|
@ -2,39 +2,42 @@ $LOAD_PATH << File.join(File.expand_path(File.dirname(__FILE__)), 'lib')
|
||||
|
||||
require "json"
|
||||
require "sinatra/base"
|
||||
require 'sinatra/config_file'
|
||||
require "sinatra/reloader"
|
||||
require "remote_storage/riak"
|
||||
|
||||
class LiquorCabinet < Sinatra::Base
|
||||
|
||||
include RemoteStorage::Riak
|
||||
#
|
||||
# Configuration
|
||||
#
|
||||
|
||||
def self.config=(config)
|
||||
@config = config
|
||||
configure_airbrake
|
||||
end
|
||||
configure do
|
||||
disable :protection
|
||||
|
||||
def self.config
|
||||
return @config if @config
|
||||
config = File.read(File.expand_path('config.yml', File.dirname(__FILE__)))
|
||||
self.config = YAML.load(config)[ENV['RACK_ENV']]
|
||||
register Sinatra::ConfigFile
|
||||
set :environments, %w{development test production staging}
|
||||
config_file 'config.yml'
|
||||
end
|
||||
|
||||
configure :development do
|
||||
register Sinatra::Reloader
|
||||
end
|
||||
|
||||
configure :development, :staging, :production do
|
||||
enable :logging
|
||||
disable :protection
|
||||
end
|
||||
|
||||
configure :production do
|
||||
disable :logging
|
||||
disable :protection
|
||||
if settings.riak
|
||||
include RemoteStorage::Riak
|
||||
# elsif settings.redis
|
||||
# include RemoteStorage::Redis
|
||||
# end
|
||||
end
|
||||
|
||||
configure :staging do
|
||||
disable :logging
|
||||
disable :protection
|
||||
end
|
||||
#
|
||||
# Cabinet doors
|
||||
#
|
||||
|
||||
["/:user/*/:key", "/:user/:key", "/:user/*/", "/:user/"].each do |path|
|
||||
before path do
|
||||
@ -91,19 +94,4 @@ class LiquorCabinet < Sinatra::Base
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.configure_airbrake
|
||||
if @config['airbrake'] && @config['airbrake']['api_key']
|
||||
require "airbrake"
|
||||
|
||||
Airbrake.configure do |airbrake|
|
||||
airbrake.api_key = @config['airbrake']['api_key']
|
||||
end
|
||||
|
||||
use Airbrake::Rack
|
||||
enable :raise_errors
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -2,7 +2,6 @@ require_relative "spec_helper"
|
||||
|
||||
describe "Directories" do
|
||||
include Rack::Test::Methods
|
||||
include RemoteStorage::Riak
|
||||
|
||||
before do
|
||||
purge_all_buckets
|
||||
|
@ -2,7 +2,6 @@ require_relative "spec_helper"
|
||||
|
||||
describe "Permissions" do
|
||||
include Rack::Test::Methods
|
||||
include RemoteStorage::Riak
|
||||
|
||||
before do
|
||||
purge_all_buckets
|
||||
|
@ -11,7 +11,6 @@ end
|
||||
|
||||
describe "App with Riak backend" do
|
||||
include Rack::Test::Methods
|
||||
include RemoteStorage::Riak
|
||||
|
||||
before do
|
||||
purge_all_buckets
|
||||
@ -126,6 +125,11 @@ describe "App with Riak backend" do
|
||||
|
||||
indexes["directory_bin"].must_include "documents"
|
||||
end
|
||||
|
||||
# it "logs the operation" do
|
||||
# logs = storage_client.get_index("rs_opslog", "user_id_bin", "jimmy")
|
||||
# logs.count.must_equal 1
|
||||
# end
|
||||
end
|
||||
|
||||
describe "with explicit content type" do
|
||||
|
@ -8,49 +8,13 @@ require 'rack/test'
|
||||
require 'purdytest'
|
||||
require 'riak'
|
||||
|
||||
set :environment, :test
|
||||
ENV["RACK_ENV"] = "test"
|
||||
|
||||
config_file = File.read(File.expand_path('../config.yml', File.dirname(__FILE__)))
|
||||
config = YAML.load(config_file)[ENV['RACK_ENV']]
|
||||
set :riak_config, config['riak'].symbolize_keys
|
||||
set :bucket_config, config['buckets']
|
||||
|
||||
::Riak.disable_list_keys_warnings = true
|
||||
|
||||
def app
|
||||
LiquorCabinet
|
||||
end
|
||||
|
||||
def storage_client
|
||||
@storage_client ||= ::Riak::Client.new(settings.riak_config)
|
||||
end
|
||||
|
||||
def data_bucket
|
||||
@data_bucket ||= storage_client.bucket(settings.bucket_config['data'])
|
||||
end
|
||||
|
||||
def auth_bucket
|
||||
@auth_bucket ||= storage_client.bucket(settings.bucket_config['authorizations'])
|
||||
end
|
||||
|
||||
def directory_bucket
|
||||
@directory_bucket ||= storage_client.bucket(settings.bucket_config['directories'])
|
||||
end
|
||||
|
||||
def binary_bucket
|
||||
@binary_bucket ||= storage_client.bucket(settings.bucket_config['binaries'])
|
||||
end
|
||||
|
||||
def info_bucket
|
||||
@info_bucket ||= storage_client.bucket(settings.bucket_config['info'])
|
||||
end
|
||||
|
||||
def purge_all_buckets
|
||||
[data_bucket, directory_bucket, auth_bucket, binary_bucket, info_bucket].each do |bucket|
|
||||
bucket.keys.each {|key| bucket.delete key}
|
||||
end
|
||||
end
|
||||
app.set :environment, :test
|
||||
|
||||
def wait_a_second
|
||||
now = Time.now.to_i
|
||||
@ -64,3 +28,38 @@ def write_last_response_to_file(filename = "last_response.html")
|
||||
end
|
||||
|
||||
alias context describe
|
||||
|
||||
if app.settings.riak
|
||||
::Riak.disable_list_keys_warnings = true
|
||||
|
||||
def client
|
||||
@client ||= ::Riak::Client.new(:host => app.settings.riak['host'],
|
||||
:http_port => app.settings.riak['http_port'])
|
||||
end
|
||||
|
||||
def data_bucket
|
||||
@data_bucket ||= client.bucket(app.settings.riak['buckets']['data'])
|
||||
end
|
||||
|
||||
def auth_bucket
|
||||
@auth_bucket ||= client.bucket(app.settings.riak['buckets']['authorizations'])
|
||||
end
|
||||
|
||||
def directory_bucket
|
||||
@directory_bucket ||= client.bucket(app.settings.riak['buckets']['directories'])
|
||||
end
|
||||
|
||||
def binary_bucket
|
||||
@binary_bucket ||= client.bucket(app.settings.riak['buckets']['binaries'])
|
||||
end
|
||||
|
||||
def opslog_bucket
|
||||
@opslog_bucket ||= client.bucket(app.settings.riak['buckets']['opslog'])
|
||||
end
|
||||
|
||||
def purge_all_buckets
|
||||
[data_bucket, directory_bucket, auth_bucket, binary_bucket].each do |bucket|
|
||||
bucket.keys.each {|key| bucket.delete key}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user