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 | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | lib/sequel_tools/actions/setup.rb | Ruby | mit | 46 | master | 526 | # frozen-string-literal: true
require_relative '../actions_manager'
class SequelTools::ActionsManager
description = 'Creates and populates a database with previously dumped schema and seeds'
Action.register :setup, description do |args, context|
begin
Action[:connect_db].run({}, context)
rescue
... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | lib/sequel_tools/actions/new_migration.rb | Ruby | mit | 46 | master | 957 | # frozen-string-literal: true
require_relative '../actions_manager'
class SequelTools::ActionsManager
desc = 'Creates a new migration'
Action.register :new_migration, desc, arg_names: [ :name ] do |args, context|
(puts 'Migration name is missing - aborting'; exit 1) unless name = args[:name]
require 'time... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/rake_exec_runner.rb | Ruby | mit | 46 | master | 1,001 | # frozen-string-literal: true
require_relative 'rake_runner'
require 'singleton'
require 'pty'
require 'time'
class RakeExecRunner
include Singleton
def initialize
@rake_runner = RakeRunner.instance # ensure bundle install is called once
end
class IncompleteResponse < StandardError; end
class TimedOut... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/spec_helper.rb | Ruby | mit | 46 | master | 2,616 | # frozen-string-literal: true
require 'bundler/setup'
# just in case, as it seems it may cause some weird behavior with JRuby:
['PGDATABASE', 'PGHOST', 'PGUSER', 'PGPORT', 'PGPASSWORD'].each{|e| ENV.delete e }
module SpecHelpers
CACHE = {}
def sample_project_root
CACHE[:sample_project_root] ||= File.expand_... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/sequel_tools_spec.rb | Ruby | mit | 46 | master | 1,701 | # frozen-string-literal: true
require 'sequel'
require 'sequel_tools'
RSpec.describe SequelTools do
it 'has a version number' do
expect(SequelTools::VERSION).not_to be nil
end
context 'Base configuration' do
it 'raises if a required key is missing' do
expect{ SequelTools.base_config }.to raise_er... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/log_level_spec.rb | Ruby | mit | 46 | master | 1,461 | # frozen-string-literal: true
require 'fileutils'
RSpec.describe 'log_level setting' do
before do
FileUtils.rm_f Dir["#{migrations_path}/*.rb"]
File.write "#{migrations_path}/20171111111111_first.rb", <<~FIRST_MIGRATION
Sequel.migration { change { create_table(:first){ primary_key :id } } }
FIRST_... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/fast_rake_runner.rb | Ruby | mit | 46 | master | 742 | require 'bundler/setup'
require 'benchmark'
require 'rake'
class FastRakeRunner
def self.cmd(command)
if command =~ /Rakefile/
command = command.sub(/Rakefile/, "#{__dir__}/sample_project/Rakefile")
else
command = "-f #{__dir__}/sample_project/Rakefile #{command}"
end
command.split(/\s/)... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/hooks_spec.rb | Ruby | mit | 46 | master | 699 | # frozen-string-literal: true
require 'fileutils'
RSpec.describe 'before hooks' do
it 'support before_any, before_action, before_any_adapter and before_action_adapter' do
drop_test_database_if_exists
expect(rake_runner.run_task('dbtest:create')).to be_successful
action_result = rake_runner.run_task('-f R... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/rake_runner.rb | Ruby | mit | 46 | master | 967 | # frozen-string-literal: true
require 'singleton'
require_relative 'fast_rake_runner'
class RakeRunner
include Singleton
attr_reader :project_root
def initialize
require 'open3'
@project_root = File.expand_path 'sample_project', __dir__
run_cmd('bundle').success or raise "Couldn't run bundle on sa... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/sample_project/Rakefile | Ruby | mit | 46 | master | 936 | # frozen-string-literal: true
require 'sequel_tools'
base_config = { dbadapter: 'postgres', dbname: 'sequel_tools_test',
username: 'sequel_tools_user' }
namespace 'db' do
SequelTools.inject_rake_tasks base_config, self
end
namespace 'dbpw' do
SequelTools.inject_rake_tasks base_config.merge(dbname: 'sequel_too... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/new_migration_spec.rb | Ruby | mit | 46 | master | 666 | # frozen-string-literal: true
require 'fileutils'
RSpec.describe 'new_migration action' do
before{ FileUtils.rm_f Dir["#{migrations_path}/*.rb"] }
it 'generates a new migration file' do
expect(Dir["#{migrations_path}/*.rb"]).to be_empty
expect(rake_runner.run_task('dbtest:new_migration[first_migration]')... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/seed_spec.rb | Ruby | mit | 46 | master | 684 | # frozen-string-literal: true
RSpec.describe 'seed action' do
before(:all) do
drop_test_database_if_exists
rake_runner.run_task 'dbtest:create'
end
it 'defines the DB constant and loads seeds.rb' do
File.write seeds_location, <<~SEEDS_END
DB << 'create table seed(name text)' unless DB.tables.i... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/connect_db_spec.rb | Ruby | mit | 46 | master | 727 | # frozen-string-literal: true
RSpec.describe 'connect_db action' do
before(:all){ drop_test_database_if_exists }
it 'connects to sequel_tools_test successfully' do
expect(rake_runner.run_task('db:connect_db')).to be_successful
end
it 'connects to sequel_tools_test_pw successfully' do
expect(rake_run... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/reset_spec.rb | Ruby | mit | 46 | master | 1,499 | # frozen-string-literal: true
require 'fileutils'
RSpec.describe 'reset action' do
before do
FileUtils.rm_f Dir["#{migrations_path}/*.rb"]
end
it 'recreates the database by rerunning all migrations in a newly created db' do
File.write "#{migrations_path}/20171111111111_sample.rb", <<~MIGRATION_CONTENT
... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/migrate_and_schema_load_and_setup_spec.rb | Ruby | mit | 46 | master | 1,995 | # frozen-string-literal: true
require 'fileutils'
RSpec.describe 'migrate and schema_load and setup actions', order: :defined do
before(:all) do
FileUtils.rm_f schema_location
FileUtils.rm_f Dir["#{migrations_path}/*.rb"]
end
before{ drop_test_database_if_exists }
it 'migrates and dump schema when c... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/up_down_redo_rollback_version_status_spec.rb | Ruby | mit | 46 | master | 5,581 | # frozen-string-literal: true
require 'fileutils'
RSpec.describe 'A complex workflow around 2 migrations being managed in different orders' do
before do
FileUtils.rm_f schema_location
drop_test_database_if_exists
end
before(:all) do
FileUtils.rm_f Dir["#{migrations_path}/*.rb"]
File.write "#{mi... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/schema_dump_spec.rb | Ruby | mit | 46 | master | 1,731 | # frozen-string-literal: true
require 'fileutils'
RSpec.describe 'stores schema.sql' do
context 'creates schema.sql on dbtest:schema_dump' do
before{ FileUtils.rm_f schema_location }
context 'without support for postgres adapter' do
it 'fails if it cannot find support for the db adapter' do
d... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/shell_spec.rb | Ruby | mit | 46 | master | 607 | # frozen-string-literal: true
RSpec.describe 'shell action' do
it 'opens a sql console to the database' do
expected = /---\s+sequel_tools_test\s/
expect{
rake_exec_runner.wait_output 'db:shell', 'select current_database();', expected
}.to_not raise_exception
end
it 'allows a custom command to ... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/irb_spec.rb | Ruby | mit | 46 | master | 948 | # frozen-string-literal: true
RSpec.describe 'irb action' do
# TODO: why isn't this test working under JRuby? The rake task seems to work though
# and the test for the shell action is pretty similar and works with JRuby...
# After recent changes in newer Rubies, this test is no longer passing on MRI.
# Writing... |
github | rosenfeld/sequel_tools | https://github.com/rosenfeld/sequel_tools | spec/actions/create_drop_db_spec.rb | Ruby | mit | 46 | master | 1,547 | # frozen-string-literal: true
RSpec.describe 'create and drop actions', order: :defined do
before(:all){ drop_test_database_if_exists }
it 'creates sequel_tools_test_test successfully when it does not exist upon dbtest:create' do
expect(rake_runner.run_task('dbtest:connect_db')).to_not be_successful
expec... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 02_inventory_management.rb | Ruby | apache-2.0 | 46 | master | 736 | require 'set'
VERBOSE = ARGV.delete('-v')
input = ARGF.map(&:chomp).map(&:freeze).freeze
two = 0
three = 0
input.each { |i|
counts = i.each_char.tally.values
two += 1 if counts.include?(2)
three += 1 if counts.include?(3)
}
puts "#{"#{two} * #{three} = " if VERBOSE}#{two * three}"
seen = Set.new
# O(k^2 * ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 23_emergency_teleportation.rb | Ruby | apache-2.0 | 46 | master | 7,642 | require_relative 'lib/priority_queue'
module Nanobot refine Array do
def dist(pt)
pt.zip(self).sum { |x, y| (x - y).abs }
end
def cover?(pt)
*pos, r = self
pos.dist(pt) <= r
end
def to4d
x, y, z = self
[x + y + z, x - y + z, x + y - z, x - y - z]
end
def to3d
# x+y+z = a
# ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 04_repose_record.rb | Ruby | apache-2.0 | 46 | master | 944 | VERBOSE = ARGV.delete('-v')
input = ARGF.map(&:chomp).map(&:freeze).freeze
guards = Hash.new { |h, k| h[k] = Hash.new(0) }
guard = nil
started_sleeping = nil
input.sort.each { |l|
last_number = Integer(l.scan(/\d+/).last, 10)
if l.end_with?('begins shift')
raise "The previous guard #{guard} didn't wake up?"... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 06_chronal_coordinates.rb | Ruby | apache-2.0 | 46 | master | 4,198 | VERBOSE = ARGV.delete('-v')
DIST = if (darg = ARGV.find { |a| a.start_with?('-d') })
ARGV.delete(darg)
Integer(darg[2..-1])
else
10000
end
points = ARGF.map { |l|
l.split(', ').map(&method(:Integer)).freeze
}.freeze
ymin, ymax = points.map(&:first).minmax
xmin, xmax = points.map(&:last).minmax
height = ymax -... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 16_chronal_classification.rb | Ruby | apache-2.0 | 46 | master | 2,303 | instructions = {
addr: ->(a, b, c, r) { r[c] = r[a] + r[b] },
addi: ->(a, b, c, r) { r[c] = r[a] + b },
mulr: ->(a, b, c, r) { r[c] = r[a] * r[b] },
muli: ->(a, b, c, r) { r[c] = r[a] * b },
banr: ->(a, b, c, r) { r[c] = r[a] & r[b] },
bani: ->(a, b, c, r) { r[c] = r[a] & b },
borr: ->(a, b, c, r) { r[c] ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 21_chronal_conversion.rb | Ruby | apache-2.0 | 46 | master | 2,549 | require_relative 'lib/optimise'
instructions = STANDARD_INSTRUCTIONS.merge(
# divi a i c sets r[c] to r[a]/i.
#
# as a side effect:
# tmp1 also set to r[a]/i + 1
# tmp2 set to r[a]/i*i
# tmp3 = 1
divi: ->(a, b, c, len, i, tmp1, tmp2, tmp3, regs, ipreg) {
ans = regs[a] / b
# Side effects
regs... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 25_4d_adventure.rb | Ruby | apache-2.0 | 46 | master | 1,043 | require_relative 'lib/union_find'
points = ARGF.map { |l| l.scan(/-?\d+/).map(&:to_i) }.freeze
uf = UnionFind.new(points)
# While a plain old points.combination(2) will work,
# let's do slightly better.
# We only need to check points whose first coordinate differ by <= 3.
# Cuts runtime in roughly half.
# Taking it ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 19_go_with_the_flow.rb | Ruby | apache-2.0 | 46 | master | 3,331 | require_relative 'lib/optimise'
instructions = STANDARD_INSTRUCTIONS.merge(
# isfactor candidate n dest: add candidate to dest if candidate is a factor of n.
#
# as a side effect:
# tmp1 is set to candidate * n
# tmp2 is set to bool(candidate * n == n)
# i is set to n + 1
# tmp3 is set to 1
isfactor: -... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 12_subterranean_sustainability.rb | Ruby | apache-2.0 | 46 | master | 1,962 | verbose = ARGV.delete('-v')
plants = ARGF.readline("\n\n", chomp: true)
raise "bad plants #{plants}" unless plants.start_with?('initial state:')
bit = {?# => true, ?. => false}.freeze
plants = plants.split(?:).last.strip.each_char.map { |c| bit.fetch(c) }.freeze
rules = ARGF.map { |l|
l, r = l.split('=>').map(&:s... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 20_a_regular_map.rb | Ruby | apache-2.0 | 46 | master | 3,174 | require 'set'
# Branching behaviour that AoC inputs never exhibit:
#
# On a branch, you need to:
# 1. Actually update your position by following the branch
# (Instead of assuming the branch will come back to the same position)
# 2. Union the positions you end up at from each choice of the branch.
# (Instead of o... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 11_max_square.rb | Ruby | apache-2.0 | 46 | master | 2,613 | SIZE = 300
MIN_CELL = -5
MAX_CELL = 4
verbose = ARGV.delete('-v')
serial = Integer(!ARGV.empty? && ARGV.first.match?(/^\d+$/) ? ARGV.first : ARGF.read)
power = (0..SIZE).map { |y|
(0..SIZE).map { |x|
rack = x + 10
(((rack * y + serial) * rack).digits[2] || 0) - 5
}.freeze
}.freeze
# https://en.wikipedia... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 13_mine_cart_madness.rb | Ruby | apache-2.0 | 46 | master | 2,849 | UP = 0
RIGHT = 1
DOWN = 2
LEFT = 3
class Cart
attr_reader :pos, :dead
def initialize(y, x, width, dir)
@pos = y * width + x
@width = width
@dir = dir
@intersections = 0
@dead = false
end
def move!
case @dir
when UP; @pos -= @width
when DOWN; @pos += @width
when LEFT; ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 10_the_stars_align.rb | Ruby | apache-2.0 | 46 | master | 970 | require 'set'
pos_and_vels = ARGF.map { |l|
l.scan(/-?\d+/).map(&:to_i).freeze
}.freeze
def yrange_at_time(pos_and_vels, t)
ymin, ymax = pos_and_vels.map { |_, y, _, vy| y + vy * t }.minmax
ymax - ymin
end
# Binary search for the time when yrange is at its lowest.
# Note that this isn't guaranteed to be the so... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 22_mode_maze.rb | Ruby | apache-2.0 | 46 | master | 2,737 | require_relative 'lib/search'
verbose = ARGV.delete('-v')
show_terrain = ARGV.delete('-t')
nums = if ARGV.size >= 3 && ARGV.all? { |arg| arg.match?(/^\d+$/) }
ARGV
else
ARGF.read.scan(/\d+/)
end
DEPTH = Integer(nums[0])
TARGX = Integer(nums[1])
TARGY = Integer(nums[2])
ICACHE = {}
LCACHE = {}
def index(x, y)
I... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 03_grid_claims.rb | Ruby | apache-2.0 | 46 | master | 634 | input = ARGF.map { |l|
l.scan(/-?\d+/).map(&:to_i).freeze
}.freeze
grid = Array.new(1000) { Array.new(1000, :free) }
good = input.to_h { |id, _| [id, true] }
clashes = 0
# The astute reader will note that y/x are swapped.
# But since h/w are swapped as well, it doesn't matter.
input.each { |id, y, x, h, w|
grid[y... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | conv21.rb | Ruby | apache-2.0 | 46 | master | 1,109 | # these f1, f2, f3 produce the same answer;
# just different ways of saying the same thing
def f1(x, v)
oldv = v | 0x10000
newv = x
until oldv == 0
newv += oldv & 0xff
newv &= 0xffffff
newv *= 65899
newv &= 0xffffff
oldv /= 256
end
newv
end
def f2(x, v)
(v | 0x10000).digits(256).reduce... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 09_marble_mania.rb | Ruby | apache-2.0 | 46 | master | 3,131 | CYCLE = 23
def cycles_needed(n_marbles)
cycles_needed = n_marbles / CYCLE
marbles_per_cycle = CYCLE - 2
adding_cycles = (0..cycles_needed).bsearch { |n|
marbles_have = marbles_per_cycle * n
cycles_left = cycles_needed - n
# Marbles to be removed are at 19, 35, 51, etc... right of current.
# I'm ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | more_15_test.rb | Ruby | apache-2.0 | 46 | master | 3,708 | require 'open3'
_template = [
[
'description',
<<~MAP,
MAP
<<~EX,
EX
],
]
t = [
# Samples from https://adventofcode.com/2018/day/15
[
'sample 1',
<<~MAP,
#######
#.G...#
#...EG#
#.#.#G#
#..G#E#
#.....#
#######
MAP
<<~EX,
[47, ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 24_immune_system_sim.rb | Ruby | apache-2.0 | 46 | master | 4,549 | def effective_power(u)
u[:num] * u[:dmg]
end
def target_selection(attackers, defenders)
defenders = defenders.to_h { |d| [d[:id], d] }
attackers.sort_by { |atk| [-effective_power(atk), -atk[:initiative]] }.each { |attacker|
chosen_target = defenders.values.max_by { |enemy|
# Since attacker damage remai... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 14_chocolate_charts.rb | Ruby | apache-2.0 | 46 | master | 4,279 | INITIAL = [3, 7].freeze
two_only = ARGV.delete('-2')
input = !ARGV.empty? && ARGV.first.match?(/^\d+$/) ? ARGV.first : ARGF.read
unless two_only
first = 0
second = 1
scores = INITIAL.dup
target = Integer(input)
until scores.size >= target + 10
scores.concat((scores[first] + scores[second]).digits.rever... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | gen14.rb | Ruby | apache-2.0 | 46 | master | 2,136 | INITIAL = [3, 7].freeze
def converged(scores)
seqs = []
return nil if scores.size < 10
(0...10).each { |start|
pos = start
poses = []
while (score = scores[pos])
poses << [score, pos]
pos += 1 + score
end
seqs[start] = poses
}
minlen = seqs.map(&:size).min
mismatch_from_right... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 17_reservoir_research.rb | Ruby | apache-2.0 | 46 | master | 4,718 | class Reservoir
attr_reader :ymin, :ymax
def initialize(clay)
@clay = clay.each_value(&:freeze).freeze
@water = Hash.new { |h, k| h[k] = {} }
@ymin, @ymax = clay.each_key.minmax
end
def fill_down(srcy:, srcx:)
done_drops = {}
checked_fill_down(srcy: srcy, srcx: srcx, done: done_drops)
en... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | more_23_test.rb | Ruby | apache-2.0 | 46 | master | 4,245 | require 'open3'
require 'time'
inline_t = [
[
'example',
<<~BOTS,
pos=<10,12,12>, r=2
pos=<12,14,12>, r=2
pos=<16,12,12>, r=4
pos=<14,14,14>, r=6
pos=<50,50,50>, r=200
pos=<10,10,10>, r=5
BOTS
[12, 12, 12], 5,
],
[
'big bot far away',
<<~BOTS,
pos=<1,1,1>, r=1
... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 07_topological.rb | Ruby | apache-2.0 | 46 | master | 1,850 | time_delay = if (targ = ARGV.find { |a| a.start_with?('-t') })
ARGV.delete(targ)
Integer(targ[2..-1])
else
60
end
nworkers = if (narg = ARGV.find { |a| a.start_with?('-n') })
ARGV.delete(narg)
Integer(narg[2..-1])
else
5
end
VERBOSE = ARGV.delete('-v')
def work(deps, parallelism = 1, work_factor = nil)
... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | test.rb | Ruby | apache-2.0 | 46 | master | 243 | require_relative '../adventofcode-common/test'
test_and_exit { |daypad|
scripts = Dir.glob("#{__dir__}/#{daypad}_*.rb")
next if scripts.empty?
raise "Need exactly one script not #{scripts}" if scripts.size != 1
"ruby #{scripts[0]}"
} |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 05_alchemical_reduction.rb | Ruby | apache-2.0 | 46 | master | 350 | def react(str)
str.each_char.with_object(String.new(capacity: str.size)) { |c, new_str|
new_str << c
new_str[-2, 2] = '' if new_str[-2]&.swapcase == c
}
end
input = ARGF.read.chomp.freeze
puts (part1 = react(input.dup).freeze).size
puts (?a..?z).map { |tried_letter|
react(part1.tr(tried_letter + tried_l... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 18_tristate_automata.rb | Ruby | apache-2.0 | 46 | master | 4,049 | require 'time'
# Nothing ever depends on the count of OPEN,
# so we are safe to make OPEN 0.
# Otherwise, we'd have to number elements 1, 2, 3.
# Not that it matters anyway; either way, space is being wasted.
# (two bits can represent four elements, but we only have three)
OPEN = 0
TREE = 1
LUMBER = 2
# 2 bits per ce... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 01_frequency_deltas.rb | Ruby | apache-2.0 | 46 | master | 981 | input = ARGF.each_line.map(&method(:Integer)).freeze
puts sum = input.sum
if sum == 0
puts 0
exit 0
end
# https://www.reddit.com/r/adventofcode/comments/a20646/2018_day_1_solutions/eaukxu5/
# Summary: Track cumulative sum for one cycle through the input.
# Note that all future iterations are offset by the total ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 08_metadata_tree.rb | Ruby | apache-2.0 | 46 | master | 503 | input = ARGF.read.split.map(&method(:Integer)).freeze
# Pass me a block telling me what to do with [child_values, metadata_values]
def val(a, &b)
n_children = a.shift
n_metadata = a.shift
yield(n_children.times.map { val(a, &b) }, a.shift(n_metadata))
end
puts val(input.dup) { |child, meta| child.sum + meta.sum... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | 15_beverage_bandits.rb | Ruby | apache-2.0 | 46 | master | 10,154 | require 'optparse'
require_relative 'lib/search'
HP = 200
ATTACK = 3
ELF = 0
GOBLIN = 1
TEAM_NAME = {
ELF => :Elf,
GOBLIN => :Goblin,
}.sort_by(&:first).map(&:last).freeze
verbose = false
one_only = false
two_only = false
progress = false
p2damage = nil
DEBUG = {}
FMT = {
unit: '%s%d',
join: ' ',
}
# I'd ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | lib/priority_queue.rb | Ruby | apache-2.0 | 46 | master | 3,472 | class MonotonePriorityQueue
def initialize
@qs = []
@prio = 0
@size = 0
end
def []=(data, priority)
raise "non-monotonic add #{priority} vs #{@prio}" if priority < @prio
(@qs[priority] ||= []) << data
@size += 1
end
def pop
return nil if @size == 0
@prio += 1 until (q = @qs[@... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | lib/union_find.rb | Ruby | apache-2.0 | 46 | master | 544 | class UnionFind
attr_reader :num_sets
def initialize(things)
@parent = things.to_h { |x| [x, x] }
@rank = things.to_h { |x| [x, 0] }
@num_sets = things.size
end
def union(x, y)
xp = find(x)
yp = find(y)
return if xp == yp
if @rank[xp] < @rank[yp]
@parent[xp] = yp
elsif ... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | lib/search.rb | Ruby | apache-2.0 | 46 | master | 1,512 | require_relative 'priority_queue'
module Search
module_function
def path_of(prevs, n)
path = [n]
current = n
while (current = prevs[current])
path.unshift(current)
end
path.freeze
end
def astar(start, neighbours, heuristic, goal, verbose: false)
g_score = Hash.new(1.0 / 0.0)
... |
github | petertseng/adventofcode-rb-2018 | https://github.com/petertseng/adventofcode-rb-2018 | lib/optimise.rb | Ruby | apache-2.0 | 46 | master | 4,076 | STANDARD_INSTRUCTIONS = {
addr: ->(a, b, c, r, _) { r[c] = r[a] + r[b] },
addi: ->(a, b, c, r, _) { r[c] = r[a] + b },
mulr: ->(a, b, c, r, _) { r[c] = r[a] * r[b] },
muli: ->(a, b, c, r, _) { r[c] = r[a] * b },
banr: ->(a, b, c, r, _) { r[c] = r[a] & r[b] },
bani: ->(a, b, c, r, _) { r[c] = r[a] & b },
b... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | Gemfile | Ruby | mit | 46 | master | 421 | source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
# Testing
gem "shoulda", ">= 0"
# Development
gem "bun... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | Rakefile | Ruby | mit | 46 | master | 2,019 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug.rb | Ruby | mit | 46 | master | 1,479 | require 'java'
require_relative 'android_debug/mixin/java_passthrough.rb'
require_relative 'android_debug/mixin/invokable.rb'
require_relative 'android_debug/jpda/jpda_helper.rb'
require_relative 'android_debug/jpda/local_variable.rb'
require_relative 'android_debug/jpda/object_in_frame.rb'
require_relative 'android_de... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/adb.rb | Ruby | mit | 46 | master | 1,797 | module AndroidDebug
# Helper static methods for interacting with ADB
module Adb
# Set an activity to wait for the debugger upon next launch
# @param activity [String]
def self.set_activity_debug(activity)
system("#{self.get_adb} shell am set-debug-app -w #{activity}")
... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/adb_native.rb | Ruby | mit | 46 | master | 2,253 | module AndroidDebug
# Native ADB implementation so we dont need the ANDROID_HOME
class AdbNative
require 'socket'
attr_reader :soc
def send_command(command, new_connection = true)
host = "localhost"
port = 5037
@soc.nil? || @soc.closed? || ne... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/debugger.rb | Ruby | mit | 46 | master | 12,686 | require 'java'
java_import 'com.sun.jdi.request.EventRequest'
java_import 'java.util.ArrayList'
module AndroidDebug
# This is the main interaction point for the user
class Debugger
INVOKE_SINGLE_THREADED = 1
attr_accessor :android_home, :on_break
# Private virtual machine object
... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/jpda/object_in_frame.rb | Ruby | mit | 46 | master | 1,848 | module AndroidDebug
module Jpda
class ObjectInFrame
include AndroidDebug::Mixin::JavaPassthrough
include AndroidDebug::Mixin::Invokable
attr_reader :java_object_reference
attr_reader :java_frame # Defined in Invokable
attr_reader :java_invokable_... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/jpda/event.rb | Ruby | mit | 46 | master | 1,161 | module AndroidDebug
module Jpda
class Event
include AndroidDebug::Mixin::JavaPassthrough
ENTRY = "entry"
EXIT = "exit"
BREAKPOINT = "breakpoint"
VM_EXIT = "vm_destry"
UNKNOWN = "unknown"
attr_reader :java_event... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/jpda/local_variable.rb | Ruby | mit | 46 | master | 3,104 | require 'java'
module AndroidDebug
module Jpda
class LocalVariable
include AndroidDebug::Mixin::JavaPassthrough
include AndroidDebug::Mixin::Invokable
attr_reader :java_frame # Defined in Invokable
attr_reader :java_invokable_object # Defined in Invokable
... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/jpda/jpda_helper.rb | Ruby | mit | 46 | master | 1,260 | require 'java'
java_import "com.sun.jdi.Bootstrap"
module AndroidDebug
module Jpda
CONNECTOR_PROCESS = "com.sun.jdi.ProcessAttach"
CONNECTOR_SOCKET = "com.sun.jdi.SocketAttach"
CONNECTOR_COMMAND_LINE = "com.sun.jdi.CommandLineLaunch"
# Static method to get a 'connector' object whic... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/jpda/frame.rb | Ruby | mit | 46 | master | 3,499 | module AndroidDebug
module Jpda
class Frame
include AndroidDebug::Mixin::JavaPassthrough
attr_reader :java_frame, :java_location
# Constructor
# @param frame [com.sun.jdi.StackFrame]
# @param location [com.sun.jdi.Location]
def initi... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/mixin/invokable.rb | Ruby | mit | 46 | master | 4,224 | module AndroidDebug
module Mixin
module Invokable
# This is a mixin that provides the ability to invoke methods from objects. The
# object must be of a type that has the 'invokeMethod' method. To specify the
# object which the invoking will be performed, you just set the... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | lib/android_debug/mixin/java_passthrough.rb | Ruby | mit | 46 | master | 879 | module AndroidDebug
module Mixin
module JavaPassthrough
attr_reader :java_object
# Most of the classes we implement are just Java class wrappers. This will attempt to call the local Java method of the object we are wrapping. For example, AndroidDebug::Jpda::Event wraps the com.sun.j... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/snapchat.rb | Ruby | mit | 46 | master | 477 | require 'android_debug'
dbg = AndroidDebug.launch_and_attach("com.snapchat.android", "com.snapchat.android.LandingPageActivity")
dbg.on_break do
'''
if(dbg.frame.method_name == "doFinanl")
puts("#{dbg.frame.method_signature}")
puts("Frame variables:")
dbg.frame.variables.each do |var|
... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/hello_world.rb | Ruby | mit | 46 | master | 987 | require_relative '../lib/android_debug.rb'
$DEBUG = true
dbg = AndroidDebug.launch_and_attach("com.wuntee.dummyandroidproject", "com.wuntee.dummyandroidproject.DummyAndroidProjectActivity")
#dbg = AndroidDebug.launch_and_attach("com.wuntee.dummyandroidproject", "com.wuntee.dummyandroidproject.DummyAndroidActivity")
d... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/log_intent.rb | Ruby | mit | 46 | master | 758 | require_relative '../lib/android_debug.rb'
$DEBUG = false
dbg = AndroidDebug.launch_and_attach("com.android.browser", "com.android.browser.BrowserActivity")
#dbg = AndroidDebug.launch_and_attach("com.wuntee.dummyandroidproject", "com.wuntee.dummyandroidproject.DummyAndroidActivity")
vars = {}
dbg.on_break do |event... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/helper.rb | Ruby | mit | 46 | master | 434 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'test/unit'
require 'shoulda'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/test_android_debug.rb | Ruby | mit | 46 | master | 228 | require 'helper'
class TestAndroidDebug < Test::Unit::TestCase
should "probably rename this file and start testing for real" do
flunk "hey buddy, you should probably rename this file and start testing for real"
end
end |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/test.rb | Ruby | mit | 46 | master | 1,643 | require_relative '../lib/android_debug.rb'
$DEBUG = true
dbg = AndroidDebug.launch_and_attach_native("com.android.browser", "com.android.browser.BrowserActivity")
#dbg = AndroidDebug.launch_and_attach("com.wuntee.dummyandroidproject", "com.wuntee.dummyandroidproject.DummyAndroidActivity")
vars = {}
dbg.on_break do ... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/test_adb_native.rb | Ruby | mit | 46 | master | 502 | require 'helper'
require_relative "../lib/android_debug/adb_native.rb"
class TestAdbNative < Test::Unit::TestCase
adb = AndroidDebug::AdbNative.new
devices = adb.devices
puts("Devices: #{devices}")
if(devices == "")
puts("WARNING: Could not test AdbNative. No ADB attached.")
else
... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | test/sample.rb | Ruby | mit | 46 | master | 446 | require 'android_debug'
dbg = AndroidDebug.launch_and_attach("com.android.browser", "com.android.browser.BrowserActivity")
dbg.on_break do
if(dbg.frame.method_name == "registerReceiver")
puts("#{dbg.frame.method_signature}")
puts("Frame variables:")
dbg.frame.variables.each do |var|
... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | bin/print_variables.rb | Ruby | mit | 46 | master | 1,354 | require 'optparse'
require_relative '../lib/android_debug.rb'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: print _variables.rb [options]"
opts.on("-d", '--debug', "Enable debug logging.") do |v|
$DEBUG = true
end
opts.on("-l", "--launch STR", "Launch an application. Ex: com.an... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | bin/hit_tracer.rb | Ruby | mit | 46 | master | 1,147 | require 'optparse'
require 'pp'
require_relative '../lib/android_debug.rb'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: hit_tracer.rb [options]"
opts.on("-d", '--debug', "Enable debug logging.") do |v|
$DEBUG = true
end
opts.on("-l", "--launch STR", "Launch an application. Ex:... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | template/invoke_method.rb | Ruby | mit | 46 | master | 1,152 | require_relative '../lib/android_debug.rb'
counter = 0
# Launch the activity and attach the debugger
dbg = AndroidDebug.launch_and_attach_native("com.android.browser", "com.android.browser.BrowserActivity")
# Set the breakpoint method
dbg.add_class_entry_breakpoint("android.content.Intent")
# Find the variable you ... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | template/single_step.rb | Ruby | mit | 46 | master | 639 | require_relative '../lib/android_debug.rb'
def print_variables(frame)
frame.variables.each do |var|
puts(var)
end
end
counter = 0
dbg = AndroidDebug.launch_and_attach_native("com.android.browser", "com.android.browser.BrowserActivity")
# Set the breakpoint method
dbg.add_class_entry_breakpoint("andr... |
github | wuntee/android_debug | https://github.com/wuntee/android_debug | template/change_variable.rb | Ruby | mit | 46 | master | 928 | require_relative '../lib/android_debug.rb'
$DEBUG = true
dbg = AndroidDebug.launch_and_attach_native("com.android.browser", "com.android.browser.BrowserActivity")
# Set the breakpoint method
dbg.add_class_entry_breakpoint("android.content.Intent")
# Find the variable you want to call the method on
dbg.on_break do ... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | Gemfile | Ruby | mit | 46 | master | 707 | source :rubygems
group :test do
gem "test-unit", "~> 2.0.9"
gem "webrat", "~> 0.7.0"
gem "mocha", "~> 0.9.8", :require => false
end
group :default do
gem "rails", "~> 3.2.0"
gem "webrat", "~> 0.7.0"
gem 'mongo_mapper', '~> 0.11.0'
gem 'devise', '>= 2.1.0'
... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | mm-devise.gemspec | Ruby | mit | 46 | master | 907 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "mm-devise/version"
Gem::Specification.new do |s|
s.name = "mm-devise"
s.version = MongoMapper::Devise::VERSION
s.date = "2011-06-01"
s.summary = %Q{Support for using MongoMapper ORM with devise}
s.descriptio... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | Rakefile | Ruby | mit | 46 | master | 970 | # encoding: UTF-8
require 'rake'
include Rake::DSL if defined?(Rake::DSL)
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
require 'rake/rdoctask'
require File.join(File.dirname(__FILE__), 'lib', 'mm-devise', 'version')
desc 'Run Devise tests using MongoMapper. Specify path to devise with ... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | test/test_helper.rb | Ruby | mit | 46 | master | 767 | ENV["RAILS_ENV"] = "test"
DEVISE_ORM = (ENV["DEVISE_ORM"] || :mongo_mapper).to_sym
DEVISE_PATH = ENV['DEVISE_PATH']
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
require "rails_app/config/environment"
require "rails/test_help"
require "orm/#{DEVISE_ORM}"
I18n.load_path << "#{DEVISE_PATH}/test/support/locale/en.yml... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | test/orm/mongo_mapper.rb | Ruby | mit | 46 | master | 278 | MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
MongoMapper.database = "devise-test-suite"
MongoMapper.database.collections.each { |c| c.drop_indexes }
class ActiveSupport::TestCase
setup do
User.collection.remove
Admin.collection.remove
end
end |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | test/rails_app/config/application.rb | Ruby | mit | 46 | master | 1,191 | APP_ROOT = File.expand_path("#{DEVISE_PATH}/test/rails_app")
require "#{APP_ROOT}/config/boot"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
Bundler.require :default, DEVISE_ORM
begin
require "#{DEVISE_ORM}/railtie"
rescue Lo... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | test/rails_app/app/mongo_mapper/admin.rb | Ruby | mit | 46 | master | 574 | require 'shared_admin'
class Admin
include MongoMapper::Document
include Shim
include SharedAdmin
## Database authenticatable
key :email, String, :null => true
key :encrypted_password, String, :null => true
## Recoverable
key :reset_password_token, String
key :reset_password_sent_at, Time
... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | test/rails_app/app/mongo_mapper/shim.rb | Ruby | mit | 46 | master | 499 | module Shim
extend ::ActiveSupport::Concern
included do
self.include_root_in_json = true
end
#
module ClassMethods
def last(options={})
options.delete(:order) if options[:order] == "id"
super(options)
end
def find_by_email(email)
first(:conditions => { :email => email })... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | test/rails_app/app/mongo_mapper/user.rb | Ruby | mit | 46 | master | 958 | require 'shared_user'
class User
include MongoMapper::Document
include Shim
include SharedUser
key :username, String
key :facebook_token, String
## Database authenticatable
key :email, String, :null => false, :default => ""
key :encrypted_password, String, :null => false, :default => ""
## Recover... |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | test/mongo_mapper/compatibility_test.rb | Ruby | mit | 46 | master | 297 | require 'test_helper'
class MongoMapperCompatibilityTest < ActiveSupport::TestCase
test 'save only when valid' do
user = new_user(:email => nil)
assert user.invalid?
user.save
assert !user.errors.empty?
user = new_user
assert user.valid?
assert user.save
end
end |
github | kristianmandrup/mm-devise | https://github.com/kristianmandrup/mm-devise | lib/generators/mongo_mapper/devise_generator.rb | Ruby | mit | 46 | master | 597 | require 'generators/devise/orm_helpers'
module MongoMapper
module Generators
class DeviseGenerator < Rails::Generators::NamedBase
include Devise::Generators::OrmHelpers
def generate_model
invoke "mongo_mapper:model", [name] unless model_exists?
end
def inject_devise_content
... |
github | voxpupuli/puppet-os_patching | https://github.com/voxpupuli/puppet-os_patching | Rakefile | Ruby | apache-2.0 | 46 | main | 906 | # Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
begin
require 'voxpupuli/test/rake'
rescue LoadError
# only available if gem group test is installed
end
begin
require 'voxpupuli/acceptance/rake'
rescue LoadError
# only available if gem group acceptanc... |
github | voxpupuli/puppet-os_patching | https://github.com/voxpupuli/puppet-os_patching | lib/facter/os_patching.rb | Ruby | apache-2.0 | 46 | main | 11,397 | # Ensure that this fact does not try to be loaded
# on old (pre v.2) versions of facter as it uses
# aggregate facts
if Facter.value(:facterversion).split('.')[0].to_i < 2
Facter.add('os_patching') do
setcode do
'not valid on legacy facter versions'
end
end
else
Facter.add('os_patching', :type => :a... |
github | voxpupuli/puppet-os_patching | https://github.com/voxpupuli/puppet-os_patching | tasks/clean_cache.rb | Ruby | apache-2.0 | 46 | main | 2,463 | #!/opt/puppetlabs/puppet/bin/ruby
require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
if is_windows
puts 'Cannot run os_patching::clean_cache on Windows'
exit 1
end
require 'open3'
require 'json'
require 'syslog/logger'
require 'time'
require 'timeout'
$stdout.sync = true
log =... |
github | voxpupuli/puppet-os_patching | https://github.com/voxpupuli/puppet-os_patching | tasks/refresh_fact.rb | Ruby | apache-2.0 | 46 | main | 2,575 | #!/opt/puppetlabs/puppet/bin/ruby
require 'rbconfig'
require 'open3'
require 'json'
require 'time'
require 'timeout'
IS_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
$stdout.sync = true
if IS_WINDOWS
# windows
# use ruby file logger
require 'logger'
log = Logger.new('C:/ProgramData/os_patc... |
github | voxpupuli/puppet-os_patching | https://github.com/voxpupuli/puppet-os_patching | tasks/patch_server.rb | Ruby | apache-2.0 | 46 | main | 26,569 | #!/opt/puppetlabs/puppet/bin/ruby
require 'rbconfig'
require 'open3'
require 'json'
require 'time'
require 'timeout'
# constant so available in methods. global variables are naughty in ruby land!
IS_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
$stdout.sync = true
if IS_WINDOWS
# windows
# use... |
github | voxpupuli/puppet-os_patching | https://github.com/voxpupuli/puppet-os_patching | spec/acceptance/os_patching_spec.rb | Ruby | apache-2.0 | 46 | main | 4,276 | require 'spec_helper_acceptance'
cache_dir = '/var/cache/os_patching'
describe 'os_patching module' do
context 'base class' do
let(:manifest) do
<<~PUPPET
class { 'cron':
manage_service => false,
}
class { 'os_patching':
fact_upload => false,
}
PUP... |
github | voxpupuli/puppet-os_patching | https://github.com/voxpupuli/puppet-os_patching | spec/classes/os_patching_spec.rb | Ruby | apache-2.0 | 46 | main | 8,982 | require 'spec_helper'
describe 'os_patching' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
case os_facts[:kernel]
when 'Linux', 'FreeBSD'
let(:cache_dir) { '/var/cache/os_patching' }
let(:fact_cmd) { '/usr/local/bin/os_patching_fact_ge... |
github | spree-contrib/spree_email_to_friend | https://github.com/spree-contrib/spree_email_to_friend | Appraisals | Ruby | bsd-3-clause | 46 | master | 696 | appraise 'spree-3-1' do
gem 'spree', '~> 3.1.0'
gem 'spree_auth_devise', '~> 3.1.0'
gem 'rails', '~> 4.2.10'
end
appraise 'spree-3-2' do
gem 'spree', '~> 3.2.0'
gem 'spree_auth_devise', '~> 3.2.0'
gem 'rails-controller-testing'
end
appraise 'spree-3-3' do
gem 'spree', '~> 3.3.0'
gem 'spree_auth_devise... |
github | spree-contrib/spree_email_to_friend | https://github.com/spree-contrib/spree_email_to_friend | Guardfile | Ruby | bsd-3-clause | 46 | master | 757 | guard "rspec", cmd: "bundle exec rspec", all_on_start: false, all_after_pass: false do
watch("spec/spec_helper.rb") { "spec" }
watch("config/routes.rb") { "spec/controllers" }
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
watch(%r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.