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 | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_collection_radio_buttons.rb | Ruby | mit | 47 | main | 1,328 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
class SlCollectionRadioButtons < ActionView::Helpers::Tags::CollectionRadioButtons #:nodoc:
include ErrorWrappable
class RadioButtonBuilder < Builder # :nodoc:
def label(*)
text
... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_switch.rb | Ruby | mit | 47 | main | 636 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
class SlSwitch < ActionView::Helpers::Tags::NumberField #:nodoc:
include ErrorWrappable
def field_type; nil; end
def render(&block)
options = @options.stringify_keys
options["... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/error_wrappable.rb | Ruby | mit | 47 | main | 428 | # frozen_string_literal: true
module Shoelace
module Components
module ErrorWrappable
def error_wrapping(html_tag)
if object_has_errors? && field_error_proc
@template_object.instance_exec(html_tag, self, &field_error_proc)
else
html_tag
end
end
priva... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_textarea.rb | Ruby | mit | 47 | main | 573 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
class SlTextarea < ActionView::Helpers::Tags::NumberField #:nodoc:
include ErrorWrappable
def render(&block)
options = @options.stringify_keys
options["value"] = options.fetch("value... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_input.rb | Ruby | mit | 47 | main | 858 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
class SlInput < ActionView::Helpers::Tags::TextField #:nodoc:
include ErrorWrappable
attr_reader :field_type
def initialize(field_type, *args)
super(*args)
@field_type = field... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_radio_button.rb | Ruby | mit | 47 | main | 524 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
class SlRadioButton < ActionView::Helpers::Tags::RadioButton #:nodoc:
include ErrorWrappable
def render(&block)
options = @options.stringify_keys
options["value"] = @tag_value
... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_checkbox.rb | Ruby | mit | 47 | main | 1,223 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
class SlCheckbox < ActionView::Helpers::Tags::CheckBox #:nodoc:
include ErrorWrappable
def render(&block)
options = @options.stringify_keys
options["value"] = @checked_value
... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_select.rb | Ruby | mit | 47 | main | 3,008 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
module SlSelectRenderable
EMPTY = "".html_safe.freeze
def select_content_tag(option_tags, _options, html_options)
html_options = html_options.stringify_keys
html_options['value'] ||=... |
github | yuki24/shoelace-rails | https://github.com/yuki24/shoelace-rails | app/helpers/shoelace/components/sl_range.rb | Ruby | mit | 47 | main | 512 | # frozen_string_literal: true
require_relative './error_wrappable'
module Shoelace
module Components
class SlRange < ActionView::Helpers::Tags::NumberField #:nodoc:
include ErrorWrappable
def field_type; nil; end
def render
@options["invalid"] = @options["data-invalid"] = "" if objec... |
github | fizx/csvget | https://github.com/fizx/csvget | csvget.gemspec | Ruby | mit | 47 | master | 2,090 | # Generated by jeweler
# DO NOT EDIT THIS FILE
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{csvget}
s.version = "0.4.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version... |
github | fizx/csvget | https://github.com/fizx/csvget | Rakefile | Ruby | mit | 47 | master | 1,690 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "csvget"
gem.executables = ["csvget", "jsonget"]
gem.summary = %Q{Uses parselets and rwget to generate csv files from websites}
gem.description = %Q{Super easy to use (but lots of dependencies :/) parse... |
github | fizx/csvget | https://github.com/fizx/csvget | lib/jsonget.rb | Ruby | mit | 47 | master | 822 | require "rubygems"
require "rwget"
require "parsley"
require "activesupport"
require "fileutils"
class JSONStore
def initialize(options = {})
@output_folder = options[:prefix] || "."
FileUtils.mkdir_p(@output_folder)
@parselets = (options[:parselets] || []).map{|path| Parsley.new(File.read(path)) }
@... |
github | fizx/csvget | https://github.com/fizx/csvget | lib/csvget.rb | Ruby | mit | 47 | master | 1,458 | require "rubygems"
require "rwget"
require "parsley"
require "fastercsv"
require "activesupport"
require "fileutils"
class CSVStore
def initialize(options = {})
@output_folder = options[:prefix] || "."
@filters = options[:filter] || []
FileUtils.mkdir_p(@output_folder)
@parselets = (options[:parselet... |
github | fizx/csvget | https://github.com/fizx/csvget | test/csvget_test.rb | Ruby | mit | 47 | master | 681 | require "test/unit"
require File.dirname(__FILE__) + "/../lib/csvget"
require "fileutils"
class CsvgetTest < Test::Unit::TestCase
include FileUtils
# def setup
# @output = {"bill-state"=>"Welcome to Google Business Solutions", "links"=>["/", "https://adwords.google.com/select/Login?sourceid=awo&subid=us-en-... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | sidekiq-priority.gemspec | Ruby | mit | 47 | master | 760 | require File.expand_path('../lib/sidekiq/priority/version', __FILE__)
Gem::Specification.new do |s|
s.authors = ['Tom Benner']
s.email = ['tombenner@gmail.com']
s.description = s.summary = %q{Prioritize Sidekiq jobs within queues}
s.homepage = 'https://github.com/socialpandas/sidekiq-priorit... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | lib/sidekiq/priority.rb | Ruby | mit | 47 | master | 769 | require 'sidekiq'
directory = File.dirname(File.absolute_path(__FILE__))
Dir.glob("#{directory}/priority/*.rb") { |file| require file }
Dir.glob("#{directory}/superworker/**/*.rb") { |file| require file } if defined?(Sidekiq::Superworker)
require "#{directory}/worker_ext.rb"
module Sidekiq
module Priority
PRIOR... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | lib/sidekiq/worker_ext.rb | Ruby | mit | 47 | master | 324 | module Sidekiq
module Worker
module ClassMethods
def perform_with_priority(priority, *args)
queue = self.get_sidekiq_options['queue']
queue = Sidekiq::Priority.queue_with_priority(queue, priority)
client_push('class' => self, 'args' => args, 'queue' => queue)
end
end
end
... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | lib/sidekiq/superworker/subjob_processor.rb | Ruby | mit | 47 | master | 637 | module Sidekiq
module Superworker
class SubjobProcessor
class << self
alias_method :original_sidekiq_item, :sidekiq_item
def sidekiq_item(subjob, klass, jid)
item = original_sidekiq_item(subjob, klass, jid)
# Modify the queue to be the prioritized queue, if necessary
... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | lib/sidekiq/superworker/worker_class.rb | Ruby | mit | 47 | master | 463 | module Sidekiq
module Superworker
class WorkerClass
class << self
def perform_with_priority(priority, *arg_values)
options = initialize_superjob(arg_values)
options[:meta] ||= {}
options[:meta].merge!({ priority: priority })
subjobs = create_subjobs(arg_values... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | lib/sidekiq/priority/server/fetch.rb | Ruby | mit | 47 | master | 768 | require 'celluloid'
require 'sidekiq/fetch'
module Sidekiq
module Priority
module Server
class Fetch < Sidekiq::BasicFetch
def initialize(options)
queues = prioritized_queues(options[:queues])
@strictly_ordered_queues = !!options[:strict]
@queues = queues.map { |q| "qu... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | spec/spec_helper.rb | Ruby | mit | 47 | master | 636 | require 'rspec/autorun'
require 'simplecov'
SimpleCov.start do
add_filter "vendor"
add_filter "spec"
add_filter "version"
end
require 'sidekiq-priority'
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | spec/sidekiq/worker_ext_spec.rb | Ruby | mit | 47 | master | 559 | require 'spec_helper'
describe Sidekiq::Worker do
describe '.perform_with_priority' do
before :all do
class TestWorker
include Sidekiq::Worker
sidekiq_options :queue => :foo
def perform(first, second)
end
end
end
it 'sends an item to client_push' do
Te... |
github | socialpandas/sidekiq-priority | https://github.com/socialpandas/sidekiq-priority | spec/sidekiq/priority/server/fetch_spec.rb | Ruby | mit | 47 | master | 888 | require 'spec_helper'
require 'sidekiq/priority/server/fetch'
describe Sidekiq::Priority::Server::Fetch do
describe '#initialize' do
before :all do
options = {
queues: ['foo', 'bar', 'foo'],
strict: true
}
@fetch = Sidekiq::Priority::Server::Fetch.new(options)
end
it 's... |
github | blockcypher/ruby-client | https://github.com/blockcypher/ruby-client | blockcypher-ruby.gemspec | Ruby | apache-2.0 | 47 | master | 971 | # frozen_string_literal: true
Gem::Specification.new do |s|
s.name = 'blockcypher-ruby'
s.summary = 'Blockcypher Ruby SDK'
s.version = '0.2.7'
s.licenses = ['Apache-2.0']
s.description = 'Ruby library to help you build your crypto application on BlockCypher'
s.summary = 'Ruby library ... |
github | blockcypher/ruby-client | https://github.com/blockcypher/ruby-client | lib/blockcypher/api.rb | Ruby | apache-2.0 | 47 | master | 11,229 | # frozen_string_literal: true
module BlockCypher
V1 = 'v1'
BTC = 'btc'
LTC = 'ltc'
DOGE = 'doge'
BCY = 'bcy'
ETH = 'eth'
MAIN_NET = 'main'
TEST_NET = 'test'
TEST_NET_3 = 'test3'
class Api
class Error < RuntimeError; end
attr_reader :api_token
def initialize(version: V1, currency: B... |
github | blockcypher/ruby-client | https://github.com/blockcypher/ruby-client | spec/spec_helper.rb | Ruby | apache-2.0 | 47 | master | 401 | # frozen_string_literal: true
require 'pry'
require 'rspec'
require 'yaml'
require 'active_support/core_ext/hash/indifferent_access'
require 'pathname'
require 'blockcypher'
SPEC_DIR = Pathname.new(File.dirname(__FILE__))
Dir[SPEC_DIR.join('support', '**', '*.rb')].sort.each { |f| require f }
CONFIG_FILE = SPEC_DIR... |
github | blockcypher/ruby-client | https://github.com/blockcypher/ruby-client | spec/blockcypher/api_spec.rb | Ruby | apache-2.0 | 47 | master | 6,178 | # frozen_string_literal: true
require 'spec_helper'
module BlockCypher
describe Api, vcr: { record: :once } do
let(:api) do
BlockCypher::Api.new({
api_token: CONFIG[:api_token],
currency: BlockCypher::BCY,
network: Bloc... |
github | blockcypher/ruby-client | https://github.com/blockcypher/ruby-client | spec/support/vcr.rb | Ruby | apache-2.0 | 47 | master | 270 | # frozen_string_literal: true
require 'vcr'
VCR.configure do |config|
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
config.hook_into :webmock
config.configure_rspec_metadata!
config.filter_sensitive_data('<api_token>') { CONFIG[:api_token] }
end |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | tackle.gemspec | Ruby | apache-2.0 | 47 | master | 1,028 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'tackle/version'
Gem::Specification.new do |spec|
spec.name = "rt-tackle"
spec.version = Tackle::VERSION
spec.licenses = ['MIT']
spec.authors = ["Rendered Text"]
... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle.rb | Ruby | apache-2.0 | 47 | master | 756 | require "tackle/version"
require "bunny"
require "logger"
module Tackle
require "tackle/connection"
require "tackle/publisher"
require "tackle/consumer"
ACK = :ack
NACK = :nack
module_function
def consume(params = {}, &block)
params = Tackle::Consumer::Params.new(params)
consumer = Tackle::C... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/connection.rb | Ruby | apache-2.0 | 47 | master | 1,060 | module Tackle
class Connection
attr_reader :channel
def initialize(amqp_url, exception_handler, logger, connection = nil)
@amqp_url = amqp_url
@exception_handler = exception_handler
@logger = logger
@connection = connection
connect
end
def connect
@logger.info("C... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer.rb | Ruby | apache-2.0 | 47 | master | 2,475 | module Tackle
require_relative "consumer/params"
require_relative "consumer/message"
require_relative "consumer/exchange"
require_relative "consumer/queue"
require_relative "consumer/main_queue"
require_relative "consumer/delay_queue"
require_relative "consumer/dead_queue"
require_relative "consumer/ac... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/publisher.rb | Ruby | apache-2.0 | 47 | master | 929 | module Tackle
class Publisher
def initialize(url, exchange_name, routing_key, logger, connection = nil)
@url = url
@exchange_name = exchange_name
@routing_key = routing_key
@logger = logger
@connection = connection
end
def publish(message)
connection = Tackle::Connect... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/exchange.rb | Ruby | apache-2.0 | 47 | master | 1,003 | module Tackle
class Consumer
class Exchange
attr_reader :routing_key
def initialize(service_name, routing_key, connection, logger)
@service_name = service_name
@routing_key = routing_key
@connection = connection
@logger = logger
@logger.info("Creating local e... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/dead_queue.rb | Ruby | apache-2.0 | 47 | master | 610 | module Tackle
class Consumer
class DeadQueue < Tackle::Consumer::Queue
def initialize(exchange, connection, logger)
name = "#{exchange.name}.dead"
options = { :durable => true }
super(name, options, connection, logger)
end
def publish(message)
message.log_erro... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/main_queue.rb | Ruby | apache-2.0 | 47 | master | 1,121 | module Tackle
class Consumer
class MainQueue < Tackle::Consumer::Queue
def initialize(exchange, connection, logger)
@exchange = exchange
name = @exchange.name
options = { :durable => true }
super(name, options, connection, logger)
bind_to_exchange
end
... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/params.rb | Ruby | apache-2.0 | 47 | master | 1,025 | module Tackle
class Consumer
class Params
attr_reader :amqp_url
attr_reader :exchange
attr_reader :routing_key
attr_reader :service
attr_reader :retry_limit
attr_reader :retry_delay
attr_reader :logger
attr_reader :exception_handler
attr_reader :manual_ack
... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/active_record_connection_reaper.rb | Ruby | apache-2.0 | 47 | master | 910 | module Tackle
class Consumer
module ActiveRecordConnectionReaper
module_function
#
# In case of a database failover, the active database connection can get
# stuck and unable to re-connect.
#
# It is important to clear all active connections after when a message
# is con... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/queue.rb | Ruby | apache-2.0 | 47 | master | 546 | module Tackle
class Consumer
class Queue
attr_reader :name
def initialize(name, options, connection, logger)
@name = name
@connection = connection
@logger = logger
@options = options
@amqp_queue = create_amqp_queue
end
def create_amqp_queue
... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/delay_queue.rb | Ruby | apache-2.0 | 47 | master | 1,088 | module Tackle
class Consumer
class DelayQueue < Tackle::Consumer::Queue
def initialize(retry_delay, exchange, connection, logger)
@retry_delay = retry_delay
name = "#{exchange.name}.delay.#{retry_delay}"
options = {
:durable => true,
:arguments => {
... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | lib/tackle/consumer/message.rb | Ruby | apache-2.0 | 47 | master | 1,254 | module Tackle
class Consumer
class Message
attr_reader :payload
attr_reader :properties
attr_reader :payload
def initialize(connection, logger, delivery_info, properties, payload)
@connection = connection
@logger = logger
@delivery_info = delivery_info
@p... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/spec_helper.rb | Ruby | apache-2.0 | 47 | master | 916 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require "tackle"
module BunnyHelper
module_function
def delete_queue(queue_name)
conn = Bunny.new
conn.start
channel = conn.channel
queue = channel.queue(queue_name, {:durable => true})
queue.delete
rescue Bunny::PreconditionFailed
... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/connection_mock_spec.rb | Ruby | apache-2.0 | 47 | master | 425 | require "spec_helper"
describe "Connection mock for test" do
before do
@tackle_options = {
:url => "amqp://localhost",
:exchange => "test-exchange",
:routing_key => "test-mock-key",
:service => "healthy-mock-service",
:connection => Object.new
}
end
it "raise NoMethodError... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/integration/healthy_consumer_spec.rb | Ruby | apache-2.0 | 47 | master | 930 | require "spec_helper"
describe "Healthy Consumers" do
before(:all) do
@messages = []
@tackle_options = {
:url => "amqp://localhost",
:exchange => "test-exchange",
:routing_key => "test-key",
:service => "healthy-service",
:retry_delay => 1,
:retry_limit => 3
}
@w... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/integration/publisher_spec.rb | Ruby | apache-2.0 | 47 | master | 588 | require "spec_helper"
describe "Publishing messages to a queue" do
before do
@tackle_options = {
:url => "amqp://localhost",
:exchange => "test-exchange",
:routing_key => "test-key",
:service => "healthy-service",
:retry_delay => 1,
:retry_limit => 3
}
end
context "c... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/integration/exchange_creation_spec.rb | Ruby | apache-2.0 | 47 | master | 888 | require "spec_helper"
describe "Exchange creation" do
before(:all) do
@messages = []
@tackle_options = {
:url => "amqp://localhost",
:exchange => "test-exchange",
:routing_key => "test-key",
:service => "test-service",
:retry_delay => 1,
:retry_limit => 3
}
@work... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/integration/multiple_consumers_spec.rb | Ruby | apache-2.0 | 47 | master | 1,752 | require "spec_helper"
describe "Multiple Consumers" do
before(:all) do
@tackle_options = {
:url => "amqp://localhost",
:exchange => "multiple-consumer-exchange",
:routing_key => "test-key",
:retry_delay => 1,
:retry_limit => 3
}
@healthy_service_messages = []
@healthy_c... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/integration/broken_consumers_spec.rb | Ruby | apache-2.0 | 47 | master | 1,692 | require "spec_helper"
describe "Broken Consumers" do
before(:all) do
@messages = []
@timestamps = []
@exceptions = []
@tackle_options = {
:url => "amqp://localhost",
:exchange => "test-exchange",
:routing_key => "test-key",
:service => "broken-service",
:retry_delay => ... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/integration/manual_ack_spec.rb | Ruby | apache-2.0 | 47 | master | 2,739 | require "spec_helper"
describe "Manual Ack Mode" do
before(:all) do
@messages = []
BunnyHelper.delete_queue("manual-acking-service.test-key")
BunnyHelper.delete_queue("manual-acking-service.test-key.dead")
@tackle_options = {
:url => "amqp://localhost",
:exchange => "test-exchange",
... |
github | renderedtext/tackle | https://github.com/renderedtext/tackle | spec/integration/queue_creation_spec.rb | Ruby | apache-2.0 | 47 | master | 1,181 | require "spec_helper"
describe "Queue creation" do
before(:all) do
@messages = []
BunnyHelper.delete_queue("test-service.test-key")
BunnyHelper.delete_queue("test-service.test-key.delay.1")
BunnyHelper.delete_queue("test-service.test-key.dead")
@tackle_options = {
:url => "amqp://localhos... |
github | gabrielecirulli/cleverbot-api | https://github.com/gabrielecirulli/cleverbot-api | cleverbot-api.gemspec | Ruby | mit | 47 | master | 584 | Gem::Specification.new do |s|
s.name = "cleverbot-api"
s.version = "0.0.4"
s.summary = "A simple API to interface with CleverBot"
s.description = "You can use this API to send messages and receive responses from CleverBot. You can create multiple instances of a connection with CleverBot and sessi... |
github | gabrielecirulli/cleverbot-api | https://github.com/gabrielecirulli/cleverbot-api | examples/cleverbot-vs-cleverbot.rb | Ruby | mit | 47 | master | 234 | require 'bundler/setup'
require 'cleverbot-api'
bot1 = CleverBot.new
bot2 = CleverBot.new
current = ''
loop do
current = bot1.think current
puts "Bot A: #{current}"
current = bot2.think current
puts "Bot B: #{current}"
end |
github | gabrielecirulli/cleverbot-api | https://github.com/gabrielecirulli/cleverbot-api | lib/cleverbot-api.rb | Ruby | mit | 47 | master | 1,924 | require 'net/http'
require 'digest/md5'
class CleverBot
def initialize
@service_uri = URI.parse 'http://www.cleverbot.com/webservicemin'
@post_params = {
start: 'y',
icognoid: 'wsf',
fno: '0',
sub: 'Say',
islearning: '1',
cleanslate: 'false'
}
@http = Net::HTTP.new... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | Gemfile | Ruby | mit | 47 | main | 469 | source 'https://rubygems.org'
# Specify your gem's dependencies in paranoia_uniqueness_validator.gemspec
gemspec
rails_version = ENV['RAILS_VERSION'] || 'default'
rails =
case rails_version
when 'master'
{ github: 'rails/rails' }
when 'default'
'>= 7.2'
else
"~> #{rails_version}"
end
gem 'rail... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | paranoia_uniqueness_validator.gemspec | Ruby | mit | 47 | main | 1,261 | lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'paranoia_uniqueness_validator/version'
Gem::Specification.new do |gem|
gem.name = 'paranoia_uniqueness_validator'
gem.version = ParanoiaUniquenessValidator::VERSION
gem.licenses = ['MIT']
... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/spec_helper.rb | Ruby | mit | 47 | main | 864 | ENV["RAILS_ENV"] = 'test'
require 'coveralls'
Coveralls.wear!
# Require dummy Rails app
require_relative '../spec/dummy/config/environment'
require 'database_cleaner'
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir["#{File.d... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/validations/uniqueness_without_deleted_spec.rb | Ruby | mit | 47 | main | 1,373 | require 'spec_helper'
require 'paranoia'
describe ParanoiaUniquenessValidator::Validations::UniquenessWithoutDeletedValidator do
context 'with nil default_sentinel_value' do
it "should validate uniqueness" do
DummyModel.create(:unique_field => "unique")
expect(DummyModel.new(:unique_field => "uniqu... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/dummy/config/application.rb | Ruby | mit | 47 | main | 847 | require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
# require "active_job/railtie"
require "active_record/railtie"
# require "action_controller/railtie"
# require "action_mailer/railtie"
# require "action_view/railtie"
# require "action_cable/engine"
# require "sprock... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/dummy/config/environments/development.rb | Ruby | mit | 47 | main | 1,894 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/dummy/config/environments/production.rb | Ruby | mit | 47 | main | 3,584 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/dummy/config/environments/test.rb | Ruby | mit | 47 | main | 1,756 | Rails.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 suit... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/dummy/db/schema.rb | Ruby | mit | 47 | main | 1,313 | # 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 source for your
# dat... |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/dummy/db/migrate/20160421194241_create_dummy_non_nil_models.rb | Ruby | mit | 47 | main | 257 | class CreateDummyNonNilModels < ActiveRecord::Migration[5.0]
def change
create_table :dummy_non_nil_models do |t|
t.string :unique_field
t.datetime :deleted_at, null: false, default: DateTime.new(0)
t.timestamps
end
end
end |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | spec/dummy/db/migrate/20130511080827_create_dummy_models.rb | Ruby | mit | 47 | main | 204 | class CreateDummyModels < ActiveRecord::Migration[5.0]
def change
create_table :dummy_models do |t|
t.string :unique_field
t.datetime :deleted_at
t.timestamps
end
end
end |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | lib/paranoia_uniqueness_validator.rb | Ruby | mit | 47 | main | 249 | require "paranoia_uniqueness_validator/validations/uniqueness_without_deleted"
require "paranoia_uniqueness_validator/version"
module ParanoiaUniquenessValidator
end
class ActiveRecord::Base
include ParanoiaUniquenessValidator::Validations
end |
github | anthonator/paranoia_uniqueness_validator | https://github.com/anthonator/paranoia_uniqueness_validator | lib/paranoia_uniqueness_validator/validations/uniqueness_without_deleted.rb | Ruby | mit | 47 | main | 1,565 | module ParanoiaUniquenessValidator
module Validations
class UniquenessWithoutDeletedValidator < ActiveRecord::Validations::UniquenessValidator
def validate_each(record, attribute, value)
finder_class = find_finder_class_for(record)
value = map_enum_attribute(finder_class, attribute, value)
... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | Rakefile | Ruby | mit | 47 | master | 393 | require 'rake/testtask'
require 'bundler/gem_tasks'
Rake::TestTask.new do |t|
t.libs = ['lib', 'test']
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task :test => 'lib/memcache/native_server.o'
file 'lib/memcache/native_server.o' do
`cd ext && ruby extconf.rb && make && cp native_server.bundle native... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | memcache.gemspec | Ruby | mit | 47 | master | 1,054 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |gem|
gem.name = "memcache"
gem.version = IO.read('VERSION')
gem.authors = ["Justin Balthrop"]
gem.email = ["git@justinbalthrop.com"]
gem.description = %... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache.rb | Ruby | mit | 47 | master | 12,126 | require 'zlib'
$:.unshift(File.dirname(__FILE__))
require 'memcache/base'
require 'memcache/server'
require 'memcache/local_server'
begin
require 'memcache/native_server'
rescue LoadError => e
puts "memcache is not using native bindings. for faster performance, compile extensions by hand or install as a local gem.... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache/segmented.rb | Ruby | mit | 47 | master | 3,368 | require 'digest/sha1'
class Memcache
module Segmented
MAX_SIZE = 1000000 # bytes
PARTIAL_VALUE = 0x40000000
def get(keys, cas = nil)
return get([keys], cas)[keys.to_s] unless keys.kind_of?(Array)
return {} if keys.empty?
results = super(keys, cas)
keys = {}
keys_to_fetch =... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache/local_server.rb | Ruby | mit | 47 | master | 1,387 | class Memcache
class LocalServer < Base
def initialize
@data = {}
@expiry = {}
end
def name
"local:#{hash}"
end
def stats
{ # curr_items may include items that have expired.
'curr_items' => @data.size,
'expiry_count' => @expiry.size,
}
end
... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache/migration.rb | Ruby | mit | 47 | master | 570 | class Memcache
class Migration < ActiveRecord::Migration
class << self
attr_accessor :table
end
def self.up
create_table table, :id => false do |t|
t.string :prefix, :null => false
t.string :key, :null => false
t.text :value, :null => false
t.int... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache/null_server.rb | Ruby | mit | 47 | master | 408 | class Memcache
class NullServer < Base
def name
"null"
end
def flush_all(delay = nil)
end
def get(keys)
keys.kind_of?(Array) ? {} : nil
end
def incr(key, amount = nil)
nil
end
def delete(key, expiry = nil)
nil
end
def set(key, value, expiry = ni... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache/server.rb | Ruby | mit | 47 | master | 7,020 | require 'socket'
require 'thread'
require 'timeout'
class Memcache
class Server < Base
CONNECT_TIMEOUT = 1.0
READ_RETRY_DELAY = 5.0
DEFAULT_PORT = 11211
attr_reader :host, :port, :status, :retry_at
def initialize(opts)
@host = opts[:host]
@port = opts[:port] || ... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache/base.rb | Ruby | mit | 47 | master | 1,464 | class Memcache
class Base
attr_accessor :prefix
def clear
flush_all
end
# Default implementations based on get and set.
def gets(keys)
get(keys, true)
end
def incr(key, amount = 1)
result = get(key)
return unless result
value = result[:value]
return... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | lib/memcache/pg_server.rb | Ruby | mit | 47 | master | 4,461 | require 'active_record'
require 'memcache/migration'
require 'pg'
class PGconn
def self.quote_ident(name)
%("#{name}")
end
end
class Memcache
class PGServer < Base
attr_reader :db, :table
def initialize(opts)
@table = opts[:table]
@db = opts[:db] || ActiveRecord::Base.connection.raw_... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_server_test.rb | Ruby | mit | 47 | master | 708 | require 'test/unit'
require File.dirname(__FILE__) + '/memcache_server_test_helper'
class MemcacheServerTest < Test::Unit::TestCase
include MemcacheServerTestHelper
include MemcacheServerTestHelper::AdvancedMethods
with_prefixes nil, "foo:", "bar:"
PORT = 11212
def setup
init_memcache(PORT) do
Mem... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_native_server_test.rb | Ruby | mit | 47 | master | 794 | require File.dirname(__FILE__) + '/memcache_server_test_helper'
class MemcacheNativeServerTest < Test::Unit::TestCase
include MemcacheServerTestHelper
include MemcacheServerTestHelper::AdvancedMethods
with_prefixes nil, "foo:", "bar:"
PORTS = [11212, 11213, 11214, 11215, 11216]
def setup
init_memcache(*... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_server_test_helper.rb | Ruby | mit | 47 | master | 5,536 | require File.dirname(__FILE__) + '/test_helper'
module MemcacheServerTestHelper
def test_prefix
assert_equal nil, m.prefix = nil
assert_equal nil, m.prefix
m.set('1', 'baz', 0)
m.set('2', 'bar', 0)
assert_equal nil, m.prefix
assert_equal 'foo', m.prefix = 'foo'
assert_equal 'foo', m.p... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_pg_server_test.rb | Ruby | mit | 47 | master | 694 | require File.dirname(__FILE__) + '/memcache_server_test_helper'
require 'memcache/pg_server'
class MemcachePGServerTest < Test::Unit::TestCase
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:host => "localhost",
:username => `whoami`.chomp,
:password => "",
:database => "... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_local_server_test.rb | Ruby | mit | 47 | master | 254 | require File.dirname(__FILE__) + '/memcache_server_test_helper'
class MemcacheLocalServerTest < Test::Unit::TestCase
include MemcacheServerTestHelper
with_prefixes nil, "foo:", "bar:"
def setup
@memcache = Memcache::LocalServer.new
end
end |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_segmented_server_test.rb | Ruby | mit | 47 | master | 578 | require 'test/unit'
require File.dirname(__FILE__) + '/memcache_server_test_helper'
require File.dirname(__FILE__) + '/memcache_segmented_test_helper'
$VERBOSE = nil
Memcache::Segmented.const_set('MAX_SIZE', 3)
class MemcacheSegmentedServerTest < Test::Unit::TestCase
include MemcacheServerTestHelper
include Memca... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_segmented_test_helper.rb | Ruby | mit | 47 | master | 556 | module MemcacheSegmentedTestHelper
def test_segmented_delete
m.set('fav_numbers', '1,2,3,4,5,6,7,8,9,10')
master_key = m.send(:super_get, 'fav_numbers')
segment_keys = m.send(:segment_keys, master_key)
assert_not_equal '1,2,3,4,5,6,7,8,9,10', master_key
assert_equal 7, segment_keys.size
a... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/test_helper.rb | Ruby | mit | 47 | master | 1,314 | require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'mocha/setup'
require 'pp'
require 'memcache'
class Test::Unit::TestCase
@@servers ||= {}
def init_memcache(*ports)
ports.each do |port|
@@servers[port] ||= start_memcache(port)
end
@memcache = yield
@memcache.flush_all
end
... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_test.rb | Ruby | mit | 47 | master | 6,327 | require 'test/unit'
require File.dirname(__FILE__) + '/test_helper'
class MemcacheTest < Test::Unit::TestCase
PORTS = [11212, 11213, 11214, 11215, 11216, 11217]
def setup
init_memcache(*PORTS) do
Memcache.new(:servers => PORTS.collect {|p| "localhost:#{p}"})
end
end
def test_get_and_set
100.... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_segmented_native_server_test.rb | Ruby | mit | 47 | master | 621 | require 'test/unit'
require File.dirname(__FILE__) + '/memcache_server_test_helper'
require File.dirname(__FILE__) + '/memcache_segmented_test_helper'
$VERBOSE = nil
Memcache::Segmented.const_set('MAX_SIZE', 3)
class MemcacheSegmentedNativeServerTest < Test::Unit::TestCase
include MemcacheServerTestHelper
include... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | test/memcache_null_server_test.rb | Ruby | mit | 47 | master | 1,214 | require 'test/unit'
require 'memcache/base'
require 'memcache/null_server'
class MemcacheNullServerTest < Test::Unit::TestCase
def setup
@memcache = Memcache::NullServer.new
end
def m
@memcache
end
def test_set_and_get
m.set(2, 'foo', 0)
assert_equal nil, m.get('2')
assert_equal nil, m... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | ext/extconf.rb | Ruby | mit | 47 | master | 2,476 | # This file was derived from Evan's Weaver memcached library: http://github.com/fauna/memcached
# See the ext/LICENSE_AFL3 file.
require 'mkmf'
require 'rbconfig'
HERE = File.expand_path(File.dirname(__FILE__))
BUNDLE = Dir.glob("libmemcached-*.tar.gz").first
BUNDLE_PATH = BUNDLE.sub(".tar.gz", "")
$CXXF... |
github | ninjudd/memcache | https://github.com/ninjudd/memcache | bench/benchmark.rb | Ruby | mit | 47 | master | 3,289 | require 'rubygems'
require 'benchmark'
require 'pp'
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'memcache'
def array(*args)
arr = []
args.each do |arg|
if arg.kind_of?(Enumerable)
arr.concat(arg.to_a)
else
arr << arg
end
end
arr
end
CHARS = array('a'..'z', 'A'..'Z', '0'..'... |
github | sporkd/mongoid-metastamp | https://github.com/sporkd/mongoid-metastamp | Rakefile | Ruby | mit | 47 | master | 207 | require "bundler/gem_tasks"
require "rspec/core/rake_task"
desc "Run all specs in spec directory"
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = "spec/**/*_spec.rb"
end
task :default => :spec |
github | sporkd/mongoid-metastamp | https://github.com/sporkd/mongoid-metastamp | mongoid-metastamp.gemspec | Ruby | mit | 47 | master | 1,121 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "mongoid/metastamp/version"
Gem::Specification.new do |s|
s.name = "mongoid-metastamp"
s.version = Mongoid::Metastamp::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Peter Gumeson"]
s.email = ["gume... |
github | sporkd/mongoid-metastamp | https://github.com/sporkd/mongoid-metastamp | spec/time_search_spec.rb | Ruby | mit | 47 | master | 6,294 | #encoding: utf-8
require "spec_helper"
describe "Mongoid::Metastamp::Time" do
let :eastern_zone do
"Eastern Time (US & Canada)"
end
let :pacific_zone do
"Pacific Time (US & Canada)"
end
let :utc_zone do
"UTC"
end
let :wed_oct_5_ten_am do
"2011-10-05 10:00:00"
end
context "given ... |
github | sporkd/mongoid-metastamp | https://github.com/sporkd/mongoid-metastamp | spec/spec_helper.rb | Ruby | mit | 47 | master | 620 | require "rubygems"
require "bundler/setup"
require "zonebie"
require "mongoid"
require "mongoid/metastamp"
require "mongoid/metastamp/time"
require "rspec"
Zonebie.set_random_timezone
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("mongoid_metastamp_test")
config.use_utc = false
config... |
github | sporkd/mongoid-metastamp | https://github.com/sporkd/mongoid-metastamp | spec/time_compatibility_spec.rb | Ruby | mit | 47 | master | 1,866 | #encoding: utf-8
require "spec_helper"
describe "Mongoid::Metastamp::Time" do
let :now do
Time.zone.now
end
describe "compatibility with Time class" do
class Legacy
include Mongoid::Document
field :timestamp, type: Time
end
let :instance do
Legacy.create(timestamp: now).rel... |
github | sporkd/mongoid-metastamp | https://github.com/sporkd/mongoid-metastamp | spec/time_storage_spec.rb | Ruby | mit | 47 | master | 7,014 | #encoding: utf-8
require "spec_helper"
describe "Mongoid::Metastamp::Time" do
before :each do
Zonebie.set_random_timezone
end
context "when storing nil" do
context "on initialization" do
let :event do
Event.new(timestamp: nil)
end
describe "on serialization" do
it... |
github | sporkd/mongoid-metastamp | https://github.com/sporkd/mongoid-metastamp | lib/mongoid/metastamp/time.rb | Ruby | mit | 47 | master | 1,846 | # encoding: utf-8
module Mongoid #:nodoc:
module Metastamp
class Time
include Mongoid::Fields::Serializable
include Mongoid::Fields::Internal::Timekeeping
def deserialize(object)
return nil if object.blank?
return super(object) if object.instance_of?(::Time)
time = obje... |
github | tcocca/active_pdftk | https://github.com/tcocca/active_pdftk | Rakefile | Ruby | mit | 47 | master | 688 | require 'rubygems'
begin
require 'bundler'
Bundler::GemHelper.install_tasks
rescue LoadError
task(:build){abort "`gem install bundler` to build gem"}
task(:install){abort "`gem install bundler` to install gem"}
task(:release){abort "`gem install bundler` to release gem"}
end
begin
require 'rspec/core/rake... |
github | tcocca/active_pdftk | https://github.com/tcocca/active_pdftk | active_pdftk.gemspec | Ruby | mit | 47 | master | 1,018 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "active_pdftk/version"
Gem::Specification.new do |s|
s.name = "active_pdftk"
s.version = ActivePdftk::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Tom Cocca"]
s.email = ["tom.cocca@gmail.com"]
s... |
github | tcocca/active_pdftk | https://github.com/tcocca/active_pdftk | spec/spec_helper.rb | Ruby | mit | 47 | master | 341 | require File.expand_path('../../lib/active_pdftk', __FILE__)
require 'rspec'
puts ActivePdftk::Call.locate_pdftk.inspect
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
RSpec.configure do |config|
config.filter_run :focus => true
config.run_all_when_everything... |
github | tcocca/active_pdftk | https://github.com/tcocca/active_pdftk | spec/active_pdftk/fdf_spec.rb | Ruby | mit | 47 | master | 1,236 | require 'spec_helper'
describe ActivePdftk::Fdf do
context "multiple fields" do
before do
@fdf = ActivePdftk::Fdf.new :field1 => 'fieldvalue1', :other_field => 'some other value'
@fdf_text = @fdf.to_s
end
it { @fdf_text.should_not be_nil }
it { @fdf_text.should match(%r{<</T\(field1\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.