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 | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/update/deleter.rb | Ruby | mit | 49 | master | 2,438 | module Alf
module Update
class Deleter < Algebra::Compiler
### overridings
def not_supported(expr, *args)
raise NotSupportedError, "Unable to delete through `#{expr}`"
end
### Reusable rules
def apply_and_split(expr, predicate, list)
top, down = predicate.and_spli... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/update/updater.rb | Ruby | mit | 49 | master | 1,619 | module Alf
module Update
class Updater < Algebra::Compiler
### overridings
def not_supported(expr, *args)
raise NotSupportedError, "Unable to update through `#{expr}`"
end
### leaf Operand, recursion end :-)
def on_leaf_operand(expr, updating, predicate)
expr.to_r... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/update/inserter.rb | Ruby | mit | 49 | master | 3,249 | module Alf
module Update
class Inserter < Algebra::Compiler
include Lang::Functional
### overridings
def call(expr, tuples)
super(expr, Algebra::Operand.coerce(tuples))
end
def not_supported(expr, *args)
raise NotSupportedError, "Unable to insert through `#{expr}`"... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/type_check.rb | Ruby | mit | 49 | master | 2,060 | module Alf
module Types
class TypeCheck
Error = Class.new(Alf::Error)
def initialize(heading, strict = true)
@heading = heading
@attr_list = heading.to_attr_list
@strict = strict
end
attr_reader :heading
def strict?
@strict
end
def... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/size.rb | Ruby | mit | 49 | master | 330 | module Alf
module Types
#
# Defines a Size domain, as a (non strictly) positive integer.
#
class Size < Integer
extend Domain::SByC.new(Integer){|i| i >= 0}
coercions do |c|
c.upon(Object){|s,t| new Support.coerce(s, Integer) }
end
end # Size
end # module Types
end # m... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/selection.rb | Ruby | mit | 49 | master | 622 | module Alf
module Types
class Selection
extend Domain::Reuse.new(Object)
coercions do |c|
c.coercion(Symbol){|x,_|
new(x)
}
c.coercion(String){|x,_|
new(x.to_sym)
}
c.coercion(Array){|x,_|
Selection.new(x.map{|y| Selector.coerce(y)... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/summarization.rb | Ruby | mit | 49 | master | 2,626 | module Alf
module Types
#
# Encapsulates a Summarization information.
#
class Summarization
extend Domain::Reuse.new(Hash)
coercions do |c|
c.delegate :to_summarization
c.coercion(Hash){|arg,_|
Summarization.new Hash[arg.map{|k,v| [ AttrName.coerce(k), Aggregator... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/renaming.rb | Ruby | mit | 49 | master | 2,058 | module Alf
module Types
#
# Encapsulates a Renaming information
#
class Renaming
extend Domain::Reuse.new(Hash)
coercions do |c|
c.delegate :to_renaming
c.coercion(Hash){|arg,_|
Renaming.new Hash[arg.map{|k,v| [ AttrName.coerce(k), AttrName.coerce(v) ] }]
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/attr_name.rb | Ruby | mit | 49 | master | 523 | module Alf
module Types
#
# Attribute name.
#
# Attribute names are ruby symbols that match the following regular expression:
#
# /^[a-zA-Z0-9_]+[?!]?$/
#
# Example:
#
# AttrName.coerce("city")
# # => :city
#
class AttrName < Symbol
extend Domain::... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/ordering.rb | Ruby | mit | 49 | master | 5,908 | module Alf
module Types
#
# Defines an ordering on tuple attributes
#
class Ordering
extend Domain::Reuse.new(Array)
def self.new(array)
super(array.map{|(x,y)| [Selector.coerce(x), y.to_sym] })
end
ArrayOfArray = ->(x){
x.is_a?(Array) && x.all?{|y| y.is_a?(Ar... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/heading.rb | Ruby | mit | 49 | master | 6,367 | module Alf
module Types
#
# Defines a Heading, that is, a set of attribute (name,domain) pairs.
#
class Heading
include Comparable
extend Domain::Reuse.new(Hash)
coercions do |c|
c.delegate :to_heading
c.coercion(Array){|arg,_|
Heading.new Hash[arg.each_sli... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/tuple_computation.rb | Ruby | mit | 49 | master | 3,432 | module Alf
module Types
#
# Defines the computation of a tuple from expressions mapped to names.
#
# Example:
# computation = TupleComputation[
# :big? => lambda{ status > 20 }
# :who => lambda{ "#{first} #{last}" }
# ]
# computation.call(:last => "Jones", :first => ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/selector.rb | Ruby | mit | 49 | master | 1,351 | module Alf
module Types
class Selector
extend Domain::Reuse.new(Object)
coercions do |c|
c.coercion(Symbol){|v,_|
Selector.new(AttrName.coerce(v))
}
c.coercion(String){|v,_|
v =~ /\./ ? c.coerce(v.split('.')) : c.coerce(v.to_sym)
}
c.coercio... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/keys.rb | Ruby | mit | 49 | master | 929 | module Alf
module Types
class Keys
extend Domain::Reuse.new(Array)
include Support::OrderedSet
coercions do |c|
c.coercion(Array){|v,_| Keys.new(v.map{|e| AttrList.coerce(e)}) }
end
def self.[](*args); coerce(args); end
def if_empty(keys = nil, &bl)
return sel... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/tuple_expression.rb | Ruby | mit | 49 | master | 4,155 | module Alf
module Types
#
# A tuple expression is a Ruby expression whose evaluates in the scope of a specific
# tuple.
#
# Example:
# expr = TupleExpression["status * 10"]
# expr.call(:status => 20)
# # => 200
#
class TupleExpression
# @return [Proc] the lambda ex... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/types/attr_list.rb | Ruby | mit | 49 | master | 4,856 | module Alf
module Types
#
# An attribute list is an ordered collection of attribute names (see AttrName).
#
# Example:
#
# list = AttrList[:name, :city]
#
class AttrList
extend Domain::Reuse.new(Array)
include Support::OrderedSet
coercions do |c|
c.delega... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/config.rb | Ruby | mit | 49 | master | 3,699 | module Alf
module Support
class Config
module ClassMethods
def options
@options ||= []
end
def each_option(&bl)
options.each(&bl)
end
def delegation_methods
public_instance_methods(false).reject{|m| m.to_s =~ /=$/ }
end
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/to_lispy.rb | Ruby | mit | 49 | master | 1,077 | module Alf
module Support
NOT_PROVIDED = Object.new.freeze
# Converts `value` to a lispy expression.
#
# Example:
#
# expr = Alf.examples.compile{
# project(:suppliers, [:name])
# }
# Support.to_lispy(expr)
# # => project(:suppliers, [:name])
#
#... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/to_ruby_literal.rb | Ruby | mit | 49 | master | 1,252 | module Alf
module Support
# Converts `value` to a ruby literal
#
# This method is provided for code generation mechanisms used by Alf in
# various places (such as .rash files). The to_ruby_literal contract is
# such that the following invariant holds:
#
# eval(to_ruby_literal(value)) ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/dot_utils.rb | Ruby | mit | 49 | master | 343 | module Alf
module Support
module DotUtils
def dot_label(label, strip = 100)
label = label.to_s[0..strip]
.gsub(/"/, '\"')
.gsub(/\n/, '\n')
.gsub(">", ">")
%Q{"#{label}"}
end
end # module DotUtils
end # module Su... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/ordered_set.rb | Ruby | mit | 49 | master | 777 | module Alf
module Support
module OrderedSet
extend Domain::Reuse::Helpers
reuse :size, :each, :include?, :empty?, :to_a, :to_set, :first, :any?, :all?
recoat :select, :reject
def elements
reused_instance
end
def -(other)
self.class.new (elements - self.class... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/csv_utils.rb | Ruby | mit | 49 | master | 832 | module Alf
module Support
#
# Provides common tooling to CSV renderer and readers
#
module CSVUtils
DEFAULT_OPTIONS = {
:headers => true
}
private
# Returns a CSV instance bound to a given io and options
def get_csv(io, options = {})
require 'csv'
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/registry.rb | Ruby | mit | 49 | master | 1,298 | module Alf
module Support
module Registry
def listeners
@listeners ||= []
end
def listen(&listener)
listeners << listener
registered.each do |what|
method_name, factory = Registry.decode_registered(what)
listener.call(method_name, factory)
en... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/coerce.rb | Ruby | mit | 49 | master | 881 | module Alf
module Support
# Defines all coercion rules, through Myrrha inheritance
Coercions = Myrrha::Coerce.dup.append do |g|
g.error_handler = lambda{|v,t,c|
raise TypeError, "Unable to coerce `#{v.inspect}` to `#{t}`", caller
}
g.coercion String, Time, lambda{|s,t| Time.pars... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/tuple_scope.rb | Ruby | mit | 49 | master | 2,187 | module Alf
module Support
#
# Specialization of Scope for working on a tuple specifically.
#
# This class works hand-in-hand with TupleExpression as it provides a scope for their
# evaluation on tuples. It also provides a handle for implementing a flyweight design
# pattern on tuples through t... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/scope.rb | Ruby | mit | 49 | master | 2,608 | module Alf
module Support
#
# Implements a sandboxed scope abstraction through a BasicObject.
#
# Example:
#
# module Foo; ... end
# module Bar; ... end
#
# Scope.new([Foo, Bar]).evaluate{
# # Foo and Bar instance methods are available
# # Kernel's ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/miscellaneous.rb | Ruby | mit | 49 | master | 2,058 | module Alf
module Support
# Returns the unqualified name of a ruby class or module.
#
# Example
#
# class_name(Alf::Support) -> :Support
#
# @param [Class] clazz a ruby class
# @return [Symbol] the unqualified name of the class as a Symbol
def class_name(clazz)
/([A-Za-z0-... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/support/tree.rb | Ruby | mit | 49 | master | 1,453 | module Alf
module Support
class Tree
EMPTY_CHILDREN = [].freeze
def initialize(root)
@root = root
end
attr_reader :root
def label(node)
case node
when Sexpr then node.first.to_s
when Algebra::Operand::Proxy then label(node.subject)... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/viewpoint/metadata.rb | Ruby | mit | 49 | master | 1,899 | module Alf
module Viewpoint
class Metadata
def initialize(expectations = [], dependencies = {}, members = [])
@expectations = expectations
@dependencies = dependencies
@members = members
yield(self) if block_given?
end
attr_reader :expectations, :dependencie... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/database/connection.rb | Ruby | mit | 49 | master | 2,797 | module Alf
class Database
class Connection
include Options.helpers(:options)
extend Forwardable
def initialize(db, options = Options.new, &connection_handler)
@db = db
@options = options.freeze
@connection_handler = connection_handler
open!
end
attr_r... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/database/options.rb | Ruby | mit | 49 | master | 504 | module Alf
class Database
class Options < Support::Config
# Cache results of native schema queries?
option :schema_cache, Boolean, true
# What viewpoint to use by default?
option :viewpoint, Module, Viewpoint::NATIVE
# What parser (class) to use for parsing expressions
optio... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/core/loader.rb | Ruby | mit | 49 | master | 235 | # Standard library
require "enumerator"
require "stringio"
require "set"
require "forwardable"
require 'time'
# Third party gems
require "path"
require "sexpr"
require "myrrha"
require 'myrrha/to_ruby_literal'
require 'myrrha/coerce' |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/core/version.rb | Ruby | mit | 49 | master | 212 | module Alf
module Core
module Version
MAJOR = 0
MINOR = 18
TINY = 0
def self.to_s
[ MAJOR, MINOR, TINY ].join('.')
end
end
VERSION = Version.to_s
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/sum.rb | Ruby | mit | 49 | master | 674 | module Alf
class Aggregator
#
# Defines a `sum()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.sum{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :total => sum{ qty })
#
class Sum < Aggregator
# Returns ... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/concat.rb | Ruby | mit | 49 | master | 1,113 | module Alf
class Aggregator
#
# Defines a `concat()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.concat{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :cat => concat{ qty })
#
class Concat < Aggregator
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/stddev.rb | Ruby | mit | 49 | master | 541 | module Alf
class Aggregator
#
# Defines a `stddev()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.stddev{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :stddev => stddev{ qty })
#
class Stddev < Variance
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/collect.rb | Ruby | mit | 49 | master | 675 | module Alf
class Aggregator
#
# Defines a `collect()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.collect{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :col => collect{ qty })
#
class Collect < Aggregator
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/count.rb | Ruby | mit | 49 | master | 671 | module Alf
class Aggregator
#
# Defines a `count()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.count.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :num_orders => count)
#
class Count < Aggregator
# Returns 0... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/min.rb | Ruby | mit | 49 | master | 722 | module Alf
class Aggregator
#
# Defines a `min()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.min{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :max => min{ qty })
#
class Min < Aggregator
# Returns ni... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/avg.rb | Ruby | mit | 49 | master | 855 | module Alf
class Aggregator
#
# Defines a `avg()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.avg{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :avg => avg{ qty })
#
class Avg < Aggregator
# Returns [0... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/max.rb | Ruby | mit | 49 | master | 723 | module Alf
class Aggregator
#
# Defines a `max()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.max{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :max => max{ qty })
#
class Max < Aggregator
# Returns ni... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/aggregator/variance.rb | Ruby | mit | 49 | master | 1,023 | module Alf
class Aggregator
#
# Defines a `variance()` aggregation operator.
#
# Example:
#
# # direct ruby usage
# Alf::Aggregator.variance{ qty }.aggregate(...)
#
# # lispy
# (summarize :supplies, [:sid], :total => variance{ qty })
#
class Variance < Aggregat... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/factory.rb | Ruby | mit | 49 | master | 2,954 | module Alf
class Predicate
module Factory
def tautology
_factor_predicate([:tautology, true])
end
def contradiction
_factor_predicate([:contradiction, false])
end
def identifier(name)
_factor_predicate([:identifier, name])
end
def qualified_ide... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/grammar.rb | Ruby | mit | 49 | master | 880 | module Alf
class Predicate
Grammar = Sexpr.load Path.relative('grammar.sexp.yml')
module Grammar
def tagging_reference
Predicate
end
def default_tagging_module
Expr
end
end
end # class Predicate
end # module Alf
require_relative 'nodes/expr'
require_relative 'n... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/not.rb | Ruby | mit | 49 | master | 293 | module Alf
class Predicate
module Not
include Expr
def operator_symbol
:'!'
end
def priority
90
end
def !
last
end
def free_variables
@free_variables ||= last.free_variables
end
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/dyadic_comp.rb | Ruby | mit | 49 | master | 405 | module Alf
class Predicate
module DyadicComp
include Expr
def priority
50
end
def !
Factory.send(OP_NEGATIONS[first], self[1], self[2])
end
def left
self[1]
end
def right
self[2]
end
def free_variables
@free_v... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/expr.rb | Ruby | mit | 49 | master | 1,327 | module Alf
class Predicate
module Expr
include Factory
OP_NEGATIONS = {
:eq => :neq,
:neq => :eq,
:lt => :gte,
:lte => :gt,
:gt => :lte,
:gte => :lt
}
def tautology?
false
end
def contradiction?
false
e... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/qualified_identifier.rb | Ruby | mit | 49 | master | 310 | module Alf
class Predicate
module QualifiedIdentifier
include Expr
def priority
100
end
def qualifier
self[1]
end
def name
self[2]
end
def free_variables
@free_variables ||= AttrList[ name ]
end
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/contradiction.rb | Ruby | mit | 49 | master | 455 | module Alf
class Predicate
module Contradiction
include Expr
def contradiction?
true
end
def !
tautology
end
def &(other)
self
end
def |(other)
other
end
def priority
100
end
def free_variables
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/in.rb | Ruby | mit | 49 | master | 404 | module Alf
class Predicate
module In
include Expr
def priority
80
end
def identifier
self[1]
end
def values
self[2]
end
def free_variables
@free_variables ||= identifier.free_variables
end
def constant_variables
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/identifier.rb | Ruby | mit | 49 | master | 254 | module Alf
class Predicate
module Identifier
include Expr
def priority
100
end
def name
self[1]
end
def free_variables
@free_variables ||= AttrList[ name ]
end
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/and.rb | Ruby | mit | 49 | master | 506 | module Alf
class Predicate
module And
include NadicBool
def operator_symbol
:'&&'
end
def and_split(attr_list)
sexpr_body.inject([tautology, tautology]) do |(top,down),term|
pair = term.and_split(attr_list)
[top & pair.first, down & pair.last]
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/nadic_bool.rb | Ruby | mit | 49 | master | 283 | module Alf
class Predicate
module NadicBool
include Expr
def priority
60
end
def free_variables
@free_variables ||= sexpr_body.inject(AttrList[]){|list,term|
list | term.free_variables
}
end
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/native.rb | Ruby | mit | 49 | master | 488 | module Alf
class Predicate
module Native
include Expr
def priority
90
end
def proc
self[1]
end
def to_ruby_code(scope = 't')
if proc.respond_to?(:source_code)
code = proc.source_code
return code if code
end
raise No... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/literal.rb | Ruby | mit | 49 | master | 248 | module Alf
class Predicate
module Literal
include Expr
def priority
100
end
def free_variables
@free_variables ||= AttrList::EMPTY
end
def value
last
end
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/tautology.rb | Ruby | mit | 49 | master | 387 | module Alf
class Predicate
module Tautology
include Expr
def tautology?
true
end
def !
contradiction
end
def &(other)
other
end
def |(other)
self
end
def priority
100
end
def free_variables
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/nodes/eq.rb | Ruby | mit | 49 | master | 248 | module Alf
class Predicate
module Eq
include DyadicComp
def operator_symbol
:==
end
def constant_variables
fv = free_variables
fv.size == 1 ? fv : AttrList::EMPTY
end
end
end
end |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/processors/qualifier.rb | Ruby | mit | 49 | master | 466 | module Alf
class Predicate
class Qualifier < Sexpr::Rewriter
grammar Grammar
def initialize(qualifier)
@qualifier = qualifier
end
attr_reader :qualifier
def on_identifier(sexpr)
return sexpr unless q = qualifier[sexpr.name]
[:qualified_identifier, q, sexpr.... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/processors/renamer.rb | Ruby | mit | 49 | master | 631 | module Alf
class Predicate
class Renamer < Sexpr::Rewriter
grammar Grammar
def on_identifier(sexpr)
return sexpr unless new_name = options[:renaming][sexpr.name]
return new_name if Sexpr===new_name
[:identifier, new_name]
end
def on_qualified_identifier(sexpr)
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/predicate/processors/to_ruby_code.rb | Ruby | mit | 49 | master | 1,528 | module Alf
class Predicate
class ToRubyCode < Sexpr::Processor
def on_tautology(sexpr)
"true"
end
def on_contradiction(sexpr)
"false"
end
def on_qualified_identifier(sexpr)
"#{sexpr.qualifier}.#{sexpr.name}"
end
def on_identifier(sexpr)
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/renderer/text.rb | Ruby | mit | 49 | master | 4,613 | module Alf
class Renderer
class Text < Renderer
def self.mime_type
"text/plain"
end
module Utils
def max(x, y)
return y if x.nil?
return x if y.nil?
x > y ? x : y
end
end
include Utils
class Cell
include Utils
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/renderer/html.rb | Ruby | mit | 49 | master | 1,221 | module Alf
class Renderer
class Html < Renderer
def self.mime_type
"text/html"
end
def each
return to_enum unless block_given?
yield "<table>"
header = nil
each_tuple do |tuple|
unless header
header = tuple.keys
yield "<... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/renderer/csv.rb | Ruby | mit | 49 | master | 717 | module Alf
class Renderer
#
# Implements Alf::Renderer contract for outputting CSV files.
#
class CSV < Renderer
include Support::CSVUtils
def self.mime_type
"text/csv"
end
def each(&bl)
return to_enum unless block_given?
with_csv(ProcIO.new(bl), optio... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/renderer/json.rb | Ruby | mit | 49 | master | 708 | module Alf
class Renderer
#
# Implements Alf::Renderer contract for outputing JSON.
#
class JSON < ::Alf::Renderer
def self.mime_type
"application/json"
end
def each
return to_enum unless block_given?
require 'json'
if TupleLike===input
yie... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/renderer/yaml.rb | Ruby | mit | 49 | master | 637 | module Alf
class Renderer
#
# Implements Alf::Renderer contract for outputing YAML files.
#
class YAML < ::Alf::Renderer
def self.mime_type
"text/yaml"
end
def each
return to_enum unless block_given?
require "yaml"
yield("---\n")
Engine::ToAr... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/renderer/rash.rb | Ruby | mit | 49 | master | 779 | module Alf
class Renderer
#
# Implements the Renderer contract through inspect
#
class Rash < Renderer
def self.mime_type
nil
end
def each
return to_enum unless block_given?
if options[:pretty]
each_tuple do |tuple|
yield "{\n" << tuple... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/relvar/read_only.rb | Ruby | mit | 49 | master | 922 | module Alf
module Relvar
class ReadOnly
include Relvar
def initialize(value)
unless value.is_a?(Algebra::Operand::Proxy)
value = Algebra::Operand::Proxy.new(value)
end
super(value)
end
def to_relation
Relation.coerce(expr.subject)
end
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/relvar/fake.rb | Ruby | mit | 49 | master | 782 | module Alf
module Relvar
class Fake
include Relvar
def initialize(expr, heading)
super(expr)
@heading = Heading.coerce(heading)
end
attr_reader :heading
def insert(tuples)
@inserted_tuples = tuples.to_a
end
attr_reader :inserted_tuples
def... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/relvar/base.rb | Ruby | mit | 49 | master | 790 | module Alf
module Relvar
class Base
extend Forwardable
include Relvar
def_delegators :expr, :connection,
:connection!
### Update
def lock(mode = :exclusive, &bl)
connection!.lock(expr.name, mode, &bl)
end
def insert(tuples)
... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/relvar/memory.rb | Ruby | mit | 49 | master | 984 | module Alf
module Relvar
class Memory
include Relvar
def initialize(value)
unless value.is_a?(Algebra::Operand)
value = Algebra::Operand.coerce(value)
end
super(value)
end
def to_relation
expr.to_relation
end
### Update
def lo... |
github | alf-tool/alf-core | https://github.com/alf-tool/alf-core | lib/alf/relvar/virtual.rb | Ruby | mit | 49 | master | 754 | module Alf
module Relvar
class Virtual
include Relvar
# Inserts some tuples inside this relation variable.
def insert(tuples)
tuples = [ tuples ] if TupleLike===tuples
Update::Inserter.new.call(expr, tuples)
end
# Updates all tuples of this relation variable.
... |
github | folio-sec/Fastfile | https://github.com/folio-sec/Fastfile | Scripts/screenshots-preview-generator.rb | Ruby | mit | 49 | master | 2,828 | #!/usr/bin/env ruby
require 'uri'
puts 'START SCREENSHOTS PREVIE GENERATOR'
def createMarkdownEachDevice
markdowns = {}
Dir.glob('./FolioTests/ReferenceImages_*').each do |e|
device = e[/ReferenceImages_((.*))/, 1]
markdowns[device] = "# #{device}\n\n"
Dir.glob(e + '/*').sort.each do |tests|
v... |
github | folio-sec/Fastfile | https://github.com/folio-sec/Fastfile | Scripts/coverage.rb | Ruby | mit | 49 | master | 439 | project_name = ARGV[0]
profdata = Dir.glob(File.join('DerivedData', '/**/Coverage.profdata')).first
Dir.glob(File.join('DerivedData', "/**/#{project_name}")) do |target|
output = `xcrun llvm-cov report -instr-profile "#{profdata}" "#{target}" -arch=x86_64`
if $?.success?
puts output
`xcrun llvm-... |
github | kenn/bitwise | https://github.com/kenn/bitwise | Rakefile | Ruby | mit | 49 | master | 377 | #!/usr/bin/env rake
require 'bundler/gem_tasks'
require 'rake/testtask'
# Compile
require 'rake/extensiontask'
Rake::ExtensionTask.new('bitwise_ext') do |ext|
ext.ext_dir = 'ext'
end
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/*_test.rb']
end
Rake::Task[... |
github | kenn/bitwise | https://github.com/kenn/bitwise | bitwise.gemspec | Ruby | mit | 49 | master | 968 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |gem|
gem.authors = ['Kenn Ejima']
gem.email = ['kenn.ejima@gmail.com']
gem.description = %q{Fast, memory efficient bitwise operations on large binary strings}
gem.summary = %q{Fast, memory efficient bitwise operations on large binary st... |
github | kenn/bitwise | https://github.com/kenn/bitwise | lib/bitwise.rb | Ruby | mit | 49 | master | 2,522 | # encoding: binary
require 'bitwise_ext'
class Bitwise
attr_accessor :value
def initialize(string = "")
self.raw = string
end
def size
@value.bytesize
end
alias :to_s :size
def set_at(index)
get_byte(index)
@value.setbyte(@div, @byte | bitmask)
end
def unset_at(index)
get_byt... |
github | kenn/bitwise | https://github.com/kenn/bitwise | test/bitwise_test.rb | Ruby | mit | 49 | master | 4,516 | # encoding: binary
require 'test_helper'
class BitwiseTest < Minitest::Test
def setup
@bitwise = Bitwise.new("\x00")
end
class BaseTest < BitwiseTest
def test_encode_to_binary
assert_equal @bitwise.raw.encoding, Encoding::BINARY
@bitwise.indexes = [1,2]
assert_equal @bitwise.raw.encod... |
github | gangelo/dsu | https://github.com/gangelo/dsu | dsu.gemspec | Ruby | mit | 49 | main | 3,310 | # frozen_string_literal: true
require_relative 'lib/dsu/version'
Gem::Specification.new do |spec|
spec.name = 'dsu'
spec.version = Dsu::VERSION
spec.authors = ['Gene M. Angelo, Jr.']
spec.email = ['public.gma@gmail.com']
spec.summary = 'dsu (Agile Daily Stand Up/DSU) mini-manager.'
spec... |
github | gangelo/dsu | https://github.com/gangelo/dsu | Rakefile | Ruby | mit | 49 | main | 409 | # 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
desc 'Generate a migration timestamp'
task :timestamp do
puts 'The below migration timestamp should be placed in the "lib/dsu/migration/version... |
github | gangelo/dsu | https://github.com/gangelo/dsu | Gemfile | Ruby | mit | 49 | main | 725 | # frozen_string_literal: true
source 'https://rubygems.org'
# Specify your gem's dependencies in dsu.gemspec
gemspec
gem 'bundler', '>= 2.5', '< 3.0'
gem 'rake', '>= 13.0', '< 14.0'
group :development do
gem 'reek', '>= 6.1', '< 7.0'
gem 'rubocop', '>= 1.65', '< 2.0'
gem 'rubocop-factory_bot', '~> 2.26', '>= ... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu.rb | Ruby | mit | 49 | main | 1,029 | # frozen_string_literal: true
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/core_ext/object/blank'
require 'i18n'
require 'thor'
require 'time'
I18n.load_path += Dir[File.join(__dir__, 'locales/**/*', '*.yml')]
# I18n.default_locale = :en # (note that `en` is already the default!)
... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/core/ruby/wrap_and_join.rb | Ruby | mit | 49 | main | 861 | # frozen_string_literal: true
module WrapAndJoin
class << self
def included(base)
base.const_set(:WRAP_AND_JOIN_JOIN_TOKEN, ', ')
end
end
def wrap_and_join(wrapper: %w["], join: Array::WRAP_AND_JOIN_JOIN_TOKEN)
validate_wrapper!(wrapper)
validate_join!(join)
wrapper << wrapper.first i... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/core/ruby/color_theme_mode.rb | Ruby | mit | 49 | main | 663 | # frozen_string_literal: true
# TODO: Error checking.
# TODO: Keep <method>! (bang)?
module ColorThemeMode
def default!
dup.merge({ mode: :default })
end
def bold!
dup.merge({ mode: :bold })
end
def italic!
dup.merge({ mode: :italic })
end
def underline!
dup.merge({ mode: :underline })... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/core/ruby/color_theme_colors.rb | Ruby | mit | 49 | main | 422 | # frozen_string_literal: true
module ColorThemeColors
DEFAULT_THEME_COLORS = { color: :default, mode: :default, background: :default }.freeze
# Ensures that default colors and mode are represented in the returned Hash.
def merge_default_colors
# TODO: Error checking.
DEFAULT_THEME_COLORS.merge(dup)
en... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/cli.rb | Ruby | mit | 49 | main | 5,650 | # frozen_string_literal: true
require 'fileutils'
require 'time'
require_relative 'base_cli'
require_relative 'presenters/entry_group/list/date_presenter'
require_relative 'subcommands/browse'
require_relative 'subcommands/config'
require_relative 'subcommands/delete'
require_relative 'subcommands/edit'
require_relati... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/base_cli.rb | Ruby | mit | 49 | main | 1,311 | # frozen_string_literal: true
require 'bundler'
require 'thor'
require_relative 'command_services/add_entry_service'
require_relative 'models/color_theme'
require_relative 'models/configuration'
require_relative 'models/entry_group'
require_relative 'services/stdout_redirector_service'
require_relative 'support/color_... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/env.rb | Ruby | mit | 49 | main | 1,062 | # frozen_string_literal: true
module Dsu
class << self
def env # rubocop:disable Metrics/MethodLength
@env ||= Struct.new(:env) do
def test?
env.fetch('DSU_ENV', nil) == 'test'
end
def development?
env.fetch('DSU_ENV', nil) == 'development'
end
... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/models/configuration.rb | Ruby | mit | 49 | main | 6,448 | # frozen_string_literal: true
require 'active_model'
require_relative '../crud/json_file'
require_relative '../migration/version'
require_relative '../support/fileable'
require_relative '../support/presentable'
require_relative '../validators/version_validator'
module Dsu
module Models
# This class represents t... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/models/entry_group.rb | Ruby | mit | 49 | main | 6,474 | # frozen_string_literal: true
require_relative '../crud/json_file'
require_relative '../migration/version'
require_relative '../services/entry_group/editor_service'
require_relative '../support/fileable'
require_relative '../support/presentable'
require_relative '../support/time_comparable'
require_relative '../suppor... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/models/migration_version.rb | Ruby | mit | 49 | main | 1,256 | # frozen_string_literal: true
require_relative '../crud/json_file'
require_relative '../services/migration_version/hydrator_service'
require_relative '../validators/version_validator'
module Dsu
module Models
# This class represents a dsu migration_version.
class MigrationVersion < Crud::JsonFile
incl... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/models/color_theme.rb | Ruby | mit | 49 | main | 7,278 | # frozen_string_literal: true
require_relative '../crud/json_file'
require_relative '../migration/version'
require_relative '../support/color_themable'
require_relative '../support/descriptable'
require_relative '../support/fileable'
require_relative '../support/presentable'
require_relative '../validators/color_theme... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/models/entry.rb | Ruby | mit | 49 | main | 1,653 | # frozen_string_literal: true
require 'active_model'
require_relative '../support/descriptable'
require_relative '../support/presentable'
require_relative '../validators/description_validator'
module Dsu
module Models
# This class represents something someone might want to share at their
# daily standup (DS... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/models/project.rb | Ruby | mit | 49 | main | 9,458 | # frozen_string_literal: true
require 'fileutils'
require_relative '../crud/json_file'
require_relative '../migration/version'
require_relative '../models/configuration'
require_relative '../services/project/hydrator_service'
require_relative '../services/project/rename_service'
require_relative '../support/descripta... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/command_services/add_entry_service.rb | Ruby | mit | 49 | main | 1,565 | # frozen_string_literal: true
require_relative '../models/entry'
require_relative '../support/color_themable'
require_relative '../support/descriptable'
require_relative '../support/fileable'
require_relative '../views/shared/error'
module Dsu
module CommandServices
# This class adds (does NOT update) an entry ... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/validators/description_validator.rb | Ruby | mit | 49 | main | 1,636 | # frozen_string_literal: true
module Dsu
module Validators
class DescriptionValidator < ActiveModel::Validator
def validate(record)
description = record.description
if description.blank?
record.errors.add(:description, :blank)
return
end
unless descript... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/validators/entries_validator.rb | Ruby | mit | 49 | main | 2,362 | # frozen_string_literal: true
require_relative '../models/entry'
require_relative '../support/field_errors'
# https://guides.rubyonrails.org/active_record_validations.html#validates-with
module Dsu
module Validators
# TODO: I18n.
class EntriesValidator < ActiveModel::Validator
include Support::FieldEr... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/validators/time_validator.rb | Ruby | mit | 49 | main | 689 | # frozen_string_literal: true
# https://guides.rubyonrails.org/active_record_validations.html#validates-with
module Dsu
module Validators
class TimeValidator < ActiveModel::Validator
def validate(record)
time = record.time
if time.nil?
record.errors.add(:time, :blank)
r... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/validators/project_name_validator.rb | Ruby | mit | 49 | main | 1,974 | # frozen_string_literal: true
require_relative '../support/field_errors'
require_relative '../support/short_string'
# https://guides.rubyonrails.org/active_record_validations.html#validates-with
module Dsu
module Validators
# TODO: I18n.
class ProjectNameValidator < ActiveModel::Validator
include Supp... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/validators/color_theme_validator.rb | Ruby | mit | 49 | main | 2,871 | # frozen_string_literal: true
require 'colorize'
# rubocop:disable Layout/LineLength
module Dsu
module Validators
class ColorThemeValidator < ActiveModel::Validator
def validate(record)
default_theme_colors = record.class::DEFAULT_THEME_COLORS
# return unless validate_color_theme_keys!(re... |
github | gangelo/dsu | https://github.com/gangelo/dsu | lib/dsu/validators/version_validator.rb | Ruby | mit | 49 | main | 945 | # frozen_string_literal: true
# https://guides.rubyonrails.org/active_record_validations.html#validates-with
module Dsu
module Validators
class VersionValidator < ActiveModel::Validator
def validate(record)
version = record.version
if version.nil?
record.errors.add(:version, 'is ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.