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 | joeyates/rake-builder | https://github.com/joeyates/rake-builder | examples/05_tests/Rakefile | Ruby | mit | 46 | master | 562 | require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake'
require 'rake/builder'
Rake::Builder.new do |builder|
builder.target = 'unit'
builder.source_search_paths = [ 'src' ]
builder.installable_headers = [ 'include' ]
end
Rake::Builder.new do |builder|
builder.task_namespace = 'test'
... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | examples/06_hello_world_objective_c/Rakefile | Ruby | mit | 46 | master | 350 | require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake'
require 'rake/builder'
Rake::Builder.new do |builder|
builder.target = 'hello_world_objective_c'
builder.programming_language = 'objective-c'
builder.library_dependencies = [ 'objc' ]
builder.linker_options = '-framework CoreFoundati... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | examples/07_multiple_targets/Rakefile | Ruby | mit | 46 | master | 418 | require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake'
require 'rake/builder'
Rake::Builder.new do |builder|
builder.target = 'foo/target_1'
builder.objects_path = 'foo/objects'
builder.programming_language = 'c'
end
Rake::Builder.new do |builder|
builder.target = 'bar/t... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | examples/01_hello_world_cpp/Rakefile | Ruby | mit | 46 | master | 206 | =begin
= A Minimal Example for Rake-Builder
=end
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake'
require 'rake/builder'
Rake::Builder.new do |builder|
builder.target = 'hello_world_cpp'
end |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | examples/02_hello_world_c/Rakefile | Ruby | mit | 46 | master | 203 | require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake'
require 'rake/builder'
Rake::Builder.new do |builder|
builder.target = 'hello_world_c'
builder.programming_language = 'c'
end |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/compiler.rb | Ruby | mit | 46 | master | 1,974 | module Compiler
class Base
EXTRA_PATHS = ['/opt/local/include']
def self.for(compiler)
COMPILERS[compiler].new
end
def initialize
@paths = {}
end
def include_paths(headers)
paths = []
headers.each do |header|
path = find_header(header)
raise "Can't fi... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/microsecond_task.rb | Ruby | mit | 46 | master | 1,653 | require 'fileutils'
module Rake
module Microsecond
class Base < Task
attr_accessor :timestamp
def prerequisites_needed?
prerequisites.any? do |n|
task = application[n]
if task.is_a?(Rake::FileTask) or
task.is_a?(self.class)
task.timestamp > @timest... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/path.rb | Ruby | mit | 46 | master | 386 | module Rake
module Path
def self.find_files(paths, extension)
files = paths.reduce([]) do |memo, path|
case
when File.file?(path)
files = FileList[path]
when path.match(/[\*\?]/)
files = FileList[path]
else
files = FileList[path + '/*.' + extensi... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder.rb | Ruby | mit | 46 | master | 19,111 | require 'logger'
require 'rake'
require 'rake/builder/autoconf/version'
require 'rake/builder/configure_ac'
require 'rake/builder/error'
require 'rake/builder/installer'
require 'rake/builder/local_config'
require 'rake/builder/logger/formatter'
require 'rake/builder/presenters/makefile/builder_presenter'
require 'rak... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/once_task.rb | Ruby | mit | 46 | master | 560 | require 'rake/tasklib'
module Rake
# A task whick is no longer needed after its first invocation
class OnceTask < Task
attr_accessor :invoked
attr_accessor :timestamp
def self.define_task(*args, &block)
task = super(*args, &block)
task.timestamp = nil
task.invoked = false
task
... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/configure_ac.rb | Ruby | mit | 46 | master | 1,009 | class Rake::Builder
class ConfigureAc
# source_file - the relative path to any one source file in the project
def initialize(project_title, version, source_file)
@project_title, @version, @source_file = project_title, version, source_file
end
def to_s
<<EOT
AC_PREREQ(2.61)
AC_INIT(#{@proj... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/qt_builder.rb | Ruby | mit | 46 | master | 5,587 | require 'rake/builder'
module Rake
class QtBuilder < Builder
# TODO:
# generate Info.plist
# package task
attr_accessor :qt_version
attr_accessor :frameworks
attr_accessor :resource_files
attr_accessor :ui_files
def initialize( &block )
super( &block )
end
priva... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/error.rb | Ruby | mit | 46 | master | 310 | class Rake::Builder
class Error < StandardError
attr_accessor :namespace
def initialize(message, namespace = nil)
super(message)
@namespace = namespace
end
def to_s
message = super
message = "#{@namespace}: #{message}" if @namespace
message
end
end
end |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/local_config.rb | Ruby | mit | 46 | master | 1,026 | require 'yaml'
class Rake::Builder
class LocalConfig
VERSIONS = ['1.0', '1.1']
attr_accessor :include_paths
attr_accessor :compilation_options
def initialize(file_name)
@file_name = file_name
@include_paths = []
@compilation_options = []
end
def load
... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/installer.rb | Ruby | mit | 46 | master | 1,327 | require 'fileutils'
class Rake::Builder
class Installer
def install(source_pathname, destination_path)
ensure_file_exists source_pathname
raise "The path '#{destination_path}' does not exist" unless File.exist?(destination_path)
raise "'#{destination_path}' is not a directory" unless File.direc... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/logger/formatter.rb | Ruby | mit | 46 | master | 223 | require 'logger'
class Rake::Builder
module Logger; end
end
module Rake::Builder::Logger
class Formatter < ::Logger::Formatter
def call(severity, time, progname, msg)
msg2str(msg) << "\n"
end
end
end |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/autoconf/version.rb | Ruby | mit | 46 | master | 1,810 | class Rake::Builder
module Autoconf
end
end
module Rake::Builder::Autoconf
class Version
def initialize(parameter_version = nil)
@parameter_version = parameter_version
if @parameter_version and not is_valid?(@parameter_version)
raise "The supplied version number '#{@parameter_version}' is... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/presenters/makefile/builder_presenter.rb | Ruby | mit | 46 | master | 2,352 | module Rake::Builder::Presenters; end
module Rake::Builder::Presenters::Makefile
class BuilderPresenter
def initialize(builder)
@builder = builder
check_target_type
end
def to_s
check_target_type
variables = main_variables
rules = main_rules
source_groups = grou... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb | Ruby | mit | 46 | master | 1,156 | module Rake; class Builder; module Presenters; module MakefileAm
class BuilderCollectionPresenter
attr_accessor :builders
def initialize(builders)
@builders = builders
end
def to_s
programs_list + program_sections + libraries_list + library_sections
end
def save
File.open(... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/presenters/makefile_am/builder_presenter.rb | Ruby | mit | 46 | master | 751 | module Rake::Builder::Presenters::MakefileAm
class BuilderPresenter
attr_accessor :builder
def initialize(builder)
@builder = builder
end
def to_s
[sources, cpp_flags, ld_flags, libraries, ''].compact.join("\n")
end
private
def sources
"#{builder.label}_SOURCES = #{bu... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/task_definers/builder_task_definer.rb | Ruby | mit | 46 | master | 4,182 | require 'logger'
require 'rake'
include Rake::DSL
class Rake::Builder
class BuilderTaskDefiner
def initialize(builder)
@builder = builder
end
def run
if @builder.task_namespace
namespace @builder.task_namespace do
define
end
else
define
end
... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | lib/rake/builder/task_definers/builder_collection_task_definer.rb | Ruby | mit | 46 | master | 440 | class Rake::Builder::BuilderCollectionTaskDefiner
def run
desc "Create input files for configure script creation"
task :autoconf, [:project_title, :version] => [] do |task, args|
raise 'No Rake::Builder projects have been defined' unless Rake::Builder.instances.size > 0
first = Rake::Builder.insta... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/spec_helper.rb | Ruby | mit | 46 | master | 604 | require 'rspec'
require 'simplecov' if RUBY_VERSION > '1.9'
if RUBY_VERSION > '1.9'
if defined?(GATHER_RSPEC_COVERAGE)
SimpleCov.start do
add_filter "/spec/"
add_filter "/vendor/"
end
end
end
require File.expand_path(File.join('..', 'lib', 'rake', 'builder'), File.dirname(__FILE__))
module In... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/compiler_spec.rb | Ruby | mit | 46 | master | 4,455 | require 'spec_helper'
describe Compiler::Base do
context '.for' do
it 'returns a compiler' do
expect(Compiler::Base.for(:gcc)).to be_a(Compiler::GCC)
end
end
subject { Compiler::Base.new }
context '#include_paths' do
let(:exists) { false }
before do
allow(File).to receive(:exist)... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder_spec.rb | Ruby | mit | 46 | master | 14,378 | require 'spec_helper'
describe Rake::Builder do
include InputOutputTestHelper
let(:target_path) { File.join('foo', 'bar') }
let(:target_pathname) { File.join(target_path, 'my_prog.exe') }
let(:source_paths) { ['src/file1.cpp'] }
let(:target_parameters) { [] }
let(:builder) do
Rake::Builder.new do |b... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/microsecond_task_spec.rb | Ruby | mit | 46 | master | 2,155 | require 'spec_helper'
describe Rake::Microsecond::DirectoryTask do
let(:path) { '/a/path' }
subject { described_class.define_task(path) }
before do
allow(subject).to receive(:mkdir_p)
Rake::Task.clear
end
context '#needed?' do
let(:directory_task) { instance_double(Rake::Microsecond::Directory... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/path_spec.rb | Ruby | mit | 46 | master | 1,101 | require 'spec_helper'
describe Rake::Path do
let(:existing_file_path) { '/path/to/a/file' }
let(:file_glob) { '/path/glob/*' }
let(:file_list) { ['FILE', 'LIST'] }
let(:a_path) { '/a/path' }
context '.find_files' do
context 'with files passed in' do
context 'if they exist' do
before do
... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/local_config_spec.rb | Ruby | mit | 46 | master | 1,635 | require 'spec_helper'
describe Rake::Builder::LocalConfig do
let(:local_config_file) { 'local_config' }
let(:include_paths) { [] }
let(:compilation_options) { [] }
let(:good_config_data) do
{
:rake_builder => {
:config_file => {:version => '1.1'},
},
:include_paths => include_path... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/install_spec.rb | Ruby | mit | 46 | master | 3,530 | require 'spec_helper'
describe Rake::Builder::Installer do
let(:destination_path) { '/destination/path' }
let(:destination_pathname) { File.join(destination_path, 'install') }
let(:destination_path_writable) { true }
before do
allow(File).to receive(:writable?).with(destination_path) { destination_path_wr... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/configure_ac_spec.rb | Ruby | mit | 46 | master | 1,113 | require 'spec_helper'
describe Rake::Builder::ConfigureAc do
subject { Rake::Builder::ConfigureAc.new('title', '1.2.3', '/source/file.c') }
context '.new' do
it 'takes three parameters' do
expect {
Rake::Builder::ConfigureAc.new
}.to raise_error(ArgumentError, /wrong number of arguments/)
... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/autoconf/version_spec.rb | Ruby | mit | 46 | master | 2,582 | require 'spec_helper'
describe Rake::Builder::Autoconf::Version do
let(:exists) { true }
let(:file_content) { '1.2.3' }
before do
allow(File).to receive(:exist?).with('VERSION') { exists }
allow(File).to receive(:read).with('VERSION') { file_content }
end
let(:params) { [] }
let(:parameter_version)... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/presenters/makefile/builder_presenter_spec.rb | Ruby | mit | 46 | master | 4,966 | require 'spec_helper'
describe Rake::Builder::Presenters::Makefile::BuilderPresenter do
def self.compiler; 'the_compiler'; end
def self.compiler_flags; 'the_compiler_flags'; end
def self.linker; 'the_linker'; end
def self.link_flags; 'the_link_flags'; end
def self.objects_path; '/objects'; end
let(:execut... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/presenters/makefile_am/builder_collection_presenter_spec.rb | Ruby | mit | 46 | master | 1,399 | require 'spec_helper'
describe Rake::Builder::Presenters::MakefileAm::BuilderCollectionPresenter do
context '.new' do
it 'takes one parameter' do
expect {
Rake::Builder::Presenters::MakefileAm::BuilderCollectionPresenter.new
}.to raise_error(ArgumentError, /wrong number of arguments/)
end... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/presenters/makefile_am/builder_presenter_spec.rb | Ruby | mit | 46 | master | 1,746 | require 'spec_helper'
describe Rake::Builder::Presenters::MakefileAm::BuilderPresenter do
context '.new' do
it 'takes one parameter' do
expect {
described_class.new
}.to raise_error(ArgumentError, /wrong number of arguments/)
end
end
context '#to_s' do
let(:builder) do
doub... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/task_definers/builder_task_definer_spec.rb | Ruby | mit | 46 | master | 7,934 | require 'spec_helper'
describe Rake::Builder::BuilderTaskDefiner do
def self.executable_target
'executable_target'
end
def self.objects_path
'/path/to/object/files'
end
def self.local_config
'local_config'
end
def self.makedepend_file
'makedepend_file'
end
def self.makefile_name
... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/task_definers/builder_collection_task_definer_spec.rb | Ruby | mit | 46 | master | 1,150 | require 'spec_helper'
describe Rake::Builder::BuilderCollectionTaskDefiner do
context '#run' do
let(:builder) do
double(
Rake::Builder,
source_files: ['foo'],
rakefile_path: '/path',
is_library?: false,
target_path: '/path2',
label: 'path2',
compiler_... |
github | joeyates/rake-builder | https://github.com/joeyates/rake-builder | spec/unit/rake/builder/logger/formatter_spec.rb | Ruby | mit | 46 | master | 414 | require 'spec_helper'
describe 'Rake::Builder::Logger::Formatter' do
let(:formatter) { Rake::Builder::Logger::Formatter.new }
let(:stream) { StringIO.new }
let(:logger) do
logger = Logger.new(stream)
logger.formatter = formatter
logger
end
context '#call' do
it 'only prints the supplied stri... |
github | sbfaulkner/sinatra-prawn | https://github.com/sbfaulkner/sinatra-prawn | sinatra-prawn.gemspec | Ruby | mit | 46 | master | 1,439 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{sinatra-prawn}
s.version = "0.9.2.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["S. Brent Faulkner"]
s.date = %q{2009-04-29}
s.description = %q{Sinatra extension to... |
github | sbfaulkner/sinatra-prawn | https://github.com/sbfaulkner/sinatra-prawn | Rakefile | Ruby | mit | 46 | master | 1,288 | require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = "sinatra-prawn"
s.summary = %Q{Sinatra extension to add support for pdf rendering with Prawn templates.}
s.email = "brentf@unwwwired.net"
s.homepage = "http://github.com/sbfaulkner/sinatra-prawn"
s.description = "Sinatra ... |
github | sbfaulkner/sinatra-prawn | https://github.com/sbfaulkner/sinatra-prawn | test/sinatra_prawn_test.rb | Ruby | mit | 46 | master | 1,309 | require File.dirname(__FILE__) + '/test_helper'
class SinatraPrawnTest < Test::Unit::TestCase
def prawn_app(&block)
mock_app {
helpers Sinatra::Prawn
set :views, File.dirname(__FILE__) + '/views'
get '/', &block
}
get '/'
end
def test_renders_inline_strings
prawn_app { prawn 'p... |
github | sbfaulkner/sinatra-prawn | https://github.com/sbfaulkner/sinatra-prawn | test/test_helper.rb | Ruby | mit | 46 | master | 1,467 | require 'rubygems'
require 'test/unit'
require 'rack/test'
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'sinatra/prawn'
require "pdf/reader"
module PDF
class TextInspector
attr_accessor :font_settings, :size, :strings
def initialize
@font_settings = []
@fonts = {}
@strings = []
... |
github | sbfaulkner/sinatra-prawn | https://github.com/sbfaulkner/sinatra-prawn | lib/sinatra/prawn.rb | Ruby | mit | 46 | master | 1,297 | require 'sinatra/base'
module Sinatra
module Prawn
module Helpers
# Generate pdf file using Prawn.
# Takes the name of a template to render as a Symbol and returns a String with the rendered output.
#
# Options for prawn may be specified in Sinatra using set :prawn, { ... }
def praw... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | Rakefile | Ruby | mit | 46 | master | 256 | # frozen_string_literal: true
require 'bundler/gem_tasks'
task(:spec).clear
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.verbose = false
end
require 'rubocop/rake_task'
RuboCop::RakeTask.new
task default: %i[rubocop spec] |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | graph_matching.gemspec | Ruby | mit | 46 | master | 1,346 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'graph_matching/version'
Gem::Specification.new do |spec|
spec.name = 'graph_matching'
spec.version = GraphMatching.gem_version.to_s
spec.authors = ['Jared Beck']
spec.email = [... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | benchmark/mwm_general/incomplete_graphs/benchmark.rb | Ruby | mit | 46 | master | 894 | # frozen_string_literal: true
# No shebang here. Usage:
# ruby -I lib benchmark/mwm_general/dense_graphs/benchmark.rb
require 'benchmark'
require 'graph_matching'
COMPLETENESS = 0.1
MIN_SIZE = 2
MAX_SIZE = 300
$stdout.sync = true
# `completeness` - decimal percentage of vertexes each vertex
# is connected to.
def... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | benchmark/mwm_general/complete_graphs/benchmark.rb | Ruby | mit | 46 | master | 635 | # frozen_string_literal: true
# No shebang here. Usage:
# ruby -I lib benchmark/mwm_general/complete_graphs/benchmark.rb
require 'benchmark'
require 'graph_matching'
MIN_SIZE = 2
MAX_SIZE = 300
$stdout.sync = true
def complete_graph(n)
g = GraphMatching::Graph::WeightedGraph.new
n_edges = (1..n - 1).reduce(:+... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | benchmark/mwm_bipartite/complete_bigraphs/benchmark.rb | Ruby | mit | 46 | master | 1,019 | # frozen_string_literal: true
# No shebang here. Usage:
# ruby -I lib benchmark/mwm_bipartite/complete_bigraphs/benchmark.rb
require 'benchmark'
require 'graph_matching'
MIN_SIZE = 2
MAX_SIZE = 300
$stdout.sync = true
# Returns a bipartite graph that is:
#
# 1. Complete - Each vertex in U has an edge to each vert... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | benchmark/mwm_bipartite/misc/calc_d2/benchmark.rb | Ruby | mit | 46 | master | 536 | # frozen_string_literal: true
# No shebang here. Usage:
# ruby -I lib benchmark/mwm_bipartite/misc/calc_d2/benchmark.rb
require 'benchmark'
require 'graph_matching'
$stdout.sync = true
# complete bigraph with three vertexes
g = GraphMatching::Graph::WeightedBigraph[
[1, 2, 1],
[1, 3, 2]
]
dogs, cats = g.partit... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | benchmark/mcm_general/complete_graphs/benchmark.rb | Ruby | mit | 46 | master | 549 | # frozen_string_literal: true
# No shebang here. Usage:
# ruby -I lib benchmark/mcm_general/complete_graphs/benchmark.rb
require 'benchmark'
require 'graph_matching'
MIN_SIZE = 2
MAX_SIZE = 500
$stdout.sync = true
def complete_graph(n)
g = GraphMatching::Graph::Graph.new
1.upto(n - 1) do |i|
(i + 1).upto(... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | benchmark/mcm_bipartite/complete_bigraphs/benchmark.rb | Ruby | mit | 46 | master | 648 | # frozen_string_literal: true
# No shebang here. Usage:
# BM_DIR='benchmark/mcm_bipartite/complete_bigraphs'
# ruby -I lib "$BM_DIR/benchmark.rb" > "$BM_DIR/time.data"
require 'benchmark'
require 'graph_matching'
MIN_SIZE = 2
MAX_SIZE = 500
$stdout.sync = true
def complete_bigraph(n)
g = GraphMatching::Graph::B... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching.rb | Ruby | mit | 46 | master | 459 | # frozen_string_literal: true
require 'graph_matching/core_ext/set'
require 'graph_matching/graph/graph'
require 'graph_matching/graph/bigraph'
require 'graph_matching/graph/weighted_graph'
require 'graph_matching/graph/weighted_bigraph'
require 'graph_matching/errors'
require 'graph_matching/version'
require 'graph_m... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/integer_vertexes.rb | Ruby | mit | 46 | master | 948 | # frozen_string_literal: true
module GraphMatching
# Converts the vertices of a graph to integers. Many graph
# matching algorithms require integer vertexes.
module IntegerVertexes
# Converts the vertices of `graph` to positive nonzero integers.
# For example, given a graph (a=b), returns a new graph (1... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/visualize.rb | Ruby | mit | 46 | master | 2,242 | # frozen_string_literal: true
require 'open3'
require 'rgl/rdot'
module GraphMatching
# Renders `GraphMatching::Graph` objects using `graphviz`.
class Visualize
TMP_DIR = '/tmp/graph_matching'
USR_BIN_ENV = '/usr/bin/env'
attr_reader :graph
def initialize(graph)
@graph = graph
end
... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/directed_edge_set.rb | Ruby | mit | 46 | master | 752 | # frozen_string_literal: true
module GraphMatching
# A `DirectedEdgeSet` is simply a set of directed edges in a
# graph. Whether the graph is actually directed or not is
# irrelevant, we can still discuss directed edges in an undirected
# graph.
#
# The naive implementation would be to use ruby's `Set` an... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/matching.rb | Ruby | mit | 46 | master | 2,776 | # frozen_string_literal: true
module GraphMatching
# > In .. graph theory, a matching .. in a graph is a set of
# > edges without common vertices.
# > https://en.wikipedia.org/wiki/Matching_%28graph_theory%29
class Matching
# Gabow (1976) uses a simple array to store his matching. It
# has one element... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/errors.rb | Ruby | mit | 46 | master | 455 | # frozen_string_literal: true
module GraphMatching
class GraphMatchingError < StandardError
end
# no-doc
class InvalidVertexNumbering < GraphMatchingError
def initialize(msg = nil)
msg ||= <<~EOS
Expected vertexes to be consecutive positive integers \
starting with zero
EOS
... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/assertion.rb | Ruby | mit | 46 | master | 784 | # frozen_string_literal: true
module GraphMatching
# Provides expressive methods for common runtime assertions, e.g.
#
# assert(banana).is_a(Fruit)
#
class Assertion
attr_reader :obj
def initialize(obj)
@obj = obj
end
def eq(other)
unless obj == other
raise "Expected #... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/ordered_set.rb | Ruby | mit | 46 | master | 1,538 | # frozen_string_literal: true
module GraphMatching
# An `OrderedSet` acts like a `Set`, but preserves insertion order.
# Internally, a `Hash` is used because, as of Ruby 1.9, it
# preserves insertion order. The Set library happens to be built
# upon a Hash currently but this might change in the future.
clas... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/core_ext/set.rb | Ruby | mit | 46 | master | 1,044 | # frozen_string_literal: true
require 'set'
# There are some methods we'd like to use which were not added
# until ruby 2.1. Fortunately, they are implemented in ruby,
# so we can simply copy them. If we ever drop support for ruby 2.0,
# this file can be deleted.
unless Set.instance_methods.include?(:intersect?)
... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/algorithm/mcm_general.rb | Ruby | mit | 46 | master | 9,490 | # frozen_string_literal: true
require_relative '../directed_edge_set'
require_relative '../matching'
require_relative 'matching_algorithm'
module GraphMatching
module Algorithm
# `MCMGeneral` implements Maximum Cardinality Matching in
# general graphs (as opposed to bipartite).
class MCMGeneral < Matchi... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/algorithm/matching_algorithm.rb | Ruby | mit | 46 | master | 375 | # frozen_string_literal: true
require_relative '../assertion'
module GraphMatching
module Algorithm
# All matching algorithms operate on a graph, hence the
# common constructor.
class MatchingAlgorithm
attr_reader :g
def initialize(graph)
@g = graph
end
def assert(obj)
... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/algorithm/mcm_bipartite.rb | Ruby | mit | 46 | master | 3,169 | # frozen_string_literal: true
require_relative '../matching'
require_relative 'matching_algorithm'
module GraphMatching
module Algorithm
# `MCMBipartite` implements Maximum Cardinality Matching in
# bipartite graphs.
class MCMBipartite < MatchingAlgorithm
def initialize(graph)
assert(graph... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/algorithm/mwm_general.rb | Ruby | mit | 46 | master | 38,707 | # frozen_string_literal: true
require_relative '../graph/weighted_graph'
require_relative '../matching'
require_relative 'matching_algorithm'
module GraphMatching
module Algorithm
# `MWMGeneral` implements Maximum Weighted Matching in
# general graphs.
class MWMGeneral < MatchingAlgorithm
# If b i... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/algorithm/mwmg_delta_assertions.rb | Ruby | mit | 46 | master | 3,030 | # frozen_string_literal: true
module GraphMatching
module Algorithm
# Can be mixed into MWMGeneral to add runtime assertions
# about the data structures used for delta2/delta3 calculations.
#
# > Check delta2/delta3 computation after every substage;
# > only works on integer weights, slows down t... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/algorithm/mwm_bipartite.rb | Ruby | mit | 46 | master | 4,413 | # frozen_string_literal: true
require_relative '../graph/weighted_bigraph'
require_relative '../matching'
require_relative 'matching_algorithm'
module GraphMatching
module Algorithm
# `MWMBipartite` implements Maximum Weighted Matching in
# bipartite graphs. It extends Maximum Cardinality
# Matching fo... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/graph/bigraph.rb | Ruby | mit | 46 | master | 1,166 | # frozen_string_literal: true
require 'rgl/bipartite'
require_relative 'graph'
require_relative '../algorithm/mcm_bipartite'
module GraphMatching
module Graph
# A bipartite graph (or bigraph) is a graph whose vertices can
# be divided into two disjoint sets U and V such that every
# edge connects a vert... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/graph/graph.rb | Ruby | mit | 46 | master | 1,476 | # frozen_string_literal: true
require 'rgl/adjacency'
require 'rgl/connected_components'
require 'set'
require_relative '../algorithm/mcm_general'
require_relative '../ordered_set'
autoload(:SecureRandom, 'securerandom')
module GraphMatching
module Graph
# Base class for all graphs.
class Graph < RGL::Adja... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/graph/weighted.rb | Ruby | mit | 46 | master | 3,889 | # frozen_string_literal: true
module GraphMatching
module Graph
# The `Weighted` module is mixed into undirected graphs to
# support edge weights. Directed graphs are not supported.
#
# Data Structure
# --------------
#
# Weights are stored in a 2D array. The weight of an edge i,j
#... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/graph/weighted_bigraph.rb | Ruby | mit | 46 | master | 373 | # frozen_string_literal: true
require_relative 'weighted'
require_relative '../algorithm/mwm_bipartite'
module GraphMatching
module Graph
# A bigraph whose edges have weights. See `Weighted`.
class WeightedBigraph < Bigraph
include Weighted
def maximum_weighted_matching
Algorithm::MWMB... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | lib/graph_matching/graph/weighted_graph.rb | Ruby | mit | 46 | master | 397 | # frozen_string_literal: true
require_relative 'weighted'
require_relative '../algorithm/mwm_general'
module GraphMatching
module Graph
# A graph whose edges have weights. See `Weighted`.
class WeightedGraph < Graph
include Weighted
def maximum_weighted_matching(max_cardinality)
Algori... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/spec_helper.rb | Ruby | mit | 46 | master | 710 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'graph_matching'
require 'byebug'
RSpec.configure do |config|
config.disable_monkey_patching!
config.filter_run_including(focus: true)
config.run_all_when_everything_filtered = true
end
RSpec::Matchers.define(:match_ed... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching_spec.rb | Ruby | mit | 46 | master | 230 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching do
describe '.gem_version' do
it 'returns a Gem::Version' do
expect(GraphMatching.gem_version).to be_a(Gem::Version)
end
end
end |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/visualize_spec.rb | Ruby | mit | 46 | master | 968 | # frozen_string_literal: true
require_relative '../spec_helper'
RSpec.describe GraphMatching::Visualize do
describe '.new' do
it 'initializes with a graph' do
g = double
v = described_class.new(g)
expect(v.graph).to eq(g)
end
end
describe '#dot' do
let(:g) { GraphMatching::Graph::... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/integer_vertexes_spec.rb | Ruby | mit | 46 | master | 642 | # frozen_string_literal: true
require 'rgl/adjacency'
require 'spec_helper'
require 'graph_matching/integer_vertexes'
RSpec.describe GraphMatching::IntegerVertexes do
describe '.to_integers' do
it 'returns new graph with vertexes converted to integers, and a legend' do
e = %w[a b]
g1 = RGL::Adjacenc... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/matching_spec.rb | Ruby | mit | 46 | master | 2,225 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Matching do
describe '.gabow' do
context 'when nil is used as a placeholder' do
it 'returns a Matching' do
a = [nil, 2, 1, nil, 5, 4]
m = described_class.gabow(a)
expect(m.edge?([1, 2])).to eq(true)
... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/algorithm/mcm_general_spec.rb | Ruby | mit | 46 | master | 3,597 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Algorithm::MCMGeneral do
let(:graph_class) { GraphMatching::Graph::Graph }
let(:g) { graph_class.new }
describe '.new' do
it 'requires a Graph' do
expect { described_class.new('banana') }.to raise_error(TypeError)
e... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/algorithm/matching_algorithm_spec.rb | Ruby | mit | 46 | master | 327 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Algorithm::MatchingAlgorithm do
let(:algorithm) { described_class.new(double) }
describe '#assert' do
it 'returns an Assertion' do
expect(algorithm.assert('banana')).to \
be_a(GraphMatching::Assertion)
end
e... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/algorithm/mcm_bipartite_spec.rb | Ruby | mit | 46 | master | 3,477 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Algorithm::MCMBipartite do
let(:g) { GraphMatching::Graph::Bigraph.new }
describe '.new' do
it 'requires a Bigraph' do
expect { described_class.new('banana') }.to raise_error(TypeError)
end
end
describe '#augment... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/algorithm/mwm_general_spec.rb | Ruby | mit | 46 | master | 11,454 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Algorithm::MWMGeneral do
let(:graph_class) { GraphMatching::Graph::WeightedGraph }
describe '.new' do
it 'requires a WeightedGraph' do
expect { described_class.new('banana') }.to raise_error(TypeError)
end
end
de... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/algorithm/mwm_bipartite_spec.rb | Ruby | mit | 46 | master | 3,600 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Algorithm::MWMBipartite do
let(:graph_class) { GraphMatching::Graph::WeightedBigraph }
describe '.new' do
it 'requires a WeightedBigraph' do
expect { described_class.new('banana') }.to raise_error(TypeError)
end
end... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/graph/weighted_spec.rb | Ruby | mit | 46 | master | 608 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Graph::Weighted do
# no-doc
class MyGraph < RGL::AdjacencyGraph
include GraphMatching::Graph::Weighted
end
describe '.[]' do
it 'sets weights' do
g = MyGraph[[1, 2, 100], [1, 3, 101]]
expect(g.w([1, 2])).to ... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/graph/graph_spec.rb | Ruby | mit | 46 | master | 1,302 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Graph::Graph do
ERR_MSG_INT_VERTEXES = 'All vertexes must be integers'
let(:g) { described_class.new }
it 'is an RGL::MutableGraph' do
expect(g).to be_a(RGL::MutableGraph)
end
describe '.[]' do
it 'checks that all v... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | spec/graph_matching/graph/bigraph_spec.rb | Ruby | mit | 46 | master | 1,923 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe GraphMatching::Graph::Bigraph do
let(:g) { described_class.new }
it 'is a Graph' do
expect(g).to be_a(GraphMatching::Graph::Graph)
end
describe '#partition' do
context 'empty graph' do
it 'returns two empty sets' do
p =... |
github | jaredbeck/graph_matching | https://github.com/jaredbeck/graph_matching | profile/mwm_general/profile.rb | Ruby | mit | 46 | master | 578 | # frozen_string_literal: true
# No shebang here. Run with:
#
# ruby -I lib profile/mwm_general/profile.rb
require 'graph_matching'
require 'ruby-prof'
def complete_graph(n)
g = GraphMatching::Graph::WeightedGraph.new
n_edges = (1..n - 1).reduce(:+)
0.upto(n - 2) do |i|
(i + 1).upto(n - 1) do |j|
g.a... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | Rakefile | Ruby | mit | 46 | main | 575 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rubocop/rake_task"
require "rake/testtask"
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ["--display-cop-names"]
end
Rake::TestTask.new("test:unit") do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/unit/**/*_test.rb"... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | Appraisals | Ruby | mit | 46 | main | 241 | # frozen_string_literal: true
appraise "activerecord-61" do
gem "activerecord", "< 6.2", ">= 6.1"
end
appraise "activerecord-70" do
gem "activerecord", "~> 7.0.0"
end
appraise "activerecord-70" do
gem "activerecord", "~> 7.1.0"
end |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | Gemfile | Ruby | mit | 46 | main | 366 | # frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
gemspec
gem "appraisal"
gem "bundler"
gem "debug"
gem "faker"
gem "minitest"
gem "mocha"
gem "rake"
gem "rubocop"
gem "rubocop-minitest"
gem "rubocop-performance"
gem "rubocop-rake"
gem ... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | redi_search.gemspec | Ruby | mit | 46 | main | 1,135 | # frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "redi_search/version"
Gem::Specification.new do |spec|
spec.name = "redi_search"
spec.version = RediSearch::VERSION
spec.authors = "Nick Pezza"
spec.email ... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search.rb | Ruby | mit | 46 | main | 775 | # frozen_string_literal: true
require "delegate"
require "forwardable"
require "redis"
require "active_support/lazy_load_hooks"
require "zeitwerk"
loader = Zeitwerk::Loader.for_gem
loader.setup
module RediSearch
class << self
attr_writer :configuration
def configuration
@configuration ||= Configurat... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/hset.rb | Ruby | mit | 46 | main | 464 | # frozen_string_literal: true
module RediSearch
class Hset
def initialize(index, document)
@index = index
@document = document
end
def call!
RediSearch.client.call!(*command, skip_ft: true)
end
def call
call!
rescue Redis::CommandError
false
end
privat... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/log_subscriber.rb | Ruby | mit | 46 | main | 2,179 | # frozen_string_literal: true
require "active_support/version"
if ActiveSupport::VERSION::MAJOR >= 7 && ActiveSupport::VERSION::MINOR >= 1
require "active_support/deprecation"
require "active_support/deprecator"
end
require "active_support/log_subscriber"
if ActiveSupport::VERSION::MAJOR > 6
require "active_supp... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/validatable.rb | Ruby | mit | 46 | main | 986 | # frozen_string_literal: true
module RediSearch
class ValidationError < StandardError
end
module Validatable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
attr_accessor :validations
def validates_inclusion_of(field, within:, **options)
self.val... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/add_field.rb | Ruby | mit | 46 | main | 574 | # frozen_string_literal: true
module RediSearch
class AddField
def initialize(index, name, type, **options, &block)
@index = index
@name = name
@type = type
@options = options
@block = block
end
def call!
field = index.schema.add_field(name, type, **options,... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/schema.rb | Ruby | mit | 46 | main | 1,047 | # frozen_string_literal: true
module RediSearch
class Schema
attr_reader :fields
def initialize(&)
@fields = []
instance_exec(&)
end
def text_field(name, ...)
self[name] || push(Schema::TextField.new(name, ...))
end
def numeric_field(name, ...)
self[name] || push(S... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/spellcheck.rb | Ruby | mit | 46 | main | 997 | # frozen_string_literal: true
module RediSearch
class Spellcheck
include LazilyLoad
include Validatable
validates_numericality_of :distance, within: 1..4, only_integer: true
def initialize(index, terms, distance: 1)
@index = index
@terms = terms
@distance = distance
end
p... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/client.rb | Ruby | mit | 46 | main | 1,330 | # frozen_string_literal: true
require "active_support/notifications"
module RediSearch
class Client
def initialize(redis = Redis.new)
@redis = redis
@pipeline = false
end
def call!(command, *params, skip_ft: false)
instrument(command.downcase, query: [command, params]) do
comm... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/index.rb | Ruby | mit | 46 | main | 2,165 | # frozen_string_literal: true
module RediSearch
class Index
attr_reader :name, :schema, :model
def initialize(name, model = nil, &)
@name = name.to_s
@schema = Schema.new(&)
@model = model
end
def search(term = nil, **term_options)
Search.new(self, term, **term_options)
... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/application_clause.rb | Ruby | mit | 46 | main | 734 | # frozen_string_literal: true
module RediSearch
class ApplicationClause
include Validatable
def clause_order
self.class.order
end
class << self
def clause_term(term, **validations)
attr_reader term
validations.each do |validation_type, options|
define_validati... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/document.rb | Ruby | mit | 46 | main | 1,716 | # frozen_string_literal: true
module RediSearch
class Document
include Display
class << self
def for_object(index, record, only: [])
field_values = index.schema.fields.filter_map do |field|
next unless only.empty? || only.include?(field.name)
[field.name.to_s, field.serial... |
github | npezza93/redi_search | https://github.com/npezza93/redi_search | lib/redi_search/search.rb | Ruby | mit | 46 | main | 1,131 | # frozen_string_literal: true
module RediSearch
class Search
extend Forwardable
include LazilyLoad
include Clauses
include Queries
attr_reader :query, :used_clauses, :index, :clauses
def_delegator :index, :model
def initialize(index, term = nil, **term_options)
@index = index
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.