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
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
lib/api/api.rb
Ruby
mit
45
master
836
module API class API < Grape::API version 'v1', using: :path rescue_from ActiveRecord::RecordNotFound do rack_response({ 'message' => '404 Not found' }.to_json, 404) end rescue_from :all do |exception| # lifted from https://github.com/rails/rails/blob/master/ + # actionpack/lib/act...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
lib/tasks/fix_assets.rake
Ruby
mit
45
master
584
require 'ostruct' desc 'Creates a non-digest version of all the digest assets' task fix_assets: :environment do require 'fileutils' regexp = /(-{1}[a-z0-9]{32}*\.{1}){1}/ assets = File.join(Rails.root, 'public', Glitter::Application.config.assets.prefix, "**/*") Dir.glob(assets).each do |file| next if F...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/seeds.rb
Ruby
mit
45
master
347
# This file should contain all the record creation # needed to seed the database with its default values. # The data can then be loaded with the rake db:seed # (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Ema...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/schema.rb
Ruby
mit
45
master
8,383
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative sou...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20150906202159_change_polycomment_type.rb
Ruby
mit
45
master
207
class ChangePolycommentType < ActiveRecord::Migration def change change_column :comments, :polycomment_id, 'integer USING CAST(polycomment_id AS integer)' end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20150623095804_create_project_members.rb
Ruby
mit
45
master
277
class CreateProjectMembers < ActiveRecord::Migration def change create_table :project_members do |t| t.references :member t.references :gallery t.string :role t.timestamps end add_index :project_members, %w(member_id gallery_id) end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20150516155313_create_rating_averages.rb
Ruby
mit
45
master
315
class CreateRatingAverages < ActiveRecord::Migration def change create_table :rating_averages do |t| t.belongs_to :rateable, polymorphic: true t.float :avg, null: false t.belongs_to :rater t.timestamps end add_index :rating_averages, [:rateable_id, :rateable_type] end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20120418010134_devise_create_users.rb
Ruby
mit
45
master
1,534
class DeviseCreateUsers < ActiveRecord::Migration def change create_table(:users) do |t| ## Database authenticatable t.string :email, null: false, default: '' t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t....
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20140707114613_create_project_followers.rb
Ruby
mit
45
master
207
class CreateProjectFollowers < ActiveRecord::Migration def change create_table :project_followers do |t| t.references :follower t.references :following t.timestamps end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20140702150946_create_notifications.rb
Ruby
mit
45
master
247
class CreateNotifications < ActiveRecord::Migration def change create_table :notifications do |t| t.references :actor t.integer :action t.integer :object_type t.integer :object_id t.timestamps end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20131104164413_pull_table.rb
Ruby
mit
45
master
259
class PullTable < ActiveRecord::Migration def up create_table :pulltable do |t| t.string :desc t.string :status t.string :lastcommit t.integer :fork t.integer :parent t.timestamps end end def down end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20150516155311_create_rates.rb
Ruby
mit
45
master
392
class CreateRates < ActiveRecord::Migration def self.up create_table :rates do |t| t.belongs_to :rater t.belongs_to :rateable, polymorphic: true t.float :stars, null: false t.string :dimension t.timestamps end add_index :rates, :rater_id add_index :rates, [:rateable_id,...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20150516155312_cache_migration.rb
Ruby
mit
45
master
342
class CacheMigration < ActiveRecord::Migration def change create_table :rating_caches do |t| t.belongs_to :cacheable, polymorphic: true t.float :avg, null: false t.integer :qty, null: false t.string :dimension t.timestamps end add_index :rating_caches, [:cacheable_id, :cach...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20130908113252_create_table_comments.rb
Ruby
mit
45
master
310
class CreateTableComments < ActiveRecord::Migration def change create_table :comments do |t| t.text :body t.string :polycomment_id t.string :polycomment_type t.integer :user_id t.boolean :issue t.timestamps end add_index :comments, :polycomment_id end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20141011185537_create_project_follower.rb
Ruby
mit
45
master
250
class CreateProjectFollower < ActiveRecord::Migration def up create_table :project_followers do |t| t.integer :project_id t.integer :follower_id t.timestamps end end def down drop_table :project_followers end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20151004045235_create_annotations.rb
Ruby
mit
45
master
264
class CreateAnnotations < ActiveRecord::Migration def change create_table :annotations do |t| t.integer :user_id t.text :json t.string :text t.string :blob_id t.timestamps end add_index :annotations, :blob_id end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20140519045811_add_sessions_table.rb
Ruby
mit
45
master
281
class AddSessionsTable < ActiveRecord::Migration def change create_table :sessions do |t| t.string :session_id, null: false t.text :data t.timestamps end add_index :sessions, :session_id, unique: true add_index :sessions, :updated_at end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20140723225432_create_issues.rb
Ruby
mit
45
master
272
class CreateIssues < ActiveRecord::Migration def change create_table :issues do |t| t.text :title t.text :description t.references :project t.references :user t.integer :status t.integer :type t.timestamps end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20150309123545_create_delayed_jobs.rb
Ruby
mit
45
master
1,218
class CreateDelayedJobs < ActiveRecord::Migration def self.up create_table :delayed_jobs, force: true do |table| # Allows some jobs to jump to the front of the queue table.integer :priority, default: 0, null: false # Provides for retries, but still fail eventually table.integer :attempts, ...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20130712235126_add_auth_columns_to_users.rb
Ruby
mit
45
master
316
class AddAuthColumnsToUsers < ActiveRecord::Migration def change add_column :users, :identity_url, :string add_column :users, :username, :string add_column :users, :remember_token, :string add_index :users, :identity_url, unique: true add_index :users, :remember_token, unique: true end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20140518213805_add_devise_to_users.rb
Ruby
mit
45
master
1,766
class AddDeviseToUsers < ActiveRecord::Migration def self.up change_table(:users) do |t| ## Database authenticatable t.string :email, null: false, default: '' t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t....
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20130713185727_remove_author_from_comments.rb
Ruby
mit
45
master
252
class RemoveAuthorFromComments < ActiveRecord::Migration def up remove_column :comments, :author remove_column :comments, :email end def down add_column :comments, :author, :string add_column :comments, :email, :string end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20150718043105_create_keys.rb
Ruby
mit
45
master
282
class CreateKeys < ActiveRecord::Migration def change create_table :keys do |t| t.integer :user_id t.text :key t.string :title t.string :fingerprint t.timestamps end add_index :keys, [:user_id], name: 'index_keys_on_user_id' end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20140518204344_create_identities.rb
Ruby
mit
45
master
205
class CreateIdentities < ActiveRecord::Migration def change create_table :identities do |t| t.references :user t.string :provider t.string :uid t.timestamps end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20141011175312_rename_project_followers_and_add_index.rb
Ruby
mit
45
master
387
class RenameProjectFollowersAndAddIndex < ActiveRecord::Migration def up rename_table :project_followers, :relationships add_index :relationships, :follower_id add_index :relationships, :following_id end def down remove_index :relationships, :following_id remove_index :relationships, :followe...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20131104181756_create_pull_requests.rb
Ruby
mit
45
master
258
class CreatePullRequests < ActiveRecord::Migration def change create_table :pull_requests do |t| t.string :desc t.string :lastcommit t.string :status t.integer :parent t.integer :fork t.timestamps end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20120427235250_create_comments.rb
Ruby
mit
45
master
260
class CreateComments < ActiveRecord::Migration def change create_table :comments do |t| t.string :author t.string :author_url t.text :body t.integer :responding_to t.references :glimage t.timestamps end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
db/migrate/20140702153236_create_notification_statuses.rb
Ruby
mit
45
master
238
class CreateNotificationStatuses < ActiveRecord::Migration def change create_table :notification_statuses do |t| t.references :victim t.references :notification t.boolean :seen t.timestamps end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/comments_controller.rb
Ruby
mit
45
master
1,851
class CommentsController < ApplicationController before_filter :authenticate_user! before_action :get_context load_and_authorize_resource def index @comments = Comment.where( 'polycomment_type = ? and polycomment_id = ? and id > ?', params[:polycomment_type], params[:polycomment_id], ...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/identities_controller.rb
Ruby
mit
45
master
2,946
class IdentitiesController < ApplicationController skip_before_filter :verify_authenticity_token, only: :create before_filter :authenticate_user!, only: [:index, :destroy] # This is the current homepage def new redirect_to(dashboard_url) if user_signed_in? @allowedmethods = Identity.allowedmethods e...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/projects_controller.rb
Ruby
mit
45
master
12,328
class ProjectsController < ApplicationController before_filter :store_return_to before_filter :return_context, except: [:new, :create, :destroy, :index, ...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/issues_controller.rb
Ruby
mit
45
master
2,108
class IssuesController < ApplicationController before_filter :authenticate_user!, except: [:show, :index] before_action :get_context before_action :set_issue, only: [:show, :reopen, :close] authorize_resource def index @issues = find_issue(params[:state]) @issues = @issues.tagged_with(params[:tag]) i...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/relationships_controller.rb
Ruby
mit
45
master
1,291
class RelationshipsController < ApplicationController before_action :authenticate_user! before_action :identify_user def follow respond_err("You can't follow yourself") && return if current_user == @user @user.followers << current_user if @user.save! notify_users 'follow_user', @user.id, [@use...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/keys_controller.rb
Ruby
mit
45
master
804
class KeysController < ApplicationController before_filter :authenticate_user! def index @key = current_user.keys.new current_user.keys.delete @key # remove new key from collection @keys = current_user.keys end def create @key = current_user.keys.new(key_params) if @key.save redirec...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/application_controller.rb
Ruby
mit
45
master
3,166
require 'escape' class ApplicationController < ActionController::Base include Escape include SessionsHelper include PathsHelper protect_from_forgery with: :exception before_action :configure_devise_permitted_parameters, if: :devise_controller? before_action :return_current_user_projects rescue_from CanC...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/rater_controller.rb
Ruby
mit
45
master
267
class RaterController < ApplicationController def create if user_signed_in? obj = Project.find(params[:id]) obj.rate params[:score].to_f, current_user, params[:dimension] render json: true else render json: false end end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/project_members_controller.rb
Ruby
mit
45
master
1,295
class ProjectMembersController < ApplicationController before_filter :get_context, except: :destroy before_filter :authenticate_user! load_and_authorize_resource only: :destroy # GET /user_id/project_id/project_member def search @users = User.search(params[:find]) end # POST /user_id/project_id/proj...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/registrations_controller.rb
Ruby
mit
45
master
221
class RegistrationsController < Devise::RegistrationsController private def build_resource(*args) super return unless session[:omniauth] @user.applyomniauth(session[:omniauth]) @user.valid? end end
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/users_controller.rb
Ruby
mit
45
master
768
class UsersController < ApplicationController before_filter :authenticate_user!, except: [:show, :show_projects] # GET /username def show @user = User.find_by username: params[:id] render_404 unless @user end def list_followers @user = User.where(username: params[:id]).first @followers = @us...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/notifications_controller.rb
Ruby
mit
45
master
805
class NotificationsController < ApplicationController before_filter :authenticate_user! def count @count = NotificationStatus.where( victim: current_user, seen: [false, nil] ).count end def index @unseennotifications = NotificationStatus.where( victim: current_user, seen: [...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/search_controller.rb
Ruby
mit
45
master
492
class SearchController < ApplicationController # GET /user/project/search def project_search get_context @images, @directories = Gg::Search.find_files(params[:search], @project) @issues = Issue.search(params[:search]).where(project_id: @project.id) render 'project_show' end # GET /search def...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/controllers/annotations_controller.rb
Ruby
mit
45
master
2,995
class AnnotationsController < ApplicationController before_filter :authenticate_user!, except: :find_by_blobid load_resource except: [:find_by_blobid, :create] authorize_resource except: :find_by_blobid # GET /annotations/for_blob/:id def find_by_blobid @annotations = Annotation.where(blob_id: params[:i...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/mailers/notif_mailer.rb
Ruby
mit
45
master
364
class NotifMailer < ActionMailer::Base default from: 'glittergallerytest@gmail.com' def notif_email(notification, victim) @victim = victim @notification = notification @subjecttext = notification.actor.username + notification.messageverb + \ notification.objectname mail(to: @vic...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/helpers/paths_helper.rb
Ruby
mit
45
master
1,992
module PathsHelper def project_branches_path(project) branches_user_project_path project.user, project, project.uniqueurl end def project_issues_path(project) user_project_issues_path project.user, project, project.uniqueurl end def issue_path(issue) user_project_issue_path( issue.project....
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/helpers/projects_helper.rb
Ruby
mit
45
master
4,149
module ProjectsHelper # set the network graph, starting at root of the tree. # also includes deleted projects in the graph def nested_projects(roots, project) content_tag :ul, class: 'nested_projects' do roots.each do |root| user_link = link_to(root.user.username, "/#{root.user.username}") ...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/helpers/sessions_helper.rb
Ruby
mit
45
master
456
module SessionsHelper %w(facebook github linkedin twitter).each do |platform| define_method "#{platform}?" do if !Rails.env.production? true elsif ENV["#{platform.upcase}_KEY"] && ENV["#{platform.upcase}_SECRET"] true end end end def store_return_to session[:return_t...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/helpers/application_helper.rb
Ruby
mit
45
master
2,463
require 'base64' module ApplicationHelper # This is used to generate image tags based on raw data. # Currently used only when we are displaying history of images. # In the normal project#show - standard image linking is used. def data_image_tag(image, width, height, id_name = nil) "<img id='#{id_name}' sr...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/notification.rb
Ruby
mit
45
master
2,300
class Notification < ActiveRecord::Base belongs_to :actor, class_name: 'User' has_many :notification_statuses has_many :victims, through: :notification_statuses, class_name: 'User', foreign_key: 'victim_id' validates :action, :actor, :model_id, presence: true # TODO...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/user.rb
Ruby
mit
45
master
3,097
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :validatable, :rememberable has_many :identities has_many :projects has_many :comments ...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/identity.rb
Ruby
mit
45
master
356
class Identity < ActiveRecord::Base belongs_to :user validates_presence_of :uid, :provider validates_uniqueness_of :uid, scope: :provider def self.allowedmethods Glitter::Application.config.auth_methods end def self.from_omniauth(omniauth) where( provider: omniauth['provider'], uid: om...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/tree.rb
Ruby
mit
45
master
1,860
class Tree attr_accessor :project, :rugged_tree, :oid, :path def initialize(project, oid = nil, path = nil) @rugged_tree = project.branch_tree oid, path @project = project @oid = oid @path = path end # Returns an array containing 3 elements, the first is readme if it exists # second is an a...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/project.rb
Ruby
mit
45
master
13,735
class Project < ActiveRecord::Base include Sortable after_create :set_path, :init, :add_tags after_destroy :deletefiles before_save :set_uniqueurl belongs_to :user # many to many relationship between projects and project's followers has_many :project_followers, dependent: :destroy, foreign_key: 'project...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/comment.rb
Ruby
mit
45
master
456
class Comment < ActiveRecord::Base belongs_to :user validates :body, presence: true default_scope { order('comments.created_at ASC')} # based on ploycomment_type it deterimnes the user action def action case polycomment_type when 'project' 'project_comment' when 'blob' 'blob_comment'...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/project_follower.rb
Ruby
mit
45
master
754
class ProjectFollower < ActiveRecord::Base belongs_to :followed_project, foreign_key: 'project_id', class_name: 'Project' belongs_to :follower, foreign_key: 'follower_id', class_name: 'User' # Returns true if user is following project, false otherwise. def self.following?(user, project) !find_by(follower: ...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/key.rb
Ruby
mit
45
master
1,184
require 'digest/md5' class Key < ActiveRecord::Base belongs_to :user before_validation :strip_white_space, :generate_fingerprint validates :title, presence: true, length: { within: 0..255 } validates :key, presence: true, length: { within: 0..5000 }, format: { with: /\A(s...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/project_member.rb
Ruby
mit
45
master
1,078
class ProjectMember < ActiveRecord::Base belongs_to :member_project, foreign_key: 'gallery_id', class_name: 'Project' belongs_to :member, foreign_key: 'member_id', class_name: 'User' validates_uniqueness_of :member_id, scope: :gallery_id roles = %w(owner collaborator reporter) validates_inclusion_of :role, i...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/ability.rb
Ruby
mit
45
master
2,520
class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user (not logged in) if user.new_record? guest(user) else signed_in(user) write_acess(user) owner(user) end end # returns true if project is public or else it # checks if user is memb...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/issue.rb
Ruby
mit
45
master
1,615
class Issue < ActiveRecord::Base # This is to avoid conflict with the :type attribute self.inheritance_column = nil enum status: [:open, :closed] belongs_to :user belongs_to :project validates_presence_of :title, :description, :user, :project, :status acts_as_taggable validate :tag_list_inclusion ...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
app/models/concerns/sortable.rb
Ruby
mit
45
master
2,113
# == Sortable concern # # find project on basis of given option # most methods use table join (may need refactoring) module Sortable extend ActiveSupport::Concern included do scope :find_most_active, lambda { joins("LEFT OUTER JOIN comments ON comments.polycomment_id = CAST(projects.id AS v...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/application.rb
Ruby
mit
45
master
1,042
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) module Glitter class Application < Rails::Application # Settings in config/environments/* take...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/unicorn.rb
Ruby
mit
45
master
931
# Set the working application directory # working_directory "/path/to/your/app" app_path = File.expand_path(File.dirname(__FILE__) + '/..') working_directory app_path # Unicorn PID file location pid app_path + "/tmp/pids/unicorn.pid" # Unicorn socket listen app_path + '/tmp/sockets/unicorn.sock', backlog: 64 liste...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/routes.rb
Ruby
mit
45
master
6,459
require 'api/api' Glitter::Application.routes.draw do # handles git-* requests mount Grack::Bundle.new({ git_path: Glitter::Application.config.git_path, project_root: Glitter::Application.config.repo_path, upload_pack: true, receive_pack: true }), at: '/', constraints: lambda { |request| /[...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/initializers/omniauth.rb
Ruby
mit
45
master
838
require 'omniauth/openid' require 'openid/store/filesystem' OmniAuth.config.logger = Rails.logger OmniAuth.logger.progname = "omniauth" Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, ENV["FACEBOOK_KEY"], ENV["FACEBOOK_SECRET"] if Glitter::Application.config.auth_methods.include?(:fa...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/initializers/devise.rb
Ruby
mit
45
master
12,540
# 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 invalid all existing # confirmat...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/environments/production.rb
Ruby
mit
45
master
3,397
Glitter::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 memory, allowing both thread web serv...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/environments/development.rb
Ruby
mit
45
master
1,430
Glitter::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 don't have to restart the web s...
github
glittergallery/GlitterGallery
https://github.com/glittergallery/GlitterGallery
config/environments/test.rb
Ruby
mit
45
master
1,560
Glitter::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # 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 s...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
Rakefile
Ruby
mit
45
master
266
require 'rake/testtask' require 'rubygems/tasks' task :default => [:''] desc "Run all tests" task :'' do Rake::TestTask.new("alltests") do |t| t.test_files = Dir.glob(File.join("test", "**", "*_test.rb")) end task("alltests").execute end Gem::Tasks.new
github
robmiller/varnisher
https://github.com/robmiller/varnisher
varnisher.gemspec
Ruby
mit
45
master
1,095
$:.push File.expand_path("../lib", __FILE__) require "varnisher/version" Gem::Specification.new do |s| s.name = "varnisher" s.version = Varnisher::VERSION s.date = Date.today.strftime("%Y-%m-%d") s.summary = "Helpful tools for working with Varnish caches" s.description = "Some tools that make working with t...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
test/domainpurger_test.rb
Ruby
mit
45
master
540
require_relative 'test_helper' require 'letters' describe Varnisher::DomainPurger do before do Varnisher.options = { 'quiet' => true } @purger = Varnisher::DomainPurger.new('www.example.com') end it "it successfully purges a domain" do stub_request(:domainpurge, 'http://www.example.com/') .t...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
test/pagepurger_test.rb
Ruby
mit
45
master
1,882
require_relative 'test_helper' describe Varnisher::PagePurger do before do Varnisher.options = { 'quiet' => true } stub_request(:any, %r(http://www\.example\.com/.*)) .to_return(:status => 200) stub_request(:get, 'http://www.example.com/foo') .to_return( :body => File.new(File.dirna...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
test/spider_test.rb
Ruby
mit
45
master
1,692
require_relative 'test_helper' describe Varnisher::Spider do before do stub_request(:get, 'http://www.example.com/foo') .to_return( :body => File.new(File.dirname(__FILE__) + "/data/spider.html"), :status => 200 ) Varnisher.options = { 'quiet' => true } @spider = Varnisher::...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
test/purger_test.rb
Ruby
mit
45
master
1,180
require_relative 'test_helper' describe Varnisher::Purger do it "successfully purges a URL" do stub_request(:purge, 'http://www.example.com/foo') .to_return(:status => 200) purger = Varnisher::Purger.new('PURGE', '/foo', 'www.example.com') assert purger.send end it "successfully purges a doma...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
lib/varnisher.rb
Ruby
mit
45
master
1,645
require 'net/http' require_relative 'varnisher/urls' require_relative 'varnisher/spider' require_relative 'varnisher/purger' require_relative 'varnisher/domainpurger' require_relative 'varnisher/pagepurger' require 'logger' # This module is a namespace for our main functionality: # # * {Varnisher::Spider} # * {Varni...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
lib/varnisher/urls.rb
Ruby
mit
45
master
2,532
require "forwardable" module Varnisher # A collection for URLs, that exposes some useful behaviour (like # selecting only URLs that have a given hostname, or converting # relative URLs to absolute). class Urls include Enumerable extend Forwardable # Given an array of URLs (either strings or URI ob...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
lib/varnisher/purger.rb
Ruby
mit
45
master
2,721
module Varnisher module HTTP # Adds the custom verb "PURGE" to the Net::HTTP library, allowing calls # to: # # Net::HTTP.new(host, port).request(Varnisher::HTTP::Purge.new(uri)) class Purge < Net::HTTPRequest METHOD = "PURGE" REQUEST_HAS_BODY = false RESPONSE_HAS_BODY = false...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
lib/varnisher/domainpurger.rb
Ruby
mit
45
master
890
require 'net/http' module Varnisher # Purges an entire domain from the Varnish cache. # # This requires a special bit of VCL in your Varnish configuration: # # if ( req.request == "DOMAINPURGE" ) { # if ( client.ip ~ auth ) { # ban("obj.http.x-host == " + req.http.host); # err...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
lib/varnisher/pagepurger.rb
Ruby
mit
45
master
4,474
require 'rubygems' require 'nokogiri' require 'net/http' require 'parallel' module Varnisher # Purges an individual URL from Varnish. class PagePurger attr_reader :urls # A bash at an abstract representation of resources. All you need # is a selector, and what attribute to select from the matched ...
github
robmiller/varnisher
https://github.com/robmiller/varnisher
lib/varnisher/spider.rb
Ruby
mit
45
master
5,566
require 'rubygems' require 'nokogiri' require 'net/http' require 'parallel' module Varnisher # Crawls a website, following links that it finds along the way, until # it either runs out of pages to visit or reaches the limit of pages # that you impose on it. # # The spider is multithreaded, which means that o...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
rubytus.gemspec
Ruby
mit
45
master
1,187
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rubytus/version' Gem::Specification.new do |spec| spec.name = "rubytus" spec.version = Rubytus::VERSION spec.authors = ["Alif Rachmawadi"] spec.email = ["subo...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
test/test_helper.rb
Ruby
mit
45
master
3,027
require 'simplecov' require 'coveralls' require 'minitest' require 'minitest/autorun' require 'minitest/pride' require 'rr' require 'goliath/test_helper' require 'rubytus/error' require 'rubytus/helpers' require 'rubytus/common' require 'rubytus/storage' require 'pry' require 'base64' SimpleCov.formatter = SimpleCov::...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
test/rubytus/test_command_runner.rb
Ruby
mit
45
master
2,377
require 'test_helper' require 'fileutils' require 'stringio' class TestCommandRunner < MiniTest::Test include Rubytus::Mock include Goliath::TestHelper def setup @err = Proc.new { assert false, 'API request failed' } end def teardown remove_data_dir end def test_setup_exit_for_invalid_data_dir...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
test/rubytus/test_helpers.rb
Ruby
mit
45
master
1,476
require 'test_helper' require 'fileutils' require 'stringio' class TestHelpers < MiniTest::Test include Rubytus::Mock def setup @config = Rubytus::Mock::Config.new end def teardown remove_data_dir end def test_validates_data_dir dir = @config.validates_data_dir(data_dir) assert File.dire...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
test/rubytus/test_storage.rb
Ruby
mit
45
master
2,458
require 'test_helper' require 'rubytus/storage' require 'rubytus/helpers' class TestStorage < MiniTest::Test include Rubytus::Mock include Rubytus::Helpers include Rubytus::StorageHelper def setup options = default_options validates_data_dir(options[:data_dir]) @uid = uid @storage = Rubyt...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
test/rubytus/test_command.rb
Ruby
mit
45
master
10,936
require 'test_helper' require 'rubytus/command' require 'rubytus/info' class TestRubytusCommand < MiniTest::Test include Rubytus::Mock include Rubytus::StorageHelper include Goliath::TestHelper def setup @err = Proc.new { assert false, 'API request failed' } end def protocol_header { 'TUS-Resumab...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/request.rb
Ruby
mit
45
master
2,208
require 'rubytus/constants' require 'rubytus/common' module Rubytus class Request include Rubytus::Constants include Rubytus::Common def initialize(env) @env = env end def get?; request_method == 'GET'; end def post?; request_method == 'POST'; end def head?; request_meth...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/api.rb
Ruby
mit
45
master
1,991
require 'goliath' require 'goliath/constants' require 'rubytus/constants' require 'rubytus/request' require 'rubytus/helpers' require 'rubytus/error' require 'stringio' module Rubytus class API < Goliath::API include Goliath::Constants include Rubytus::Constants include Rubytus::Helpers def on_heade...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/helpers.rb
Ruby
mit
45
master
4,003
require 'rubytus/constants' require 'rubytus/common' require 'rubytus/error' module Rubytus module Helpers include Rubytus::Constants include Rubytus::Common def prepare_headers(env, headers) request = Rubytus::Request.new(env) env['api.headers'].merge!(handle_cors(request, headers)) ...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/constants.rb
Ruby
mit
45
master
970
module Rubytus module Constants RESOURCE_UID_REGEX = /^([a-z0-9]{32})$/ BASE_PATH_REGEX = /^(\/[a-zA-Z0-9\-_]+\/)$/ RESUMABLE_CONTENT_TYPE = 'application/offset+octet-stream' ENV_STORAGE = 'TUSD_STORAGE' ENV_DATA_DIR = 'TUSD_DATA_DIR' ENV_BASE_PATH = ...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/command.rb
Ruby
mit
45
master
1,782
require 'rubytus/api' require 'rubytus/request' require 'rubytus/error' require 'rubytus/storage' require 'rubytus/middlewares/tus_barrier' require 'rubytus/middlewares/storage_barrier' module Rubytus class Command < API include Constants include StorageHelper use Middlewares::TusBarrier use Middlew...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/info.rb
Ruby
mit
45
master
577
require 'json' module Rubytus class Info < Hash def initialize(args = {}) self['Offset'] = args[:offset] || 0 self['EntityLength'] = args[:entity_length] || 0 self['Meta'] = args[:meta] || nil end def offset=(value) self['Offset'] = value.to_i en...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/storage.rb
Ruby
mit
45
master
2,829
require 'json' require 'rubytus/info' require 'rubytus/error' require 'pathname' module Rubytus module StorageHelper def validates_data_dir(data_dir) if Pathname.new(data_dir).relative? data_dir = File.join(ENV['PWD'], data_dir) end begin unless File.directory?(data_dir) ...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/middlewares/tus_barrier.rb
Ruby
mit
45
master
1,180
module Rubytus module Middlewares class TusBarrier include Rubytus::Constants include Goliath::Rack::AsyncMiddleware def post_process(env, status, headers, body) request = Rubytus::Request.new(env) if request.collection? unless request.options? || request.post? ...
github
picocandy/rubytus
https://github.com/picocandy/rubytus
lib/rubytus/middlewares/storage_barrier.rb
Ruby
mit
45
master
1,040
require 'rubytus/error' module Rubytus module Middlewares class StorageBarrier include Rubytus::Constants include Goliath::Rack::AsyncMiddleware def post_process(env, status, headers, body) status = STATUS_OK action = env['api.action'] storage = env['api.options'][:st...
github
kylewlacy/timerizer
https://github.com/kylewlacy/timerizer
timerizer.gemspec
Ruby
mit
45
master
650
require_relative "./lib/timerizer/version" Gem::Specification.new do |gem| gem.name = "timerizer" gem.version = Timerizer::VERSION gem.license = "MIT" gem.summary = "Rails time helpers... without the Rails" gem.description = "A simple set of Rails-like time helpers" gem.authors = ["Kyle Lacy"] gem.email ...
github
kylewlacy/timerizer
https://github.com/kylewlacy/timerizer
lib/timerizer.rb
Ruby
mit
45
master
6,426
require "date" require_relative "./timerizer/core" # {Time} class monkey-patched with {Timerizer::Duration} support. class Time # Represents an error where two times were expected to be in the future, but were in the past. # @see #until class TimeIsInThePastError < ArgumentError; end # Represents an error wher...
github
kylewlacy/timerizer
https://github.com/kylewlacy/timerizer
lib/timerizer/wall_clock.rb
Ruby
mit
45
master
7,613
module Timerizer # Represents a time, but not a date. '7:00 PM' would be an example of a WallClock object class WallClock # Represents an error where an invalid meridiem was passed to WallClock. # @see #new class InvalidMeridiemError < ArgumentError; end # Represents an error where a time beyond 24 ...
github
kylewlacy/timerizer
https://github.com/kylewlacy/timerizer
lib/timerizer/duration.rb
Ruby
mit
45
master
29,775
module Timerizer # Represents a duration of time. For example, '5 days', '4 years', and # '5 years, 4 hours, 3 minutes, 2 seconds' are all durations conceptually. # # A `Duration` is made up of two different primitive units: seconds and # months. The philosphy behind this is this: every duration of time # c...
github
kylewlacy/timerizer
https://github.com/kylewlacy/timerizer
lib/timerizer/duration/rounded_time.rb
Ruby
mit
45
master
6,721
# frozen_string_literal: true require 'forwardable' module Timerizer class Duration # Wraps rounding a {Timerizer::Duration} to the nearest value by the number # of "places", which are customary time units (seconds, minutes, hours, # days, months, years, etc; decades and weeks are not included). # ...
github
kylewlacy/timerizer
https://github.com/kylewlacy/timerizer
spec/spec_helper.rb
Ruby
mit
45
master
301
require "bundler/setup" require "timerizer" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" config.expose_dsl_globally = false config.expect_with :rspec do |c| c.syntax = :expect end end