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 | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | relaxdb.gemspec | Ruby | mit | 98 | master | 1,980 | # Updating the gemspec
# ruby -e 'Dir["spec/*"].each { |fn| puts "\"#{fn}\," }'
Gem::Specification.new do |s|
s.name = "relaxdb"
s.version = "0.5.3"
s.date = "2010-05-19"
s.summary = "RelaxDB provides a simple interface to CouchDB"
s.email = "paul.p.carey@gmail.com"
s.homepage = "http://github.com/paulca... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb.rb | Ruby | mit | 98 | master | 1,140 | require 'rubygems'
require 'extlib'
begin
require 'yajl'
require 'yajl/json_gem'
rescue LoadError
require 'json'
end
require 'cgi'
require 'net/http'
require 'logger'
require 'parsedate' if RUBY_VERSION.to_f < 1.9
require 'pp'
require 'tempfile'
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirn... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/paginate_params.rb | Ruby | mit | 98 | master | 1,578 | module RelaxDB
class PaginateParams
@@params = %w(key startkey startkey_docid endkey endkey_docid limit update descending group reduce include_docs)
@@params.each do |param|
define_method(param.to_sym) do |*val|
if val.empty?
instance_variable_get("@#{param}")
else... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/all_delegator.rb | Ruby | mit | 98 | master | 1,246 | module RelaxDB
#
# The AllDelegator allows clients to query CouchDB in a natural way
# FooDoc.all - returns all docs in CouchDB of type FooDoc
# FooDoc.all.size - issues a query to a reduce function that returns the total number of docs for that class
# FooDoc.all.destroy! - TODO - better description... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/document.rb | Ruby | mit | 98 | master | 16,084 | module RelaxDB
class Document
include RelaxDB::Validators
# Used to store validation messages
attr_accessor :errors
# A call issued to save_all will save this object and the
# contents of the save_list. This allows secondary objects to
# be saved at the same time as this ob... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/taf2_curb_server.rb | Ruby | mit | 98 | master | 1,413 | module RelaxDB
class Server
class Response
attr_reader :body
def initialize body
@body = body
end
end
attr_reader :host, :port
def initialize(host, port)
@host, @port = host, port
end
def close_connection
# Impl only in net_http as connection... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/references_proxy.rb | Ruby | mit | 98 | master | 532 | module RelaxDB
class ReferencesProxy
attr_reader :target
def initialize(client, relationship)
@client = client
@relationship = relationship
@target = nil
end
def target
return @target if @target
id = @client.data["#{@relationship}_id"]
@target =... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/view_uploader.rb | Ruby | mit | 98 | master | 1,697 | module RelaxDB
class ViewUploader
class << self
# Methods must start and finish on different lines
# The function declaration must start at the beginning of a line
# As '-' is used as a delimiter, the view name may not contain '-'
# Expected function declaration form is
#... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/view_result.rb | Ruby | mit | 98 | master | 323 | module RelaxDB
class ViewResult < DelegateClass(Array)
attr_reader :offset, :total_rows
def initialize(result_hash)
objs = RelaxDB.create_from_hash(result_hash)
@offset = result_hash["offset"]
@total_rows = result_hash["total_rows"]
super(objs)
end
end
... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/design_doc.rb | Ruby | mit | 98 | master | 1,410 | module RelaxDB
class DesignDocument
attr_reader :data
def initialize(design_doc_name, data)
@design_doc_name = design_doc_name
@data = data
end
def add_map_view(view_name, function)
add_view(view_name, "map", function)
end
def add_reduce_view(view_name, f... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/relaxdb.rb | Ruby | mit | 98 | master | 9,045 | module RelaxDB
class NotFound < StandardError; end
class DocumentNotSaved < StandardError; end
class UpdateConflict < DocumentNotSaved; end
class ValidationFailure < DocumentNotSaved; end
@@db = nil
class <<self
def configure(config)
@@db = CouchDB.new config
raise "A design_d... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/net_http_server.rb | Ruby | mit | 98 | master | 1,425 | module RelaxDB
class Server
attr_reader :host, :port
def initialize(host, port)
@host = host
@port = port
end
def cx
unless @cx && @cx.active?
@cx = Net::HTTP.start(@host, @port)
end
@cx
end
def close_connection
@cx.finish if @... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/server.rb | Ruby | mit | 98 | master | 2,994 | module RelaxDB
class HTTP_404 < StandardError; end
class HTTP_409 < StandardError; end
class HTTP_412 < StandardError; end
class CouchDB
attr_reader :logger, :server
# Used for test instrumentation only i.e. to assert that
# an expected number of requests have been issued
at... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/uuid_generator.rb | Ruby | mit | 98 | master | 1,355 | module RelaxDB
#
# UUIDs have a significant impact on CouchDB file size and performance
# See https://issues.apache.org/jira/browse/COUCHDB-465 and
# http://mail-archives.apache.org/mod_mbox/couchdb-dev/201001.mbox/%3chi57et$19n$1@ger.gmane.org%3e
#
# This approach uses the default CouchDB UUID generator (... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/paginator.rb | Ruby | mit | 98 | master | 4,123 | module RelaxDB
class Paginator
attr_reader :paginate_params
def initialize(paginate_params, page_params)
@paginate_params = paginate_params
@orig_paginate_params = @paginate_params.clone
@page_params = page_params.is_a?(String) ? JSON.parse(page_params).to_mash : page_params
... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/migration.rb | Ruby | mit | 98 | master | 1,201 | module RelaxDB
class Migration
def self.load_batch klass, startkey, limit
skip = startkey.nil? ? 0 : 1
result = RelaxDB.rf_view "#{klass}_all", :startkey => startkey,
:raw => true, :limit => limit, :skip => skip
ids = result["rows"].map { |h| h["id"] }
RelaxDB.load! ids ... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/extlib.rb | Ruby | mit | 98 | master | 543 | class Errors < Hash
alias_method :on, :[]
alias_method :count, :size
def full_messages
full_messages = []
each_key do |attr|
full_messages << attr.to_s + ": " + self[attr]
end
full_messages
end
end
class Time
# Ensure that all Times are stored as UTC
# Times in the following format ... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/query.rb | Ruby | mit | 98 | master | 2,141 | module RelaxDB
# A Query is used to build the query string made against a view
# All parameter values are first JSON encoded and then URL encoded
# Nil values are set to the empty string
class Query
# keys is not included in the standard param as it is significantly different from the others
@@... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/view_by_delegator.rb | Ruby | mit | 98 | master | 572 | module RelaxDB
class ViewByDelegator < Delegator
def initialize(view_name, opts)
super([])
@view_name = view_name
@opts = opts
end
def __getobj__
unless @ids
@opts[:raw] = true
@ids = RelaxDB.doc_ids @view_name, @opts
end
@ids
end
... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/migration_version.rb | Ruby | mit | 98 | master | 365 | class RelaxDB::MigrationVersion < RelaxDB::Document
DOC_ID = "relaxdb_migration_version"
property :version, :default => 0
def self.version
retrieve.version
end
def self.update v
mv = retrieve
mv.version = v
mv.save!
end
def self.retrieve
(v = RelaxDB.load(DOC_ID)) ... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/view_object.rb | Ruby | mit | 98 | master | 698 | module RelaxDB
# An immuntable object typically used to display the results of a view
class ViewObject
def initialize(hash)
hash.each do |k, v|
if k.to_s =~ /_at$/
v = Time.parse(v).utc rescue v
end
instance_variable_set("@#{k}", v)
meta_class.instance_eval ... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/relaxdb/views.rb | Ruby | mit | 98 | master | 1,950 | module RelaxDB
class ViewCreator
def self.all(kls)
class_name = kls[0]
map = <<-QUERY
function(doc) {
var class_match = #{kls_check kls}
if (class_match) {
emit(doc._id, 1);
}
}
QUERY
View.new "#{class_name}_all", map... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | lib/more/grapher.rb | Ruby | mit | 98 | master | 1,520 | module RelaxDB
#
# The GraphCreator uses dot to create a graphical model of an entire CouchDB database
# It probably only makes sense to run it on a database of a limited size
# The created graphs can be very useful for exploring relationships
# Run ruby scratch/grapher_demo.rb for an example
#
class G... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/relaxdb_spec.rb | Ruby | mit | 98 | master | 10,983 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB do
before(:each) do
setup_test_db
end
describe ".create_object" do
it "should return an instance of a known object if passed a hash with a class key" do
data = { "re... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/view_docs_by_spec.rb | Ruby | mit | 98 | master | 2,642 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe "view_docs_by" do
before(:all) do
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc"
end
describe "view_docs_by" do
before(:each) do
RelaxD... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/qpaginate_spec.rb | Ruby | mit | 98 | master | 2,496 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe "RelaxDB Pagination" do
before(:each) do
setup_test_db
letters = [
["a", 1], ["a", 2], ["a", 3],
["b", 1], ["b", 2], ["b", 3], ["b", 4], ["b", 5],
["c", 1], ["c", 2... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/paginate_spec.rb | Ruby | mit | 98 | master | 11,639 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe "RelaxDB Pagination" do
before(:each) do
setup_test_db
letters = [
["a", 1], ["a", 2], ["a", 3],
["b", 1], ["b", 2], ["b", 3], ["b", 4], ["b", 5],
["c", 1], ["c", 2... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/uuid_generator_spec.rb | Ruby | mit | 98 | master | 743 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::UuidGenerator do
before(:all) do
setup_test_db
@ug = RelaxDB::UuidGenerator
end
before(:each) do
@ug.reset
end
it "should retrieve UUIDs from CouchDB" do
RelaxD... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/server_spec.rb | Ruby | mit | 98 | master | 882 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB do
before(:all) do
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc"
@server = RelaxDB::Server.new("localhost", 5984)
end
before(:each) do
RelaxDB.de... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/document_spec.rb | Ruby | mit | 98 | master | 15,557 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::Document do
before(:each) do
setup_test_db
end
describe ".new" do
it "should create an object with an id" do
Atom.new._id.should_not be_nil
end
it "sh... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/derived_properties_spec.rb | Ruby | mit | 98 | master | 3,137 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
class DpInvite < RelaxDB::Document
property :event_name, :derived => [:event, lambda { |en, i| i.event.name }]
references :event
end
class DpEvent < RelaxDB::Document
property :name
end
describe RelaxDB::D... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/view_object_spec.rb | Ruby | mit | 98 | master | 1,295 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::ViewObject do
describe ".new" do
it "should provide readers for the object passed in the hash" do
data = { :name => "chaise", :variety => "longue" }
obj = RelaxDB::ViewObje... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/all_delegator_spec.rb | Ruby | mit | 98 | master | 1,199 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::AllDelegator do
before(:all) do
setup_test_db
end
describe "size" do
it "should return the total count for a given class" do
docs = (1..101).map { |i| Primitives.new :num =... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/migration_spec.rb | Ruby | mit | 98 | master | 2,874 | require File.join(File.dirname(__FILE__), "spec_helper")
require File.join(File.dirname(__FILE__), "spec_models")
describe RelaxDB::Migration do
before(:each) do
@mig = RelaxDB::Migration
setup_test_db
end
it "should yield each obj to the block and save the result" do
Primitives.new... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/callbacks_spec.rb | Ruby | mit | 98 | master | 1,985 | require File.dirname(__FILE__) + '/spec_helper.rb'
# A little naiive, needs quite a bit more thought and work
describe RelaxDB::Document, "callbacks" do
before(:all) do
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc"
end
before(:each) do
RelaxDB.delete_db "relaxdb_sp... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/references_proxy_spec.rb | Ruby | mit | 98 | master | 2,372 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::ReferencesProxy do
before(:all) do
setup_test_db
end
describe "references" do
it "should return nil when accessed before assignment" do
r = Rating.new
r.photo.should ... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/spec_helper.rb | Ruby | mit | 98 | master | 1,758 | begin
require 'spec'
rescue LoadError
require 'rubygems'
gem 'rspec'
require 'spec'
end
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'relaxdb'
class RdbFormatter; def call(sv, time, progname, msg); puts msg; end; end
def setup_test_db
# RelaxDB.configure :host => "localhost", :port => 5984, :desi... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/view_by_spec.rb | Ruby | mit | 98 | master | 2,276 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe "view_by" do
before(:each) do
setup_test_db
docs = (1..10).map { |i| Primitives.new :_id => "id#{i}", :str => i.to_s }
... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/query_spec.rb | Ruby | mit | 98 | master | 2,653 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::Query do
before(:all) do
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => ""
end
describe "#view_name" do
it "should match a single key attribute" do
q =... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/migration_version_spec.rb | Ruby | mit | 98 | master | 747 | require File.join(File.dirname(__FILE__), "spec_helper")
require File.join(File.dirname(__FILE__), "spec_models")
describe RelaxDB::MigrationVersion do
before(:each) do
setup_test_db
end
it "should not exist in a clean db" do
RelaxDB.load(RelaxDB::MigrationVersion::DOC_ID).should be_nil
end
... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/doc_inheritable_spec.rb | Ruby | mit | 98 | master | 2,441 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe "Inheritance" do
before(:each) do
setup_test_db
end
describe "properties" do
it "should by inherited from a parent document" do
d = SubDescendant.new(:x => 1).save!
RelaxDB.re... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/spec_models.rb | Ruby | mit | 98 | master | 2,874 | class FooBar < RelaxDB::Document
references :bf
end
class BarFoo < RelaxDB::Document
references :fb
end
class Atom < RelaxDB::Document
end
class Initiative < RelaxDB::Document
property :x
attr_reader :foo
def initialize(data)
data[:_id] = data[:x]
super data
@foo = :bar
end
end
class Primiti... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/design_doc_spec.rb | Ruby | mit | 98 | master | 811 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::DesignDocument do
before(:all) do
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc"
end
before(:each) do
RelaxDB.delete_db "relaxdb_spec" rescue "ok"
... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | spec/paginate_params_spec.rb | Ruby | mit | 98 | master | 477 | require File.dirname(__FILE__) + '/spec_helper.rb'
require File.dirname(__FILE__) + '/spec_models.rb'
describe RelaxDB::PaginateParams do
it "should be invalid if hasn't been initialized with both a startkey and endkey" do
RelaxDB::PaginateParams.new({}).should be_invalid
end
it "should be valid if ini... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | scratch/benchmark.rb | Ruby | mit | 98 | master | 817 | require 'rubygems'
require 'benchmark'
require 'time'
require 'parsedate'
js_comp = "2008/11/25 15:18:21 +0000" # Time.now.utc.strftime("%Y/%m/%d %H:%M:%S +0000")
iso8601 = "2008-11-25T12:15:34Z"
secs = 1227615341
count = 10_000
Benchmark.bmbm do |x|
x.report("ISO8601 Time.parse") do
count.times do
Time.p... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | scratch/key_query_demo.rb | Ruby | mit | 98 | master | 1,134 | # Silence parenthesis warnings with ruby -W0 scratch/keys.rb
#
# A couple of simple illustrations of how keys affect queries
#
$:.unshift(File.dirname(__FILE__) + "/../lib")
require 'relaxdb'
require File.dirname(__FILE__) + "/../spec/spec_models"
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc =... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | scratch/view_by_bench.rb | Ruby | mit | 98 | master | 2,824 | require 'benchmark'
$:.unshift(File.dirname(__FILE__) + "/../lib")
require 'relaxdb'
require File.dirname(__FILE__) + "/../spec/spec_models"
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "spec_doc"
RelaxDB.delete_db "relaxdb_spec" rescue :ok
RelaxDB.use_db "relaxdb_spec"
RelaxDB.replicate_db ... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | scratch/grapher_demo.rb | Ruby | mit | 98 | master | 603 | require 'rubygems'
require 'relaxdb'
require 'spec/spec_models'
# Configure RelaxDB
RelaxDB::UuidGenerator.id_length = 5
RelaxDB.configure :host => "localhost", :port => 5984
RelaxDB.delete_db "relaxdb_grapher_demo_db" rescue "ok"
RelaxDB.use_db "relaxdb_grapher_demo_db"
# Create the data
paul = User.new(:name => "pa... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | scratch/find_offending_view.rb | Ruby | mit | 98 | master | 1,226 | require 'rubygems'
require 'relaxdb'
#
# Purpose of this script is to make it easy to determine which view is
# causing a "Cannot encode 'undefined' value as JSON" error for a
# particular doc. Just a quick hack, as such a feature belongs more to
# CouchDB than a client lib.
#
# Config
src_db = "sd_min"
src_doc_i... |
github | imagov/keycloak | https://github.com/imagov/keycloak | keycloak.gemspec | Ruby | mit | 98 | master | 1,653 | # coding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "keycloak/version"
Gem::Specification.new do |spec|
spec.name = "keycloak"
spec.version = Keycloak::VERSION
spec.authors = ["Guilherme Portugues", "Leandro Vital Catarin... |
github | imagov/keycloak | https://github.com/imagov/keycloak | lib/keycloak.rb | Ruby | mit | 98 | master | 36,018 | # frozen_string_literal: true
require 'keycloak/version'
require 'rest-client'
require 'json'
require 'jwt'
require 'base64'
require 'uri'
def isempty?(value)
value.respond_to?(:empty?) ? !!value.empty? : !value
end
module Keycloak
OLD_KEYCLOAK_JSON_FILE = 'keycloak.json'.freeze
KEYCLOAK_JSON_FILE = 'config/ke... |
github | imagov/keycloak | https://github.com/imagov/keycloak | lib/keycloak/exceptions.rb | Ruby | mit | 98 | master | 310 | module Keycloak
class KeycloakException < StandardError; end
class UserLoginNotFound < KeycloakException; end
class ProcCookieTokenNotDefined < KeycloakException; end
class ProcExternalAttributesNotDefined < KeycloakException; end
class InstallationFileNotFound < KeycloakException; end
end |
github | imagov/keycloak | https://github.com/imagov/keycloak | lib/generators/keycloak.rb | Ruby | mit | 98 | master | 811 | # Set proxy to connect in keycloak server
Keycloak.proxy = ''
# If true, then all request exception will explode in application (this is the default value)
Keycloak.generate_request_exception = true
# controller that manage the user session
Keycloak.keycloak_controller = 'session'
# realm name (only if the installation... |
github | imagov/keycloak | https://github.com/imagov/keycloak | lib/generators/keycloak/config/config_generator.rb | Ruby | mit | 98 | master | 276 | module Keycloak
module Generators
class ConfigGenerator < Rails::Generators::Base
source_root(File.expand_path(File.dirname(__FILE__)))
def copy_initializer
copy_file '../../keycloak.rb', 'config/initializers/keycloak.rb'
end
end
end
end |
github | imagov/keycloak | https://github.com/imagov/keycloak | spec/keycloak_spec.rb | Ruby | mit | 98 | master | 1,936 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Keycloak do
it 'has a version number' do
expect(Keycloak::VERSION).not_to be nil
end
describe 'Module configuration' do
describe '.installation_file=' do
it 'should raise an error if given file does not exist' do
expect{ K... |
github | imagov/keycloak | https://github.com/imagov/keycloak | spec/spec_helper.rb | Ruby | mit | 98 | master | 364 | require "bundler/setup"
require "keycloak"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with :rs... |
github | github/ssh_data | https://github.com/github/ssh_data | ssh_data.gemspec | Ruby | mit | 98 | master | 759 | $:.unshift File.expand_path('../lib', __FILE__)
require "ssh_data/version"
Gem::Specification.new do |s|
s.name = "ssh_data"
s.summary = "Library for parsing SSH certificates"
s.version = SSHData::VERSION
s.license = "MIT"
s.homepage = "https://github.com/github/ssh_data"
s.authors = ["mastahyeti"]
s.ema... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/private_key_spec.rb | Ruby | mit | 98 | master | 3,875 | require_relative "./spec_helper"
describe SSHData::PrivateKey do
(Dir["spec/fixtures/*for_rsa_ca"].reject { |p| p =~ /skecdsa|sked25519/ } + Dir["spec/fixtures/*.plaintext.pem"]).each do |path|
name = File.basename(path)
describe name do
let(:sha256_fpr) { ssh_keygen_fingerprint(name, :sha256, priv: t... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/signature_spec.rb | Ruby | mit | 98 | master | 6,528 | require_relative "./spec_helper"
describe SSHData::Signature do
def read_fixture_file(name)
fixture_file_path = File.join("spec/fixtures/signatures", name)
File.read(fixture_file_path)
end
let(:name) { File.basename(path) }
let(:signature) { File.read(path) }
let(:message) { read_fixture_file("messa... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/spec_helper.rb | Ruby | mit | 98 | master | 1,191 | require "ssh_data"
require "ed25519"
require "rspec-parameterized"
require "open3"
RSpec.configure do |config|
config.color_mode = :off
end
REPO_PATH = File.expand_path(File.join(__FILE__, "..", ".."))
FIXTURE_PATH = File.expand_path(File.join(REPO_PATH, "spec", "fixtures"))
def fixture(name, binary: false, pem... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/certificate_spec.rb | Ruby | mit | 98 | master | 13,271 | require_relative "./spec_helper"
describe SSHData::Certificate do
let(:rsa_ca) { SSHData::PrivateKey::RSA.generate(2048) }
let(:dsa_ca) { SSHData::PrivateKey::DSA.generate }
let(:ecdsa_ca) { SSHData::PrivateKey::ECDSA.generate("nistp256") }
let(:ed25519_ca) { SSHData::PrivateKey::ED25519.generate }
... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/encoding_spec.rb | Ruby | mit | 98 | master | 32,582 | require "securerandom"
require_relative "./spec_helper"
describe SSHData::Encoding do
let(:junk) { String.new("\xff\xff", encoding: Encoding::ASCII_8BIT) }
describe "#pem_type" do
let(:type) { "FOO BAR" }
let(:head) { "-----BEGIN #{type}-----" }
let(:foot) { "-----END #{type}-----" }
let(:data) { ... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/public_key_spec.rb | Ruby | mit | 98 | master | 1,152 | require_relative "./spec_helper"
describe SSHData::PublicKey do
it "supports the deprecated PublicKey.parse method" do
expect {
described_class.parse(fixture("rsa_leaf_for_rsa_ca.pub"))
}.not_to raise_error
end
Dir["spec/fixtures/*ca.pub"].each do |path|
name = File.basename(path)
describ... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/public_key/skecdsa_spec.rb | Ruby | mit | 98 | master | 4,317 | require_relative "../spec_helper"
describe SSHData::PublicKey::SKECDSA do
let(:openssh_key) { SSHData::PublicKey.parse_openssh(fixture("skecdsa_leaf_for_rsa_ca.pub")) }
let(:ec_p384_publickey) { ec_private_to_public(OpenSSL::PKey::EC.generate('secp384r1')) }
it "can parse openssh-generate keys" do
expect { ... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/public_key/dsa_spec.rb | Ruby | mit | 98 | master | 2,772 | require_relative "../spec_helper"
describe SSHData::PublicKey::DSA do
let(:private_key) { SSHData::PrivateKey::DSA.generate.openssl }
let(:public_key) { private_key.public_key }
let(:params) { public_key.params }
let(:msg) { "hello, world!" }
let(:digest) { OpenSSL::Digest::SHA1.new }
l... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/public_key/sked25519_spec.rb | Ruby | mit | 98 | master | 1,842 | require_relative "../spec_helper"
describe SSHData::PublicKey::SKED25519 do
let(:signing_key) { Ed25519::SigningKey.generate }
let(:verify_key) { signing_key.verify_key }
let(:msg) { "hello, world!" }
let(:raw_sig) { signing_key.sign(msg) }
let(:sig) { SSHData::Encoding.encode_signature(SSHData::Pu... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/public_key/rsa_spec.rb | Ruby | mit | 98 | master | 2,964 | require_relative "../spec_helper"
describe SSHData::PublicKey::RSA do
let(:private_key) { OpenSSL::PKey::RSA.generate(2048) }
let(:public_key) { private_key.public_key }
let(:params) { public_key.params }
let(:msg) { "hello, world!" }
let(:digest) { OpenSSL::Digest::SHA1.new }
let(:raw_sig) { p... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/public_key/ecdsa_spec.rb | Ruby | mit | 98 | master | 3,742 | require_relative "../spec_helper"
describe SSHData::PublicKey::ECDSA do
let(:openssh_key) { SSHData::PublicKey.parse_openssh(fixture("ecdsa_leaf_for_rsa_ca.pub")) }
it "can parse openssh-generate keys" do
expect { openssh_key }.not_to raise_error
end
it "can be rencoded" do
expect(openssh_key.rfc4253... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/public_key/ed25519_spec.rb | Ruby | mit | 98 | master | 2,390 | require_relative "../spec_helper"
describe SSHData::PublicKey::ED25519 do
let(:signing_key) { Ed25519::SigningKey.generate }
let(:verify_key) { signing_key.verify_key }
let(:msg) { "hello, world!" }
let(:raw_sig) { signing_key.sign(msg) }
let(:sig) { SSHData::Encoding.encode_signature(SSHData::Publ... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/private_key/dsa_spec.rb | Ruby | mit | 98 | master | 2,541 | require_relative "../spec_helper"
describe SSHData::PrivateKey::DSA do
let(:private_key) { SSHData::PrivateKey::DSA.generate.openssl }
let(:public_key) { private_key.public_key }
let(:params) { private_key.params }
let(:message) { "hello, world!" }
let(:cert_key) { SSHData::PrivateKey::DSA.gener... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/private_key/ed25519_spec.rb | Ruby | mit | 98 | master | 2,915 | require_relative "../spec_helper"
describe SSHData::PrivateKey::ED25519 do
let(:signing_key) { Ed25519::SigningKey.generate }
let(:verify_key) { signing_key.verify_key }
let(:comment) { "asdf" }
let(:message) { "hello, world!" }
let(:cert_key) { SSHData::PrivateKey::DSA.generate.public_key }
l... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/private_key/ecdsa_spec.rb | Ruby | mit | 98 | master | 2,755 | require_relative "../spec_helper"
describe SSHData::PrivateKey::ECDSA do
let(:openssh_key) { SSHData::PrivateKey.parse(fixture("ecdsa_leaf_for_rsa_ca")) }
let(:cert_key) { SSHData::PrivateKey::DSA.generate.public_key }
it "can raises AlgorithmError for unknown curves" do
expect {
described_class.ge... |
github | github/ssh_data | https://github.com/github/ssh_data | spec/private_key/rsa_spec.rb | Ruby | mit | 98 | master | 3,249 | require_relative "../spec_helper"
describe SSHData::PrivateKey::RSA do
let(:private_key) { OpenSSL::PKey::RSA.generate(2048) }
let(:public_key) { private_key.public_key }
let(:params) { private_key.params }
let(:message) { "hello, world!" }
let(:cert_key) { SSHData::PrivateKey::DSA.generate.publ... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data.rb | Ruby | mit | 98 | master | 924 | require "openssl"
require "base64"
module SSHData
# Break down a key in OpenSSH authorized_keys format (see sshd(8) manual
# page).
#
# key - An OpenSSH formatted public key or certificate, including algo,
# base64 encoded key and optional comment.
#
# Returns an Array containing the algorithm Stri... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/private_key.rb | Ruby | mit | 98 | master | 2,253 | module SSHData
module PrivateKey
OPENSSH_PEM_TYPE = "OPENSSH PRIVATE KEY"
RSA_PEM_TYPE = "RSA PRIVATE KEY"
DSA_PEM_TYPE = "DSA PRIVATE KEY"
ECDSA_PEM_TYPE = "EC PRIVATE KEY"
ENCRYPTED_PEM_TYPE = "ENCRYPTED PRIVATE KEY"
# Parse an SSH private key.
#
# key - A PEM or O... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/error.rb | Ruby | mit | 98 | master | 255 | module SSHData
Error = Class.new(StandardError)
DecodeError = Class.new(Error)
VerifyError = Class.new(Error)
AlgorithmError = Class.new(Error)
DecryptError = Class.new(Error)
UnsupportedError = Class.new(Error)
end |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/certificate.rb | Ruby | mit | 98 | master | 8,354 | require "securerandom"
require "ipaddr"
module SSHData
class Certificate
# Special values for valid_before and valid_after.
BEGINNING_OF_TIME = Time.at(0)
END_OF_TIME = Time.at((2**64)-1)
# Integer certificate types
TYPE_USER = 1
TYPE_HOST = 2
# Certificate algorithm identifiers
ALG... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/encoding.rb | Ruby | mit | 98 | master | 21,687 | module SSHData
module Encoding
# Fields in an OpenSSL private key
# https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
OPENSSH_PRIVATE_KEY_MAGIC = "openssh-key-v1\x00"
OPENSSH_SIGNATURE_MAGIC = "SSHSIG"
OPENSSH_SIGNATURE_VERSION = 0x01
OPENSSH_SIGNATURE_FIELDS = [
[:s... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/signature.rb | Ruby | mit | 98 | master | 4,348 | # frozen_string_literal: true
module SSHData
class Signature
PEM_TYPE = "SSH SIGNATURE"
SIGNATURE_PREAMBLE = "SSHSIG"
MIN_SUPPORTED_VERSION = 1
MAX_SUPPORTED_VERSION = 1
# Spec: no SHA1 or SHA384. In practice, OpenSSH is always going to use SHA512.
# Note the actual signing / verify primitiv... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key.rb | Ruby | mit | 98 | master | 2,527 | module SSHData
module PublicKey
# Public key algorithm identifiers
ALGO_RSA = "ssh-rsa"
ALGO_DSA = "ssh-dss"
ALGO_ECDSA256 = "ecdsa-sha2-nistp256"
ALGO_ECDSA384 = "ecdsa-sha2-nistp384"
ALGO_ECDSA521 = "ecdsa-sha2-nistp521"
ALGO_ED25519 = "ssh-ed25519"
ALGO_SKED25... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/private_key/ecdsa.rb | Ruby | mit | 98 | master | 3,025 | module SSHData
module PrivateKey
class ECDSA < Base
attr_reader :curve, :public_key_bytes, :private_key_bytes, :openssl
# Generate a new private key.
#
# curve - The String curve to use. One of SSHData::PublicKey::NISTP256,
# SSHData::PublicKey::NISTP384, or SSHData::PublicK... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/private_key/dsa.rb | Ruby | mit | 98 | master | 2,351 | module SSHData
module PrivateKey
class DSA < Base
attr_reader :p, :q, :g, :x, :y, :openssl
# Generate a new private key.
#
# Returns a PublicKey::Base subclass instance.
def self.generate
openssl_key =
if defined?(OpenSSL::PKey.generate_parameters)
dsa_... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/private_key/base.rb | Ruby | mit | 98 | master | 1,118 | module SSHData
module PrivateKey
class Base
attr_reader :algo, :comment, :public_key
def initialize(**kwargs)
@algo = kwargs[:algo]
@comment = kwargs[:comment]
end
# Generate a new private key.
#
# Returns a PublicKey::Base subclass instance.
def self.ge... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/private_key/ed25519.rb | Ruby | mit | 98 | master | 1,907 | module SSHData
module PrivateKey
class ED25519 < Base
attr_reader :pk, :sk, :ed25519_key
# Generate a new private key.
#
# Returns a PublicKey::Base subclass instance.
def self.generate
PublicKey::ED25519.ed25519_gem_required!
from_ed25519(Ed25519::SigningKey.generat... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/private_key/rsa.rb | Ruby | mit | 98 | master | 2,864 | module SSHData
module PrivateKey
class RSA < Base
attr_reader :n, :e, :d, :iqmp, :p, :q, :openssl
# Generate a new private key.
#
# size - The Integer key size to generate.
# unsafe_allow_small_key: - Bool of whether to allow keys of less than
# ... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/base.rb | Ruby | mit | 98 | master | 1,968 | module SSHData
module PublicKey
class Base
attr_reader :algo
def initialize(**kwargs)
@algo = kwargs[:algo]
end
# Calculate the fingerprint of this public key.
#
# md5: - Bool of whether to generate an MD5 fingerprint instead of the
# default SHA256.
... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/dsa.rb | Ruby | mit | 98 | master | 3,639 | module SSHData
module PublicKey
class DSA < Base
attr_reader :p, :q, :g, :y, :openssl
# Convert an SSH encoded DSA signature to DER encoding for verification with
# OpenSSL.
#
# sig - A binary String signature from an SSH packet.
#
# Returns a binary String signature, as... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/ecdsa.rb | Ruby | mit | 98 | master | 4,585 | module SSHData
module PublicKey
class ECDSA < Base
attr_reader :curve, :public_key_bytes, :openssl
NISTP256 = "nistp256"
NISTP384 = "nistp384"
NISTP521 = "nistp521"
OPENSSL_CURVE_NAME_FOR_CURVE = {
NISTP256 => "prime256v1",
NISTP384 => "secp384r1",
NISTP521 ... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/security_key.rb | Ruby | mit | 98 | master | 1,220 | module SSHData
module PublicKey
module SecurityKey
# Defaults to match OpenSSH, user presence is required by verification is not.
DEFAULT_SK_VERIFY_OPTS = {
user_presence_required: true,
user_verification_required: false
}
SK_FLAG_USER_PRESENCE = 0b001
SK_FLAG_U... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/sked25519.rb | Ruby | mit | 98 | master | 1,818 | module SSHData
module PublicKey
class SKED25519 < ED25519
include SecurityKey
attr_reader :application
def initialize(algo:, pk:, application:)
@application = application
super(algo: algo, pk: pk)
end
def self.algorithm_identifier
ALGO_SKED25519
end
... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/skecdsa.rb | Ruby | mit | 98 | master | 2,109 | module SSHData
module PublicKey
class SKECDSA < ECDSA
include SecurityKey
attr_reader :application
OPENSSL_CURVE_NAME_FOR_CURVE = {
NISTP256 => "prime256v1",
}
def self.check_algorithm!(algo, curve)
unless algo == ALGO_SKECDSA256
raise DecodeError, "bad al... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/rsa.rb | Ruby | mit | 98 | master | 2,462 | module SSHData
module PublicKey
class RSA < Base
attr_reader :e, :n, :openssl
ALGO_DIGESTS = {
ALGO_RSA => OpenSSL::Digest::SHA1,
ALGO_RSA_SHA2_256 => OpenSSL::Digest::SHA256,
ALGO_RSA_SHA2_512 => OpenSSL::Digest::SHA512
}
def initialize(algo:, e:, n:)
... |
github | github/ssh_data | https://github.com/github/ssh_data | lib/ssh_data/public_key/ed25519.rb | Ruby | mit | 98 | master | 2,061 | module SSHData
module PublicKey
class ED25519 < Base
attr_reader :pk, :ed25519_key
# ed25519 isn't a hard requirement for using this Gem. We only do actual
# validation with the key if the ed25519 Gem has been loaded.
def self.enabled?
Object.const_defined?(:Ed25519)
end
... |
github | antirez/redimension | https://github.com/antirez/redimension | test.rb | Ruby | bsd-2-clause | 98 | master | 1,551 | require 'rubygems'
require 'redis'
require "./redimension.rb"
def fuzzy_test(dim,items,queries)
redis = Redis.new()
redis.del("redim-fuzzy")
rn = Redimension.new(redis,"redim-fuzzy",dim,64)
id = 0
dataset = []
1000.times {
vars = []
dim.times {vars << rand(1000)}
dataset... |
github | antirez/redimension | https://github.com/antirez/redimension | redimension.rb | Ruby | bsd-2-clause | 98 | master | 7,377 | class Redimension
attr_accessor :debug, :hashkey
attr_reader :redis, :key, :dim, :prec
def initialize(redis,key,dim,prec=64)
@debug = false
@redis = redis
@dim = dim
@key = key
@prec = prec
@hashkey = false
@binary = false # Default is hex encoding
... |
github | antirez/redimension | https://github.com/antirez/redimension | example2.rb | Ruby | bsd-2-clause | 98 | master | 776 | require 'rubygems'
require 'redis'
require "./redimension.rb"
redis = Redis.new
redis.del("people-by-salary")
redis.del("people-by-salary-map")
myindex = Redimension.new(redis,"people-by-salary",2,64)
myindex.hashkey = "people-by-salary-map"
myindex.update([45,120000],"Josh")
myindex.update([50,110000],"Pamela")
myind... |
github | antirez/redimension | https://github.com/antirez/redimension | example.rb | Ruby | bsd-2-clause | 98 | master | 363 | require 'rubygems'
require 'redis'
require "./redimension.rb"
redis = Redis.new
redis.del("people-by-salary")
myindex = Redimension.new(redis,"people-by-salary",2,64)
myindex.index([45,120000],"Josh")
myindex.index([50,110000],"Pamela")
myindex.index([30,125000],"Angela")
results = myindex.query([[40,50],[100000,11500... |
github | shioyama/wharel | https://github.com/shioyama/wharel | wharel.gemspec | Ruby | mit | 98 | master | 1,272 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "wharel/version"
Gem::Specification.new do |spec|
spec.name = "wharel"
spec.version = Wharel::VERSION
spec.authors = ["Chris Salzberg"]
spec.email = ["chris@dejimata.com"]
... |
github | shioyama/wharel | https://github.com/shioyama/wharel | Gemfile | Ruby | mit | 98 | master | 348 | source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in wharel.gemspec
gemspec
gem 'pry-byebug'
case (ENV['RAILS_VERSION'] || '6.0')
when '5.2'
gem 'activerecord', '~> 5.2'
gem 'sqlite3', '~> 1.3.13'
else
gem 'activerecord', "~> #... |
github | shioyama/wharel | https://github.com/shioyama/wharel | lib/wharel.rb | Ruby | mit | 98 | master | 1,453 | require "wharel/version"
require "active_record"
module Wharel
module QueryMethods
%w[select where order having pluck pick group].each do |method_name|
next unless ::ActiveRecord::Base.singleton_class.method_defined?(method_name)
module_eval <<-EOM, __FILE__, __LINE__ + 1
def #{method_name}(*,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.