repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/new_rails_defaults.rb | config/initializers/new_rails_defaults.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON s... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/factory_girl.rb | config/initializers/factory_girl.rb | # frozen_string_literal: true
require 'active_support/testing/time_helpers'
if defined? FactoryGirl
FactoryGirl::SyntaxRunner.send(:include, ActiveSupport::Testing::TimeHelpers)
end
| ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/wrap_parameters.rb | config/initializers/wrap_parameters.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format
# to an empty array.
ActiveSupport.on_load(:action_co... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/inflections.rb | config/initializers/inflections.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflect... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/simple_form_bootstrap.rb | config/initializers/simple_form_bootstrap.rb | # frozen_string_literal: true
require 'simple_form_extensions'
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'btn btn-default'
config.boolean_label_class = nil
config.wrappers :... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/kaminari_config.rb | config/initializers/kaminari_config.rb | # frozen_string_literal: true
Kaminari.configure do |config|
# config.default_per_page = 25
config.window = 2
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
end
| ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/rails_admin.rb | config/initializers/rails_admin.rb | # frozen_string_literal: true
RailsAdmin.config do |config|
### Popular gems integration
# inherit from application controller
config.parent_controller = 'ApplicationController'
## == Devise ==
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_us... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/setup_mail.rb | config/initializers/setup_mail.rb | # frozen_string_literal: true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
address: Rails.application.secrets.smtp_address,
port: Rails.application.secrets.smtp_port,
domain: Rails.application.secrets.smtp_domain,
enable_starttls_auto: true
}
# optional server authentic... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/simple_form.rb | config/initializers/simple_form.rb | # frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
# rubocop:disable Metrics/LineLength
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/cookies_serializer.rb | config/initializers/cookies_serializer.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :marshal
| ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/00_devise.rb | config/initializers/00_devise.rb | # frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render inv... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/assets.rb | config/initializers/assets.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.image... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/backtrace_silencers.rb | config/initializers/backtrace_silencers.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using
# but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers i... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/mime_types.rb | config/initializers/mime_types.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
| ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/initializers/secret_token.rb | config/initializers/secret_token.rb | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll ... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/deploy/staging.rb | config/deploy/staging.rb | # frozen_string_literal: true
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary server in each group
# is considered to be the first unless any hosts have the primary
# property set. Don't declare `role :all`, it's a meta role.
# role :app, %w{deploy@example.com}
# role :web... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/deploy/production.rb | config/deploy/production.rb | # frozen_string_literal: true
# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary server in each group
# is considered to be the first unless any hosts have the primary
# property set. Don't declare `role :all`, it's a meta role.
# role :app, %w{deploy@example.com}
# role :web... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/environments/test.rb | config/environments/test.rb | # frozen_string_literal: true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.applic... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/environments/development.rb | config/environments/development.rb | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those
# in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
YaleSTC/reservations | https://github.com/YaleSTC/reservations/blob/2d5f0b2511a50787d79023bb3bbd148160dc3cc2/config/environments/production.rb | config/environments/production.rb | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those
# in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memor... | ruby | MIT | 2d5f0b2511a50787d79023bb3bbd148160dc3cc2 | 2026-01-04T17:43:15.442188Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/ci.rb | ci.rb | require 'rubygems'
require 'dash-ci'
CI.register('sinatras-hat') do
build :specs, 'spec spec/'
build :cucumber, 'cucumber -f progress features/'
end
CI.run('sinatras-hat', :token => ENV['DASH_TOKEN']) | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/support/env.rb | features/support/env.rb | require File.join(File.dirname(__FILE__), *%w[.. .. lib sinatras-hat])
require 'sinatra/test'
require 'acts_as_fu'
Sinatra::Test.module_eval do
def mock_app(base=Sinatra::Base, &block)
@app = Sinatra.new(base, &block)
end
end
World do
extend ActsAsFu
extend Sinatra::Test
end
require 'spec/expectations' | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/create_steps.rb | features/steps/create_steps.rb | When /^I make a POST request with valid form params$/ do
post "/people?person[name]=Pat"
end
When /^I make a POST request with invalid form params$/ do
post "/people?person[name]="
end
# When /^I make a POST request with valid serialized attributes for a valid format$/ do
# post "/people.xml", ({:person => { :n... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/new_steps.rb | features/steps/new_steps.rb | When /^I get the new page for that record$/ do
get '/people/new'
end
When /^I get the new action with a valid format$/ do
get '/people/new.xml'
end
When /^I get the new action with an invalid format$/ do
get '/people/new.oops'
end
Then /^the body is a serialized new record$/ do
body.should == Person.new.to_x... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/update_steps.rb | features/steps/update_steps.rb | When /^I make a put request with valid form params$/ do
put "/people/#{@record.to_param}?person[name]=UPDATED"
end
When /^I make a PUT request with invalid form params$/ do
put "/people/#{@record.to_param}?person[name]="
end
Then /^the record is updated$/ do
@record.reload
@record.name.should == "UPDATED"
end... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/show_steps.rb | features/steps/show_steps.rb | # TODO Use acts_as_fu to build some actual models to test
When /^I get the show page for that record$/ do
get "/people/#{@record.to_param}"
end
When /^I get the show page for the non\-existent record$/ do
get "/people/87345873485763485"
end
When /^I make a request for that record with a format$/ do
get "/peopl... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/edit_steps.rb | features/steps/edit_steps.rb | When /^I get the edit page for that record$/ do
get "/people/#{@record.to_param}/edit"
end
When /^I get the edit page for a non\-existent record$/ do
get "/people/23472398732498734/edit"
end | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/only_steps.rb | features/steps/only_steps.rb | Given /^I mount the model for only the :index action$/ do
@app = mock_app do
set :views, File.join(File.dirname(__FILE__), '..', 'support', 'views')
# set :logging, true
mount Person do
only :index
end
end
end | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/format_steps.rb | features/steps/format_steps.rb | Given /^specify a custom 'ruby' formatter$/ do
# this is implemented in common_steps.rb
end
Then /^the body is the custom serialized record$/ do
@response.body.should == @record.inspect
end
Then /^the result should be custom serialized$/ do
@response.body.should == Person.all.inspect
end
| ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/common_steps.rb | features/steps/common_steps.rb | Before do
build_model(:people) do
string :name
timestamps
has_many :comments
validates_presence_of :name
end
build_model(:comments) do
integer :person_id
string :name
timestamps
belongs_to :person
end
Person.delete_all
Comment.delete_all
end
Given /^a model that has... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/destroy_steps.rb | features/steps/destroy_steps.rb | When /^I make a DELETE request to the path for that record$/ do
delete "/people/#{@record.to_param}"
end
When /^I make a DELETE request to a path for a non\-existent record$/ do
delete "/people/345345435"
end
Then /^the record gets destroyed$/ do
Person.find_by_id(@record.id).should be_nil
end
Then /^I am redi... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/authenticated_steps.rb | features/steps/authenticated_steps.rb | Given /^I mount the model protecing the show action$/ do
@app = mock_app do
set :views, File.join(File.dirname(__FILE__), '..', 'support', 'views')
# set :logging, true
mount Person do
protect :show
end
end
end
| ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/index_steps.rb | features/steps/index_steps.rb | # TODO Use acts_as_fu to build some actual models to test
Given /^the model has some records$/ do
@record = Person.create :name => "Pat"
@frank = Person.create :name => "Frank"
end
When /^Make a GET request to the index without a format$/ do
get '/people'
end
When /^Make a GET request to the index with a known... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/header_steps.rb | features/steps/header_steps.rb | Then /^"(.*)" should be the record "(.*)" time$/ do |header, key|
DateTime.parse(response.headers[header].to_s).should == @record.send(key)
end
Then /^"(.*)" should be set$/ do |header|
response.headers[header].should_not be_blank
end
| ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/features/steps/nested_steps.rb | features/steps/nested_steps.rb | When /^Make a GET request to the nested index without a format$/ do
get "/people/#{@record.id}/comments"
end
When /^Make a GET request to the nested index with a valid format$/ do
get "/people/#{@record.id}/comments.xml"
end
Then /^the body is the serialized list of children$/ do
@response.body.should == @recor... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/response_spec.rb | spec/response_spec.rb | require 'spec/spec_helper'
class Article; end
describe Sinatra::Hat::Response do
attr_reader :maker, :response, :request
def new_response(maker=@maker)
Sinatra::Hat::Response.new(maker, request)
end
before(:each) do
@maker = new_maker
@request = fake_request
stub(request.options).views {... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/extendor_spec.rb | spec/extendor_spec.rb | require 'spec/spec_helper'
describe Sinatra::Hat::Extendor do
describe "mount" do
context "when used at top level" do
it "takes a klass" do
proc {
mock_app { mount(Article) }
}.should_not raise_error
end
it "uses Rack::MethodOverride" do
app = mock_app
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/router_spec.rb | spec/router_spec.rb | require 'spec/spec_helper'
describe Sinatra::Hat::Router do
before(:each) do
build_models!
end
describe "initialization" do
it "takes an instance of Maker" do
proc {
maker = new_maker
Sinatra::Hat::Router.new(maker)
}.should_not raise_error
end
end
describe "#gen... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/model_spec.rb | spec/model_spec.rb | require 'spec/spec_helper'
describe Sinatra::Hat::Model do
attr_reader :model, :maker, :fake_request
before(:each) do
build_models!
end
def new_model(maker=new_maker)
Sinatra::Hat::Model.new(maker)
end
describe "initialization" do
it "takes an instance of Maker" do
proc {
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/maker_spec.rb | spec/maker_spec.rb | require 'spec/spec_helper'
class Article; end
class Comment; end
describe Sinatra::Hat::Maker do
attr_reader :model, :maker, :request
describe "initializing" do
it "takes a klass" do
proc {
new_maker(Article)
}.should_not raise_error
end
it "takes options" do
proc {
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/responder_spec.rb | spec/responder_spec.rb | require 'spec/spec_helper'
describe Sinatra::Hat::Responder do
attr_reader :maker, :responder
def new_responder(maker=@maker)
Sinatra::Hat::Responder.new(maker)
end
before(:each) do
build_models!
@maker = new_maker
end
describe "initialization" do
it "takes an instance of Maker" do... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/hash_mutator_spec.rb | spec/hash_mutator_spec.rb | require 'spec/spec_helper'
describe Sinatra::Hat::HashMutator do
attr_reader :mutator, :hash
before(:each) do
@hash = {
:success => proc { :ftw! },
:failure => proc { :fail }
}
@mutator = Sinatra::Hat::HashMutator.new(hash)
end
it "lets you alter the success key of the passed in h... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/resource_spec.rb | spec/resource_spec.rb | require 'spec/spec_helper'
describe Sinatra::Hat::Resource do
before(:each) do
build_models!
end
describe "initialization" do
it "takes an instance of Maker" do
proc {
Sinatra::Hat::Resource.new(new_maker)
}.should_not raise_error
end
end
describe "paths" do
context ... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/spec_helper.rb | spec/spec_helper.rb | ARGV.clear
$LOAD_PATH << File.join(File.dirname(__FILE__), '..')
require 'rubygems'
require 'spec'
require 'rr'
require 'sinatra/base'
require 'sinatra/test'
require 'sinatra/test/rspec'
# What we're testing:
require 'lib/sinatras-hat'
# Tired of stupid mocks
require 'acts_as_fu/base'
def fixture(path)
File.join... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/actions/show_spec.rb | spec/actions/show_spec.rb | require 'spec/spec_helper'
describe "handle show" do
attr_reader :maker, :app, :request
before(:each) do
build_models!
mock_app { }
@maker = new_maker(Article)
@request = fake_request(:id => @article.to_param)
end
def handle(*args)
maker.handle(:show, *args)
end
it "takes a re... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/actions/update_spec.rb | spec/actions/update_spec.rb | require 'spec/spec_helper'
describe "handle create" do
attr_reader :maker, :app, :request, :article
before(:each) do
build_models!
mock_app { }
@maker = new_maker(Article)
@request = fake_request("article[name]" => "Hooray!")
stub(request).redirect(anything)
end
def handle(*args)
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/actions/new_spec.rb | spec/actions/new_spec.rb | require 'spec/spec_helper'
describe "handle index" do
attr_reader :maker, :app, :request
before(:each) do
build_models!
mock_app { }
@maker = new_maker(Article)
@request = fake_request
end
def handle(*args)
maker.handle(:new, *args)
end
it "takes a request" do
maker.handle... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/actions/create_spec.rb | spec/actions/create_spec.rb | require 'spec/spec_helper'
describe "handle create" do
attr_reader :maker, :app, :request, :article
before(:each) do
build_models!
mock_app { }
@maker = new_maker(Article)
@request = fake_request("article[name]" => "The article")
stub(request).redirect(anything)
end
def handle(*args)... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/actions/destroy_spec.rb | spec/actions/destroy_spec.rb | require 'spec/spec_helper'
describe "handle destroy" do
attr_reader :maker, :app, :request, :article
before(:each) do
build_models!
mock_app { }
@maker = new_maker(Article)
@request = fake_request(:id => @article.to_param)
stub(maker.model).find(:id => @article.to_param) { @article }
st... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/actions/edit_spec.rb | spec/actions/edit_spec.rb | require 'spec/spec_helper'
describe "handle show" do
attr_reader :maker, :app, :request
before(:each) do
build_models!
mock_app { }
@maker = new_maker(Article)
@request = fake_request(:id => @article.to_param)
end
def handle(*args)
maker.handle(:edit, *args)
end
it "takes a re... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/spec/actions/index_spec.rb | spec/actions/index_spec.rb | require 'spec/spec_helper'
describe "handle index" do
attr_reader :maker, :app, :request
before(:each) do
build_models!
mock_app { }
@maker = new_maker(Article)
@request = fake_request
end
def handle(*args)
maker.handle(:index, *args)
end
it "takes a request" do
maker.hand... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/example/app-with-cache.rb | example/app-with-cache.rb | require File.dirname(__FILE__) + '/lib/common.rb'
require 'rack/cache'
class MountedApp < Sinatra::Base
set :app_file, __FILE__
set :logging, true
use Rack::Cache do
set :verbose, true
set :metastore, 'heap:/'
set :entitystore, 'heap:/'
end
get '/' do
redirect '/posts'
end
moun... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/example/app-with-auth.rb | example/app-with-auth.rb | require File.dirname(__FILE__) + '/lib/common.rb'
class MountedApp < Sinatra::Base
set :app_file, __FILE__
set :logging, true
mount(Post) do
protect :index,
:username => 'bliggety',
:password => 'blam',
:realm => "Use Protection"
end
run!
end | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/example/app.rb | example/app.rb | require File.dirname(__FILE__) + '/lib/common.rb'
class MountedApp < Sinatra::Base
set :app_file, __FILE__
set :logging, true
get '/' do
"You created a post, and this is a custom response."
end
mount(Post) do
finder { |model, params| model.all }
record { |model, params| model.first(:id => p... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/example/simple-app.rb | example/simple-app.rb | require File.dirname(__FILE__) + '/lib/common.rb'
# This is the simplest possible app
mount(Post) | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/example/lib/common.rb | example/lib/common.rb | $LOAD_PATH << File.join(File.dirname(__FILE__), '..', '..')
$LOAD_PATH << File.join(File.dirname(__FILE__))
require 'rubygems'
require 'sinatra'
require 'lib/sinatras-hat'
# Models
require 'post'
require 'comment'
configure do
DataMapper.setup(:default, 'sqlite3:db.sqlite3')
Post.auto_migrate!
Comment.auto_mig... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/example/lib/comment.rb | example/lib/comment.rb | require 'dm-core'
require 'dm-serializer'
class Comment
include DataMapper::Resource
include DataMapper::Serialize
property :id, Serial, :key => true
property :post_id, Integer
property :body, Text
belongs_to :post
end | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/example/lib/post.rb | example/lib/post.rb | require 'dm-core'
require 'dm-serializer'
require 'dm-timestamps'
class Post
include DataMapper::Resource
include DataMapper::Serialize
property :id, Serial, :key => true
property :name, String
property :body, Text
property :created_at, DateTime
property :updated_at, DateTime
has n, :comments
end | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat.rb | lib/sinatras-hat.rb | $LOAD_PATH << File.join(File.dirname(__FILE__))
require 'benchmark'
require 'sinatra/base'
require 'extlib'
require 'core_ext/array'
require 'core_ext/hash'
require 'core_ext/object'
require 'core_ext/module'
require 'sinatras-hat/logger'
require 'sinatras-hat/extendor'
require 'sinatras-hat/authentication'
require ... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/core_ext/array.rb | lib/core_ext/array.rb | class Array
def extract_options!
last.is_a?(Hash) ? pop : { }
end
end | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/core_ext/object.rb | lib/core_ext/object.rb | require 'metaid'
class Object
def tap
yield self
self
end
def with(hash)
hash.each do |key, value|
meta_def(key) { hash[key] } unless respond_to?(key)
meta_def("#{key}=") { |v| hash[key] = v } unless respond_to?("#{key}=")
end
return unless block_given?
result = yield... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/core_ext/module.rb | lib/core_ext/module.rb | class Module
def delegate(*methods)
options = methods.pop
raise ArgumentError, "Delegation needs a target." unless options.is_a?(Hash) && to = options[:to]
methods.each do |method|
module_eval(<<-EOS, "(__DELEGATION__)", 1)
def #{method}(*args, &block)
#{to}.__send__(#{method.insp... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/core_ext/hash.rb | lib/core_ext/hash.rb | class Hash
def make_indifferent!
keys_values = self.dup
replace(Hash.new { |h,k| h[k.to_s] if Symbol === k })
merge!(keys_values)
end
def nest!
new_params = Hash.new.make_indifferent!
each_pair do |full_key, value|
this_param = new_params
split_keys = full_key.to_s.split(/\]\[|... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/resource.rb | lib/sinatras-hat/resource.rb | module Sinatra
module Hat
# Handles the logic of generating a path for a given resource,
# taking any and all parents into consideration.
class Resource
def initialize(maker)
@maker = maker
end
def path(suffix, record=nil)
records = record ? path_records_for(record... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/authentication.rb | lib/sinatras-hat/authentication.rb | # from http://www.gittr.com/index.php/archive/sinatra-basic-authentication-selectively-applied
# adapted by pat nakajima for sinatra's hat
module Sinatra
module Authorization
class ProtectedAction
attr_reader :credentials, :request, :block
def initialize(request, credentials={}, &block)
@cr... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/actions.rb | lib/sinatras-hat/actions.rb | module Sinatra
module Hat
# Contains all of the actions that Sinatra's Hat supports.
# Each action states a name, a path, optionally, the HTTP
# verb, then a block which takes a request object, optionally
# loads data using the :finder or :record options, then
# responds, based on whether or not t... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/logger.rb | lib/sinatras-hat/logger.rb | module Sinatra
module Hat
# TODO This needs to be using Rack::CommonLogger
class Logger
def initialize(maker)
@maker = maker
end
def info(msg)
say msg
end
def debug(msg)
say msg
end
def warn(msg)
say msg
end
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/hash_mutator.rb | lib/sinatras-hat/hash_mutator.rb | module Sinatra
module Hat
# Used for specifying custom responses using a corny DSL.
class HashMutator
def initialize(hash)
@hash = hash
end
def success(&block)
@hash[:success] = block
end
def failure(&block)
@hash[:failure] = block
end
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/responder.rb | lib/sinatras-hat/responder.rb | module Sinatra
module Hat
# The responder assigns data to instance variables, then either
# gets the appropriate response proc and instance_exec's it in the
# context of a new Response object, or serializes the data.
class Responder
delegate :model, :to => :maker
attr_reader :maker
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/maker.rb | lib/sinatras-hat/maker.rb | module Sinatra
module Hat
# This is where it all comes together
class Maker
include Sinatra::Hat::Extendor
include Sinatra::Authorization::Helpers
attr_reader :klass, :app
def self.actions
@actions ||= { }
end
def self.action(name, path, options... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/response.rb | lib/sinatras-hat/response.rb | module Sinatra
class NoTemplateError < StandardError; end
module Hat
# Tells Sinatra what to do next.
class Response
attr_reader :maker
delegate :model, :resource_path, :to => :maker
def initialize(maker, request)
@maker = maker
@request = request
end... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/router.rb | lib/sinatras-hat/router.rb | module Sinatra
module Hat
# Tells Sinatra which routes to generate. The routes
# created automatically when the actions are loaded.
class Router
delegate :resource_path, :logger, :to => :maker
attr_reader :maker, :app
def self.cache
@cache ||= []
end
... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/extendor.rb | lib/sinatras-hat/extendor.rb | module Sinatra
module Hat
# This module gives both Sinatra::Base and Sinatra::Hat::Maker
# the #mount method, which is used to mount resources. When
# mount is called in an instance of Maker, it sets the new
# instance's parent.
module Extendor
def mount(klass, options={}, &block)
un... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
nakajima/sinatras-hat | https://github.com/nakajima/sinatras-hat/blob/e2ee15d57bb6831af4769c94ce01604e0546c1d6/lib/sinatras-hat/model.rb | lib/sinatras-hat/model.rb | module Sinatra
module Hat
# A wrapper around the model class that we're mounting
class Model
attr_reader :maker
delegate :options, :klass, :prefix, :to => :maker
def initialize(maker)
@maker = maker
end
# Loads all records using the maker's :finder op... | ruby | MIT | e2ee15d57bb6831af4769c94ce01604e0546c1d6 | 2026-01-04T17:43:56.302326Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/benchmark/update_event.rb | benchmark/update_event.rb | require "perftools"
require "benchmark"
require "logger"
require "chronologic"
Chronologic.connection = Cassandra.new("ChronologicTest")
# logger = Logger.new(STDOUT)
# logger.level = Logger::DEBUG
# Chronologic::Service::Schema.logger = logger
protocol = Chronologic::Service::Protocol
subscriber_count = Integer(AR... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/benchmark/objectless_feed.rb | benchmark/objectless_feed.rb | require 'chronologic'
require 'benchmark'
n_events = 100
# n_objects = rand(10)
n_objects = 20
n_feeds = 1000
Chronologic.connection = Cassandra.new('Chronologic')
protocol = Chronologic::Service::Protocol
timestamp = Time.now.tv_sec
timeline = ['objectless', timestamp].join('-')
puts "Benchmarking for #{timeline}"
... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/benchmark/publish.rb | benchmark/publish.rb | # $ ruby -rubygems -Ilib benchmark/publish.rb
require "perftools"
require "benchmark"
require "chronologic"
def create_friendship(timeline, subscriber)
Chronologic::Protocol.subscribe(timeline, subscriber)
end
def create_event(key, timeline)
ev = Chronologic::Event.new
ev.key = key
ev.timestamp = Time.now
... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/benchmark/timeline_client.rb | benchmark/timeline_client.rb | # $ ruby -rubygems -Ilib benchmark/publish.rb
require "benchmark"
require "chronologic"
iterations = Integer(ARGV.last)
timelines = [1, 2, 3, 4, 5, 6, 3104, 1699].map { |id| ["user_#{id}", "user_#{id}_home"] }.flatten
# cl = Chronologic::Client.new("http://localhost:7979")
cl = Chronologic::Client.new('https://api.... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/benchmark/timeline.rb | benchmark/timeline.rb | # $ ruby -rubygems -Ilib benchmark/publish.rb
require "perftools"
require "benchmark"
require "logger"
require "chronologic"
servers = [
'10.250.203.127:9160',
'10.210.13.171:9160',
'10.250.227.63:9160',
'10.250.230.111:9160'
]
Chronologic.connection = Cassandra.new(
"ChronologicTest",
servers,
:retrie... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic_spec.rb | spec/chronologic_spec.rb | require 'spec_helper'
describe Chronologic do
it "holds a Cassandra connection" do
fake_connection = Object.new
Chronologic.connection = fake_connection
Chronologic.connection.should eq(fake_connection)
end
it "has a schema helper" do
Chronologic.schema.should eq(Chronologic::Service::Schema)
... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/helpers.rb | spec/helpers.rb | module ChronologicHelpers
def simple_event(kind=:service)
case kind
when :service
Chronologic::Service::Event.new.tap do |event|
event.key = "checkin_1"
event.data = {"type" => "checkin", "message" => "I'm here!"}
event.objects = {"user" => "user_1", "spot" => "spot_1"}
... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/functional_helper.rb | spec/functional_helper.rb | require 'cassandra/0.7'
require 'chronologic'
require 'rack/test'
require 'helpers'
MultiJson.engine = :yajl
module FunctionalTestHelpers
def self.truncate_cfs
c = Cassandra.new("ChronologicTest")
[:Object, :Subscription, :Timeline, :Event].each do |cf|
c.truncate!(cf)
end
end
def truncate_c... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/spec_helper.rb | spec/spec_helper.rb | require 'chronologic'
require 'webmock/rspec'
require 'cassandra/0.7'
require 'cassandra/mock'
require 'helpers'
MultiJson.engine = :yajl
RSpec.configure do |config|
config.include(ChronologicHelpers)
config.include(WebMock::API)
config.before do
if ENV['CASSANDRA']
Chronologic::Service::Schema.write... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/service/schema_spec.rb | spec/chronologic/service/schema_spec.rb | require 'spec_helper'
describe Chronologic::Service::Schema do
let(:protocol) { Chronologic::Service::Protocol }
before do
@schema = Chronologic::Service::Schema
end
it "creates an object" do
attrs = {"name" => "akk"}
@schema.create_object("user_1", attrs)
@schema.object_for("user_1").shou... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/service/objectless_feed_spec.rb | spec/chronologic/service/objectless_feed_spec.rb | require 'spec_helper'
describe Chronologic::Service::ObjectlessFeed do
let(:protocol) { Chronologic::Service::Protocol }
subject { Chronologic::Service::ObjectlessFeed }
it_behaves_like "a feed strategy"
# AKK: reduce duplication of code in this examples
it "generates a feed for a timeline key" do
akk... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/service/protocol_spec.rb | spec/chronologic/service/protocol_spec.rb | require 'spec_helper'
describe Chronologic::Service::Protocol do
let(:protocol) { Chronologic::Service::Protocol }
it "records an entity" do
akk = {"name" => "akk"}
jp = {"name" => "Juan Pelota's"}
protocol.record("user_1", akk)
protocol.record("spot_1", jp)
hsh = {"user_1" => akk, "spot_1" ... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/service/feed_spec.rb | spec/chronologic/service/feed_spec.rb | require 'spec_helper'
describe Chronologic::Service::Feed do
let(:protocol) { Chronologic::Service::Protocol }
subject { Chronologic::Service::Feed }
it_behaves_like "a feed strategy"
it "generates a feed for a timeline key" do
akk = {"name" => "akk"}
jp = {"name" => "Juan Pelota's"}
protocol.re... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/service/event_spec.rb | spec/chronologic/service/event_spec.rb | require 'spec_helper'
describe Chronologic::Service::Event do
it_behaves_like "a CL event"
subject do
described_class.from_attributes(
:key => "event_1",
:data => {"foo" => {"one" => "two"}},
:objects => {"user" => "user_1", "spot" => "spot_1"},
:timelines => ["user_1", "sxsw"],
... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/service/app_spec.rb | spec/chronologic/service/app_spec.rb | require 'spec_helper'
require 'rack/test'
describe Chronologic::Service::App do
include Rack::Test::Methods
let(:protocol) { Chronologic::Service::Protocol }
it "writes a new entity record" do
data = {
"name" => "Juan Pelota's",
"awesome_factor" => "100"
}
post "/object", {:object_key... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/client/connection_spec.rb | spec/chronologic/client/connection_spec.rb | require 'spec_helper'
describe Chronologic::Client::Connection do
let(:client) { Chronologic::Client::Connection.new('http://localhost:3000') }
it "records an object" do
stub_request(:post, "http://localhost:3000/object").
to_return(:status => 201)
client.record("user_1", {"name" => "akk"}).should... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/client/fake_spec.rb | spec/chronologic/client/fake_spec.rb | require 'spec_helper'
describe Chronologic::Client::Fake do
def valid_event_hash
{
'key' => 'event_1',
'timelines' => [],
'objects' => {},
'subevents' => [],
'data' => {}
}
end
def valid_event
Chronologic::Client::Event.from_attributes(valid_event_hash)
end
descri... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/chronologic/client/event_spec.rb | spec/chronologic/client/event_spec.rb | require 'spec_helper'
describe Chronologic::Client::Event do
it_behaves_like "a CL event"
let(:event) { simple_event(:client) }
it "serializes for HTTP transport" do
event.to_transport.should_not have_key("timestamp")
event.to_transport["data"].should == MultiJson.encode(event.data)
event.to_transp... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/functional/api_spec.rb | spec/functional/api_spec.rb | require 'functional_helper'
describe "The Chronologic API" do
let(:schema) { Chronologic::Service::Schema }
before do
Chronologic.connection = Cassandra.new('ChronologicTest')
end
context "POST /subscription" do
it "creates a subscription from timeline key to subscriber key" do
# home <- tech
... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/functional/privacy_spec.rb | spec/functional/privacy_spec.rb | require 'functional_helper'
describe "Privacy controls in Chronologic" do
include Rack::Test::Methods
# Rewrite this from a chronologic client
it "checks whether a user can see events for another user" do
pending("Come back to this when you're good and sure about it")
post '/subscription', {
'tim... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/spec/functional/use_cases_spec.rb | spec/functional/use_cases_spec.rb | require 'functional_helper'
describe "Chronologic API uses cases" do
it "publish an event with subevents, remove the event and subevents, get a blank timeline" do
event = simple_event(:client)
comment0 = Chronologic::Client::Event.from_attributes(
'key' => 'comment_1',
'data' => {'type' => 'comm... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/examples/paginate.rb | examples/paginate.rb | require "pp"
require "chronologic"
Chronologic.connection = Cassandra.new("ChronologicTest")
puts "Paginating with Chronologic::Schema"
page = Chronologic::Schema.timeline_for("user_1165", :per_page => 5).keys
puts "First/last: #{page.first}/#{page.last}"
pp Chronologic::Schema.timeline_for("user_1165", :per_page => ... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/examples/05_gowalla.rb | examples/05_gowalla.rb | # Create some objects, create some subscriptions, publish some events, fetch
require 'boilerplate'
connection = Chronologic::Client::Connection.new('http://localhost:7979')
connection.record("user:ak", {"long_name" => "Adam Keys"})
connection.record("user:rs", {"long_name" => "Richard Schneeman"})
connection.record("... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/examples/boilerplate.rb | examples/boilerplate.rb | require 'rubygems'
require 'bundler/setup'
require 'pp'
require 'chronologic'
| ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/examples/gowalla.rb | examples/gowalla.rb | #!/usr/bin/env ruby
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
require 'chronologic'
c = Chronologic::Client.new
c.clear!
puts "Create objects for users, spots, trips, highlights"
c.object(:user_1, {:name => 'Scott Raymond'})
c.object(:user_2, {:name => 'Josh Williams'})
c.object(:spot_1, {:name... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
gowalla-archive/chronologic | https://github.com/gowalla-archive/chronologic/blob/1fecdea9edce001e10e024fae43bf4c06f837b98/examples/privacy.rb | examples/privacy.rb | require 'chronologic'
cl = Chronologic::Client.new('http://localhost:7979')
# AK is public and friends with BF and BO
cl.subscribe('user_ak_feed', 'user_bf')
cl.subscribe('user_ak_feed', 'user_bo')
# BF is public and friends with BO and AK
cl.subscribe('user_bf_feed', 'user_bo')
cl.subscribe('user_bf_feed', 'user_ak... | ruby | MIT | 1fecdea9edce001e10e024fae43bf4c06f837b98 | 2026-01-04T17:43:46.847213Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.