Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
Documentation and random cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewtodd committed Jul 1, 2009
1 parent c15e540 commit 1441442
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
31 changes: 30 additions & 1 deletion README.rdoc
Expand Up @@ -10,7 +10,36 @@ Say you'd like to run chef-server on a host that doesn't support Erlang. What do

http://github.com/matthewtodd/doily

== The Obvious Part

Of course, mimicking CouchDB with a Rails app disregards pretty much every huge scaling problem CouchDB was designed to solve. So, this project is merely a stopgap measure for me and not any attempt to try to be awesome. Well, maybe just a little awesome.

== Alternatives

* http://hosting.couch.io/
* others?
* others?

== Use it!

I happen to be deploying to Heroku. Here's how you would do that:

git clone git://github.com/matthewtodd/hideabed.git
cd hideabed
heroku create
heroku config:add HIDEABED_API_KEY=...
heroku config:add HIDEABED_SESSION_SECRET=...
heroku addons:add piggyback_ssl
git push heroku master
heroku rake db:migrate

And then, assuming your HIDEABED_API_KEY is "bob" and your app is prancing-igloo-37, you'd do something like this to test:

curl https://bob:X@prancing-igloo-37.heroku.com/

If you happen to see "curl: (1) Protocol https not supported or disabled in libcurl", then perhaps you got curl by installing git-core via MacPorts. Not to worry:

sudo port install curl +ssl

== Contribute

Like I say, *barely* enough CouchDB. (Check out the Cucumber features for all that the code actually promises to do.) So, if you'd like to take this somewhere, feel free!
25 changes: 6 additions & 19 deletions app/controllers/application_controller.rb
@@ -1,31 +1,18 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details

# Scrub sensitive parameters from your log
# filter_parameter_logging :password

before_filter :ssl_required, :unless => :development?
before_filter :authentication_required

private

def development?
Rails.env.development?
end

def ssl_required
unless request.ssl?
render :json => '{"error":"SSL is required."}', :status => :bad_request
end
render(:json => { :error => 'SSL is required.' }, :status => :bad_request) unless request.ssl?
end

def authentication_required
authenticate_or_request_with_http_basic do |username, password|
username == HIDEABED_API_KEY
end
authenticate_or_request_with_http_basic { |api_key, _| api_key == HIDEABED_API_KEY }
end

def development?
Rails.env.development?
end
end
2 changes: 1 addition & 1 deletion app/controllers/properties_controller.rb
Expand Up @@ -2,4 +2,4 @@ class PropertiesController < ApplicationController
def index
render :json => { :version => '0.9' }
end
end
end
6 changes: 1 addition & 5 deletions features/views.feature
Expand Up @@ -8,15 +8,11 @@ Feature: Views
| name |
| petstore |
And these documents
| database | name | data |
| database | name | data |
| petstore | ab12cd34 | { 'document_type' => 'dog', 'name' => 'rover' } |
| petstore | ef56ab34 | { 'document_type' => 'cat', 'name' => 'fluffy' } |
| petstore | _design/dogs | { 'views' => { 'all_name' => { 'map' => 'function(doc) { if (doc.document_type == "dog") { emit(doc.name, doc); } }' }}} |

Scenario: Showing a View
When I get /petstore/_design/dogs/_view/all_name
Then I should see json '{"total_rows":1, "offset":0, "rows":[{"id":"ab12cd34", "key":"rover", "value":{"document_type":"dog", "name":"rover"}}]}'

Scenario: Showing a non-existent View

Scenario: Showing a View that includes a Reduce clause

0 comments on commit 1441442

Please sign in to comment.