Use config_file, include backend module depending on config (closes #8)
This commit is contained in:
		
							parent
							
								
									0c586b3193
								
							
						
					
					
						commit
						1be4020991
					
				
							
								
								
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							@ -2,8 +2,8 @@ source "http://rubygems.org"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
gem "sinatra"
 | 
					gem "sinatra"
 | 
				
			||||||
gem "sinatra-contrib"
 | 
					gem "sinatra-contrib"
 | 
				
			||||||
 | 
					gem "activesupport"
 | 
				
			||||||
gem "riak-client"
 | 
					gem "riak-client"
 | 
				
			||||||
gem "airbrake"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
group :test do
 | 
					group :test do
 | 
				
			||||||
  gem 'rake'
 | 
					  gem 'rake'
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										31
									
								
								Gemfile.lock
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								Gemfile.lock
									
									
									
									
									
								
							@ -1,16 +1,13 @@
 | 
				
			|||||||
GEM
 | 
					GEM
 | 
				
			||||||
  remote: http://rubygems.org/
 | 
					  remote: http://rubygems.org/
 | 
				
			||||||
  specs:
 | 
					  specs:
 | 
				
			||||||
    activesupport (3.2.2)
 | 
					    activesupport (3.2.13)
 | 
				
			||||||
      i18n (~> 0.6)
 | 
					      i18n (= 0.6.1)
 | 
				
			||||||
      multi_json (~> 1.0)
 | 
					      multi_json (~> 1.0)
 | 
				
			||||||
    airbrake (3.0.9)
 | 
					    backports (3.3.0)
 | 
				
			||||||
      activesupport
 | 
					 | 
				
			||||||
      builder
 | 
					 | 
				
			||||||
    backports (2.3.0)
 | 
					 | 
				
			||||||
    beefcake (0.3.7)
 | 
					    beefcake (0.3.7)
 | 
				
			||||||
    builder (3.1.3)
 | 
					    builder (3.1.3)
 | 
				
			||||||
    eventmachine (0.12.10)
 | 
					    eventmachine (1.0.3)
 | 
				
			||||||
    i18n (0.6.1)
 | 
					    i18n (0.6.1)
 | 
				
			||||||
    kgio (2.7.4)
 | 
					    kgio (2.7.4)
 | 
				
			||||||
    m (1.2.1)
 | 
					    m (1.2.1)
 | 
				
			||||||
@ -22,9 +19,9 @@ GEM
 | 
				
			|||||||
    purdytest (1.0.0)
 | 
					    purdytest (1.0.0)
 | 
				
			||||||
      minitest (~> 2.2)
 | 
					      minitest (~> 2.2)
 | 
				
			||||||
    rack (1.5.2)
 | 
					    rack (1.5.2)
 | 
				
			||||||
    rack-protection (1.1.4)
 | 
					    rack-protection (1.5.0)
 | 
				
			||||||
      rack
 | 
					      rack
 | 
				
			||||||
    rack-test (0.6.1)
 | 
					    rack-test (0.6.2)
 | 
				
			||||||
      rack (>= 1.0)
 | 
					      rack (>= 1.0)
 | 
				
			||||||
    raindrops (0.10.0)
 | 
					    raindrops (0.10.0)
 | 
				
			||||||
    rake (0.9.2.2)
 | 
					    rake (0.9.2.2)
 | 
				
			||||||
@ -33,18 +30,18 @@ GEM
 | 
				
			|||||||
      builder (>= 2.1.2)
 | 
					      builder (>= 2.1.2)
 | 
				
			||||||
      i18n (>= 0.4.0)
 | 
					      i18n (>= 0.4.0)
 | 
				
			||||||
      multi_json (~> 1.0)
 | 
					      multi_json (~> 1.0)
 | 
				
			||||||
    sinatra (1.3.1)
 | 
					    sinatra (1.4.2)
 | 
				
			||||||
      rack (~> 1.3, >= 1.3.4)
 | 
					      rack (~> 1.5, >= 1.5.2)
 | 
				
			||||||
      rack-protection (~> 1.1, >= 1.1.2)
 | 
					      rack-protection (~> 1.4)
 | 
				
			||||||
      tilt (~> 1.3, >= 1.3.3)
 | 
					      tilt (~> 1.3, >= 1.3.4)
 | 
				
			||||||
    sinatra-contrib (1.3.1)
 | 
					    sinatra-contrib (1.4.0)
 | 
				
			||||||
      backports (>= 2.0)
 | 
					      backports (>= 2.0)
 | 
				
			||||||
      eventmachine
 | 
					      eventmachine
 | 
				
			||||||
      rack-protection
 | 
					      rack-protection
 | 
				
			||||||
      rack-test
 | 
					      rack-test
 | 
				
			||||||
      sinatra (~> 1.3.0)
 | 
					      sinatra (~> 1.4.2)
 | 
				
			||||||
      tilt (~> 1.3)
 | 
					      tilt (~> 1.3)
 | 
				
			||||||
    tilt (1.3.3)
 | 
					    tilt (1.3.7)
 | 
				
			||||||
    unicorn (4.3.1)
 | 
					    unicorn (4.3.1)
 | 
				
			||||||
      kgio (~> 2.6)
 | 
					      kgio (~> 2.6)
 | 
				
			||||||
      rack
 | 
					      rack
 | 
				
			||||||
@ -54,7 +51,7 @@ PLATFORMS
 | 
				
			|||||||
  ruby
 | 
					  ruby
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEPENDENCIES
 | 
					DEPENDENCIES
 | 
				
			||||||
  airbrake
 | 
					  activesupport
 | 
				
			||||||
  m
 | 
					  m
 | 
				
			||||||
  purdytest
 | 
					  purdytest
 | 
				
			||||||
  rake
 | 
					  rake
 | 
				
			||||||
 | 
				
			|||||||
@ -1,23 +1,26 @@
 | 
				
			|||||||
defaults: &defaults
 | 
					development: &defaults
 | 
				
			||||||
  riak:
 | 
					  riak:
 | 
				
			||||||
    host: localhost
 | 
					    host: localhost
 | 
				
			||||||
    http_port: 8098
 | 
					    http_port: 8098
 | 
				
			||||||
  buckets:
 | 
					    buckets:
 | 
				
			||||||
    data: "user_data"
 | 
					      data: rs_data
 | 
				
			||||||
    directories: "rs_directories"
 | 
					      directories: rs_directories
 | 
				
			||||||
    binaries: "rs_binaries"
 | 
					      binaries: rs_binaries
 | 
				
			||||||
    authorizations: "authorizations"
 | 
					      authorizations: rs_authorizations
 | 
				
			||||||
 | 
					      opslog: rs_opslog
 | 
				
			||||||
development:
 | 
					 | 
				
			||||||
  <<: *defaults
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
test:
 | 
					test:
 | 
				
			||||||
  <<: *defaults
 | 
					  <<: *defaults
 | 
				
			||||||
  buckets:
 | 
					  riak:
 | 
				
			||||||
    data: "user_data_test"
 | 
					    buckets:
 | 
				
			||||||
    directories: "rs_directories_test"
 | 
					      data: rs_data_test
 | 
				
			||||||
    binaries: "rs_binaries_test"
 | 
					      directories: rs_directories_test
 | 
				
			||||||
    authorizations: "authorizations_test"
 | 
					      binaries: rs_binaries_test
 | 
				
			||||||
 | 
					      authorizations: rs_authorizations_test
 | 
				
			||||||
 | 
					      opslog: rs_opslog_test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					staging:
 | 
				
			||||||
 | 
					  <<: *defaults
 | 
				
			||||||
 | 
					
 | 
				
			||||||
production:
 | 
					production:
 | 
				
			||||||
  <<: *defaults
 | 
					  <<: *defaults
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,8 @@
 | 
				
			|||||||
require "riak"
 | 
					require "riak"
 | 
				
			||||||
require "json"
 | 
					require "json"
 | 
				
			||||||
require "cgi"
 | 
					require "cgi"
 | 
				
			||||||
 | 
					require "active_support/core_ext/time/conversions"
 | 
				
			||||||
 | 
					require "active_support/core_ext/numeric/time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module RemoteStorage
 | 
					module RemoteStorage
 | 
				
			||||||
  module Riak
 | 
					  module Riak
 | 
				
			||||||
@ -8,23 +10,24 @@ module RemoteStorage
 | 
				
			|||||||
    ::Riak.url_decoding = true
 | 
					    ::Riak.url_decoding = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def client
 | 
					    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
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def data_bucket
 | 
					    def data_bucket
 | 
				
			||||||
      @data_bucket ||= client.bucket(LiquorCabinet.config['buckets']['data'])
 | 
					      @data_bucket ||= client.bucket(settings.riak['buckets']['data'])
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def directory_bucket
 | 
					    def directory_bucket
 | 
				
			||||||
      @directory_bucket ||= client.bucket(LiquorCabinet.config['buckets']['directories'])
 | 
					      @directory_bucket ||= client.bucket(settings.riak['buckets']['directories'])
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def auth_bucket
 | 
					    def auth_bucket
 | 
				
			||||||
      @auth_bucket ||= client.bucket(LiquorCabinet.config['buckets']['authorizations'])
 | 
					      @auth_bucket ||= client.bucket(settings.riak['buckets']['authorizations'])
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def binary_bucket
 | 
					    def binary_bucket
 | 
				
			||||||
      @binary_bucket ||= client.bucket(LiquorCabinet.config['buckets']['binaries'])
 | 
					      @binary_bucket ||= client.bucket(settings.riak['buckets']['binaries'])
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def authorize_request(user, directory, token, listing=false)
 | 
					    def authorize_request(user, directory, token, listing=false)
 | 
				
			||||||
@ -146,7 +149,7 @@ module RemoteStorage
 | 
				
			|||||||
      permission = authorizations[""]
 | 
					      permission = authorizations[""]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      authorizations.each do |key, value|
 | 
					      authorizations.each do |key, value|
 | 
				
			||||||
        if directory.match /^(public\/)?#{key}(\/|$)/
 | 
					        if directory.match(/^(public\/)?#{key}(\/|$)/)
 | 
				
			||||||
          if permission.nil? || permission == "r"
 | 
					          if permission.nil? || permission == "r"
 | 
				
			||||||
            permission = value
 | 
					            permission = value
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
@ -253,7 +256,7 @@ module RemoteStorage
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def update_directory_object(user, directory, timestamp)
 | 
					    def update_directory_object(user, directory, timestamp)
 | 
				
			||||||
      if directory.match /\//
 | 
					      if directory.match(/\//)
 | 
				
			||||||
        parent_directory = directory[0..directory.rindex("/")-1]
 | 
					        parent_directory = directory[0..directory.rindex("/")-1]
 | 
				
			||||||
      elsif directory != ""
 | 
					      elsif directory != ""
 | 
				
			||||||
        parent_directory = "/"
 | 
					        parent_directory = "/"
 | 
				
			||||||
 | 
				
			|||||||
@ -2,39 +2,42 @@ $LOAD_PATH << File.join(File.expand_path(File.dirname(__FILE__)), 'lib')
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
require "json"
 | 
					require "json"
 | 
				
			||||||
require "sinatra/base"
 | 
					require "sinatra/base"
 | 
				
			||||||
 | 
					require 'sinatra/config_file'
 | 
				
			||||||
require "sinatra/reloader"
 | 
					require "sinatra/reloader"
 | 
				
			||||||
require "remote_storage/riak"
 | 
					require "remote_storage/riak"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class LiquorCabinet < Sinatra::Base
 | 
					class LiquorCabinet < Sinatra::Base
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  include RemoteStorage::Riak
 | 
					  #
 | 
				
			||||||
 | 
					  # Configuration
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def self.config=(config)
 | 
					  configure do
 | 
				
			||||||
    @config = config
 | 
					    disable :protection
 | 
				
			||||||
    configure_airbrake
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def self.config
 | 
					    register Sinatra::ConfigFile
 | 
				
			||||||
    return @config if @config
 | 
					    set :environments, %w{development test production staging}
 | 
				
			||||||
    config = File.read(File.expand_path('config.yml', File.dirname(__FILE__)))
 | 
					    config_file 'config.yml'
 | 
				
			||||||
    self.config = YAML.load(config)[ENV['RACK_ENV']]
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  configure :development do
 | 
					  configure :development do
 | 
				
			||||||
    register Sinatra::Reloader
 | 
					    register Sinatra::Reloader
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  configure :development, :staging, :production do
 | 
				
			||||||
    enable :logging
 | 
					    enable :logging
 | 
				
			||||||
    disable :protection
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  configure :production do
 | 
					  if settings.riak
 | 
				
			||||||
    disable :logging
 | 
					    include RemoteStorage::Riak
 | 
				
			||||||
    disable :protection
 | 
					  # elsif settings.redis
 | 
				
			||||||
 | 
					  #  include RemoteStorage::Redis
 | 
				
			||||||
 | 
					  # end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  configure :staging do
 | 
					  #
 | 
				
			||||||
    disable :logging
 | 
					  # Cabinet doors
 | 
				
			||||||
    disable :protection
 | 
					  #
 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ["/:user/*/:key", "/:user/:key", "/:user/*/", "/:user/"].each do |path|
 | 
					  ["/:user/*/:key", "/:user/:key", "/:user/*/", "/:user/"].each do |path|
 | 
				
			||||||
    before path do
 | 
					    before path do
 | 
				
			||||||
@ -91,19 +94,4 @@ class LiquorCabinet < Sinatra::Base
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  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
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,6 @@ require_relative "spec_helper"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
describe "Directories" do
 | 
					describe "Directories" do
 | 
				
			||||||
  include Rack::Test::Methods
 | 
					  include Rack::Test::Methods
 | 
				
			||||||
  include RemoteStorage::Riak
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before do
 | 
					  before do
 | 
				
			||||||
    purge_all_buckets
 | 
					    purge_all_buckets
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,6 @@ require_relative "spec_helper"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
describe "Permissions" do
 | 
					describe "Permissions" do
 | 
				
			||||||
  include Rack::Test::Methods
 | 
					  include Rack::Test::Methods
 | 
				
			||||||
  include RemoteStorage::Riak
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before do
 | 
					  before do
 | 
				
			||||||
    purge_all_buckets
 | 
					    purge_all_buckets
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,6 @@ require_relative "spec_helper"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
describe "App with Riak backend" do
 | 
					describe "App with Riak backend" do
 | 
				
			||||||
  include Rack::Test::Methods
 | 
					  include Rack::Test::Methods
 | 
				
			||||||
  include RemoteStorage::Riak
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before do
 | 
					  before do
 | 
				
			||||||
    purge_all_buckets
 | 
					    purge_all_buckets
 | 
				
			||||||
@ -109,6 +108,11 @@ describe "App with Riak backend" do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
          indexes["directory_bin"].must_include "documents"
 | 
					          indexes["directory_bin"].must_include "documents"
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # it "logs the operation" do
 | 
				
			||||||
 | 
					        #   logs = storage_client.get_index("rs_opslog", "user_id_bin", "jimmy")
 | 
				
			||||||
 | 
					        #   logs.count.must_equal 1
 | 
				
			||||||
 | 
					        # end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe "with explicit content type" do
 | 
					      describe "with explicit content type" do
 | 
				
			||||||
 | 
				
			|||||||
@ -8,45 +8,13 @@ require 'rack/test'
 | 
				
			|||||||
require 'purdytest'
 | 
					require 'purdytest'
 | 
				
			||||||
require 'riak'
 | 
					require 'riak'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set :environment, :test
 | 
					 | 
				
			||||||
ENV["RACK_ENV"] = "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
 | 
					def app
 | 
				
			||||||
  LiquorCabinet
 | 
					  LiquorCabinet
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def storage_client
 | 
					app.set :environment, :test
 | 
				
			||||||
  @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 purge_all_buckets
 | 
					 | 
				
			||||||
  [data_bucket, directory_bucket, auth_bucket, binary_bucket].each do |bucket|
 | 
					 | 
				
			||||||
    bucket.keys.each {|key| bucket.delete key}
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def wait_a_second
 | 
					def wait_a_second
 | 
				
			||||||
  now = Time.now.to_i
 | 
					  now = Time.now.to_i
 | 
				
			||||||
@ -60,3 +28,34 @@ def write_last_response_to_file(filename = "last_response.html")
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
alias context describe
 | 
					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 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