This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'ffast', | |
git: 'https://github.com/jonatas/fast.git', | |
require: 'fast' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account | |
def withdraw(value) | |
if @total >= value | |
@total -= value | |
:ok | |
else | |
:not_allowed | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'ffast', | |
git: 'https://github.com/jonatas/fast.git', | |
require: 'fast' | |
end | |
Fast.class_eval do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'pp' | |
Query = Struct.new(:attributes, :conditions) | |
Condition = Struct.new(:query, :operator, :arg) | |
class Parser | |
attr_reader :query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
game = <<~MAZE | |
++++++++++++++++++++++ | |
+ + ++ ++ + | |
+ + + +++ + ++ | |
+ + + ++ ++++ + ++ | |
+++ ++++++ +++ + + | |
+ ++ ++ + | |
+++++ ++++++ +++++ + | |
+ + +++++++ + + | |
+ +++++++ S + + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Query = Struct.new(:attributes, :source, :conditions, :order_by) | |
class SQLParser | |
attr_reader :query | |
def initialize(string) | |
@tokens = string.scan(/\(|\)|:?\w+|[\+\-\/\*=]+|[<>]=?/) | |
@query = Query.new | |
end | |
def next_token | |
@tokens.shift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$: << "../crystalball/lib" | |
require 'crystalball' | |
map = Crystalball::MapStorage::YAMLStorage.new('execution_map.yml').load | |
repository = Git::Base.new | |
files = ARGV.map do |file| | |
Crystalball::SourceDiff::FileDiff.new(repository, | |
Git::Diff::DiffFile.new(repository, path: file)) | |
end | |
puts Crystalball::Predictor.new(map,files).cases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require '../../fast/lib/fast' | |
def experimental_spec(file, occurrence) | |
parts = file.split('/') | |
dir = parts[0..-2] | |
filename = "experiment_#{occurrence}_#{__FILE__.split('.').first}_#{parts[-1]}" | |
File.join(*dir, filename) | |
end | |
def experiment(file, expression, replacement, index=nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require '../../fast/lib/fast' | |
class RenameToSeed < Parser::Rewriter | |
def on_send(node) | |
return unless Fast.match?(node, '(send nil :create)') | |
replace node.loc.selector, 'seed' | |
super | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require '../../fast/lib/fast' | |
class RenameToSeed < Parser::Rewriter | |
def on_send(node) | |
return unless Fast.match?(node, '(send nil :create)') | |
replace node.loc.selector, 'seed' | |
super | |
end | |
end |