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
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
examples/worker_dedupe.rb
Ruby
mit
97
master
350
$LOAD_PATH.unshift("../lib") require 'rubygems' require 'gearman' # Control logger l = Logger.new($stdout) l.level = Logger::DEBUG Gearman.logger=l servers = ['localhost:4730'] worker = Gearman::Worker.new(servers) worker.add_ability('dedupe') do |data, job| puts "Should only see one of these come through!" t...
github
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
examples/client_reverse_string.rb
Ruby
mit
97
master
341
#!/usr/bin/env ruby $:.unshift '../lib' require 'gearman' client = Gearman::Client.new('localhost:4730') # Create 100 foreground jobs, one at a time (1..100).each do |jid| data = rand(36**8).to_s(36) puts "#{jid} #{data}" task = Gearman::Task.new('reverse_string', data) task.on_complete {|d| puts d } client...
github
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
spec/connection_pool_spec.rb
Ruby
mit
97
master
2,265
require 'spec_helper' require 'socket' describe Gearman::ConnectionPool do context "normalizing job servers" do before :each do @connection_pool = Gearman::ConnectionPool.new end it "should handle a string for input" do connection = Gearman::Connection.new("localhost", 1234) connection...
github
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
spec/spec_helper.rb
Ruby
mit
97
master
326
require 'simplecov' require 'rspec' require 'rspec/mocks' SimpleCov.start do add_filter "/spec/" merge_timeout 3600 end $:.unshift(File.expand_path('../lib', __FILE__)) require 'gearman' Gearman.logger = Logger.new(STDERR) Gearman.logger.level = Logger::DEBUG RSpec.configure do |config| config.mock_with :rspe...
github
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
spec/client_spec.rb
Ruby
mit
97
master
2,343
require 'spec_helper' require 'socket' describe Gearman::Client do before(:all) do @tcp_server = TCPServer.new 5789 end after(:all) do @tcp_server.close end before(:each) do @mock_connection_pool = double(Gearman::ConnectionPool) Gearman::ConnectionPool.stub(:new).and_return @mock_connectio...
github
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
spec/taskset_spec.rb
Ruby
mit
97
master
2,699
require 'spec_helper' require 'socket' require 'rspec' require 'rspec/mocks' require 'gearman' describe Gearman::TaskSet do before do end after do end xit "handles a NetworkError when submitting a job" do bad_socket = double(TCPSocket) bad_socket.should_receive(:write) { |*args| args[0].len...
github
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
spec/task_spec.rb
Ruby
mit
97
master
4,920
require 'spec_helper' require 'socket' require 'rspec' require 'rspec/mocks' require 'gearman' describe Gearman::Task do before(:each) do end context :creation do it "throws an exception when passed bogus opts" do expect { Gearman::Task.new("bogus_task", "data", {:bogus => 'bogon'}) }....
github
johnewart/gearman-ruby
https://github.com/johnewart/gearman-ruby
spec/support/fake_tcp_socket.rb
Ruby
mit
97
master
355
class FakeTCPSocket def readline(some_text = nil) return @canned_response end def flush end def write(some_text = nil) end def readchar return 6 end def read(num) return num > @canned_response.size ? @canned_response : @canned_response[0..num] end def set_canned(response) @ca...
github
mailtrap/actionmailer-balancer
https://github.com/mailtrap/actionmailer-balancer
actionmailer-balancer.gemspec
Ruby
mit
97
main
1,339
# frozen_string_literal: true require_relative 'lib/actionmailer/balancer/version' Gem::Specification.new do |spec| spec.name = 'actionmailer-balancer' spec.version = ActionMailer::Balancer::VERSION spec.authors = ['Railsware Products Studio, Inc.'] spec.email = ['support@mailtrap.io'] spec.summary = 'Acti...
github
mailtrap/actionmailer-balancer
https://github.com/mailtrap/actionmailer-balancer
spec/spec_helper.rb
Ruby
mit
97
main
423
# frozen_string_literal: true require 'actionmailer/balancer' require 'mail' require 'action_mailer' 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` ...
github
mailtrap/actionmailer-balancer
https://github.com/mailtrap/actionmailer-balancer
spec/actionmailer/balancer/delivery_method_spec.rb
Ruby
mit
97
main
3,618
# frozen_string_literal: true RSpec.describe ActionMailer::Balancer::DeliveryMethod do # rubocop:disable RSpec/SpecFilePathFormat describe '#deliver!' do subject(:deliver!) { described_class.new(settings).deliver!(message) } let(:settings) do { delivery_methods: [ { metho...
github
mailtrap/actionmailer-balancer
https://github.com/mailtrap/actionmailer-balancer
lib/actionmailer/balancer.rb
Ruby
mit
97
main
259
# frozen_string_literal: true require_relative 'balancer/delivery_method' require_relative 'balancer/railtie' if defined? Rails require_relative 'balancer/version' module ActionMailer module Balancer class SettingsError < StandardError; end end end
github
mailtrap/actionmailer-balancer
https://github.com/mailtrap/actionmailer-balancer
lib/actionmailer/balancer/railtie.rb
Ruby
mit
97
main
398
# frozen_string_literal: true module ActionMailer module Balancer class Railtie < Rails::Railtie initializer 'action_mailer_balancer.add_delivery_method', before: 'action_mailer.set_configs' do ActiveSupport.on_load(:action_mailer) do ::ActionMailer::Base.add_delivery_method(:balancer, Ac...
github
mailtrap/actionmailer-balancer
https://github.com/mailtrap/actionmailer-balancer
lib/actionmailer/balancer/delivery_method.rb
Ruby
mit
97
main
1,482
# frozen_string_literal: true module ActionMailer module Balancer class DeliveryMethod attr_reader :delivery_methods, :weights_sum def initialize(settings = {}) add_delivery_methods(settings) end def deliver!(message) delivery_method = choose_delivery_method mess...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
Gemfile
Ruby
mit
97
master
524
source 'https://rubygems.org' gemspec if ENV['EDGE'] gem 'warden-github', github: 'atmos/warden-github' end rails_version = ENV['RAILS_VERSION'] rails_opts = case rails_version when 'master' { github: 'rails/rails' } when nil {} else ...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
warden-github-rails.gemspec
Ruby
mit
97
master
1,073
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'warden/github/rails/version' Gem::Specification.new do |gem| gem.name = 'warden-github-rails' gem.version = Warden::GitHub::Rails::VERSION gem.authors = ['Philipe Fatio'] gem.email ...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
example/app/controllers/organizations_controller.rb
Ruby
mit
97
master
383
class OrganizationsController < ApplicationController def index @orgs = github_user.api.organizations end def show @org = github_user.api.organization(params[:id]) @members = github_user.api.organization_members(params[:id]) @repos = github_user.api.organization_repositories(params[:id]) @tea...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
example/app/controllers/teams_controller.rb
Ruby
mit
97
master
230
class TeamsController < ApplicationController def show @team = github_user.api.team(params[:id]) @repos = github_user.api.team_repositories(params[:id]) @members = github_user.api.team_members(params[:id]) end end
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
example/config/application.rb
Ruby
mit
97
master
375
require File.expand_path('../boot', __FILE__) require "action_controller/railtie" if defined?(Bundler) Bundler.require(*Rails.groups(assets: %w(development test))) end module Example class Application < Rails::Application config.encoding = "utf-8" config.filter_parameters += [:password] config.active...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
example/config/routes.rb
Ruby
mit
97
master
616
Example::Application.routes.draw do github_authenticate do get '/orgs' => 'organizations#index', as: :orgs get '/profile' => 'users#show', as: :profile end github_authenticate(team: lambda { |req| req.params[:id] }) do get '/teams/:id' => 'teams#show', as: :team end github_authenticate(org: lamb...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
example/config/environments/production.rb
Ruby
mit
97
master
242
Example::Application.configure do config.eager_load = true config.cache_classes = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.active_support.deprecation = :notify end
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
example/config/environments/test.rb
Ruby
mit
97
master
372
Example::Application.configure do config.eager_load = true config.cache_classes = true config.whiny_nils = true config.consider_all_requests_local = true config.action_controller.perform_caching = false config.action_dispatch.show_exceptions = false config.action_controller.allow_forgery_protection = fals...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
example/config/environments/development.rb
Ruby
mit
97
master
321
Example::Application.configure do config.eager_load = false config.cache_classes = false config.whiny_nils = true config.consider_all_requests_local = true config.action_controller.perform_caching = false config.active_support.deprecation = :log config.action_dispatch.best_standards_support = :builtin end
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
lib/warden/github/rails.rb
Ruby
mit
97
master
760
require 'warden/github' require 'warden/github/rails/version' require 'warden/github/rails/routes' require 'warden/github/rails/railtie' require 'warden/github/rails/config' require 'warden/github/rails/controller_helpers' require 'forwardable' module Warden module GitHub module Rails extend SingleForwar...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
lib/warden/github/rails/controller_helpers.rb
Ruby
mit
97
master
1,353
module Warden module GitHub module Rails module ControllerHelpers def self.included(klass) klass.helper_method(:github_authenticated?, :github_user) end # Initiates the OAuth flow if not already authenticated for the # specified scope. def github_authentica...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
lib/warden/github/rails/railtie.rb
Ruby
mit
97
master
1,798
module Warden module GitHub module Rails class Railtie < ::Rails::Railtie SERIALIZE_FROM_SESSION = -> ((class_name, data)) do class_name.constantize.new.tap { |user| user.marshal_load(data) } end SERIALIZE_INTO_SESSION = -> (user) do [user.class.name, user.marshal...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
lib/warden/github/rails/test_helpers.rb
Ruby
mit
97
master
686
require 'warden/github' require 'warden/github/rails/test_helpers/mock_user' module Warden module GitHub module Rails module TestHelpers include ::Warden::Test::Helpers # Login a mock GitHub user and return it. def github_login(scope=Rails.default_scope) MockUser.new.tap ...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
lib/warden/github/rails/config.rb
Ruby
mit
97
master
1,449
module Warden module GitHub module Rails class Config BadConfig = Class.new(StandardError) # Default scope to use when not explicitly specified. attr_accessor :default_scope # The list of scopes and their configs. This is used to add custom # configs to a specific s...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
lib/warden/github/rails/routes.rb
Ruby
mit
97
master
2,813
module Warden module GitHub module Rails module Routes # Enforces an authenticated GitHub user for the routes. If not # authenticated, it initiates the OAuth flow. # # Team and organization memberships can be checked by specifying a hash # such as `team: 'foobar'` or ...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
lib/warden/github/rails/test_helpers/mock_user.rb
Ruby
mit
97
master
1,117
module Warden module GitHub module Rails module TestHelpers class MockUser < User def initialize(*args) super @memberships = { team: [], org: [] } end # Prevent the stubbed memberships from being overwritten by the hook # that sets the...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/spec_helper.rb
Ruby
mit
97
master
1,071
if RUBY_ENGINE == 'ruby' if ENV['CI'] require 'coveralls' Coveralls::Output.silent = true Coveralls.wear! do add_filter 'spec/' add_filter 'example/' end else require 'simplecov' SimpleCov.start end end require 'rack/test' require 'warden/github/rails/test_helpers' require 'ad...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/integration/scope_spec.rb
Ruby
mit
97
master
1,097
require 'spec_helper' # Test if the configs in rails_app/config/initializers/warden_github_rails.rb # are actually being set and used by warden. describe 'request to custom configured scope' do def test_redirect(url, args) request = get url params = Addressable::URI.parse(request.location).query_values ...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/integration/view_helpers_spec.rb
Ruby
mit
97
master
398
require 'spec_helper' describe 'view helpers' do describe '#github_user' do subject(:request) { get "/view_tests/user" } it 'is defined' do expect(request.body).to include('true') end end describe '#github_authenticated?' do subject(:request) { get "/view_tests/authenticated" } it 'i...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/integration/membership_spec.rb
Ruby
mit
97
master
7,532
require 'spec_helper' describe 'request to a protected resource' do context 'that requires a team membership' do context 'which is specified by a numeric team id' do subject { get '/team/protected' } context 'when not logged in' do it { is_expected.to be_github_oauth_redirect } end ...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/integration/controller_helpers_spec.rb
Ruby
mit
97
master
2,503
require 'spec_helper' describe 'controller helpers' do { scoped: :admin, unscoped: Warden::GitHub::Rails.default_scope }.each do |type, scope| context "when using #{type}" do describe '#github_authenticate!' do subject(:request) { get "/#{type}/authenticate" } context 'when not...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/integration/route_spec.rb
Ruby
mit
97
master
1,933
require 'spec_helper' describe 'request to a protected resource' do subject { get '/protected' } context 'when not logged in' do it { is_expected.to be_github_oauth_redirect } end context 'when logged in' do before { github_login } it { is_expected.to be_ok } end context 'with multiple scope...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/app/controllers/scoped_controller.rb
Ruby
mit
97
master
520
class ScopedController < ActionController::Base def authenticate github_authenticate!(:admin) head :ok end def logout was_logged_in = !github_user(:admin).nil? github_logout(:admin) render plain: was_logged_in end def authenticated render plain: github_authenticated?(:admin) end ...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/app/controllers/unscoped_controller.rb
Ruby
mit
97
master
458
class UnscopedController < ActionController::Base def authenticate github_authenticate! head :ok end def logout was_logged_in = !github_user.nil? github_logout render plain: was_logged_in end def authenticated render plain: github_authenticated? end def user render plain: gi...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/config/application.rb
Ruby
mit
97
master
426
require File.expand_path('../boot', __FILE__) require 'action_controller/railtie' require 'warden/github/rails' unless Rails.env.test? begin require 'debugger' rescue LoadError require 'ruby-debug' end end module RailsApp class Application < Rails::Application config.encoding = "utf-8" config...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/config/routes.rb
Ruby
mit
97
master
2,572
RailsApp::Application.routes.draw do responses = { 200 => lambda { |env| [200, {}, ['welcome']] }, 404 => lambda { |env| [404, {}, ['not found']] } } # Routes for route constraints tests: github_authenticate { get '/protected' => responses[200] } github_authenticated { get '/condition...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/config/initializers/warden_github_rails.rb
Ruby
mit
97
master
591
Warden::GitHub::Rails.setup do |config| config.add_scope :user, client_id: ENV['GITHUB_CLIENT_ID'] || 'foo', client_secret: ENV['GITHUB_CLIENT_SECRET'] || 'bar', scope: 'user' config.add_scope :admin, client_id: ENV['GITHUB_CLIENT_ID'] || 'abc'...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/config/environments/test.rb
Ruby
mit
97
master
382
RailsApp::Application.configure do config.eager_load = true config.cache_classes = true config.whiny_nils = true config.consider_all_requests_local = true config.action_controller.perform_caching = false config.action_dispatch.show_exceptions = false config.action_controller.allow_forgery_protection...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/config/environments/production.rb
Ruby
mit
97
master
274
RailsApp::Application.configure do config.eager_load = true config.cache_classes = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.i18n.fallbacks = true config.active_support.deprecation = :notify end
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/rails_app/config/environments/development.rb
Ruby
mit
97
master
328
RailsApp::Application.configure do config.eager_load = false config.cache_classes = false config.whiny_nils = true config.consider_all_requests_local = true config.action_controller.perform_caching = false config.active_support.deprecation = :log config.action_dispatch.best_standards_support = :buil...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/unit/config_spec.rb
Ruby
mit
97
master
1,669
require 'spec_helper' describe Warden::GitHub::Rails::Config do subject(:config) { described_class.new } describe '#default_scope' do it 'defaults to :user' do expect(config.default_scope).to eq(:user) end end describe '#scopes' do it 'defaults to an empty hash' do expect(config.scope...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/unit/mock_user_spec.rb
Ruby
mit
97
master
1,009
require 'spec_helper' describe Warden::GitHub::Rails::TestHelpers::MockUser do it { is_expected.to be_a Warden::GitHub::User } describe '#stub_membership' do subject(:user) { described_class.new } it 'stubs memberships' do expect(user).not_to be_team_member(123) expect(user).not_to be_team_me...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/unit/test_helpers_spec.rb
Ruby
mit
97
master
847
require 'spec_helper' describe Warden::GitHub::Rails::TestHelpers do describe '#github_login' do before { allow(self).to receive(:login_as) } context 'when no scope is specified' do it 'uses the default scope from config to login' do allow(Warden::GitHub::Rails).to receive(:default_scope) { :f...
github
fphilipe/warden-github-rails
https://github.com/fphilipe/warden-github-rails
spec/unit/rails_spec.rb
Ruby
mit
97
master
241
require 'spec_helper' describe Warden::GitHub::Rails do describe '.setup' do it 'yields a config instance' do described_class.setup do |config| expect(config).to be_a(described_class::Config) end end end end
github
kdan-mobile-software-ltd/json_requester
https://github.com/kdan-mobile-software-ltd/json_requester
Gemfile
Ruby
mit
97
master
459
# frozen_string_literal: true source "https://rubygems.org" gemspec # Simple, but flexible HTTP client library, with support for multiple backends. gem "faraday", "~> 2.14.1" # Perform multipart-post requests using Faraday. gem "faraday-multipart", "~> 1.2.0" group :development, :test do gem "pry", "~> 0.16.0" ...
github
kdan-mobile-software-ltd/json_requester
https://github.com/kdan-mobile-software-ltd/json_requester
json_requester.gemspec
Ruby
mit
97
master
1,018
# frozen_string_literal: true Gem::Specification.new do |s| s.name = "json_requester" s.version = File.read("./VERSION.md") s.platform = Gem::Platform::RUBY s.summary = "Basic Wrapper of Faraday" s.description = "wrapper of faraday" s.authors = ["JiaRou Lee"] s.email = "laura3...
github
kdan-mobile-software-ltd/json_requester
https://github.com/kdan-mobile-software-ltd/json_requester
spec/json_requester_spec.rb
Ruby
mit
97
master
8,971
# frozen_string_literal: true require "spec_helper" RSpec.describe JsonRequester do let(:host) { "http://example.com" } let(:requester) { JsonRequester.new(host) } let(:requester_with_override_user_agent) { JsonRequester.new(host, user_agent: "test_agent") } describe "#initialize" do it "initializes with...
github
kdan-mobile-software-ltd/json_requester
https://github.com/kdan-mobile-software-ltd/json_requester
lib/json_requester.rb
Ruby
mit
97
master
4,946
# frozen_string_literal: true require "faraday" require "faraday/multipart" require "json" class JsonRequester attr_reader :host, :conn def initialize(host, multipart: false, ssl_verify: true, timeout: 60, user_agent: "") @host = host @multipart = multipart @ssl_verify = ssl_verify @timeout = tim...
github
arikast/askbash
https://github.com/arikast/askbash
askbash.rb
Ruby
mit
97
master
918
#!/usr/bin/ruby ################################ ### the entry point which bash will call ### see the README.md for full instructions how to setup ################################ require_relative 'lib/core.rb' require_relative 'lib/config-search.rb' include ConfigSearch begin config = ARGV[0] #config = c...
github
arikast/askbash
https://github.com/arikast/askbash
bashrc-generator.rb
Ruby
mit
97
master
652
#!/usr/bin/ruby ################################################ ### this generates entries to put in your .bashrc ### see the README.md for instructions on the easiest way to incorporate its output in your .bashrc or .bash_profile ################################################ require_relative 'lib/core.rb' requi...
github
arikast/askbash
https://github.com/arikast/askbash
lib/universal-utils.rb
Ruby
mit
97
master
1,183
module UniversalUtils def debugMode? ENV["ASKBASH_DEBUG"] end def log(msg) debug = debugMode? if debug logfile = 'askbash.log' if ! ENV['ASKBASH_HOME'].nil? logfile = "#{ENV['ASKBASH_HOME']}/#{logfile}" end open(logfile, 'a') { |f| if debug == "2" f.pu...
github
arikast/askbash
https://github.com/arikast/askbash
lib/core.rb
Ruby
mit
97
master
11,571
##################################################################### ### this is the main program which gathers and outputs the completion ##################################################################### require 'yaml' require_relative 'universal-utils.rb' require_relative 'tokenize.rb' include UniversalUtils...
github
arikast/askbash
https://github.com/arikast/askbash
lib/tokenize.rb
Ruby
mit
97
master
6,351
require 'yaml' class Assembly attr_accessor :parsers, :text, :result def initialize(text) @text = text @parsers = [] @result = [] end def makeView AssemblyView.new self end def pushTerm(term) if term.nil? || term =~ /^\s*$/ return ...
github
arikast/askbash
https://github.com/arikast/askbash
lib/config-search.rb
Ruby
mit
97
master
1,338
######################## ### manages the process of locating completion config files ######################## module ConfigSearch COMPLETION_CONF_DIRS = [ "#{ENV['HOME']}/.askbash", ENV['ASKBASH_HOME'], # File.dirname(__FILE__) ] CompletionConf = Struct.new(:command, :configfile) def allCompletionConfs(...
github
arikast/askbash
https://github.com/arikast/askbash
lib/testtools.rb
Ruby
mit
97
master
1,429
module TestTools def expectedIs(a, b) b.sort! output = AutoCompleter.new(@config, a).parse.sort! if output != b puts caller puts "for input: #{a}" puts "#{output} != #{b}" puts ">>> Test FAILED <<<" exit end end def expectedContains(a, b) output = AutoCompl...
github
arikast/askbash
https://github.com/arikast/askbash
lib/completers/FileCompleter.rb
Ruby
mit
97
master
832
################### ### this completer is for completing a local file path ################### class FileCompleter < DynamicCompleter def deriveChoices(rawChoice, token) if ! token.nil? && token.length > 0 && token[-1] == " " return [ token ] end tok = if token.nil? then "" else token.strip ...
github
arikast/askbash
https://github.com/arikast/askbash
lib/completers/ExecCompleter.rb
Ruby
mit
97
master
557
#################### ### this class executes its rawchoice in a bash shell and returns the results ### the variable $ASKBASH_TOKEN will be available in the shell #################### class ExecCompleter < DynamicCompleter def deriveChoices(rawchoice, token) log "deriveChoices '#{token}'" cmd = "export ASKBAS...
github
arikast/askbash
https://github.com/arikast/askbash
lib/completers/FilesCompleter.rb
Ruby
mit
97
master
1,183
################### ### this completer is for completing one or more local file paths separated by an arbitrary token separator ################### require_relative 'FileCompleter.rb' class FilesCompleter < DynamicCompleter def initialize(choiceTree) @tree = choiceTree @fc = FileCompleter.new(choiceTree) ...
github
arikast/askbash
https://github.com/arikast/askbash
lib/completers/PwdDirCompleter.rb
Ruby
mit
97
master
207
############# ### matches dirs from the pwd ############# class PwdDirCompleter < DynamicCompleter def deriveChoices(choice, token) Dir.pwd.sub(/^\//, '').split('/').map { |s| "#{s} " } end end
github
arikast/askbash
https://github.com/arikast/askbash
lib/completers/RegexCompleter.rb
Ruby
mit
97
master
484
############# ### matches by treating choice as a regex for the token. if the regex accepts the token, then the token itself is returned as a choice ############# class RegexCompleter < DynamicCompleter def deriveChoices(choice, token) if token.nil? [] elsif match = token.match( /^(#{choice})$/) ...
github
arikast/askbash
https://github.com/arikast/askbash
lib/completers/FilesCSVCommaCompleter.rb
Ruby
mit
97
master
439
################### ### DEPRECATED - this class remains purely for legacy purposes ### instead, use an ordinary FilesCompleter and specify comma as its separator in your yaml like this: "<Files>, " ### this completer is for completing one or more local file paths separated by a comma ################### require_relativ...
github
arikast/askbash
https://github.com/arikast/askbash
test/core-test.rb
Ruby
mit
97
master
3,598
#!/usr/bin/ruby # for use with bash autocompletion # # to setup, run this in bash: # ./askbash.bash # # then to use: mycmdtotriggercompletion [tab] # # to enable debug logging, run this in your shell to write debug stmts to askbash.log: # export ASKBASH_DEBUG=1 # to include line numbers use this: # export ASKBASH_DEBU...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
env_bang.gemspec
Ruby
mit
97
main
976
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'env_bang/version' Gem::Specification.new do |spec| spec.name = "env_bang" spec.version = ENV_BANG::VERSION spec.authors = ["Jonathan Camenisch"] spec.email = ...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
env_bang-rails.gemspec
Ruby
mit
97
main
776
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'env_bang/version' Gem::Specification.new do |spec| spec.name = "env_bang-rails" spec.version = ENV_BANG::VERSION spec.authors = ["Jonathan Camenisch"] spec.email ...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
Rakefile
Ruby
mit
97
main
388
#!/usr/bin/env rake require "bundler/gem_helper" require 'rake/testtask' namespace 'dotenv' do Bundler::GemHelper.install_tasks :name => 'env_bang' end namespace 'dotenv-rails' do Bundler::GemHelper.install_tasks :name => 'env_bang-rails' end desc 'Run all tests' Rake::TestTask.new do |t| t.test_files = FileLi...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
test/env_bang_test.rb
Ruby
mit
97
main
14,666
require_relative 'test_helper' describe ENV_BANG do before do ENV_BANG.instance_eval { @vars = nil } ENV_BANG::Classes.default_class = nil end it "Raises exception if unconfigured ENV var requested" do ENV['UNCONFIGURED'] = 'unconfigured' _{ ENV!['UNCONFIGURED'] }.must_raise KeyError end it...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
test/test_helper.rb
Ruby
mit
97
main
515
require 'simplecov' SimpleCov.start do if ENV['CI'] require 'simplecov-lcov' SimpleCov::Formatter::LcovFormatter.config do |c| c.report_with_single_file = true c.single_report_path = 'coverage/lcov.info' end formatter SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
lib/env_bang-rails.rb
Ruby
mit
97
main
565
require 'env_bang' class ENV_BANG class Railtie < Rails::Railtie def env_rb_file File.join(Rails.root.to_s, 'config/env.rb') end def warn(msg) if Rails.logger Rails.logger.warn(msg) else puts "WARNING: #{msg}" end end config.before_configuration do ...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
lib/env_bang.rb
Ruby
mit
97
main
2,152
require "env_bang/version" require "env_bang/classes" require "env_bang/formatter" require "forwardable" class ENV_BANG class << self extend Forwardable include Enumerable def config(&block) instance_eval(&block) end def use(var, *args) var = var.to_s description = args.first....
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
lib/env_bang/formatter.rb
Ruby
mit
97
main
471
class ENV_BANG module Formatter class << self def formatted_error(var, description) indent(4, " Missing required environment variable: #{var}#{description and "\n" << unindent(description) } ") end def unindent(string) width = string.scan(/^ */).map(&:length).min ...
github
jcamenisch/ENV_BANG
https://github.com/jcamenisch/ENV_BANG
lib/env_bang/classes.rb
Ruby
mit
97
main
2,780
class ENV_BANG module Classes class << self attr_writer :default_class def default_class @default_class ||= :StringUnlessFalsey end def cast(value, options = {}) public_send(:"#{options.fetch(:class, default_class)}", value, options) end def boolean(value, op...
github
afomera/richer_text
https://github.com/afomera/richer_text
richer_text.gemspec
Ruby
mit
97
main
1,140
require_relative "lib/richer_text/version" Gem::Specification.new do |spec| spec.name = "richer_text" spec.version = RicherText::VERSION spec.authors = ["Andrea Fomera"] spec.email = ["afomera@hey.com"] spec.homepage = "https://github.com/afomera/richer_text" spec.summary = "A r...
github
afomera/richer_text
https://github.com/afomera/richer_text
Gemfile
Ruby
mit
97
main
296
source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Specify your gem's dependencies in richer_text.gemspec. gemspec gem "pg" gem "sprockets-rails" gem "puma" # Start debugger with binding.b [https://github.com/ruby/debug] # gem "debug", ">= 1.0.0"
github
afomera/richer_text
https://github.com/afomera/richer_text
test/test_helper.rb
Ruby
mit
97
main
710
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__) require "rails/test_help" ...
github
afomera/richer_text
https://github.com/afomera/richer_text
test/dummy/app/controllers/posts_controller.rb
Ruby
mit
97
main
1,135
class PostsController < ApplicationController before_action :set_post, only: %i[ show edit update destroy ] # GET /posts def index @posts = Post.all end # GET /posts/1 def show end # GET /posts/new def new @post = Post.new end # GET /posts/1/edit def edit end # POST /posts def...
github
afomera/richer_text
https://github.com/afomera/richer_text
test/dummy/config/application.rb
Ruby
mit
97
main
789
require_relative "boot" require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) require "richer_text" module Dummy class Application < Rails::Application config.load_defaults Rails::VERSION::STRING.to_f...
github
afomera/richer_text
https://github.com/afomera/richer_text
test/dummy/test/system/posts_test.rb
Ruby
mit
97
main
854
require "application_system_test_case" class PostsTest < ApplicationSystemTestCase setup do @post = posts(:one) end test "visiting the index" do visit posts_url assert_selector "h1", text: "Posts" end test "should create post" do visit posts_url click_on "New post" fill_in "Title",...
github
afomera/richer_text
https://github.com/afomera/richer_text
test/dummy/test/controllers/posts_controller_test.rb
Ruby
mit
97
main
973
require "test_helper" class PostsControllerTest < ActionDispatch::IntegrationTest setup do @post = posts(:one) end test "should get index" do get posts_url assert_response :success end test "should get new" do get new_post_url assert_response :success end test "should create post" ...
github
afomera/richer_text
https://github.com/afomera/richer_text
test/dummy/db/schema.rb
Ruby
mit
97
main
2,864
# 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. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
afomera/richer_text
https://github.com/afomera/richer_text
test/dummy/db/migrate/20230107020316_create_richer_text_rich_texts.rb
Ruby
mit
97
main
400
class CreateRicherTextRichTexts < ActiveRecord::Migration[7.0] def change create_table :richer_text_rich_texts do |t| t.string :name, null: false t.text :body, size: :long t.references :record, null: false, polymorphic: true t.timestamps t.index [:record_type, :record_id, :name], n...
github
afomera/richer_text
https://github.com/afomera/richer_text
db/migrate/20230916224959_create_richer_text_json_texts.rb
Ruby
mit
97
main
399
class CreateRicherTextJsonTexts < ActiveRecord::Migration[7.0] def change create_table :richer_text_json_texts do |t| t.string :name, null: false t.text :body, size: :long t.references :record, null: false, polymorphic: true t.timestamps t.index [:record_type, :record_id, :name], n...
github
afomera/richer_text
https://github.com/afomera/richer_text
app/models/richer_text/rich_text.rb
Ruby
mit
97
main
658
module RicherText class RichText < ApplicationRecord belongs_to :record, polymorphic: true, touch: true serialize :body, coder: RicherText::Content delegate :to_s, :nil?, to: :body delegate :blank?, :empty?, :present?, to: :to_html has_many_attached :images before_save :update_images ...
github
afomera/richer_text
https://github.com/afomera/richer_text
app/models/richer_text/o_embed.rb
Ruby
mit
97
main
3,041
require "oembed" module RicherText class OEmbed < ApplicationRecord include RicherText::Embeddable PATTERNS = [ {source: "^http:\\/\\/([^\\.]+\\.)?flickr\\.com\\/(.*?)", options: ""}, {source: "^https:\\/\\/([^\\.]+\\.)?flickr\\.com\\/(.*?)", options: ""}, {source: "^http:\\/\\/flic\\.kr\\...
github
afomera/richer_text
https://github.com/afomera/richer_text
app/models/richer_text/json_text.rb
Ruby
mit
97
main
1,823
module RicherText class JsonText < ApplicationRecord DEFAULT_BODY = {"type" => "doc", "content" => [{"type" => "paragraph", "attrs" => {"textAlign" => "left"}}]} belongs_to :record, polymorphic: true, touch: true serialize :body, coder: JSON, default: DEFAULT_BODY.to_json has_many_attached :images ...
github
afomera/richer_text
https://github.com/afomera/richer_text
app/helpers/richer_text/tag_helper.rb
Ruby
mit
97
main
3,415
require "action_view/helpers/tags/placeholderable" module ActionView::Helpers class Tags::Editor < Tags::Base include Tags::Placeholderable delegate :dom_id, to: ActionView::RecordIdentifier def render options = @options.stringify_keys add_default_name_and_id(options) options["input"]...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text.rb
Ruby
mit
97
main
1,447
require "active_support" require "active_support/rails" require "richer_text/version" require "richer_text/engine" module RicherText extend ActiveSupport::Autoload autoload :Attribute autoload :Content autoload :Rendering autoload :Fragment autoload :Serialization autoload :TagHelper autoload :Embed...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/generators/richer_text/install/install_generator.rb
Ruby
mit
97
main
2,769
require "pathname" module RicherText module Generators class InstallGenerator < ::Rails::Generators::Base source_root RicherText::Engine.root def create_migrations rails_command "railties:install:migrations FROM=active_storage,richer_text", inline: true end def copy_files ...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/content.rb
Ruby
mit
97
main
1,300
module RicherText class Content include ActiveModel::Conversion, Serialization, Rendering delegate :blank?, :empty?, :html_safe, :present?, to: :to_html def initialize(body) @body = body @fragment = RicherText::Fragment.parse(body) end def inspect "#<#{self.class.name} #{to_h...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/node.rb
Ruby
mit
97
main
799
module RicherText class Node attr_reader :json, :attrs, :children, :type include RicherText::Rendering STYLES = { "textAlign" => "text-align" } def self.build(json) node = json.is_a?(String) ? JSON.parse(json) : json klass = "RicherText::Nodes::#{node["type"].underscore.classif...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/fragment.rb
Ruby
mit
97
main
293
module RicherText class Fragment class << self def parse(html) new(Nokogiri::HTML.fragment(html)) end end attr_reader :source def initialize(source) @source = source end def find_all(selector) source.css(selector) end end end
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/html_visitor.rb
Ruby
mit
97
main
3,564
module RicherText class HTMLVisitor include ActionView::Helpers::TagHelper def visit(node) node.accept(self) end def visit_attachment_figure(node) "<figure sgid=#{node.attrs["sgid"]}> #{node_previewable?(node) ? "<img src=#{node.url} />" : "<a href=#{node.url} target='_blank'>"} ...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/rendering.rb
Ruby
mit
97
main
595
require "active_support/concern" require "active_support/core_ext/module/attribute_accessors_per_thread" module RicherText module Rendering extend ActiveSupport::Concern included do thread_cattr_accessor :renderer, instance_accessor: false delegate :render, to: :class end class_methods ...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/embeddable.rb
Ruby
mit
97
main
352
module RicherText module Embeddable extend ActiveSupport::Concern included do def embeddable_sgid to_sgid(expires_in: nil, for: "embeddable").to_s end def to_embeddable_partial_path to_partial_path end def to_richer_text_editor_partial_path to_partial_p...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/attribute.rb
Ruby
mit
97
main
1,544
module RicherText module Attribute extend ActiveSupport::Concern class_methods do def has_richer_text(name, store_as: :html, attachments: true) # Store if the attribute is using JSON or not. class_attribute :"richer_text_#{name}_json", instance_writer: false self.send(:"richer_t...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/mark.rb
Ruby
mit
97
main
398
module RicherText class Mark attr_reader :attrs, :type TAGS = { "bold" => "strong", "italic" => "em", "strike" => "del", "code" => "code", "highlight" => "mark", "link" => "a" } def initialize(json) @attrs = json.fetch("attrs", {}) @type = json.fetch("...
github
afomera/richer_text
https://github.com/afomera/richer_text
lib/richer_text/embed.rb
Ruby
mit
97
main
534
module RicherText class Embed include Rendering def self.find(sgid) @embed = GlobalID::Locator.locate_signed(sgid, for: "embeddable") new(@embed) if @embed end attr_reader :embed def initialize(embed) @embed = embed end def object @embed end delegate :t...