source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | steverandy/concen | https://github.com/steverandy/concen | app/models/concen/visit/page.rb | Ruby | mit | 19 | master | 2,905 | module Concen
module Visit
class Page
include Mongoid::Document
store_in self.name.underscore.gsub("/", ".").pluralize
field :hour, :type => Time
field :url, :type => String
field :count, :type => Integer, :default => 1
field :title, :type => String
index :hour, :backg... |
github | steverandy/concen | https://github.com/steverandy/concen | app/models/concen/visit/referral.rb | Ruby | mit | 19 | master | 1,245 | module Concen
module Visit
class Referral
include Mongoid::Document
store_in self.name.underscore.gsub("/", ".").pluralize
field :hour, :type => Time
field :url, :type => String
field :domain, :type => String
field :count, :type => Integer, :default => 1
index :hour, :... |
github | steverandy/concen | https://github.com/steverandy/concen | test/test_helper.rb | Ruby | mit | 19 | master | 767 | # Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require File.expand_path("../fabricators.rb", __FILE__)
require "rails/test_help"
require "database_cleaner"
require "turn"
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perf... |
github | steverandy/concen | https://github.com/steverandy/concen | test/fabricators.rb | Ruby | mit | 19 | master | 408 | Fabricator("concen/user") do
username { Fabricate.sequence(:username) { |i| "username#{i}" } }
full_name { Fabricate.sequence(:full_name) { |i| "Full Name #{i}" } }
email { Fabricate.sequence(:email) { |i| "user#{i}@mail.com" } }
password "thisismypassword"
password_confirmation "thisismypassword"
end
Fabric... |
github | steverandy/concen | https://github.com/steverandy/concen | test/dummy/config/application.rb | Ruby | mit | 19 | master | 1,944 | require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"
Bundler.require
require "concen"
module Dummy
class Application < Rails::Application
# Settings in co... |
github | steverandy/concen | https://github.com/steverandy/concen | test/dummy/config/initializers/secret_token.rb | Ruby | mit | 19 | master | 496 | # 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 be exposed to dictionary attac... |
github | steverandy/concen | https://github.com/steverandy/concen | test/unit/grid_file_test.rb | Ruby | mit | 19 | master | 1,662 | require "test_helper"
class GridFileTest < ActiveSupport::TestCase
def setup
DatabaseCleaner.clean
end
test "can store file in GridFS" do
page = Fabricate "concen/page"
grid_file = page.grid_files.build
grid_file.store File.read("#{Rails.root}/public/404.html"), "404.html"
assert_equal F... |
github | steverandy/concen | https://github.com/steverandy/concen | test/unit/page_test.rb | Ruby | mit | 19 | master | 6,394 | require "test_helper"
class ConcenTest < ActiveSupport::TestCase
def setup
DatabaseCleaner.clean
end
test "can create page" do
page = Fabricate "concen/page"
refute_nil page.id
end
test "can create child page" do
page = Fabricate "concen/page"
child_page = page.children.create :titl... |
github | steverandy/concen | https://github.com/steverandy/concen | test/unit/user_test.rb | Ruby | mit | 19 | master | 1,416 | require "test_helper"
class UserTest < ActiveSupport::TestCase
def setup
DatabaseCleaner.clean
end
test "can create user" do
user = Fabricate "concen/user"
assert_not_nil user.id
end
test "has password_digest" do
user = Fabricate "concen/user"
assert_not_nil user.password_digest
e... |
github | steverandy/concen | https://github.com/steverandy/concen | lib/concen.rb | Ruby | mit | 19 | master | 331 | require "concen/engine" if defined?(Rails)
module Concen
mattr_accessor :application_name, :typekit_id, :markdown_extensions, :parse_markdown_with_smartypants
@@application_name = nil
@@typekit_id = "qxq7sbk"
@@markdown_extensions = {}
@@parse_markdown_with_smartypants = true
def self.setup
yield self... |
github | steverandy/concen | https://github.com/steverandy/concen | lib/concen/engine.rb | Ruby | mit | 19 | master | 365 | require "rails"
require "mongoid"
require "mongo/rails/instrumentation/railtie"
module Concen
class Engine < Rails::Engine
rake_tasks do
load "concen/railties/setup.rake"
load "concen/railties/page.rake"
end
# Add a load path for this specific Engine
# config.autoload_paths << File.expan... |
github | steverandy/concen | https://github.com/steverandy/concen | lib/concen/railties/page.rake | Ruby | mit | 19 | master | 356 | namespace :concen do
namespace :page do
desc "Reset publish_month for all the pages. Should be used when time zone is changed."
task :reset_publish_month => :environment do
Time.zone = Rails::Application.config.time_zone
for page in Concen::Page.all
page.send(:set_publish_month)
pa... |
github | steverandy/concen | https://github.com/steverandy/concen | lib/concen/railties/setup.rake | Ruby | mit | 19 | master | 2,396 | # encoding: utf-8
namespace :concen do
desc "Create initial setup for Control Center."
task :setup do
if ["development", "test"].include? Rails.env
Rake::Task["concen:generate_mongoid_config"].invoke
Rake::Task["concen:generate_initializer"].invoke
end
message = "Concen setup for #{Rails.en... |
github | steverandy/concen | https://github.com/steverandy/concen | config/routes.rb | Ruby | mit | 19 | master | 1,478 | require "rack/gridfs"
# Use Rails.application.routes.prepend on Rails 3.1.
Rails.application.routes.draw do
match "/visits/record.gif" => "concen/visits#record", :as => "record_visit"
match "/visits/js" => "concen/visits#visit_recorder_js", :as => "visit_recorder_js"
scope :constraints => {:subdomain => "concen... |
github | steverandy/concen | https://github.com/steverandy/concen | config/initializers/prepend_routing_paths.rb | Ruby | mit | 19 | master | 291 | # TODO: Use Rails.application.routes.prepend on Rails 3.1
# and disasble the following code block.
Concen::Engine.paths["config/routes"].to_a.each do |route|
Rails.application.routes_reloader.paths.unshift(route) if File.exists?(route)
Rails.application.routes_reloader.paths.uniq!
end |
github | steverandy/concen | https://github.com/steverandy/concen | config/initializers/notification.rb | Ruby | mit | 19 | master | 334 | ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload|
payload.delete(:params)
extra_hash = {:total_runtime => (finish - start) * 1000}
payload.merge! extra_hash
unless payload[:controller].include? "Concen"
Concen::Response.safely(false).create(paylo... |
github | steverandy/concen | https://github.com/steverandy/concen | config/initializers/assets.rb | Ruby | mit | 19 | master | 278 | if Rails.env.production?
Rails.application.config.assets.precompile += %w(concen/ie.css concen/non_ios.css)
Rails.application.config.assets.precompile += %w(concen/pages.js concen/performances.js concen/statuses.js concen/traffics.js concen/users.js concen/excanvas.js)
end |
github | danielb2/trakt | https://github.com/danielb2/trakt | trakt.gemspec | Ruby | mit | 19 | master | 792 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'trakt/version'
Gem::Specification.new do |gem|
gem.name = "trakt"
gem.version = Trakt::VERSION
gem.authors = ["Daniel Bretoi"]
gem.email = ["daniel@... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/show_spec.rb | Ruby | mit | 19 | master | 1,552 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Show do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
it... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/movies_spec.rb | Ruby | mit | 19 | master | 711 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Movie do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
i... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/movie_spec.rb | Ruby | mit | 19 | master | 647 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Movie do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
i... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/friends_spec.rb | Ruby | mit | 19 | master | 493 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Friends do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/list_spec.rb | Ruby | mit | 19 | master | 2,544 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::List do
before do
list = trakt.list.get("testlist")
list.delete rescue nil
end
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username ... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/genres_spec.rb | Ruby | mit | 19 | master | 792 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Genres do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/account_spec.rb | Ruby | mit | 19 | master | 679 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Account do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/calendar_spec.rb | Ruby | mit | 19 | master | 831 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Calendar do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/activity_spec.rb | Ruby | mit | 19 | master | 546 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Activity do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/search_spec.rb | Ruby | mit | 19 | master | 1,699 | require File.dirname(__FILE__) + '/spec_helper'
describe Trakt do
describe Trakt::Search do
let(:trakt) do
details = get_account_details
trakt = Trakt.new :apikey => details['apikey'],
:username => details['username'],
:password => details['password']
trakt
end
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | spec/spec_helper.rb | Ruby | mit | 19 | master | 436 | require "rspec"
require "trakt"
require "yaml"
require "vcr"
def get_account_details
account = IO.read File.dirname(__FILE__) + '/account_details.yml'
YAML.load(account)
end
VCR.configure do |c|
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
c.allow_http_connections_when_no_cassette = true
c.hook_i... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt.rb | Ruby | mit | 19 | master | 1,163 | require "trakt/version"
require "json"
require "excon"
require "digest"
require "trakt/connection"
require "trakt/account"
require "trakt/list"
require "trakt/movie"
require "trakt/search"
require "trakt/activity"
require "trakt/calendar"
require "trakt/show"
require "trakt/friends"
require "trakt/movies"
require "trak... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/account.rb | Ruby | mit | 19 | master | 270 | module Trakt
class Account
include Connection
def settings
require_settings %w|username password apikey|
post 'account/settings/'
end
def test
require_settings %w|username password apikey|
post 'account/test/'
end
end
end |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/show.rb | Ruby | mit | 19 | master | 1,069 | module Trakt
class Show
include Connection
def episode_unseen(data)
require_settings %w|username password apikey|
post('show/episode/unseen/', data)
end
def episode_seen(data)
require_settings %w|username password apikey|
post('show/episode/seen/', data)
end
def seen(da... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/calendar.rb | Ruby | mit | 19 | master | 233 | module Trakt
class Calendar
include Connection
def premieres(*args)
get_with_args('/calendar/premieres.json/', *args)
end
def shows(*args)
get_with_args('/calendar/shows.json/', *args)
end
end
end |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/search.rb | Ruby | mit | 19 | master | 645 | module Trakt
class Search
include Connection
def movies(query)
require_settings %w|apikey|
get('/search/movies.json/',clean_query(query))
end
def shows(query)
require_settings %w|apikey|
get('/search/shows.json/',clean_query(query))
end
def episode(query)
require_... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/friends.rb | Ruby | mit | 19 | master | 836 | module Trakt
class Friends
include Connection
def add(username)
require_settings %w|username password apikey|
post "friends/#{__method__}/", 'friend' => username
end
def all
require_settings %w|username password apikey|
post 'friends/all/'
end
def approve(username)
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/movie.rb | Ruby | mit | 19 | master | 1,226 | module Trakt
class Movie
include Connection
def cancelcheckin
post("/movie/cancelcheckin")
end
def cancelwatching
post("/movie/cancelwatching")
end
def checkin(options = {})
post("/movie/checkin", options)
end
def scrobble(options = {})
post("/movie/scrobble", o... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/list.rb | Ruby | mit | 19 | master | 862 | module Trakt
class List
include Connection
# TODO options should be the various options at some point
attr_accessor :slug, :add_info
def add(name,options={})
result = post 'lists/add/', options.merge(:name => name)
@slug = result['slug']
@add_info = result
return self
end
... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/activity.rb | Ruby | mit | 19 | master | 1,016 | module Trakt
# Refer to the api doc on what parameters these functions take. http://trakt.tv/api-docs/activity-community
# For eaxmple, the current description for community reads:
#
# http://api.trakt.tv/activity/community.format/apikey/types/actions/start_ts/end_ts
#
# So you just do: <tt>trakt.activi... |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/genres.rb | Ruby | mit | 19 | master | 243 | module Trakt
class Genres
include Connection
def movies
require_settings %w|apikey|
get "/genres/movies.json",''
end
def shows
require_settings %w|apikey|
get "/genres/shows.json",''
end
end
end |
github | danielb2/trakt | https://github.com/danielb2/trakt | lib/trakt/connection.rb | Ruby | mit | 19 | master | 1,514 | module Trakt
module Connection
attr_reader :trakt
def initialize(trakt)
@trakt = trakt
end
def connection
@connection ||= Excon.new("http://api.trakt.tv");
end
def require_settings(required)
required.each do |setting|
raise "Required setting #{setting} is missing." un... |
github | yeah/page_cache_fu | https://github.com/yeah/page_cache_fu | init.rb | Ruby | mit | 19 | master | 940 | require 'dispatcher'
# require 'lib/page_cache_fu.rb'
Dispatcher.to_prepare do
ApplicationController.send(:class_inheritable_accessor, :page_cache_fu_options)
if File.expand_path(ActionController::Base.page_cache_directory) == File.expand_path('public',RAILS_ROOT)
ActionController::Base.page_cache_directory =... |
github | yeah/page_cache_fu | https://github.com/yeah/page_cache_fu | uninstall.rb | Ruby | mit | 19 | master | 712 | require 'ftools'
# Remove page_cache_sweeper from the local script directory.
#
# If page_cache_sweeper doesn't exists, print a warning and exit.
#
if File.directory? "script"
dest_dir = "script"
end
dest_sweeper_file = File.join(dest_dir, "page_cache_sweeper") if dest_dir
if !dest_dir
STDERR.puts "Could not fin... |
github | yeah/page_cache_fu | https://github.com/yeah/page_cache_fu | install.rb | Ruby | mit | 19 | master | 774 | require 'ftools'
# Install page_cache_sweeper into the local script directory.
#
# If page_cache_sweeper already exists, print a warning and exit.
#
if File.directory? "script"
dest_dir = "script"
end
src_sweeper_file = File.join(File.dirname(__FILE__),"script/page_cache_sweeper")
dest_sweeper_file = File.join(dest... |
github | yeah/page_cache_fu | https://github.com/yeah/page_cache_fu | Rakefile | Ruby | mit | 19 | master | 576 | require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the page_cache_fu plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for t... |
github | yeah/page_cache_fu | https://github.com/yeah/page_cache_fu | lib/page_cache_fu.rb | Ruby | mit | 19 | master | 406 | module PageCacheFu
private
def self.mode_match(mode1, mode2)
mode1, mode2 = mode1.to_s, mode2.to_s
length = [mode1.size,mode2.size].max
mode1, mode2 = ("%0#{length}d" % mode1), ("%0#{length}d" % mode2)
match = true
0.upto(length-1) do |i|
unless mode1[i].to_i & mode2[i].to_i == mode2[i].t... |
github | yeah/page_cache_fu | https://github.com/yeah/page_cache_fu | lib/page_cache_fu/patches.rb | Ruby | mit | 19 | master | 2,976 | module PageCacheFu
module Patches
module CachingPagesClassMethods
def caches_page_with_expiry(*actions)
if actions.last.is_a?(::Hash)
self.page_cache_fu_options ||= {}
actions[0..-2].each do |action|
self.page_cache_fu_options[action.to_sym] = actions.last
... |
github | yeah/page_cache_fu | https://github.com/yeah/page_cache_fu | lib/page_cache_fu/cache_sweeper.rb | Ruby | mit | 19 | master | 1,043 | module PageCacheFu
module CacheSweeper
def self.sweep_if_expired(file, options={})
if File.exists?(file)
if options[:match_mode].nil? or mode_match((mode=sprintf('%o',File.stat(file).mode)[-3,3]), options[:match_mode])
if File.directory?(file)
if options[:not_if_directory]
... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | guard_against_physical_delete.gemspec | Ruby | mit | 19 | master | 1,250 | # -*- encoding: utf-8 -*-
require_relative "lib/guard_against_physical_delete/version"
Gem::Specification.new do |s|
s.name = "guard_against_physical_delete"
s.version = GuardAgainstPhysicalDelete::VERSION
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | Rakefile | Ruby | mit | 19 | master | 406 | # encoding: utf-8
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "guard_against_delete #{versio... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | spec/database.rb | Ruby | mit | 19 | master | 1,928 | require 'active_record'
require 'database_cleaner'
::ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => "test.db"})
class CreateAllTables < ::ActiveRecord::Migration[5.0]
def self.up
create_table(:logicals) {|t| t.string :name; t.datetime :deleted_at; t.boolean :after_saved }
creat... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | spec/spec_helper.rb | Ruby | mit | 19 | master | 416 | require 'bundler'
Bundler.setup(:default, :development)
require 'simplecov'
SimpleCov.start do
add_filter "/spec/"
end
require 'guard_against_physical_delete'
require 'database'
RSpec.configure do |config|
config.mock_with :rspec
config.before(:suite) do
DatabaseCleaner.clean_with :deletion
DatabaseCl... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | spec/guard_against_physical_delete/support_counter_cache_spec.rb | Ruby | mit | 19 | master | 3,060 | require 'spec_helper'
describe GuardAgainstPhysicalDelete do
let(:parent) do
Parent.create!
end
context 'when child is physically deleted' do
subject do
child.destroy
end
let!(:child) do
parent.children.create!
end
it 'decrements counter' do
expect { subject }.to chan... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | spec/guard_against_physical_delete/guard_spec.rb | Ruby | mit | 19 | master | 3,875 | require 'spec_helper'
require 'countdownlatch'
describe GuardAgainstPhysicalDelete do
shared_examples_for 'guard against physical delete' do
let(:model) do
model_class.create!
end
context 'when model has no deleted_at column' do
let(:model_class) do
Physical
end
it do
... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | lib/guard_against_physical_delete.rb | Ruby | mit | 19 | master | 582 | require 'active_record'
require 'guard_against_physical_delete/physical_delete_error'
require 'guard_against_physical_delete/relation'
require 'guard_against_physical_delete/base'
require 'guard_against_physical_delete/support_counter_cache'
ActiveSupport.on_load :active_record do
ActiveRecord::Base.send(:include, G... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | lib/guard_against_physical_delete/relation.rb | Ruby | mit | 19 | master | 342 | module GuardAgainstPhysicalDelete
module Relation
def self.included(base)
base.prepend MethodOverrides
end
module MethodOverrides
def delete_all
unless klass.delete_permitted?
raise GuardAgainstPhysicalDelete::PhysicalDeleteError, klass.name
end
super
... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | lib/guard_against_physical_delete/base.rb | Ruby | mit | 19 | master | 1,641 | module GuardAgainstPhysicalDelete
module Base
def self.included(obj)
obj.extend ClassMethods
obj.class_eval do
class_attribute :logical_delete_column
class << self
alias_method :set_logical_delete_column, :logical_delete_column=
end
set_logical_delete_column... |
github | cookpad/guard_against_physical_delete | https://github.com/cookpad/guard_against_physical_delete | lib/guard_against_physical_delete/support_counter_cache/associations/builder/belongs_to.rb | Ruby | mit | 19 | master | 2,529 | module GuardAgainstPhysicalDelete
module SupportCounterCache
module Associations
module Builder
module BelongsTo
def self.included(obj)
class << obj
prepend MethodOverrides
private
def add_logical_delete_counter_cache_methods(mixin)
... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | Rakefile | Ruby | mit | 19 | master | 2,672 | require "rake"
require "rake/clean"
require "rake/gempackagetask"
require "rake/rdoctask"
require "rake/testtask"
require "spec/rake/spectask"
require "fileutils"
def __DIR__
File.dirname(__FILE__)
end
include FileUtils
require "lib/strokedb/version"
GEM_NAME = "strokedb"
GEM_VERSION = StrokeDB::VERSION
def sudo... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb.rb | Ruby | mit | 19 | master | 835 | require 'set'
require 'fileutils'
# These libs are not published as gems yet.
# git submodule init && git submodule update
begin
($:.unshift *(Dir[ File.join( File.dirname(__FILE__), '..', 'vendor', '**', 'lib' ) ].to_a.map {|f| File.expand_path(f) }) ).uniq!
libs = %w[extlib tokyocabinet-wrapper declarations]
l... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/version.rb | Ruby | mit | 19 | master | 388 | module StrokeDB
VERSION = '0.1.0' unless defined?(StrokeDB::Core::VERSION)
# StrokeDB::Core::RELEASE meanings:
# 'dev' : unreleased
# 'pre' : pre-release Gem candidates
# nil : released
# You should never check in to trunk with this changed. It should
# stay 'dev'. Change it to nil in release t... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/stroke_objects.rb | Ruby | mit | 19 | master | 251 | require 'strokedb/stroke_objects/lazy_accessors.rb'
require 'strokedb/stroke_objects/slot_hooks.rb'
require 'strokedb/stroke_objects/instance_methods.rb'
require 'strokedb/stroke_objects/class_methods.rb'
require 'strokedb/stroke_objects/database.rb' |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/constants.rb | Ruby | mit | 19 | master | 773 | module StrokeDB
# Coverage threshold - bump this float anytime your changes increase the spec coverage
# DO NOT LOWER THIS NUMBER. EVER.
COVERAGE = 50
# XML Schema time format
# Time.now.xmlschema(6)
# #=> "2008-04-27T23:39:09.920288+04:00"
# Time.xmlschema("2008-04-27T23:39:09.920288+04:00")
# ... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/associations.rb | Ruby | mit | 19 | master | 256 | prefix = "strokedb/associations"
require "#{prefix}/base"
require "#{prefix}/belongs_to"
require "#{prefix}/has_many"
module StrokeDB
module Associations
def self.included(mod)
mod.extend(BelongsTo)
mod.extend(HasMany)
end
end
end |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/validations.rb | Ruby | mit | 19 | master | 525 | prefix = "strokedb/validations"
require "#{prefix}/errors"
require "#{prefix}/base_slot_validation"
require "#{prefix}/base"
require "#{prefix}/presence"
require "#{prefix}/kind"
# TODO: more validations
#require "#{prefix}/format"
#require "#{prefix}/uniqueness"
#require "#{prefix}/numericality"
# ...
module StrokeDB... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/util.rb | Ruby | mit | 19 | master | 404 | require 'time'
require 'strokedb/util/options_hash'
require 'strokedb/util/uuid'
require 'strokedb/util/class_factory'
require 'strokedb/util/require_one_of'
require 'strokedb/util/verify'
require 'strokedb/util/pluggable_module'
require 'strokedb/util/lazy_mapping_array'
require 'strokedb/util/lazy_mapping_hash'
modu... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories.rb | Ruby | mit | 19 | master | 1,044 | require 'strokedb/repositories/helpers'
require 'strokedb/repositories/abstract_repository'
require 'strokedb/repositories/abstract_async_repository'
require 'strokedb/repositories/metadata_hash_layer'
require 'strokedb/repositories/iterators'
require 'strokedb/repositories/tokyocabinet_repository'
__END__
Repositori... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views.rb | Ruby | mit | 19 | master | 227 | %w[
abstract_view
tokyocabinet_view
encoding_layer
default_key_codec
default_value_codec
heads_update_strategy
versions_update_strategy
pretty_finder_layer
].map do |view|
require "strokedb/views/#{view}"
end |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/console.rb | Ruby | mit | 19 | master | 254 | module StrokeDB
module Console
include ::GemConsole
help "no help yet"
def project_name
"StrokeDB #{::StrokeDB::VERSION}"
end
def setup
puts "TODO: some DB setup..."
end
end # Console
end # StrokeDB |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/associations/base.rb | Ruby | mit | 19 | master | 706 | module StrokeDB
module Associations
module Base
include Declarations
def register_association(association)
local_declarations(:associations, []) do |list|
association.setup(self)
list << association
end
end
def associations
inherite... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/associations/belongs_to.rb | Ruby | mit | 19 | master | 827 | module StrokeDB
module Associations
module BelongsTo
include Base
#
# belongs_to :slotname
#
def belongs_to(slotname, options = {})
register_association(Association.new({:slotname => slotname}.merge(options)))
end
class Association
attr_accessor :sl... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/associations/has_many.rb | Ruby | mit | 19 | master | 1,768 | module StrokeDB
module Associations
module HasMany
include Base
#
# class WebSite
# has_many :pages
# has_many :reviews, :as => :reviewable_object
# has_many :visits
# has_many :visitors, :through => :visits
#
def has_many(slotname, options = {}, &bl... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/document/nsurl.rb | Ruby | mit | 19 | master | 702 | module StrokeDB
module NSURL
include Declarations
NO_NSURL = Object.new.freeze
# Returns the most local NSURL or sets
# nsulr in the current scope.
def nsurl(nsurl = NO_NSURL)
return self.nsurl=(nsurl) if nsurl != NO_NSURL
inherited_declarations(:nsurl) do |all_nsurls|
... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/pretty_finder_layer.rb | Ruby | mit | 19 | master | 5,439 | module StrokeDB
module Views
module PrettyFinderLayer
DEFAULT_FIND_OPTIONS = {
:start_key => nil, # start search with a given prefix
:end_key => nil, # stop search with a given prefix
:limit => nil, # retrieve at most <N> entries
:offset => 0, # skip a... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/versions_update_strategy.rb | Ruby | mit | 19 | master | 237 | module StrokeDB
module Views
module VersionsUpdateStrategy
# Add pairs of new document version to index.
def update(repository, doc)
update_pairs(map(doc), nil)
end
end
end
end |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/heads_update_strategy.rb | Ruby | mit | 19 | master | 572 | module StrokeDB
module Views
module HeadsUpdateStrategy
Cprevious_version = "previous_version".freeze
# Updates index with a HEAD document version.
# Previous version's keys are removed.
def update(repository, doc)
previous_version = doc[Cprevious_version] or return update_... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/default_key_codec.rb | Ruby | mit | 19 | master | 4,457 | module StrokeDB
module Views
# DefaultKeyEncoder takes primitive types along with arrays and documents.
# Arrays are encoded recursively with items being space-separated.
# Note: core classes are extended by method which name is SHA1 UUID of the string:
# "StrokeDB::Core::Views::DefaultKeyEncoder"
... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/on_memory_view.rb | Ruby | mit | 19 | master | 3,142 | require 'tokyocabinet'
module StrokeDB
module Views
module OnMemoryView
attr_accessor :ram_list
# Opens a view with the options.
def open(options)
@ram_list = Array.new
nil
end
# Safely closes the view (closes file/connection or frees some resources).
... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/tokyocabinet_view.rb | Ruby | mit | 19 | master | 4,986 | require 'tokyocabinet'
module StrokeDB
module Views
module TokyoCabinetView
include TokyoCabinet
attr_accessor :tc_path, :tc_bdb, :tc_bdbcur
C = "".freeze
# Opens a view with the options.
def open(options)
OptionsHash!(options)
@tc_path = options.require... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/encoding_layer.rb | Ruby | mit | 19 | master | 1,022 | module StrokeDB
module Views
# Module requires the following methods to be defined in a view object:
#
# * encode_key(k)
# * decode_key(ek)
# * encode_value(v)
# * decode_value(ev)
#
# encode_* methods are called in the map(doc) method.
# decode_* methods are used in find(...) ... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/abstract_view.rb | Ruby | mit | 19 | master | 2,668 | module StrokeDB
module Views
# View API
# Document update process:
# * update(repository, doc) # new version of doc is passed as an argument
# * map(doc) # interesting document is used to produce key-value pairs
# * update_pairs(add_pairs, remove_pairs)... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/views/default_value_codec.rb | Ruby | mit | 19 | master | 223 | module StrokeDB
module Views
# Default codec just passes value by.
module DefaultValueCodec
def encode_value(v)
v
end
def decode_value(ev)
ev
end
end
end
end |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/on_memory_repository.rb | Ruby | mit | 19 | master | 1,829 | require 'tokyocabinet'
module StrokeDB
module Repositories
module OnMemoryRepository
attr_reader :uuid
attr_accessor :ram_versions, :ram_heads
# Opens a repository
def open(options)
@ram_versions = Hash.new
@ram_heads = Hash.new
@uuid = generate_uuid(nil)... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/iterators.rb | Ruby | mit | 19 | master | 539 | require 'tokyocabinet'
module StrokeDB
module Repositories
module Iterators
class Iterator
include Enumerable
attr_accessor :repo
def initialize(repo)
@repo = repo
end
end
class UuidsIterator < Iterator
def each(*args, &blk)
@repo.each... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/abstract_async_repository.rb | Ruby | mit | 19 | master | 534 | module StrokeDB
module Repositories
# TODO: finish this!
module AbstractAsyncRepository
# When database is opened
def on_open
end
# When database is closed
def on_close
end
# Receives a document by version
def on_get_version(doc)
end
... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/helpers.rb | Ruby | mit | 19 | master | 225 | require 'strokedb/repositories/helpers/abstract_helpers'
require 'strokedb/repositories/helpers/default_uuid_helpers'
require 'strokedb/repositories/helpers/hash_helper'
require 'strokedb/repositories/helpers/marshal_helper' |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/abstract_repository.rb | Ruby | mit | 19 | master | 2,545 | module StrokeDB
module Repositories
# Store operations: POST, GET, PUT, DELETE
# (CREATE, READ, UPDATE, DELETE)
#
# Different pieces of functionality are implemented as independent modules.
# You should create your own repository class and extend it with all
# the modul... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/metadata_hash_layer.rb | Ruby | mit | 19 | master | 720 | module StrokeDB
module Repositories
module MetadataHashLayer
Cuuid = "uuid".freeze
Cversion = "version".freeze
Cprevious_version = "previous_version".freeze
# Adds "version" fields to a hash before save.
# Returns version
def put(doc)
# Opera... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/tokyocabinet_repository.rb | Ruby | mit | 19 | master | 6,639 | require 'tokyocabinet'
module StrokeDB
module Repositories
module TokyoCabinetRepository
include TokyoCabinet
attr_reader :uuid
attr_reader :tc_path
attr_reader :tc_storage_path, :tc_heads_path, :tc_log_path
attr_reader :tc_storage, :tc_heads, :tc_log
REPO_UUI... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/view_updater.rb | Ruby | mit | 19 | master | 700 | require 'tokyocabinet'
module StrokeDB
module Repositories
# Wraps around store() method invoking views updates.
#
module ViewUpdater
attr_accessor :vu_views
def open(options)
OptionsHash! options
@vu_views = options["views"] || []
super(options)
end
... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/helpers/marshal_helper.rb | Ruby | mit | 19 | master | 267 | module StrokeDB
module Repositories
module MarshalHelper
def encode_doc(doc)
super(Marshal.dump(doc))
end
def decode_doc(encoded_doc)
Marshal.load(super(encoded_doc))
end
end
end # Repositories
end # StrokeDB |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/helpers/default_uuid_helpers.rb | Ruby | mit | 19 | master | 328 | module StrokeDB
module Repositories
module DefaultUuidHelpers
# TODO: use raw uuids, maybe add encode/decode methods for uuid
def generate_version(doc)
Util::random_uuid
end
def generate_uuid(doc = nil)
Util::random_uuid
end
end
end # Repositories
end # S... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/repositories/helpers/abstract_helpers.rb | Ruby | mit | 19 | master | 1,177 | module StrokeDB
module Repositories
module AbstractHelpers
# Version is generated before save action
def generate_version(doc)
end
# Must accept nil (for new documents)
def generate_uuid(doc = nil)
end
# Encodes document before serialization.
# Use supe... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/validations/presence.rb | Ruby | mit | 19 | master | 1,818 | module StrokeDB
module Validations
module Presence
# Validates that the specified attributes are not blank (as defined by Object#blank?).
#
# Configuration options:
# * <tt>message</tt> - A custom error message (default is: proc{|d,s| "#{s} can't be blank." })
# * <tt>boolean</tt> - ... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/validations/kind.rb | Ruby | mit | 19 | master | 1,263 | module StrokeDB
module Validations
module Kind
include Base
def validates_kind_of(slot, options = {})
# TODO: check the args
options = {:type => options} unless options.is_a? Hash
register_validation(Validation.new({:slotname => slot}.merge(options)))
end
alias val... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/validations/base_slot_validation.rb | Ruby | mit | 19 | master | 1,592 | module StrokeDB
module Validations
class BaseSlotValidation
DEFAULT_OPTIONS = {
:if => true,
:unless => false,
:allow => :__STROKEDB_NOTHING__ # funny way to define "very-very no value"
}
attr_accessor :slotname, :message, :if, :unless, :options
... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/validations/errors.rb | Ruby | mit | 19 | master | 1,586 | module StrokeDB
module Validations
class Errors
include Enumerable
attr_accessor :doc, :errors
def initialize(doc)
@doc = doc
@errors = []
end
# Add validation and message or Error object to the list of errors.
# Returns self.
def add(validation, me... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/validations/base.rb | Ruby | mit | 19 | master | 502 | module StrokeDB
module Validations
module Base
include Declarations
def register_validation(validation)
local_declarations(:validations, []) do |list|
list << validation
end
end
def validations
inherited_declarations(:validations) do |inherit... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/util/pluggable_module.rb | Ruby | mit | 19 | master | 715 | module StrokeDB
#
# module DatabaseAPI
# extend PluggableModule # <- magic starts here!
# include Validations
# include Associations
# end
#
# module Person
# include DatabaseAPI
# has_many :articles, :as => :author # this method is defined by PluggableModule
# end
#
# module Art... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/util/options_hash.rb | Ruby | mit | 19 | master | 1,164 | module StrokeDB
module Util
# Usage: OptionsHash!(options); options.require("required_option")
# 1. Lets access string and symbol keys interchangebly.
# 2. Lets specify required keys.
def OptionsHash(hash, defaults = nil)
OptionsHash!(hash.dup, defaults)
end
def OptionsHash!(hash, d... |
github | oleganza/strokedb-core | https://github.com/oleganza/strokedb-core | lib/strokedb/util/uuid.rb | Ruby | mit | 19 | master | 4,463 | module StrokeDB
module Util
begin
class FastUUID
require 'rubygems'
require 'inline'
C_FLAGS = `uuid-config --cflags`.chomp
LD_FLAGS = `uuid-config --ldflags --libs`.chomp
inline(:C) do |builder|
builder.add_compile_flags C_FLAGS
builder.add_li... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.