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 | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/others_test.rb | Ruby | mit | 300 | main | 870 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
class AdminOthersTest < LokkaTestCase
include AdminLoginContext
def test_get_admin_index_shows_dashboard
get '/admin/'
assert last_response.ok?
end
def test_get_admin_plugins_shows_index
... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/tags_test.rb | Ruby | mit | 300 | main | 1,385 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
require_relative '../../support/custom_assertions'
class AdminTagsTest < LokkaTestCase
include AdminLoginContext
include CustomAssertions::NotFoundPage
def setup
super
@tag = create(:tag)
... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/pages_test.rb | Ruby | mit | 300 | main | 2,059 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
require_relative '../../support/custom_assertions'
class AdminPagesTest < LokkaTestCase
include AdminLoginContext
include CustomAssertions::NotFoundPage
def setup
super
@page = create(:page)... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/attachments_test.rb | Ruby | mit | 300 | main | 1,176 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
class AdminAttachmentsTest < LokkaTestCase
include AdminLoginContext
def setup_s3_stub
Aws.config[:s3] = {
stub_responses: {
list_buckets: {},
put_object: {}
}
}
... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/snippets_test.rb | Ruby | mit | 300 | main | 1,903 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
require_relative '../../support/custom_assertions'
class AdminSnippetsTest < LokkaTestCase
include AdminLoginContext
include CustomAssertions::NotFoundPage
def setup
super
@snippet = create(... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/categories_test.rb | Ruby | mit | 300 | main | 2,458 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
require_relative '../../support/custom_assertions'
class AdminCategoriesTest < LokkaTestCase
include AdminLoginContext
include CustomAssertions::NotFoundPage
def setup
super
@category = crea... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/themes_test.rb | Ruby | mit | 300 | main | 497 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
class AdminThemesTest < LokkaTestCase
include AdminLoginContext
def test_get_admin_themes_shows_index
get '/admin/themes'
assert last_response.ok?
assert_match 'curvy', last_response.body
... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/users_test.rb | Ruby | mit | 300 | main | 2,389 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
require_relative '../../support/custom_assertions'
class AdminUsersTest < LokkaTestCase
include AdminLoginContext
include CustomAssertions::NotFoundPage
def setup
super
@user = User.first
... |
github | lokka/lokka | https://github.com/lokka/lokka | test/integration/admin/field_names_test.rb | Ruby | mit | 300 | main | 1,356 | # frozen_string_literal: true
require_relative '../../test_helper'
require_relative '../../support/admin_helper'
require_relative '../../support/custom_assertions'
class AdminFieldNamesTest < LokkaTestCase
include AdminLoginContext
include CustomAssertions::NotFoundPage
def setup
super
@field_name = cr... |
github | lokka/lokka | https://github.com/lokka/lokka | test/support/custom_assertions.rb | Ruby | mit | 300 | main | 856 | # frozen_string_literal: true
module CustomAssertions
module NotFoundPage
def assert_not_found_page
assert_equal 404, last_response.status
end
end
module LoginFailed
def assert_login_failed
refute last_response.redirect?, 'Expected no redirect'
assert_match '<body class="admin_logi... |
github | lokka/lokka | https://github.com/lokka/lokka | test/support/admin_helper.rb | Ruby | mit | 300 | main | 261 | # frozen_string_literal: true
require_relative 'integration_helper'
module AdminLoginContext
include InSiteContext
def setup
super
create(:user, name: 'test')
post '/admin/login', name: 'test', password: 'test'
follow_redirect!
end
end |
github | lokka/lokka | https://github.com/lokka/lokka | db/seeds.rb | Ruby | mit | 300 | main | 1,942 | created_at = updated_at = '2011-01-09T05:39:08+09:00'
Site.create!(title: 'Test Site',
description: 'description...',
dashboard: %q(<p>Welcome to Lokka!</p><p>To post a new article, choose "<a href=""/admin/posts/new"">New</a>" under "Posts" on the menu to the left. To change the title of the... |
github | lokka/lokka | https://github.com/lokka/lokka | db/migrate/002_add_api_token_to_users.rb | Ruby | mit | 300 | main | 211 | # frozen_string_literal: true
class AddApiTokenToUsers < ActiveRecord::Migration[8.1]
def change
add_column :users, :api_token, :string, limit: 64
add_index :users, :api_token, unique: true
end
end |
github | lokka/lokka | https://github.com/lokka/lokka | db/migrate/001_create_tables.rb | Ruby | mit | 300 | main | 2,904 | # frozen_string_literal: true
class CreateTables < ActiveRecord::Migration[8.1]
def change
create_table :sites do |t|
t.string :title, limit: 255
t.string :description, limit: 255
t.text :dashboard
t.string :theme, limit: 64
t.integer :per_page
t.string :default_sort, limit: 2... |
github | lokka/lokka | https://github.com/lokka/lokka | config/puma.rb | Ruby | mit | 300 | main | 412 | # frozen_string_literal: true
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
threads min_threads_count, max_threads_count
port ENV.fetch('PORT', 3000)
environment ENV.fetch('RACK_ENV', 'development')
pidfile ENV.fetch('PIDFILE', 'tmp/pi... |
github | nov/json-jwt | https://github.com/nov/json-jwt | json-jwt.gemspec | Ruby | mit | 299 | main | 1,262 | Gem::Specification.new do |gem|
gem.name = 'json-jwt'
gem.version = File.read('VERSION')
gem.authors = ['nov matake']
gem.email = ['nov@matake.jp']
gem.homepage = 'https://github.com/nov/json-jwt'
gem.summary = %q{JSON Web Token and its family (JSON Web Signature, JSON Web Encryp... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/spec_helper.rb | Ruby | mit | 299 | main | 341 | require 'simplecov'
SimpleCov.start do
add_filter 'spec'
end
require 'rspec'
require 'rspec/its'
require 'json/jwt'
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
end
require 'helpers/sign_key_fixture_helper'
require 'helpers/nimbus_spec_helper'
require 'hel... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/json/jwt_spec.rb | Ruby | mit | 299 | main | 16,323 | require 'spec_helper'
describe JSON::JWT do
let(:jwt) { JSON::JWT.new claims }
let(:jws) do
jwt.alg = :HS256
jws = JSON::JWS.new jwt
jws.signature = 'signature'
jws
end
let(:claims) do
{
iss: 'joe',
exp: 1300819380,
'http://example.com/is_root' => true
}.with_indiffere... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/json/jwe_spec.rb | Ruby | mit | 299 | main | 8,696 | require 'spec_helper'
describe JSON::JWE do
let(:private_key_path) { der_file_path 'rsa/private_key' }
describe '#content_type' do
let(:jwe) { JSON::JWE.new 'hello' }
it do
jwe.content_type.should == 'application/jose'
end
end
describe 'encrypt!' do
shared_examples_for :unexpected_algor... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/json/jws_spec.rb | Ruby | mit | 299 | main | 16,556 | require 'spec_helper'
describe JSON::JWS do
let(:alg) { :none }
let(:jwt) do
_jwt_ = JSON::JWT.new claims
_jwt_.alg = alg
_jwt_
end
let(:jwt_blank) do
_jwt_ = JSON::JWT.new nil
_jwt_.alg = alg
_jwt_
end
let(:jws) { JSON::JWS.new jwt }
let(:jws_blank) { JSON::JWS.new jwt_blank }
... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/json/jwk_spec.rb | Ruby | mit | 299 | main | 5,849 | require 'spec_helper'
describe JSON::JWK do
describe '#initialize' do
let(:jwk) { JSON::JWK.new key }
subject { jwk }
shared_examples_for :jwk_with_kid do
it { should be_instance_of JSON::JWK }
describe 'kid' do
subject { jwk[:kid] }
it { should == jwk.thumbprint }
end
... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/json/jwk/jwkizable_spec.rb | Ruby | mit | 299 | main | 1,446 | require 'spec_helper'
describe JSON::JWK::JWKizable do
describe '#to_jwk' do
subject { key.to_jwk }
shared_examples_for :jwkizable_as_public do
it { should be_instance_of JSON::JWK }
it { should include *public_key_attributes.collect(&:to_s) }
it { should_not include *private_key_attribute... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/json/jwk/set_spec.rb | Ruby | mit | 299 | main | 1,583 | require 'spec_helper'
describe JSON::JWK::Set do
let(:jwk) { public_key.to_jwk }
let(:set) { JSON::JWK::Set.new jwk }
describe '#content_type' do
it do
set.content_type.should == 'application/jwk-set+json'
end
end
context 'when single JWK given' do
subject { JSON::JWK::Set.new jwk }
i... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/json/jwk/set/fetcher_spec.rb | Ruby | mit | 299 | main | 6,979 | require 'spec_helper'
describe JSON::JWK::Set::Fetcher do
describe JSON::JWK::Set::Fetcher::Cache do
let(:something) { SecureRandom.hex(32) }
it 'just execute given block' do
expect(
subject.fetch('cache_key') do
something
end
).to eq something
end
end
describe... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/helpers/nimbus_spec_helper.rb | Ruby | mit | 299 | main | 357 | module NimbusSpecHelper
module_function
def setup
nimbus_path = File.expand_path(
File.join(
File.dirname(__FILE__),
'json-jwt-nimbus',
'nimbus_jwe.rb'
)
)
if File.exist? nimbus_path
require nimbus_path
end
end
def nimbus_available?
defined? Nimbus... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/helpers/sign_key_fixture_helper.rb | Ruby | mit | 299 | main | 1,340 | module SignKeyFixtureHelper
def shared_secret
'shared-secret'
end
def pem_file(file_name)
File.new pem_file_path(file_name)
end
def pem_file_path(file_name)
File.join(
File.dirname(__FILE__),
"../fixtures/#{file_name}.pem"
)
end
def der_file_path(file_name)
File.join(
... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/helpers/webmock_helper.rb | Ruby | mit | 299 | main | 923 | require 'webmock/rspec'
module WebMockHelper
def mock_json(method, endpoint, response_file, options = {})
stub_request(method, endpoint).to_return(
response_for(response_file, options)
)
result = yield
a_request(method, endpoint).should have_been_made.once
result
end
def request_to(end... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/interop/with_rfc_example_spec.rb | Ruby | mit | 299 | main | 726 | require 'spec_helper'
describe 'interop' do
describe 'with RFC Example' do
describe 'JWK Thubmprint' do
subject do
JSON::JWK.new(
kty: :RSA,
n: '0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/interop/with_nimbus_jose_spec.rb | Ruby | mit | 299 | main | 3,033 | require 'spec_helper'
describe 'interop' do
describe 'with Nimbus JOSE' do
if NimbusSpecHelper.nimbus_available?
context 'JWE' do
let(:shared_key) { SecureRandom.hex 16 } # default shared key is too short
let(:private_key_path) { der_file_path 'rsa/private_key' }
describe 'encrypt!... |
github | nov/json-jwt | https://github.com/nov/json-jwt | spec/interop/with_jsrsasign_spec.rb | Ruby | mit | 299 | main | 1,724 | require 'spec_helper'
describe 'interop' do
describe 'with jsrsasign' do
context 'JWS' do
let(:public_key) do
pem = <<~PEM
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEoBUyo8CQAFPeYPvv78ylh5MwFZjT
CLQeb042TjiMJxG+9DLFmRSMlBQ9T/RsLLc+PmpB1+7yPAR+oR5gZn... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jwt.rb | Ruby | mit | 299 | main | 4,311 | require 'openssl'
require 'base64'
require 'faraday'
require 'faraday/follow_redirects'
require 'active_support'
require 'active_support/core_ext'
require 'json/jose'
module JSON
class JWT < ActiveSupport::HashWithIndifferentAccess
VERSION = ::File.read(
::File.join(::File.dirname(__FILE__), '../../VERSION... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jwe.rb | Ruby | mit | 299 | main | 9,694 | require 'securerandom'
require 'bindata'
require 'aes_key_wrap'
module JSON
class JWE
class InvalidFormat < JWT::InvalidFormat; end
class DecryptionFailed < JWT::VerificationFailed; end
class UnexpectedAlgorithm < JWT::UnexpectedAlgorithm; end
NUM_OF_SEGMENTS = 5
include JOSE
attr_accessor... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jws.rb | Ruby | mit | 299 | main | 6,945 | module JSON
class JWS < JWT
class InvalidFormat < JWT::InvalidFormat; end
class VerificationFailed < JWT::VerificationFailed; end
class UnexpectedAlgorithm < JWT::UnexpectedAlgorithm; end
NUM_OF_SEGMENTS = 3
attr_writer :signature_base_string
def initialize(jwt)
update jwt
end
... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jose.rb | Ruby | mit | 299 | main | 1,913 | require 'active_support/security_utils'
module JSON
module JOSE
extend ActiveSupport::Concern
included do
extend ClassMethods
register_header_keys :alg, :jku, :jwk, :x5u, :x5t, :x5c, :kid, :typ, :cty, :crit
# NOTE: not used anymore in this gem, but keeping in case developers are calling i... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jwk.rb | Ruby | mit | 299 | main | 4,209 | module JSON
class JWK < ActiveSupport::HashWithIndifferentAccess
class UnknownAlgorithm < JWT::Exception; end
def initialize(params = {}, ex_params = {})
case params
when OpenSSL::PKey::RSA, OpenSSL::PKey::EC
super params.to_jwk(ex_params)
when OpenSSL::PKey::PKey
raise Unkn... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jwk/jwkizable.rb | Ruby | mit | 299 | main | 2,277 | module JSON
class JWK
module JWKizable
module RSA
def to_jwk(ex_params = {})
params = {
kty: :RSA,
e: Base64.urlsafe_encode64(e.to_s(2), padding: false),
n: Base64.urlsafe_encode64(n.to_s(2), padding: false)
}.merge ex_params
if priva... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jwk/set.rb | Ruby | mit | 299 | main | 732 | module JSON
class JWK
class Set < Array
class KidNotFound < JWT::Exception; end
def initialize(*jwks)
jwks = if jwks.first.is_a?(Hash) && (keys = jwks.first.with_indifferent_access[:keys])
keys
else
jwks
end
jwks = Array(jwks).flatten.collect do |jw... |
github | nov/json-jwt | https://github.com/nov/json-jwt | lib/json/jwk/set/fetcher.rb | Ruby | mit | 299 | main | 2,381 | module JSON
class JWK
class Set
module Fetcher
class UnexpectedFormat < JWT::Exception; end
class Cache
def fetch(cache_key, options = {})
yield
end
def delete(cache_key, options = {}); end
end
def self.logger
@@logger
... |
github | seomoz/qless | https://github.com/seomoz/qless | Gemfile | Ruby | mit | 299 | master | 512 | source "http://rubygems.org"
# Specify your gem's dependencies in qless.gemspec
gemspec
group :extras do
gem 'debugger', :platform => :mri_19
end
group :development do
gem 'byebug', :platforms => [:ruby_20, :ruby_21]
gem 'cane', :platforms => [:ruby_20, :ruby_21]
gem 'poltergeist', '~> 1.0.0'
gem 'pry'
g... |
github | seomoz/qless | https://github.com/seomoz/qless | qless.gemspec | Ruby | mit | 299 | master | 1,824 | # -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'qless/version'
Gem::Specification.new do |s|
s.name = 'qless'
s.version = Qless::VERSION
s.licenses = ['MIT']
s.authors = ['Dan Lecocq', 'Myron Marston']
s.email = ['dan@moz.com', 'myron@moz.com']
... |
github | seomoz/qless | https://github.com/seomoz/qless | Vagrantfile | Ruby | mit | 299 | master | 799 | # Encoding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
# http://docs.vagrantup.com/v2/
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.hostname = 'qless'
config.ssh.forward_agent = true
# Part of provisioning is cloning a coupl... |
github | seomoz/qless | https://github.com/seomoz/qless | Rakefile | Ruby | mit | 299 | master | 4,553 | #!/usr/bin/env rake
require 'bundler/gem_helper'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--profile --format progress]
t.ruby_opts = "-Ispec -rsimplecov_setup"
end
# TODO: bump this up as test coverage increases. It was 90.29 when I... |
github | seomoz/qless | https://github.com/seomoz/qless | utils/qless-growl.gemspec | Ruby | mit | 299 | master | 772 | # -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
require 'qless/version'
Gem::Specification.new do |s|
s.name = 'qless-growl'
s.version = Qless::VERSION
s.authors = ['Dan Lecocq']
s.email = ['dan@seomoz.org']
s.homepage = 'http://github.com/seomoz/qles... |
github | seomoz/qless | https://github.com/seomoz/qless | utils/qless-campfire.gemspec | Ruby | mit | 299 | master | 790 | # -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
require 'qless/version'
Gem::Specification.new do |s|
s.name = 'qless-campfire'
s.version = Qless::VERSION
s.authors = ['Dan Lecocq']
s.email = ['dan@seomoz.org']
s.homepage = 'http://github.com/seomoz/q... |
github | seomoz/qless | https://github.com/seomoz/qless | utils/dev/qless_web_dev_helper.rb | Ruby | mit | 299 | master | 772 | module QlessWebDevHelper
class NoPerformJob; end;
class << self
def create_mock_jobs(client)
queues = []
num_queues = 5
num_queues.times { |i|
random_queue_name = 'foo-' + random_jid
queues << client.queues[random_queue_name]
}
num_jobs = 100
num_jobs.times ... |
github | seomoz/qless | https://github.com/seomoz/qless | conf/console.rb | Ruby | mit | 299 | master | 311 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'irb/completion'
QLESS_CONSOLE = true
require 'qless'
module StdoutLogger
def logger
@logger ||= Logger.new($stdout)
end
end
# Load everything!
Dir["./lib/**/*.rb"].sort.each do |f|
require f.gsub("./lib/", "")
end
require 'pp' |
github | seomoz/qless | https://github.com/seomoz/qless | spec/simplecov_setup.rb | Ruby | mit | 299 | master | 363 | # Encoding: utf-8
require 'simplecov'
SimpleCov.start do
add_filter '/spec'
add_filter '/bundle'
add_filter '/lib/qless/test_helpers/worker_helpers'
end
SimpleCov.at_exit do
path = File.join(SimpleCov.coverage_path, 'coverage_percent.txt')
File.open(path, 'w') do |f|
f.write SimpleCov.result.covered_pe... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/spec_helper.rb | Ruby | mit | 299 | master | 2,863 | # Encoding: utf-8
begin
# use `bundle install --standalone' to get this...
require_relative '../bundle/bundler/setup'
rescue LoadError
# fall back to regular bundler if the developer hasn't bundled standalone
require 'bundler'
Bundler.setup
end
require 'rspec/fire'
module QlessSpecHelpers
def with_env_va... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/job_spec.rb | Ruby | mit | 299 | master | 11,152 | # Encoding: utf-8
# The things we're testing
require 'qless'
# Spec stuff
require 'spec_helper'
require 'timecop'
module Qless
# This class does not have a perform method
class NoPerformJob; end
describe Job, :integration do
let(:queue) { client.queues['foo'] }
it 'can specify a jid in put and klass ... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/events_spec.rb | Ruby | mit | 299 | master | 2,200 | # Encoding: utf-8
# The things we're testing
require 'qless'
# Spec stuff
require 'spec_helper'
module Qless
describe ClientEvents, :integration, :uses_threads do
let(:queue) { client.queues['foo'] }
let(:events) { Hash.new { |h, k| h[k] = [] } }
let(:pubsub) { new_client }
# Tracked and untracked... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/subscriber_spec.rb | Ruby | mit | 299 | master | 1,682 | # Encoding: utf-8
# The things we're testing
require 'qless'
require 'qless/subscriber'
# Spec stuff
require 'spec_helper'
module Qless
describe Subscriber, :integration, :uses_threads do
let(:channel) { SecureRandom.uuid } # use a unique channel
let(:logger) { StringIO.new }
def publish(message)
... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/config_spec.rb | Ruby | mit | 299 | master | 795 | # Encoding: utf-8
# The things we're testing
require 'qless'
# Spec stuff
require 'spec_helper'
module Qless
describe Config, :integration do
it 'can set, get and erase configuration' do
client.config['testing'] = 'foo'
client.config['testing'].should eq('foo')
client.config.all['testing'].sh... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/server_spec.rb | Ruby | mit | 299 | master | 28,940 | # Encoding: utf-8
ENV['RACK_ENV'] = 'test'
require 'spec_helper'
require 'yaml'
require 'qless'
require 'qless/server'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'rack/test'
Capybara.javascript_driver = :poltergeist
module Qless
describe Server, :integration, type: :request do
# Our main t... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/lua_script_spec.rb | Ruby | mit | 299 | master | 2,517 | # Encoding: utf-8
# The things we're testing
require 'qless'
# Spec stuff
require 'spec_helper'
module Qless
describe LuaScript, :integration do
let(:redis) { client.redis }
let(:script) { LuaScript.new('qless', redis) }
it 'does not make any redis requests upon initialization' do
# Should not b... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/qless_spec.rb | Ruby | mit | 299 | master | 2,690 | # Encoding: utf-8
# The things we're testing
require 'qless'
# Spec stuff
require 'spec_helper'
module Qless
describe Client, :integration do
let(:queue) { client.queues['foo'] }
describe ClientJobs do
it 'provides access to multiget' do
queue.put('Foo', {}, jid: 'jid')
jobs = client... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/queue_spec.rb | Ruby | mit | 299 | master | 2,964 | # Encoding: utf-8
# The things we're testing
require 'qless'
# Spec stuff
require 'spec_helper'
module Qless
describe Queue, :integration do
let(:queue) { client.queues['foo'] }
it 'provides access to jobs in different states' do
queue.put('Foo', {})
[:depends, :running, :stalled, :scheduled, ... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/middleware/memory_usage_monitor_spec.rb | Ruby | mit | 299 | master | 5,859 | require 'spec_helper'
require 'support/forking_worker_context'
require 'qless/middleware/memory_usage_monitor'
module Qless
module Middleware
describe MemoryUsageMonitor do
include_context "forking worker"
mem_usage_from_other_technique = nil
shared_examples_for "memory usage monitor" do
... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/middleware/timeout_spec.rb | Ruby | mit | 299 | master | 2,081 | require 'spec_helper'
require 'support/forking_worker_context'
require 'qless/middleware/timeout'
module Qless::Middleware
describe Timeout do
include_context "forking worker"
def define_job_class(name, &block)
stub_const(name, Class.new(&block))
end
def duration_of
start = Time.now
... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/workers/serial_spec.rb | Ruby | mit | 299 | master | 7,773 | # Encoding: utf-8
# The things we're testing
require 'qless'
require 'qless/worker/serial'
require 'qless/job_reservers/round_robin'
require 'qless/middleware/retry_exceptions'
# Spec stuff
require 'spec_helper'
require 'qless/test_helpers/worker_helpers'
module Qless
describe Workers::SerialWorker, :integration d... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/workers/forking_spec.rb | Ruby | mit | 299 | master | 5,533 | # Encoding: utf-8
require 'spec_helper'
require 'qless/middleware/retry_exceptions'
require 'support/forking_worker_context'
require 'shellwords'
require 'timeout'
module Qless
describe Workers::ForkingWorker do
include_context "forking worker"
context 'when the parent process is killed with a TERM signal'... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/exe/qless_stats_spec.rb | Ruby | mit | 299 | master | 3,354 | # Encoding: utf-8
require 'json'
require 'socket'
require 'tempfile'
require 'spec_helper'
describe 'qless-stats', :integration do
let(:path) { './exe/qless-stats' }
def run(*args)
`#{path} #{args.join(' ')}`
end
describe 'statsd subcommand' do
def get_statsd_messages
begin
sock = UD... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/integration/exe/qless_config_spec.rb | Ruby | mit | 299 | master | 1,032 | # Encoding: utf-8
require 'json'
require 'tempfile'
require 'spec_helper'
describe 'qless-config', :integration do
let(:path) { './exe/qless-config' }
let(:default) do
{
'application' => 'qless',
'grace-period' => 10,
'stats-history' => 30,
'jobs-history' => 604800,
'heartbeat'... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/support/forking_worker_context.rb | Ruby | mit | 299 | master | 760 | require 'qless'
require 'qless/test_helpers/worker_helpers'
require 'qless/worker'
require 'qless/job_reservers/round_robin'
require 'tempfile'
class TempfileWithString < Tempfile
# To mirror StringIO#string
def string
rewind
read.tap { close }
end
end
shared_context "forking worker" do
include Qless:... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/worker_spec.rb | Ruby | mit | 299 | master | 6,622 | # Encoding: utf-8
# The thing we're testing
require 'qless/worker'
# Standard
require 'logger'
# Spec
require 'spec_helper'
module Qless
describe Workers do
shared_context 'with a dummy client' do
# Our client should ignore everything
let(:client) { double('client').as_null_object }
# Our ... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/job_spec.rb | Ruby | mit | 299 | master | 9,778 | # Encoding: utf-8
require 'spec_helper'
require 'qless/job'
module Qless
describe Job do
class JobClass
class Nested
end
end
module SomeJobMiddleware
def around_perform(job)
super
end
end
let(:client) { double('client').as_null_object }
describe '.build' do... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/queue_spec.rb | Ruby | mit | 299 | master | 4,490 | # Encoding: utf-8
require 'spec_helper'
require 'yaml'
require 'qless/queue'
# A job class where to_s has been changed
class SomeJobClassWithDifferentToS
def self.to_s
'this is a different to_s'
end
end
module Qless
describe Queue, :integration do
['name', :name].each do |name|
it "can query leng... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/qless_spec.rb | Ruby | mit | 299 | master | 3,861 | # Encoding: utf-8
require 'spec_helper'
require 'qless'
describe Qless do
describe '.generate_jid' do
it 'generates a UUID suitable for use as a jid' do
Qless.generate_jid.should match(/\A[a-f0-9]{32}\z/)
end
end
def redis_double(overrides = {})
attributes = { id: 'redis://foo:1/1', info: { '... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/middleware/sentry_spec.rb | Ruby | mit | 299 | master | 2,276 | # Encoding: utf-8
require 'spec_helper'
require 'qless/middleware/sentry'
require 'qless'
require 'qless/worker'
module Qless
module Middleware
describe Sentry do
let(:client) { instance_double('Qless::Client').as_null_object }
let(:klass) do
Class.new do
def self.perform(job)
... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/middleware/redis_reconnect_spec.rb | Ruby | mit | 299 | master | 3,127 | # Encoding: utf-8
require 'spec_helper'
require 'qless/middleware/redis_reconnect'
require 'redis'
require 'qless/worker'
module Qless
module Middleware
describe RedisReconnect do
let(:url_1) { 'redis://localhost:1234/2' }
let(:url_2) { 'redis://localhost:4321/3' }
it 'has a human readable de... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/middleware/retry_exceptions_spec.rb | Ruby | mit | 299 | master | 6,745 | # Encoding: utf-8
require 'spec_helper'
require 'qless/middleware/retry_exceptions'
require 'qless'
module Qless
module Middleware
describe RetryExceptions do
let(:container_class) do
Class.new do
attr_accessor :perform
def around_perform(job)
perform.call
... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/middleware/requeue_exceptions_spec.rb | Ruby | mit | 299 | master | 9,440 | # Encoding: utf-8
require 'spec_helper'
require 'qless/middleware/requeue_exceptions'
module Qless
module Middleware
describe RequeueExceptions do
let(:container_class) do
Class.new do
attr_accessor :perform
def around_perform(job)
perform.call
end
... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/middleware/timeout_spec.rb | Ruby | mit | 299 | master | 5,509 | require 'spec_helper'
require 'qless/job'
require 'qless/middleware/timeout'
module Qless
module Middleware
::RSpec.describe Timeout do
class JobClass
def around_perform_call_counter
@around_perform_call_counter ||= 0
end
def around_perform(job)
@around_perform_... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/job_reservers/round_robin_spec.rb | Ruby | mit | 299 | master | 1,826 | # Encoding: utf-8
require 'spec_helper'
require 'qless/queue'
require 'qless/job_reservers/round_robin'
module Qless
module JobReservers
describe RoundRobin do
let(:q1) { instance_double('Qless::Queue') }
let(:q2) { instance_double('Qless::Queue') }
let(:q3) { instance_double('Qless::Queue') }... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/job_reservers/ordered_spec.rb | Ruby | mit | 299 | master | 1,933 | # Encoding: utf-8
require 'spec_helper'
require 'qless/queue'
require 'qless/job_reservers/ordered'
module Qless
module JobReservers
describe Ordered do
let(:q1) { instance_double('Qless::Queue') }
let(:q2) { instance_double('Qless::Queue') }
let(:q3) { instance_double('Qless::Queue') }
... |
github | seomoz/qless | https://github.com/seomoz/qless | spec/unit/job_reservers/shuffled_round_robin_spec.rb | Ruby | mit | 299 | master | 2,920 | # Encoding: utf-8
require 'spec_helper'
require 'qless/queue'
require 'qless/job_reservers/shuffled_round_robin'
module Qless
module JobReservers
describe ShuffledRoundRobin do
let(:q1) { instance_double('Qless::Queue') }
let(:q2) { instance_double('Qless::Queue') }
let(:q3) { instance_double(... |
github | seomoz/qless | https://github.com/seomoz/qless | benchmarks/current_memory_usage.rb | Ruby | mit | 299 | master | 683 | require 'benchmark'
n = 1000
Benchmark.bmbm do |x|
x.report("shelling out") do
n.times { Integer(`ps -o rss= -p #{Process.pid}`) * 1024 }
end
x.report("rusage") do
require 'rusage'
n.times { Process.rusage }
end
end
=begin
On my computer:
Rehearsal ----------------------------------------------... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless.rb | Ruby | mit | 299 | master | 7,362 | # Encoding: utf-8
require 'socket'
require 'redis'
require 'json'
require 'securerandom'
# The top level container for all things qless
module Qless
# Define our error base class before requiring the other files so they can
# define subclasses.
Error = Class.new(StandardError)
# to maintain backwards compati... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/queue.rb | Ruby | mit | 299 | master | 5,120 | # Encoding: utf-8
require 'qless/job'
require 'redis'
require 'json'
module Qless
# A class for interacting with jobs in different states in a queue. Not meant
# to be instantiated directly, it's accessed with Queue#jobs
class QueueJobs
def initialize(name, client)
@name = name
@client = clien... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/subscriber.rb | Ruby | mit | 299 | master | 1,572 | # Encoding: utf-8
require 'thread'
module Qless
# A class used for subscribing to messages in a thread
class Subscriber
def self.start(*args, &block)
new(*args, &block).tap(&:start)
end
attr_reader :channel, :redis
def initialize(client, channel, options = {}, &message_received_callback)
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/server.rb | Ruby | mit | 299 | master | 12,793 | # Encoding: utf-8
require 'sinatra/base'
require 'qless'
module Qless
# The Qless web interface
class Server < Sinatra::Base
# Path-y-ness
dir = File.dirname(File.expand_path(__FILE__))
set :views , "#{dir}/server/views"
set :public_folder, "#{dir}/server/static"
# For debugging purpos... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/failure_formatter.rb | Ruby | mit | 299 | master | 1,256 | # Encoding: utf-8
module Qless
# A helper for formatting failure messages
class FailureFormatter
Failure = Struct.new(:group, :message) do
# allow de-structring assignment
def to_ary
[group, message]
end
end
def initialize
@replacements = { Dir.pwd => '.' }
@repla... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/lua_script.rb | Ruby | mit | 299 | master | 2,320 | # Encoding: utf-8
require 'digest/sha1'
module Qless
LuaScriptError = Class.new(Qless::Error)
# Wraps a lua script. Knows how to reload it if necessary
class LuaScript
SCRIPT_ROOT = File.expand_path('../lua', __FILE__)
def initialize(name, redis)
@name = name
@redis = redis
@sha =... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/config.rb | Ruby | mit | 299 | master | 654 | # Encoding: utf-8
require 'json'
module Qless
# A configuration class associated with a qless client
class Config
def initialize(client)
@client = client
end
def [](key)
@client.call('config.get', key)
end
def []=(key, value)
@client.call('config.set', key, value)
end
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/tasks.rb | Ruby | mit | 299 | master | 229 | # Encoding: utf-8
warn "Qless tasks are deprecated (they haven't worked for " \
"quite some time) and you should start a worker by " \
"writing a bit of ruby code that instantiates and " \
"runs a worker instead." |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/job.rb | Ruby | mit | 299 | master | 12,551 | # Encoding: utf-8
require 'qless'
require 'qless/queue'
require 'qless/lua_script'
require 'redis'
require 'json'
module Qless
# The base for both Job and RecurringJob
class BaseJob
attr_reader :client
def initialize(client, jid)
@client = client
@jid = jid
end
def klass
@kl... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/test_helpers/worker_helpers.rb | Ruby | mit | 299 | master | 1,395 | module Qless
module WorkerHelpers
# Yield with a worker running, and then clean the worker up afterwards
def run_worker_concurrently_with(worker, &block)
thread = Thread.start { stop_worker_after(worker, &block) }
thread.abort_on_exception = true
worker.run
ensure
thread.join(0.1)
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/job_reservers/ordered.rb | Ruby | mit | 299 | master | 486 | # Encoding: utf-8
module Qless
module JobReservers
class Ordered
attr_reader :queues
def initialize(queues)
@queues = queues
end
def reserve
@queues.each do |q|
job = q.pop
return job if job
end
nil
end
def prep_for_work!
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/job_reservers/round_robin.rb | Ruby | mit | 299 | master | 947 | # Encoding: utf-8
module Qless
module JobReservers
# Round-robins through all the provided queues
class RoundRobin
attr_reader :queues
def initialize(queues)
@queues = queues
@num_queues = queues.size
@last_popped_queue_index = @num_queues - 1
end
def reserve... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/job_reservers/shuffled_round_robin.rb | Ruby | mit | 299 | master | 432 | # Encoding: utf-8
require 'qless/job_reservers/round_robin'
module Qless
module JobReservers
# Like round-robin but shuffles the order of the queues
class ShuffledRoundRobin < RoundRobin
def initialize(queues)
super(queues.shuffle)
end
def prep_for_work!
@queues = @queues.... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/worker/base.rb | Ruby | mit | 299 | master | 7,870 | # Encoding: utf-8
# Standard stuff
require 'time'
require 'logger'
require 'thread'
# Qless requires
require 'qless'
require 'qless/subscriber'
module Qless
module Workers
JobLockLost = Class.new(StandardError)
class BaseWorker
attr_accessor :output, :reserver, :interval, :paused,
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/worker/serial.rb | Ruby | mit | 299 | master | 1,183 | # Encoding: utf-8
# Qless requires
require 'qless'
require 'qless/worker/base'
module Qless
module Workers
# A worker that keeps popping off jobs and processing them
class SerialWorker < BaseWorker
def initialize(reserver, options = {})
super(reserver, options)
end
def run
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/worker/forking.rb | Ruby | mit | 299 | master | 7,819 | # Encoding: utf-8
# Qless requires
require 'qless'
require 'qless/worker/base'
require 'qless/worker/serial'
require 'thread'
module Qless
module Workers
class ForkingWorker < BaseWorker
# The child startup interval
attr_accessor :max_startup_interval
def initialize(reserver, options = {})
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/middleware/redis_reconnect.rb | Ruby | mit | 299 | master | 649 | # Encoding: utf-8
module Qless
module Middleware
# A module for reconnecting to redis for each job
module RedisReconnect
def self.new(*redis_connections, &block)
Module.new do
define_singleton_method :to_s do
'Qless::Middleware::RedisReconnect'
end
defi... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/middleware/requeue_exceptions.rb | Ruby | mit | 299 | master | 3,095 | # Encoding: utf-8
module Qless
module Middleware
# This middleware is like RetryExceptions, but it doesn't use qless-core's
# internal retry/retry-tracking mechanism. Instead, it re-queues the job
# when it fails with a matched error, and increments a counter in the job's
# data.
#
# This is ... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/middleware/timeout.rb | Ruby | mit | 299 | master | 3,127 | require 'timeout'
require 'qless/middleware/requeue_exceptions'
module Qless
# Unique error class used when a job is timed out by this middleware.
# Allows us to differentiate this timeout from others caused by `::Timeout::Error`
JobTimedoutError = Class.new(StandardError)
InvalidTimeoutError = Class.new(Argum... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/middleware/retry_exceptions.rb | Ruby | mit | 299 | master | 2,187 | # Encoding: utf-8
module Qless
module Middleware
# Auto-retries particular errors using qless-core's internal retry tracking
# mechanism. Supports a backoff strategy (typically exponential).
#
# Note: this does not support varying the number of allowed retries by
# exception type. If you want tha... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/middleware/memory_usage_monitor.rb | Ruby | mit | 299 | master | 1,878 | module Qless
module Middleware
# Monitors the memory usage of the Qless worker, instructing
# it to shutdown when memory exceeds the given :max_memory threshold.
class MemoryUsageMonitor < Module
def initialize(options)
max_memory = options.fetch(:max_memory)
module_eval do
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/middleware/sentry.rb | Ruby | mit | 299 | master | 1,728 | # Encoding: utf-8
require 'raven'
module Qless
module Middleware
# This middleware logs errors to the sentry exception notification service:
# http://getsentry.com/
module Sentry
def around_perform(job)
super
rescue Exception => e
SentryLogger.new(e, job).log
raise
... |
github | seomoz/qless | https://github.com/seomoz/qless | lib/qless/middleware/metriks.rb | Ruby | mit | 299 | master | 954 | # Encoding: utf-8
# This middleware is now a no-op because
# the metriks dependency breaks builds.
module Qless
module Middleware
module Metriks
# Tracks the time jobs take, grouping the timings by the job class.
module TimeJobsByClass
def around_perform(job)
super
end
... |
github | travis-ci/travis-api | https://github.com/travis-ci/travis-api | Gemfile | Ruby | mit | 298 | master | 2,986 | source 'https://rubygems.org'
ruby '3.2.2'
gem 'mime-types'
# travis maintained gems
gem 'gh', git: 'https://github.com/travis-ci/gh'
gem 'marginalia', git: 'https://github.com/travis-ci/marginalia'
gem 'metriks', git: 'https://github.com/travis-ci/metriks'
gem 'metriks-librato_metrics', git: 'https://github.com/tra... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.