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 | mgsnova/feature | https://github.com/mgsnova/feature | lib/feature/repository/simple_repository.rb | Ruby | mit | 183 | master | 1,686 | module Feature
module Repository
# SimpleRepository for active feature list
# Simply add features to that should be active,
# no config or data sources required.
#
# Example usage:
# repository = SimpleRepository.new
# repository.add_active_feature(:feature_name)
# # use reposito... |
github | mgsnova/feature | https://github.com/mgsnova/feature | lib/feature/repository/active_record_repository.rb | Ruby | mit | 183 | master | 1,790 | module Feature
module Repository
# AcitveRecordRepository for active feature list
# Right now we assume you have at least name:string and active:boolean
# defined in your table.
#
# Example usage:
# repository = ActiveRecordRepository.new(FeatureToggle)
# repository.add_active_feature(... |
github | mgsnova/feature | https://github.com/mgsnova/feature | lib/feature/repository/yaml_repository.rb | Ruby | mit | 183 | master | 2,755 | module Feature
module Repository
# YamlRepository for active and inactive features
# The yaml config file should look like this:
#
# features:
# an_active_feature: true
# an_inactive_feature: false
#
# Example usage:
# repository = YamlRepository.new('/path/to/yaml/... |
github | mgsnova/feature | https://github.com/mgsnova/feature | spec/spec_helper.rb | Ruby | mit | 183 | master | 337 | require 'pathname'
require 'timecop'
require 'coveralls'
require 'fakeredis/rspec'
Coveralls.wear!
Coveralls::Output.silent = true
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
SPEC_ROOT = Pathname(__FILE__).dirname.expand_path
require SPEC_ROOT.parent... |
github | mgsnova/feature | https://github.com/mgsnova/feature | spec/feature/testing_spec.rb | Ruby | mit | 183 | master | 3,459 | require 'spec_helper'
require 'feature/testing'
shared_examples 'a testable repository' do
before do
expect(Feature.active?(:active_feature)).to be_truthy
expect(Feature.active?(:another_active_feature)).to be_truthy
expect(Feature.active?(:deactive_feature)).to be_falsey
expect(Feature.active?(:anot... |
github | mgsnova/feature | https://github.com/mgsnova/feature | spec/feature/yaml_repository_spec.rb | Ruby | mit | 183 | master | 4,290 | require 'spec_helper'
require 'tempfile'
include Feature::Repository
describe Feature::Repository::YamlRepository do
context 'proper config file' do
before(:each) do
@filename = Tempfile.new(['feature_config', '.yaml']).path
fp = File.new(@filename, 'w')
fp.write <<"EOF"
features:
feature_... |
github | mgsnova/feature | https://github.com/mgsnova/feature | spec/feature/redis_repository_spec.rb | Ruby | mit | 183 | master | 1,583 | require 'spec_helper'
include Feature::Repository
describe Feature::Repository::RedisRepository do
before(:each) do
@repository = RedisRepository.new('application_features')
end
it 'should have no active features after initialization' do
expect(@repository.active_features).to eq([])
end
it 'should... |
github | mgsnova/feature | https://github.com/mgsnova/feature | spec/feature/simple_repository_spec.rb | Ruby | mit | 183 | master | 1,130 | require 'spec_helper'
include Feature::Repository
describe Feature::Repository::SimpleRepository do
before(:each) do
@repository = SimpleRepository.new
end
it 'should have no active features after initialization' do
expect(@repository.active_features).to eq([])
end
it 'should add an active feature... |
github | mgsnova/feature | https://github.com/mgsnova/feature | spec/feature/feature_spec.rb | Ruby | mit | 183 | master | 7,044 | require 'spec_helper'
describe Feature do
context 'without FeatureRepository' do
before(:each) do
Feature.instance_variable_set(:@repository, nil)
end
it 'should raise an exception when calling active?' do
expect do
Feature.active?(:feature_a)
end.to raise_error('missing Reposit... |
github | mgsnova/feature | https://github.com/mgsnova/feature | spec/feature/active_record_repository_spec.rb | Ruby | mit | 183 | master | 1,513 | require 'spec_helper'
include Feature::Repository
describe Feature::Repository::ActiveRecordRepository do
before(:each) do
# Mock the model
@features = double('FeatureToggle')
@repository = ActiveRecordRepository.new(@features)
end
it 'should have no active features after initialization' do
all... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | gemini-ai.gemspec | Ruby | mit | 183 | main | 1,236 | # frozen_string_literal: true
require_relative 'static/gem'
Gem::Specification.new do |spec|
spec.name = Gemini::GEM[:name]
spec.version = Gemini::GEM[:version]
spec.authors = [Gemini::GEM[:author]]
spec.summary = Gemini::GEM[:summary]
spec.description = Gemini::GEM[:description]
spec.homepage = Gemi... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | Gemfile | Ruby | mit | 183 | main | 268 | # frozen_string_literal: true
source 'https://rubygems.org'
gemspec
group :test, :development do
gem 'dotenv', '~> 3.1', '>= 3.1.8'
gem 'pry-byebug', '~> 3.11'
gem 'rspec', '~> 3.13', '>= 3.13.1'
gem 'rubocop', '~> 1.78'
gem 'rubocop-rspec', '~> 3.6'
end |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | ports/dsl/gemini-ai.rb | Ruby | mit | 183 | main | 241 | # frozen_string_literal: true
require_relative '../../static/gem'
require_relative '../../controllers/client'
module Gemini
def self.new(...)
Controllers::Client.new(...)
end
def self.version
Gemini::GEM[:version]
end
end |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/spec_helper.rb | Ruby | mit | 183 | main | 4,937 | # frozen_string_literal: true
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to expl... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/controllers/client_spec.rb | Ruby | mit | 183 | main | 1,186 | # frozen_string_literal: true
require_relative '../../ports/dsl/gemini-ai'
require_relative '../../components/errors'
RSpec.describe Gemini do
it 'avoids unsupported services' do
expect do
described_class.new(
credentials: {
service: 'unknown-service'
}
)
end.to raise_e... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/tasks/run-embed.rb | Ruby | mit | 183 | main | 827 | # frozen_string_literal: true
require 'dotenv/load'
require_relative '../../ports/dsl/gemini-ai'
client = Gemini.new(
credentials: {
service: 'generative-language-api',
api_key: ENV.fetch('GOOGLE_API_KEY', nil)
},
options: { model: 'text-embedding-004', server_sent_events: true }
)
result = client.emb... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/tasks/run-json.rb | Ruby | mit | 183 | main | 4,810 | # frozen_string_literal: true
require 'dotenv/load'
require_relative '../../ports/dsl/gemini-ai'
# # References:
# # - https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versioning
# # - https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models
CACHE_FILE_PATH = 'available-models-json.tmp'
... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/tasks/run-available-models.rb | Ruby | mit | 183 | main | 3,326 | # frozen_string_literal: true
require 'dotenv/load'
require_relative '../../ports/dsl/gemini-ai'
# # References:
# # - https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versioning
# # - https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models
CACHE_FILE_PATH = 'available-models.tmp'
model... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/tasks/run-system.rb | Ruby | mit | 183 | main | 694 | # frozen_string_literal: true
require 'dotenv/load'
require_relative '../../ports/dsl/gemini-ai'
client = Gemini.new(
credentials: {
service: 'vertex-ai-api',
region: 'us-east4'
},
options: { model: 'gemini-pro', server_sent_events: true }
)
result = client.stream_generate_content(
{ contents: { rol... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/tasks/run-generate.rb | Ruby | mit | 183 | main | 1,089 | # frozen_string_literal: true
require 'dotenv/load'
require_relative '../../ports/dsl/gemini-ai'
client = Gemini.new(
credentials: {
service: 'generative-language-api',
api_key: ENV.fetch('GOOGLE_API_KEY', nil)
},
options: { model: 'gemini-pro', server_sent_events: true }
)
result = client.stream_gene... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/tasks/run-count-tokens.rb | Ruby | mit | 183 | main | 805 | # frozen_string_literal: true
require 'dotenv/load'
require_relative '../../ports/dsl/gemini-ai'
client = Gemini.new(
credentials: {
service: 'generative-language-api',
api_key: ENV.fetch('GOOGLE_API_KEY', nil)
},
options: { model: 'gemini-pro', server_sent_events: true }
)
result = client.count_token... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | spec/tasks/run-safety.rb | Ruby | mit | 183 | main | 1,065 | # frozen_string_literal: true
require 'dotenv/load'
require_relative '../../ports/dsl/gemini-ai'
client = Gemini.new(
credentials: {
service: 'vertex-ai-api',
region: 'us-east4'
},
options: { model: 'gemini-pro', server_sent_events: true }
)
result = client.stream_generate_content(
{ contents: { rol... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | static/gem.rb | Ruby | mit | 183 | main | 472 | # frozen_string_literal: true
module Gemini
GEM = {
name: 'gemini-ai',
version: '4.3.0',
author: 'gbaptista',
summary: "Interact with Google's Gemini AI.",
description: "A Ruby Gem for interacting with Gemini through Vertex AI, Generative Language API, or AI Studio, Google's generative AI service... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | components/errors.rb | Ruby | mit | 183 | main | 638 | # frozen_string_literal: true
module Gemini
module Errors
class GeminiError < StandardError
def initialize(message = nil)
super
end
end
class MissingProjectIdError < GeminiError; end
class UnsupportedServiceError < GeminiError; end
class ConflictingCredentialsError < GeminiEr... |
github | gbaptista/gemini-ai | https://github.com/gbaptista/gemini-ai | controllers/client.rb | Ruby | mit | 183 | main | 8,732 | # frozen_string_literal: true
require 'event_stream_parser'
require 'faraday'
require 'faraday/typhoeus'
require 'json'
require 'googleauth'
require_relative '../components/errors'
module Gemini
module Controllers
class Client
ALLOWED_REQUEST_OPTIONS = %i[timeout open_timeout read_timeout write_timeout].... |
github | miyucy/snappy | https://github.com/miyucy/snappy | snappy.gemspec | Ruby | mit | 183 | master | 1,296 | # frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "snappy/version"
Gem::Specification.new do |spec|
spec.name = "snappy"
spec.version = Snappy::VERSION
spec.authors = ["miyucy"]
spec.email = ["fistf... |
github | miyucy/snappy | https://github.com/miyucy/snappy | Rakefile | Ruby | mit | 183 | master | 2,030 | require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"
require "rbconfig"
DLEXT = RbConfig::CONFIG["DLEXT"]
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
t.warning = true
t.verbose = true
end
if defined?(JRUBY_VERSION)
r... |
github | miyucy/snappy | https://github.com/miyucy/snappy | test/snappy_reader_test.rb | Ruby | mit | 183 | master | 3,461 | # frozen_string_literal: true
require "test_helper"
require "stringio"
class SnappyReaderTest < Test::Unit::TestCase
def setup
@buffer = StringIO.new
Snappy::Writer.new @buffer do |w|
w << "foo"
w << "bar"
w << "baz"
w << "quux"
end
@buffer.rewind
end
def subject
@su... |
github | miyucy/snappy | https://github.com/miyucy/snappy | test/snappy_writer_test.rb | Ruby | mit | 183 | master | 1,424 | # frozen_string_literal: true
require "test_helper"
require "stringio"
class SnappyWriterTest < Test::Unit::TestCase
def setup
@buffer = StringIO.new
end
def subject
@subject ||= Snappy::Writer.new @buffer
end
sub_test_case "#initialize" do
test "should yield itself to the block" do
yiel... |
github | miyucy/snappy | https://github.com/miyucy/snappy | test/snappy_test.rb | Ruby | mit | 183 | master | 2,696 | # frozen_string_literal: true
require "test_helper"
require "securerandom"
class SnappyTest < Test::Unit::TestCase
def random_data(length = 1024)
SecureRandom.alphanumeric(length)
end
test "VERSION" do
assert do
::Snappy.const_defined?(:VERSION)
end
end
test "well done" do
s = random... |
github | miyucy/snappy | https://github.com/miyucy/snappy | test/snappy_hadoop_test.rb | Ruby | mit | 183 | master | 567 | # frozen_string_literal: true
require "test_helper"
require "stringio"
class SnappyHadoopTest < Test::Unit::TestCase
T = [*"a".."z", *"A".."Z", *"0".."9"].freeze
def random_data(length = 1024)
Array.new(length) { T.sample }.join
end
test "well done" do
s = random_data
assert_equal s, Snappy::Had... |
github | miyucy/snappy | https://github.com/miyucy/snappy | test/hadoop/snappy_hadoop_reader_test.rb | Ruby | mit | 183 | master | 2,555 | # frozen_string_literal: true
require "test_helper"
require "stringio"
class SnappyHadoopReaderTest < Test::Unit::TestCase
def setup
@buffer = StringIO.new
Snappy::Hadoop::Writer.new @buffer do |w|
w << "foo"
w << "bar"
w << "baz"
w << "quux"
end
@buffer.rewind
end
def s... |
github | miyucy/snappy | https://github.com/miyucy/snappy | test/hadoop/snappy_hadoop_writer_test.rb | Ruby | mit | 183 | master | 1,199 | # frozen_string_literal: true
require "test_helper"
require "stringio"
class SnappyHadoopWriterTest < Test::Unit::TestCase
def setup
@buffer = StringIO.new
end
def subject
@subject ||= Snappy::Hadoop::Writer.new @buffer
end
sub_test_case "#initialize" do
test "should yield itself to the block"... |
github | miyucy/snappy | https://github.com/miyucy/snappy | ext/extconf.rb | Ruby | mit | 183 | master | 944 | require "mkmf"
require "fileutils"
$CXXFLAGS += " -std=c++11 "
have_libsnappy = pkg_config("libsnappy") || have_library("snappy")
unless have_libsnappy
# build vendor/snappy
pwd = File.dirname File.expand_path __FILE__
dir = File.join pwd, "..", "vendor", "snappy"
Dir.chdir(dir) do
FileUtils.rm_rf "build... |
github | miyucy/snappy | https://github.com/miyucy/snappy | lib/snappy/writer.rb | Ruby | mit | 183 | master | 986 | # frozen_string_literal: true
require 'snappy/shim'
module Snappy
class Writer
MAGIC = "\x82SNAPPY\x0".b
DEFAULT_VERSION = 1
MINIMUM_COMPATIBLE_VERSION = 1
DEFAULT_BLOCK_SIZE = 32 * 1024
attr_reader :io, :block_size
def initialize(io, block_size = DEFAULT_BLOCK_SIZE)
@block_size = bl... |
github | miyucy/snappy | https://github.com/miyucy/snappy | lib/snappy/hadoop.rb | Ruby | mit | 183 | master | 546 | # encoding: utf-8
# frozen_string_literal: true
require 'stringio'
require 'snappy/hadoop/reader'
require 'snappy/hadoop/writer'
module Snappy
module Hadoop
def self.deflate(source, block_size = Snappy::Hadoop::Writer::DEFAULT_BLOCK_SIZE)
compressed_io = StringIO.new
writer = Snappy::Hadoop::Writer.... |
github | miyucy/snappy | https://github.com/miyucy/snappy | lib/snappy/reader.rb | Ruby | mit | 183 | master | 1,405 | # frozen_string_literal: true
require "snappy/shim"
require "snappy/writer"
module Snappy
class Reader
attr_reader :io, :magic, :default_version, :minimum_compatible_version
def initialize(io)
@io = Snappy.set_encoding io
read_header!
yield self if block_given?
end
def each
... |
github | miyucy/snappy | https://github.com/miyucy/snappy | lib/snappy/hadoop/reader.rb | Ruby | mit | 183 | master | 1,589 | # frozen_string_literal: true
require 'stringio'
require 'snappy/shim'
module Snappy
module Hadoop
class Reader
attr_reader :io
def initialize(io)
@io = Snappy.set_encoding io
yield self if block_given?
end
def each
return to_enum unless block_given?
un... |
github | miyucy/snappy | https://github.com/miyucy/snappy | lib/snappy/hadoop/writer.rb | Ruby | mit | 183 | master | 1,171 | # frozen_string_literal: true
require 'snappy/shim'
module Snappy
module Hadoop
class Writer
DEFAULT_BLOCK_SIZE = 256 * 1024
attr_reader :io, :block_size
def initialize(io, block_size = DEFAULT_BLOCK_SIZE)
@block_size = block_size
@buffer = String.new
@io = Snappy.set... |
github | standardrb/standard-rails | https://github.com/standardrb/standard-rails | Rakefile | Ruby | mit | 183 | main | 1,957 | require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end
task :copy_rubocop_rails_entry_point_and_comment_out_monkey_patch do
gem_spec = Gem.loaded_specs["rubocop-rails"]
gem_require_path = Pathname... |
github | standardrb/standard-rails | https://github.com/standardrb/standard-rails | standard-rails.gemspec | Ruby | mit | 183 | main | 1,341 | require_relative "lib/standard/rails/version"
Gem::Specification.new do |spec|
spec.name = "standard-rails"
spec.version = Standard::Rails::VERSION
spec.authors = ["Justin Searls"]
spec.email = ["searls@gmail.com"]
spec.summary = "A Standard plugin that adds Rails-specific rules to Standard"
spec.homepage... |
github | standardrb/standard-rails | https://github.com/standardrb/standard-rails | test/test_helper.rb | Ruby | mit | 183 | main | 220 | $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
begin
require "simplecov"
SimpleCov.start do
load_profile "test_frameworks"
end
rescue LoadError
end
require "standard/rails"
require "minitest/autorun" |
github | standardrb/standard-rails | https://github.com/standardrb/standard-rails | test/standard/rails_test.rb | Ruby | mit | 183 | main | 3,066 | require "test_helper"
require "rubocop"
class Standard::RailsTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Standard::Rails::VERSION
end
BASE_CONFIG = "config/base.yml"
INHERITED_OPTIONS = %w[
Description
Reference
Safe
SafeAutoCorrect
StyleGuide
VersionAd... |
github | standardrb/standard-rails | https://github.com/standardrb/standard-rails | test/standard/rails/plugin_test.rb | Ruby | mit | 183 | main | 1,304 | require "test_helper"
module Standard::Rails
class PluginTest < Minitest::Test
def setup
end
def test_configuring_target_rails_version
subject = Plugin.new({"target_rails_version" => 5.2})
result = subject.rules(LintRoller::Context.new)
assert_equal 5.2, result.value["AllCops"]["Targ... |
github | standardrb/standard-rails | https://github.com/standardrb/standard-rails | lib/standard/rails/load_rubocop_rails_without_the_monkey_patch.rb | Ruby | mit | 183 | main | 1,724 | # GENERATED FILE - DO NOT EDIT
#
# This file should look just like: https://github.com/rubocop/rubocop-rails/blob/master/lib/rubocop-rails.rb
# Except without the `Inject.defaults!` monkey patching.
#
# Because there are both necessary require statements and additional patching
# of RuboCop built-in cops in this file, ... |
github | standardrb/standard-rails | https://github.com/standardrb/standard-rails | lib/standard/rails/plugin.rb | Ruby | mit | 183 | main | 4,404 | require "yaml"
module Standard
module Rails
class Plugin < LintRoller::Plugin
def initialize(config)
@config = config
@merges_upstream_metadata = LintRoller::Support::MergesUpstreamMetadata.new
end
def about
LintRoller::About.new(
name: "standard-rails",
... |
github | trishume/pro | https://github.com/trishume/pro | pro.gemspec | Ruby | mit | 183 | master | 1,083 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'pro/version'
Gem::Specification.new do |spec|
spec.name = "pro"
spec.version = Pro::VERSION
spec.authors = ["Tristan Hume"]
spec.email = ["tris.hume@gmail.com... |
github | trishume/pro | https://github.com/trishume/pro | lib/pro/indexer.rb | Ruby | mit | 183 | master | 4,868 | require "pro/index"
require "colored"
require "yaml"
module Pro
# creates an index object from cache
# or by searching the file system
class Indexer
CACHE_PATH = File.expand_path("~/.proCache")
INDEXER_LOCK_PATH = File.expand_path("~/.proCacheLock")
def initialize
@base_dirs = find_base_dirs
... |
github | trishume/pro | https://github.com/trishume/pro | lib/pro/index.rb | Ruby | mit | 183 | master | 402 | module Pro
Repo = Struct.new(:name,:path)
class Index
include Enumerable
attr_reader :bases,:base_dirs,:created_version
def initialize(bases,base_dirs)
@bases, @base_dirs = bases, base_dirs
@created_version = Pro::VERSION
end
# yields all repo objects in all bases
def each
... |
github | trishume/pro | https://github.com/trishume/pro | lib/pro/commands.rb | Ruby | mit | 183 | master | 5,062 | require "pro/index"
require "find"
require "fuzzy_match"
require "colored"
require "open3"
SHELL_FUNCTION = <<END
# pro cd function
{{name}}() {
local projDir=$(pro search $1)
cd ${projDir}
}
END
CD_INFO = <<END
This installs a command to allow you to cd to a git repo
arbitrarily deep in your PRO_BASE based on f... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | rails-dom-testing.gemspec | Ruby | mit | 183 | main | 1,025 | # coding: utf-8
# frozen_string_literal: true
require_relative "lib/rails/dom/testing/version"
Gem::Specification.new do |spec|
spec.name = "rails-dom-testing"
spec.version = Rails::Dom::Testing::VERSION
spec.authors = ["Rafael Mendonça França", "Kasper Timm Hansen"]
spec.email = ... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | Gemfile | Ruby | mit | 183 | main | 353 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in rails-dom-testing.gemspec
gemspec
group :rubocop do
gem "rubocop", require: false
gem "rubocop-minitest", require: false
gem "rubocop-packaging", require: false
gem "rubocop-performance", require: false
gem "ru... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | Rakefile | Ruby | mit | 183 | main | 225 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
task default: :test
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.warning = true
t.verbose = true
end |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | test/test_helper.rb | Ruby | mit | 183 | main | 505 | # frozen_string_literal: true
require "rails-dom-testing"
require "active_support/test_case"
require "minitest/autorun"
ActiveSupport::TestCase.test_order = :random
module DomTestingHelpers
def jruby?
!! Nokogiri.jruby?
end
def with_default_html_version(version)
old_version = Rails::Dom::Testing.defau... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | test/selector_assertions_test.rb | Ruby | mit | 183 | main | 18,708 | # encoding: utf-8
# frozen_string_literal: true
require "test_helper"
class AssertSelectTest < ActiveSupport::TestCase
Assertion = Minitest::Assertion
include DomTestingHelpers
include Rails::Dom::Testing::Assertions::SelectorAssertions
def assert_failure(message, &block)
e = assert_raises(Assertion, &b... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | test/dom_assertions_test.rb | Ruby | mit | 183 | main | 6,445 | # frozen_string_literal: true
require "test_helper"
class DomAssertionsTest < ActiveSupport::TestCase
Assertion = Minitest::Assertion
include Rails::Dom::Testing::Assertions::DomAssertions
def test_responds_to_assert_dom_equal
assert respond_to?(:assert_dom_equal)
end
def test_dom_equal
html = "<... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | test/parser_selection_test.rb | Ruby | mit | 183 | main | 3,960 | # frozen_string_literal: true
require "test_helper"
class DomTestingParserSelectionTest < ActiveSupport::TestCase
include DomTestingHelpers
test "with default html4" do
with_default_html_version(:html4) do
assert_equal(Nokogiri::HTML4::Document, Rails::Dom::Testing.html_document)
assert_equal(Nok... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | lib/rails/dom/testing.rb | Ruby | mit | 183 | main | 1,611 | # frozen_string_literal: true
require "nokogiri"
require "active_support"
require "active_support/core_ext/module/attribute_accessors"
require "rails/dom/testing/assertions"
module Rails
module Dom
module Testing
mattr_accessor :default_html_version, default: :html4
class << self
def html5... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | lib/rails/dom/testing/railtie.rb | Ruby | mit | 183 | main | 359 | # frozen_string_literal: true
module Rails
module Dom
module Testing
class Railtie < Rails::Railtie # :nodoc:
config.after_initialize do |app|
version = app.config.try(:dom_testing_default_html_version) # Rails 7.1+
Rails::Dom::Testing.default_html_version = version if version
... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | lib/rails/dom/testing/assertions.rb | Ruby | mit | 183 | main | 289 | # frozen_string_literal: true
require_relative "assertions/dom_assertions"
require_relative "assertions/selector_assertions"
module Rails
module Dom
module Testing
module Assertions
include DomAssertions
include SelectorAssertions
end
end
end
end |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | lib/rails/dom/testing/assertions/selector_assertions.rb | Ruby | mit | 183 | main | 16,572 | # frozen_string_literal: true
require_relative "selector_assertions/html_selector"
module Rails
module Dom
module Testing
module Assertions
# Adds the +assert_dom+ method for use in Rails functional
# test cases, which can be used to make assertions on the response HTML of a controller
... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | lib/rails/dom/testing/assertions/dom_assertions.rb | Ruby | mit | 183 | main | 6,131 | # frozen_string_literal: true
module Rails
module Dom
module Testing
module Assertions
module DomAssertions
# \Test two HTML strings for equivalency (e.g., equal even when attributes are in another order)
#
# # assert that the referenced method generates the appropri... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb | Ruby | mit | 183 | main | 1,377 | # frozen_string_literal: true
module Rails
module Dom
module Testing
module Assertions
module SelectorAssertions
class SubstitutionContext # :nodoc:
def initialize
@substitute = "?"
end
def substitute!(selector, values, format_for_present... |
github | rails/rails-dom-testing | https://github.com/rails/rails-dom-testing | lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb | Ruby | mit | 183 | main | 5,872 | # frozen_string_literal: true
require "minitest"
require_relative "substitution_context"
module Rails
module Dom
module Testing
module Assertions
module SelectorAssertions
class HTMLSelector # :nodoc:
attr_reader :css_selector, :tests, :message
include Minitest:... |
github | soveran/nest | https://github.com/soveran/nest | nest.gemspec | Ruby | mit | 183 | master | 584 | Gem::Specification.new do |s|
s.name = "nest"
s.version = "3.2.0"
s.summary = "Object-oriented keys for Redis."
s.description = "It is a design pattern in key-value databases to use the key to simulate structure, and Nest can take care of that."
s.license = "MI... |
github | soveran/nest | https://github.com/soveran/nest | test/nest_test.rb | Ruby | mit | 183 | master | 2,622 | require_relative "helper"
# Creating namespaces.
scope do
test "return the namespace" do
n1 = Nest.new("foo", Redic.new)
assert "foo" == n1.to_s
end
test "prepend the namespace" do
n1 = Nest.new("foo")
assert "foo:bar" == n1["bar"].to_s
end
test "work in more than one level" do
n1 = Nes... |
github | soveran/nest | https://github.com/soveran/nest | lib/nest.rb | Ruby | mit | 183 | master | 1,803 | # Copyright (c) 2010 Michel Martens
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, dist... |
github | kazuho/rat | https://github.com/kazuho/rat | tun.rb | Ruby | mit | 183 | main | 13,977 | # frozen_string_literal: true
require 'socket'
class String
def get16be(off)
getbyte(off) * 256 + getbyte(off + 1)
end
def set16be(off, v)
# this seems faster than pack-then-replace
setbyte(off, (v >> 8) & 0xff)
setbyte(off + 1, v & 0xff)
end
end
class IP
class V4
def self.src_addr(byt... |
github | kazuho/rat | https://github.com/kazuho/rat | rat.rb | Ruby | mit | 183 | main | 2,025 | # frozen_string_literal: true
require 'irb'
require 'json'
require 'rackup'
require './tun'
require './nat'
require './nattable'
if ENV['RAT_USE_FIBER']
require 'async/scheduler'
require 'falcon'
require 'rack/handler/falcon'
Fiber.set_scheduler(Async::Scheduler.new)
def spawn_thread(_last = false, &block)... |
github | kazuho/rat | https://github.com/kazuho/rat | reflector.rb | Ruby | mit | 183 | main | 642 | # frozen_string_literal: true
# How to setup:
# sudo ip tuntap add dev tap-e mode tun user <username>
# sudo ip addr add 10.1.2.3/32 dev tap-e
# sudo ip link set tap-e up
# sudo ip route add 10.1.2.0/24 via 10.1.2.3
require './tun'
TRUE_ADDR = "\xa\1\2\xfe".b
FAKE_ADDR = "\xa\1\2\4".b
tun = Tun.new('rat')
loop do
... |
github | kazuho/rat | https://github.com/kazuho/rat | webif.rb | Ruby | mit | 183 | main | 1,395 | # frozen_string_literal: true
proc do |nat|
puts 'generating webif'
proc do |_env|
resp = "<style type='text/css'>body {font-family: monospace} th, td {padding: 0 1em}</style>"
[nat.tcp_table, nat.udp_table, nat.icmp_echo_table].each do |table|
table.gc
resp += "<h3>#{table.name} (#{table.size}... |
github | kazuho/rat | https://github.com/kazuho/rat | nat.rb | Ruby | mit | 183 | main | 2,174 | # frozen_string_literal: true
class Nat
attr_accessor :global_addr, :tcp_table, :udp_table, :icmp_echo_table
def egress?(packet)
packet.dest_addr != @global_addr
end
def transform(packet)
return unless packet&.l4
case packet.l4
when TCP
table = @tcp_table
when UDP
table = @ud... |
github | kazuho/rat | https://github.com/kazuho/rat | nattable.rb | Ruby | mit | 183 | main | 5,974 | # frozen_string_literal: true
class NATTable
attr_accessor :name, :idle_timeout, :global_ports, :get_logfp
class Entry
attr_accessor :prev, :next, :create_at, :last_access, :local_addr, :local_port, :global_port, :remote_addr,
:remote_port, :packets_sent, :packets_received, :bytes_sent, :byt... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | search_object.gemspec | Ruby | mit | 182 | master | 1,458 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'search_object/version'
Gem::Specification.new do |spec|
spec.name = "search_object"
spec.version = SearchObject::VERSION
spec.authors = ["Radoslav Stankov"]
spec.emai... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | Rakefile | Ruby | mit | 182 | master | 216 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new(:rubocop)
task default: %i[rubocop spec] |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/Gemfile | Ruby | mit | 182 | master | 270 | # frozen_string_literal: true
source 'https://rubygems.org'
gem 'rails', '6.1.5'
gem 'bootstrap-sass'
gem 'jquery-rails'
gem 'rspec-rails'
gem 'sass-rails', '~> 5.0.0'
gem 'slim'
gem 'sqlite3'
gem 'webrick', '~> 1.8'
gem 'will_paginate'
gem 'will_paginate-bootstrap' |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/Rakefile | Ruby | mit | 182 | master | 279 | # frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('config/application', __dir__)
Example::Application.load_tasks |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/config/application.rb | Ruby | mit | 182 | master | 1,101 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Load SearchObject manually from lib
$:.unshift File.expand_path('../../../lib', __FILE__)
require 'search_object'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:defa... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/config/initializers/secret_token.rb | Ruby | mit | 182 | master | 661 | # Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to diction... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/config/environments/test.rb | Ruby | mit | 182 | master | 1,598 | Example::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test s... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/config/environments/development.rb | Ruby | mit | 182 | master | 1,115 | Example::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web s... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/db/schema.rb | Ruby | mit | 182 | master | 1,510 | # 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 | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/db/seeds.rb | Ruby | mit | 182 | master | 659 | User.delete_all
Post.delete_all
users = [
User.create!(name: 'John'),
User.create!(name: 'Jake'),
User.create!(name: 'Jade'),
]
category_names = [
'Books',
'Code',
'Design',
'Database',
'Education',
'Personal',
'News',
'Stuff',
'Others'
]
400.times do |i|
Post.create!(
user: u... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/db/migrate/20131102130117_create_users.rb | Ruby | mit | 182 | master | 207 | class CreateUsers < ActiveRecord::Migration[4.2]
def change
create_table :users do |t|
t.string :name, null: false
t.timestamps
end
add_index :users, :name, unique: true
end
end |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/db/migrate/20131102130413_create_posts.rb | Ruby | mit | 182 | master | 533 | class CreatePosts < ActiveRecord::Migration[4.2]
def change
create_table :posts do |t|
t.integer :user_id, null: false
t.string :title, null: false
t.string :body, null: false
t.string :category_name, null: false
t.integer :views_count, null: false, default: 0
t.integer :likes_... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/app/models/post.rb | Ruby | mit | 182 | master | 450 | # frozen_string_literal: true
class Post < ActiveRecord::Base
belongs_to :user
validates :user, presence: true
validates :title, presence: true
validates :body, presence: true
validates :category_name, presence: true
validates :views_count, numericality: true
validates :... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/app/models/post_search.rb | Ruby | mit | 182 | master | 1,401 | # frozen_string_literal: true
class PostSearch
include SearchObject.module(:model, :sorting, :will_paginate, :enum)
scope { Post.includes(:user).all }
sort_by :id, :created_at, :views_count, :likes_count, :comments_count
per_page 15
min_per_page 10
max_per_page 100
option :user_id
option :category... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/spec/spec_helper.rb | Ruby | mit | 182 | master | 734 | # frozen_string_literal: true
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdi... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | example/spec/models/post_search_spec.rb | Ruby | mit | 182 | master | 2,009 | # frozen_string_literal: true
require 'spec_helper'
describe PostSearch do
let(:user) { create_user }
def create_user
User.create! name: "User #{User.count + 1}"
end
def create(attributes = {})
Post.create! attributes.reverse_merge(
user: user,
title: 'Title',
body: 'Body',
c... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object.rb | Ruby | mit | 182 | master | 661 | # frozen_string_literal: true
require 'search_object/version'
require 'search_object/errors'
require 'search_object/helper'
require 'search_object/base'
require 'search_object/search'
require 'search_object/plugin/model'
require 'search_object/plugin/paging'
require 'search_object/plugin/will_paginate'
require 'search... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/helper.rb | Ruby | mit | 182 | master | 1,970 | # frozen_string_literal: true
module SearchObject
# :api: private
module Helper
module_function
def stringify_keys(hash)
# Note(rstankov): From Rails 5+ ActionController::Parameters aren't Hash
# In a lot of cases `stringify_keys` is used on action params
hash = hash.to_unsafe_h if has... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/errors.rb | Ruby | mit | 182 | master | 493 | # frozen_string_literal: true
module SearchObject
class MissingScopeError < ArgumentError
def initialize(message = 'No scope provided. Scope can be defined on a class level or passed as an option.')
super message
end
end
class InvalidNumberError < ArgumentError
attr_reader :field, :number
... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/base.rb | Ruby | mit | 182 | master | 2,125 | # frozen_string_literal: true
module SearchObject
module Base
def self.included(base)
base.extend ClassMethods
base.instance_eval do
@config = {
defaults: {},
options: {}
}
end
end
def initialize(options = {})
config = self.class.config
s... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/search.rb | Ruby | mit | 182 | master | 754 | # frozen_string_literal: true
module SearchObject
# :api: private
class Search
attr_reader :params
def initialize(scope:, options: nil, defaults: nil, params: nil)
@scope = scope
@options = options || {}
@defaults = defaults || {}
self.params = params
end
def params=(para... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/plugin/sorting.rb | Ruby | mit | 182 | master | 1,463 | # frozen_string_literal: true
module SearchObject
module Plugin
module Sorting
def self.included(base)
base.extend ClassMethods
base.instance_eval do
option :sort do |scope, _|
scope.order sort_attribute => sort_direction
end
end
end
def ... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/plugin/paging.rb | Ruby | mit | 182 | master | 1,462 | # frozen_string_literal: true
module SearchObject
module Plugin
module Paging
def self.included(base)
base.extend ClassMethods
end
attr_reader :page, :per_page
def initialize(options = {})
@page = [options[:page].to_i, 0].max
@per_page = self.class.calculate_... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/plugin/enum.rb | Ruby | mit | 182 | master | 2,071 | # frozen_string_literal: true
module SearchObject
module Plugin
module Enum
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def option(name, options = nil, &block)
return super unless options.is_a?(Hash) && options[:enum]
handler = ... |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/plugin/model.rb | Ruby | mit | 182 | master | 306 | # frozen_string_literal: true
module SearchObject
module Plugin
module Model
def self.included(base)
base.class_eval do
include ActiveModel::Conversion
extend ActiveModel::Naming
end
end
def persisted?
false
end
end
end
end |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/plugin/kaminari.rb | Ruby | mit | 182 | master | 303 | # frozen_string_literal: true
module SearchObject
module Plugin
module Kaminari
include Paging
def self.included(base)
base.extend Paging::ClassMethods
end
private
def apply_paging(scope)
scope.page(page).per(per_page)
end
end
end
end |
github | RStankov/SearchObject | https://github.com/RStankov/SearchObject | lib/search_object/plugin/will_paginate.rb | Ruby | mit | 182 | master | 341 | # frozen_string_literal: true
module SearchObject
module Plugin
module WillPaginate
include Paging
def self.included(base)
base.extend Paging::ClassMethods
end
private
def apply_paging(scope)
scope.paginate per_page: per_page, page: page.zero? ? nil : page
e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.