Skip to content

Instantly share code, notes, and snippets.

View craigw's full-sized avatar
🦄

Craig R Webster craigw

🦄
View GitHub Profile
#! /usr/bin/env ruby
libs = []
libs << "irb/completion"
libs << File.dirname(__FILE__) + '/../config/boot.rb'
command_line = []
command_line << "irb"
command_line << libs.inject("") { |acc, lib| acc + %( -r "#{lib}") }
command_line << "--simple-prompt"
require 'rubygems'
require 'hpricot'
require 'net/http'
require File.dirname(__FILE__) + '/../vendor/gems/activecouch/init'
$: << File.dirname(__FILE__) + '/../app/models'
ActiveCouch::Base.class_eval do
set_database_name 'blog'
site 'http://localhost:5984/'
require File.dirname(__FILE__) + '/../../spec_helper'
describe "Stylesheet" do
stylesheet_root = File.expand_path(RAILS_ROOT + '/public')
stylesheets = Dir[File.join(stylesheet_root, "**", "*.css")]
stylesheets.each do |stylesheet|
describe stylesheet do
it "should not @import files that don't exist" do
// GET /blog/_view/articles/titles_by_created_at?startkey=[%222007-12-01T00:00:00Z%22]&endkey=[%222007-12-31T24:00:00Z%22]
{"total_rows":75,"offset":0,"rows":[
{"id":"showing-multiple-message-types-with-the-flash","key":["2007-12-15T20:14:02Z"],"value":"Showing multiple message types with the flash"},
{"id":"class-instance-and-singleton-methods","key":["2007-12-20T14:50:41Z"],"value":"Class, Instance and Singleton methods"}
]}
// GET /blog/_articles/titles_by_posted_at?key=["2007-12-20T14:50:41Z"]
{"total_rows":75,"offset":0,"rows":[
{"id":"class-instance-and-singleton-methods","key":["2007-12-20T20:50:41Z"],"value":"Class, Instance and Singleton methods"}
]}
// GET /blog/_articles/titles_by_posted_at
{
"total_rows":75,
"offset":0,
"rows":[
{"id":"showing-multiple-message-types-with-the-flash","key":["2007-12-15T20:14:02Z"],"value":"Showing multiple message types with the flash"},
{"id":"class-instance-and-singleton-methods","key":["2007-12-20T14:50:41Z"],"value":"Class, Instance and Singleton methods"},
// ... and so on ...
}
// Get all article titles ordered by posted date.
function(doc) {
if(doc.type == 'article') {
emit([doc.posted_at], doc.title);
}
}
{
"_id": "_design/articles",
"_rev": "28651884",
"language": "javascript",
"views": {
"all": {
"map": "function(doc) { if(doc.type == 'article') { emit(null, doc); } }"
},
"by_author_id": {
"map": "function(doc) { if(doc.type == 'article') { emit([doc.author_id], doc); } }"
{
"_id": "_design/articles",
"_rev": "42351258",
"language": "javascript",
"views": {
"titles": {
"map": "function(doc) { emit(null, { 'id': doc._id, 'title': doc.title }); }"
}
}
}
function(doc) {
if(doc.type == 'article') {
emit(null, { 'id': doc._id, 'title': doc.title });
}
}