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 | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/load_spec.rb | Ruby | mit | 185 | staging | 686 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe VpsAdminOS::Converter do
it 'loads the public entrypoints and net interface registrations' do
expect { require 'vpsadminos-converter' }.not_to raise_error
expect { require 'vpsadminos-converter/cli' }.not_to raise_error
expect { require ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/devices_spec.rb | Ruby | mit | 185 | staging | 1,486 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/devices'
RSpec.describe VpsAdminOS::Converter::Devices do
describe VpsAdminOS::Converter::Devices::Device do
it 'defaults inherit to true' do
device = described_class.new('char', '1', '3', 'rwm')
expect(device.inherit... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/group_spec.rb | Ruby | mit | 185 | staging | 478 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/group'
RSpec.describe VpsAdminOS::Converter::Group do
it 'builds the default group' do
group = described_class.default
expect(group.name).to eq('default')
expect(group.path).to eq('default')
end
it 'dumps the group c... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/exporter_spec.rb | Ruby | mit | 185 | staging | 1,826 | # frozen_string_literal: true
require 'spec_helper'
require 'yaml'
require 'vpsadminos-converter/exporter'
RSpec.describe VpsAdminOS::Converter::Exporter::Mixin do
before do
stub_const('TestExporterContainer', Class.new)
stub_const('TestExporterUser', Class.new)
stub_const('TestExporterGroup', Class.new... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/cg_params_spec.rb | Ruby | mit | 185 | staging | 923 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/cg_params'
RSpec.describe VpsAdminOS::Converter::CGParams do
subject(:params) { described_class.new }
it 'stores scalar values as single-element arrays' do
params.set('memory.limit_in_bytes', 1024)
expect(params['memory.li... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/net_interface_spec.rb | Ruby | mit | 185 | staging | 2,240 | # frozen_string_literal: true
require 'spec_helper'
require 'ipaddress'
require 'vpsadminos-converter/net_interface/bridge'
require 'vpsadminos-converter/net_interface/routed'
RSpec.describe VpsAdminOS::Converter::NetInterface do
let(:base_class) { VpsAdminOS::Converter::NetInterface::Base }
let(:bridge_class) { ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/cli/command_spec.rb | Ruby | mit | 185 | staging | 1,167 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/cli/command'
RSpec.describe VpsAdminOS::Converter::Cli::Command do
let(:command_class) do
Class.new(described_class) do
def perform
:ok
end
end
end
it 'instantiates the command class and invokes the re... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/cli/app_spec.rb | Ruby | mit | 185 | staging | 2,677 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/cli'
RSpec.describe VpsAdminOS::Converter::Cli::App do
it 'passes the export defaults to the command object' do
command = instance_double(VpsAdminOS::Converter::Cli::Vz6::Export, export: nil)
allow(VpsAdminOS::Converter::Cli::... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/cli/vz6/migrate_spec.rb | Ruby | mit | 185 | staging | 5,846 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/cli/vz6/migrate'
require 'vpsadminos-converter/container'
require 'vpsadminos-converter/vz6/container'
require 'vpsadminos-converter/vz6/migrator/simfs'
RSpec.describe VpsAdminOS::Converter::Cli::Vz6::Migrate do
def migrate_opts(overr... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/cli/vz6/export_spec.rb | Ruby | mit | 185 | staging | 8,354 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/cli/vz6/export'
require 'vpsadminos-converter/exporter'
require 'vpsadminos-converter/container'
require 'vpsadminos-converter/vz6/container'
RSpec.describe VpsAdminOS::Converter::Cli::Vz6::Export do
def export_opts(overrides = {})
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/cli/vz6/base_spec.rb | Ruby | mit | 185 | staging | 5,447 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/cli/vz6/base'
RSpec.describe VpsAdminOS::Converter::Cli::Vz6::Base do
def base_opts(overrides = {})
{
vpsadmin: false,
zfs: false,
'zfs-dataset' => nil,
'zfs-subdir' => 'private',
'zfs-compressed-send... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/migrator_spec.rb | Ruby | mit | 185 | staging | 2,427 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/vz6'
RSpec.describe VpsAdminOS::Converter::Vz6::Migrator do
let(:vz_ct) { instance_double(VpsAdminOS::Converter::Vz6::Container, ctid: '101', ploop?: ploop) }
let(:target_ct) { instance_double(VpsAdminOS::Converter::Container, id: '... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/config_item_spec.rb | Ruby | mit | 185 | staging | 3,599 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/devices'
require 'vpsadminos-converter/vz6/config_item'
RSpec.describe VpsAdminOS::Converter::Vz6::ConfigItem do
def value_for(key, value, ctid: '101')
described_class.new(ctid, key, value).value
end
it 'passes through plain ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/config_spec.rb | Ruby | mit | 185 | staging | 1,401 | # frozen_string_literal: true
require 'spec_helper'
require 'stringio'
require 'vpsadminos-converter/vz6/config'
require 'vpsadminos-converter/vz6/config_item'
RSpec.describe VpsAdminOS::Converter::Vz6::Config do
def parse_config(text)
described_class.new('101', StringIO.new(text))
end
it 'ignores comments... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/container_spec.rb | Ruby | mit | 185 | staging | 5,691 | # frozen_string_literal: true
require 'spec_helper'
require 'stringio'
require 'vpsadminos-converter/user'
require 'vpsadminos-converter/group'
require 'vpsadminos-converter/vz6/container'
RSpec.describe VpsAdminOS::Converter::Vz6::Container do
let(:vz_ct) { described_class.new('101') }
let(:user) { VpsAdminOS::C... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/migrator/state_spec.rb | Ruby | mit | 185 | staging | 4,388 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/vz6/migrator/state'
StateSpecVzCt = Struct.new(:ctid, :ploop?)
StateSpecTargetCt = Struct.new(:id, :dataset)
RSpec.describe VpsAdminOS::Converter::Vz6::Migrator::State do
let(:vz_ct) { StateSpecVzCt.new('101', false) }
let(:target_... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/migrator/zfs_spec.rb | Ruby | mit | 185 | staging | 7,525 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/vz6/migrator/zfs'
require 'vpsadminos-converter/vz6/container'
RSpec.describe VpsAdminOS::Converter::Vz6::Migrator::Zfs do
let(:root_ds) { fake_dataset(name: 'tank/ct/101', relative_name: 'private') }
let(:child_ds) { fake_dataset(n... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/migrator/ploop_spec.rb | Ruby | mit | 185 | staging | 2,242 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/vz6/migrator/ploop'
RSpec.describe VpsAdminOS::Converter::Vz6::Migrator::Ploop do
let(:vz_ct) do
instance_double(
VpsAdminOS::Converter::Vz6::Container,
ctid: '101',
running?: true,
status: { mounted: mount... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/migrator/base_spec.rb | Ruby | mit | 185 | staging | 3,022 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/vz6/migrator/base'
RSpec.describe VpsAdminOS::Converter::Vz6::Migrator::Base do
let(:target_ct) { Struct.new(:id).new('101') }
let(:opts) { { dst: 'node.example', port: nil } }
let(:state) do
instance_double(
VpsAdminOS:... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | converter/spec/vpsadminos/converter/vz6/migrator/simfs_spec.rb | Ruby | mit | 185 | staging | 2,933 | # frozen_string_literal: true
require 'spec_helper'
require 'vpsadminos-converter/vz6/migrator/simfs'
RSpec.describe VpsAdminOS::Converter::Vz6::Migrator::Simfs do
let(:vz_ct) { instance_double(VpsAdminOS::Converter::Vz6::Container, ctid: '101', running?: running) }
let(:target_ct) { OpenStruct.new(id: '101', roo... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/osvm.gemspec | Ruby | mit | 185 | staging | 848 | lib = File.expand_path('lib', __dir__)
$:.unshift(lib) unless $:.include?(lib)
require 'osvm/version'
Gem::Specification.new do |s|
s.name = 'osvm'
s.version = if ENV['OS_BUILD_ID']
"#{OsVm::VERSION}.build#{ENV['OS_BUILD_ID']}"
else
OsVm::VERSION
end
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm.rb | Ruby | mit | 185 | staging | 305 | module OsVm; end
require 'osvm/exceptions'
require 'osvm/mac_address_generator'
require 'osvm/machine_log'
require 'osvm/machine_config'
require 'osvm/port_reservation'
require 'osvm/shared_dir'
require 'osvm/machine'
require 'osvm/vpsadminos_machine'
require 'osvm/nixos_machine'
require 'osvm/version' |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/machine_config.rb | Ruby | mit | 185 | staging | 7,954 | require 'json'
require 'osvm/mac_address_generator'
module OsVm
class MachineConfig
class Cpu
# @return [Integer]
attr_reader :cores
# @return [Integer]
attr_reader :threads
# @return [Integer]
attr_reader :sockets
def initialize(cfg)
@cores = cfg.fetch('cores... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/machine_log.rb | Ruby | mit | 185 | staging | 1,873 | module OsVm
class MachineLog
def initialize(path)
@path = path
@file = File.open(path, 'w')
end
%i[start stop destroy].each do |m|
define_method(m) do
log do |io|
io.puts("ACTION: #{m}")
end
end
end
def kill(signal)
log do |io|
io.p... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/exceptions.rb | Ruby | mit | 185 | staging | 315 | module OsVm
class Error < ::StandardError; end
class TimeoutError < Error; end
class UnrecoverableTimeoutError < TimeoutError; end
class CommandError < Error; end
class CommandSucceeded < CommandError; end
class CommandFailed < CommandError; end
class MachineShellClosed < CommandError; end
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/port_reservation.rb | Ruby | mit | 185 | staging | 1,864 | require 'singleton'
module OsVm
# Singleton class handling port reservations
class PortReservation
include Singleton
class << self
%i[get_port release_port get_ports release_ports reset_to_ports].each do |v|
define_method(v) do |*args, **kwargs, &block|
instance.send(v, *args, **kw... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/vpsadminos_machine.rb | Ruby | mit | 185 | staging | 3,475 | require 'json'
module OsVm
# vpsAdminOS-specific machine driver
class VpsadminosMachine < Machine
# osctl command without `osctl`, output is returned as JSON
# @param cmd [String]
# @return [Hash]
def osctl_json(cmd)
status, output = succeeds("osctl -j #{cmd}")
JSON.parse(output)
en... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/nixos_machine.rb | Ruby | mit | 185 | staging | 2,062 | module OsVm
# NixOS-specific machine driver
class NixosMachine < Machine
def destroy_disks
FileUtils.rm_f(root_disk_path)
super
end
protected
def service_check_command(name)
"systemctl is-active --quiet #{name}"
end
def poweroff_command
'poweroff'
end
def ... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/machine.rb | Ruby | mit | 185 | staging | 19,361 | require 'base64'
require 'digest'
require 'fileutils'
require 'shellwords'
require 'socket'
module OsVm
class Machine
# @return [String]
attr_reader :name
# Kernel parameters passed to {#start}
# @return [Array<String>]
attr_reader :start_kernel_params
# @param name [String]
# @param co... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/shared_dir.rb | Ruby | mit | 185 | staging | 2,256 | require 'fileutils'
require 'pathname'
require 'securerandom'
module OsVm
# {SharedDir} is used to push and pull files to and from machines
class SharedDir
# @return [Machine]
attr_reader :machine
# @return [String]
attr_reader :fs_name
# @return [String]
attr_reader :host_path
# @re... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/mac_address_generator.rb | Ruby | mit | 185 | staging | 1,241 | require 'securerandom'
require 'singleton'
module OsVm
class MacAddressGenerator
include Singleton
PREFIX = '52:54:00'.freeze
def initialize
@registry = Set.new
@mutex = Mutex.new
end
# Generate and register a unique MAC address
# @return [String]
def next_mac
synchro... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/cli/app.rb | Ruby | mit | 185 | staging | 571 | require 'gli'
module OsVm::Cli
class App
include GLI::App
def self.get
cli = new
cli.setup
cli
end
def self.run
exit(get.run(ARGV))
end
def setup
program_desc 'vpsAdminOS test suite evaluator'
version OsVm::VERSION
subcommand_option_handling :norma... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/lib/osvm/cli/command.rb | Ruby | mit | 185 | staging | 494 | require 'libosctl'
module OsVm
class Cli::Command < OsCtl::Lib::Cli::Command
def self.run(method)
proc do |global_opts, opts, args|
cmd = new(global_opts, opts, args)
cmd.method(method).call
end
end
def script
require_args!('file', strict: false)
# Remove osvm co... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/spec_helper.rb | Ruby | mit | 185 | staging | 706 | # frozen_string_literal: true
require 'rspec'
require 'fileutils'
require 'tmpdir'
require 'stringio'
require 'json'
require 'time'
REPO_ROOT = File.expand_path('../..', __dir__)
$:.unshift(File.join(REPO_ROOT, 'osvm', 'lib'))
$:.unshift(File.join(REPO_ROOT, 'libosctl', 'lib'))
require 'osvm/cli'
Dir[File.join(__d... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/machine_push_file_spec.rb | Ruby | mit | 185 | staging | 571 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::Machine, '#push_file' do
it 'passes preserve through when pushing files' do
with_tmpdir do |dir|
machine = build_machine(dir:)
shared_dir = instance_spy(OsVm::SharedDir)
allow(machine).to receive(:mkdir_p)
machine.... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/vpsadminos_machine_spec.rb | Ruby | mit | 185 | staging | 4,346 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::VpsadminosMachine do
it 'parses osctl json output' do
with_tmpdir do |dir|
machine = build_vpsadminos_machine(dir:)
allow(machine).to receive(:succeeds).with('osctl -j pool ls').and_return([0, '{"state":"active"}'])
expe... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/shared_dir_spec.rb | Ruby | mit | 185 | staging | 2,991 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::SharedDir do
def build_machine_double(dir)
instance_spy(OsVm::Machine).tap do |machine|
allow(machine).to receive(:send).with(:tmpdir).and_return(dir)
allow(machine).to receive(:all_succeed)
allow(machine).to receive(:suc... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/mac_address_generator_spec.rb | Ruby | mit | 185 | staging | 794 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::MacAddressGenerator do
it 'generates mac addresses with the configured prefix' do
expect(described_class.next_mac).to start_with('52:54:00:')
end
it 'generates unique mac addresses' do
first = described_class.next_mac
second =... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/port_reservation_spec.rb | Ruby | mit | 185 | staging | 1,362 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::PortReservation do
before do
described_class.reset_to_ports([10_000, 10_001, 10_002, 10_003])
end
it 'returns a stable port per key' do
first = described_class.get_port(key: 'alpha')
second = described_class.get_port(key: 'alp... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/machine_kill_spec.rb | Ruby | mit | 185 | staging | 276 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::Machine, '#kill' do
it 'returns self when the machine is already stopped' do
with_tmpdir do |dir|
machine = build_machine(dir:)
expect(machine.kill).to eq(machine)
end
end
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/machine_spec.rb | Ruby | mit | 185 | staging | 9,429 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::Machine do
it 'creates tmp and socket directories and adds the default shared filesystem' do
with_tmpdir do |dir|
machine = build_machine(dir:)
expect(File.directory?(File.join(dir, 'tmp'))).to be(true)
expect(File.direc... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/nixos_machine_spec.rb | Ruby | mit | 185 | staging | 2,521 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::NixosMachine do
it 'returns the systemd service check command' do
with_tmpdir do |dir|
machine = build_nixos_machine(dir:)
expect(machine.send(:service_check_command, 'sshd')).to eq('systemctl is-active --quiet sshd')
end
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/machine_config_spec.rb | Ruby | mit | 185 | staging | 5,377 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::MachineConfig do
describe '.load_file' do
it 'parses json and delegates to from_config' do
with_tmpdir do |dir|
path = File.join(dir, 'machine.json')
config_hash = machine_config_hash
File.write(path, JSON.dum... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/machine_log_spec.rb | Ruby | mit | 185 | staging | 1,232 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::MachineLog do
it 'records lifecycle actions and structured command events' do
with_tmpdir do |dir|
path = File.join(dir, 'machine.log')
log = described_class.new(path)
log.start
log.stop
log.destroy
log... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/cli/command_spec.rb | Ruby | mit | 185 | staging | 751 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::Cli::Command do
it 'requires a script file argument' do
expect do
described_class.new({}, {}, []).script
end.to raise_error(GLI::BadCommandLine, 'missing argument <file>')
end
it 'shifts argv and loads the selected file' do
... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/osvm/cli/app_spec.rb | Ruby | mit | 185 | staging | 225 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe OsVm::Cli::App do
it 'builds the command tree' do
app = described_class.get
expect(app.commands.keys.map(&:to_s)).to include('script')
end
end |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | osvm/spec/support/osvm_test_helpers.rb | Ruby | mit | 185 | staging | 3,837 | # frozen_string_literal: true
class OsVmSpecMachine < OsVm::Machine
def qemu_command(kernel_params: [])
['qemu-kvm', *qemu_boot_options(kernel_params), *qemu_disk_options, *qemu_virtiofs_options]
end
def service_check_command(name)
"sv check #{name}"
end
end
module OsvmTestHelpers
def deep_merge(ba... |
github | vpsfreecz/vpsadminos | https://github.com/vpsfreecz/vpsadminos | skills/update-redhat-family-image-releases/scripts/discover_release_updates.rb | Ruby | mit | 185 | staging | 10,802 | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'net/http'
require 'optparse'
require 'pathname'
ROCKY_ROOT = 'https://ftp.linux.cz/pub/linux/rocky'
ALMALINUX_ROOT = 'https://repo.almalinux.org/almalinux'
CENTOS_STREAM_ROOT = 'https://mirror.stream.centos.org'
FEDORA_RELEASES_ROOT = 'http://ftp.fi.muni.cz/p... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | Gemfile | Ruby | mit | 185 | master | 2,063 | source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '~> 4.2.0'
gem 'pg'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks', '~> 2.5.3'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
gem 'debugger', group: [:developme... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | Rakefile | Ruby | mit | 185 | master | 252 | # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Prwatch::Application.load_tasks |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | GuardFile | Ruby | mit | 185 | master | 2,331 | guard 'rails', port: 3006 do
watch('Gemfile.lock')
watch(%r{^(config)/.*})
watch(%r{^(lib)/.*})
end
guard 'livereload' do
watch(%r{app/views/.+.(erb|haml|slim)$})
watch(%r{app/helpers/.+.rb})
watch(%r{public/.+.(css|js|html)})
watch(%r{config/locales/.+.yml})
# Rails Assets Pipeline
watch(%r{(app|ven... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | spec/rails_helper.rb | Ruby | mit | 185 | master | 1,241 | require 'simplecov'
require 'coveralls'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
SimpleCov.start 'rails'
require 'rubygems'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rs... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | spec/helpers/repositories_helper_spec.rb | Ruby | mit | 185 | master | 997 | require 'rails_helper'
RSpec.describe RepositoriesHelper, :type => :helper, vcr: true do
before(:each) do
create :report, github_key: "cloudflare/redoctober"
create :report, github_key: "youtube/vitess"
create :report, github_key: "gin-gonic/gin"
create :report, github_key: "fiorix/freegeoip"
end
... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | spec/models/report_spec.rb | Ruby | mit | 185 | master | 6,126 | require 'rails_helper'
RSpec.describe Report, :type => :model do
let(:report) { build :report }
describe ".language" do
it "should return nil languages with a specific key" do
report = build :report, language: nil
allow(report).to receive(:fetch_metadata).and_return(true)
allow(report).to re... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | spec/models/issue_spec.rb | Ruby | mit | 185 | master | 673 | require 'rails_helper'
RSpec.describe Issue, type: :model do
describe "#duration_tier" do
it "should fit into the right tier" do
duration = Issue.duration_tiers[1] - 1.minute
issue = Issue.new(
created_at: 1.minute.ago - duration,
closed_at: 1.minute.ago
)
expect(issue.dur... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | spec/controllers/repositories_controller_spec.rb | Ruby | mit | 185 | master | 2,080 | require 'rails_helper'
RSpec.describe RepositoriesController, :type => :controller do
describe "GET show" do
render_views
it "returns html success", :vcr do
get :show, owner: "hstove", repository: "rbtc_arbitrage"
expect(response).to be_success
end
it "returns json success", :vcr do
... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/models/issue.rb | Ruby | mit | 185 | master | 963 | class Issue < Hashie::Mash
class << self
def find key, opts={}, block
GH.skinny("repos/#{key}/issues", opts) do |issues|
issues.map do |pr|
block.call self.new pr.to_hash
end
end
end
def duration_tiers
[1.hour] + (1..10).map do |n|
(3 ** n).hours
... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/models/report.rb | Ruby | mit | 185 | master | 5,724 | require 'action_view'
include ActionView::Helpers::DateHelper
class Report < ActiveRecord::Base
serialize :basic_distribution, Hash
serialize :pr_distribution, Hash
serialize :issues_distribution, Hash
before_create :fetch_metadata
after_create :bootstrap_async
NO_LANGUAGE_KEY = "__no_language__"
scope... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/controllers/application_controller.rb | Ruby | mit | 185 | master | 418 | class ApplicationController < ActionController::Base
include ActionController::MimeResponds
include ActionController::ImplicitRender
protect_from_forgery with: :exception
helper_method :report_path
def report_path(report, type = "path")
opts = report.param_opts
send("repository_#{type}", (opts))
e... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/controllers/repositories_controller.rb | Ruby | mit | 185 | master | 1,764 | class RepositoriesController < ApplicationController
before_filter :fetch_report, only: [:show, :refresh, :badge]
has_scope :language
rescue_from Octokit::ClientError, with: :not_found_badge
def index
@reports = apply_scopes(Report).ready.paginate(page: params[:page] || 1)
@reports = @reports.with_iss... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/jobs/scrape_job.rb | Ruby | mit | 185 | master | 254 | class ScrapeJob < ActiveJob::Base
def perform(search_key)
repos = GH.client.search_repositories search_key,
sort: :stars,
per_page: 100,
page: 1
repos.items.each do |repo|
Report.from_key repo.full_name
end
end
end |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/helpers/highcharts_helper.rb | Ruby | mit | 185 | master | 2,126 | module HighchartsHelper
def analysis_highchart(data, labels)
id = labels.join(" vs. ")
chart = LazyHighCharts::HighChart.new('graph') do |f|
f.chart type: "scatter", zoomType: "xy"
f.title text: id
f.series name: labels[0], color: labels[1], data: data
f.xAxis title: {text: labels[0]},... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/helpers/repositories_helper.rb | Ruby | mit | 185 | master | 2,930 | module RepositoriesHelper
def response_distribution_chart report
categories = Issue.duration_tiers.map do |tier|
distance_of_time_in_words(tier)
end
chart = LazyHighCharts::HighChart.new('graph') do |f|
f.title(:text => "Distribution of Time to Close an Issue")
# f.series name: "All Iss... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | app/helpers/sortable_headers_helper.rb | Ruby | mit | 185 | master | 1,115 | module SortableHeadersHelper
def sortable_header(attr, opts={})
opts = default_sortable_opts(opts, attr)
current_direction = params[:sortable_direction]
if opts[:is_sorted]
opts[:sort_symbol] = sort_symbols[current_direction]
(opposite = sort_symbols.keys).delete(current_direction)
opts[... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/unicorn.rb | Ruby | mit | 185 | master | 978 | worker_processes 2
timeout 30
preload_app true
before_fork do |server, worker|
# Replace with MongoDB or whatever
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
Rails.logger.info('Disconnected from ActiveRecord')
end
# If you are using Redis but not Resque, change this
if ... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/application.rb | Ruby | mit | 185 | master | 1,400 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module Prwatch
class Application < Rails::Application
config.autoload_paths << "#{config.root}... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/routes.rb | Ruby | mit | 185 | master | 2,217 | Prwatch::Application.routes.draw do
mount Afterparty::Engine, at: "afterparty", as: "afterparty_engine"
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'
regex = /[\w|\.*|-]+/
constraints = {repository: regex, owner: regex}
get 'github/:owner/:repository' => 'repositories#show',
as: "repository",
... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/environments/development.rb | Ruby | mit | 185 | master | 1,483 | Prwatch::Application.configure do
config.middleware.insert_after(ActionDispatch::Static, Rack::LiveReload)
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
config.action_mailer.default_url_options = {
:host => "localhost",
:p... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/environments/production.rb | Ruby | mit | 185 | master | 3,969 | Prwatch::Application.configure do
config.cache_store = :dalli_store
config.logger = Logger.new(STDOUT)
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password ... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/environments/test.rb | Ruby | mit | 185 | master | 1,657 | Prwatch::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test s... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/initializers/octokit.rb | Ruby | mit | 185 | master | 584 | # Octokit.auto_paginate = true
module GH
class << self
def method_missing method, *args
key = *args
client.send method, *args
end
def client
@client ||= Octokit::Client.new access_token: ENV['PRWATCH_GITHUB_KEY']
end
def skinny url, opts={}, &block
opts[:per_page] ||= 100
... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/initializers/mime_types.rb | Ruby | mit | 185 | master | 248 | # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
Mime::Type.register "image/svg+xml", :svg |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | config/initializers/secret_token.rb | Ruby | mit | 185 | master | 661 | # Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to diction... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | db/schema.rb | Ruby | mit | 185 | master | 1,897 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | db/migrate/20140722184552_create_afterparty_jobs.rb | Ruby | mit | 185 | master | 419 | class CreateAfterpartyJobs < ActiveRecord::Migration
def self.up
create_table :afterparty_jobs do |t|
t.text :job_dump
t.string :queue
t.datetime :execute_at
t.boolean :completed
t.boolean :has_error
t.text :error_message
t.text :error_backtrace
t.datetime :complete... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | db/migrate/20140727192920_add_metadata_to_reports.rb | Ruby | mit | 185 | master | 363 | class AddMetadataToReports < ActiveRecord::Migration
def change
add_column :reports, :open_issues_count, :integer
add_column :reports, :description, :string
add_column :reports, :language, :string
add_column :reports, :forks_count, :integer
add_column :reports, :stargazers_count, :integer
add_... |
github | hstove/issue_stats | https://github.com/hstove/issue_stats | db/migrate/20140724185440_create_reports.rb | Ruby | mit | 185 | master | 220 | class CreateReports < ActiveRecord::Migration
def change
create_table :reports do |t|
t.string :github_key
t.text :basic_distribution
t.integer :github_stars
t.timestamps
end
end
end |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | Appraisals | Ruby | apache-2.0 | 185 | master | 306 | # frozen_string_literal: true
appraise 'activesupport-7_0' do
gem 'activesupport', '~> 7.0'
end
appraise 'activesupport-7_1' do
gem 'activesupport', '~> 7.1'
end
appraise 'activesupport-7_2' do
gem 'activesupport', '~> 7.2'
end
appraise 'activesupport-8_0' do
gem 'activesupport', '~> 8.0'
end |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | rrule.gemspec | Ruby | apache-2.0 | 185 | master | 979 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rrule/version'
Gem::Specification.new do |s|
s.name = 'rrule'
s.version = RRule::VERSION
s.summary = 'RRule expansion'
s.description = 'A gem for expanding dates according to t... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | Rakefile | Ruby | apache-2.0 | 185 | master | 337 | # frozen_string_literal: true
require 'rubygems'
require 'rake'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require File.expand_path('lib/rrule', __dir__)
RSpec::Core::RakeTask.new(:spec)
require 'rubocop/rake_task'
RuboCop::RakeTask.new
namespace :spec do
task all: ['spec']
end
task default: %w[s... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule.rb | Ruby | apache-2.0 | 185 | master | 1,448 | # frozen_string_literal: true
require 'active_support'
require 'active_support/core_ext/time'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/integer/time'
require 'active_support/core_ext/array/wrap'
module RRule
autoload :Rule, 'rrule/rule'
autoload :Context, 'rrule/context'
au... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/context.rb | Ruby | apache-2.0 | 185 | master | 4,170 | # frozen_string_literal: true
module RRule
class Context
attr_reader :options, :dtstart, :tz, :day_of_year_mask, :year
def initialize(options, dtstart, tz)
@options = options
@dtstart = dtstart
@tz = tz
end
def rebuild(year, month)
@year = year
reset_year if year != l... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/humanizer.rb | Ruby | apache-2.0 | 185 | master | 6,230 | # frozen_string_literal: true
module RRule
# Based off https://github.com/jakubroztocil/rrule/blob/master/src/nlp/totext.ts
#
class Humanizer
attr_reader :rrule, :options
OPTION_ATTRIBUTE_RE = /_option/.freeze
DAY_NAMES = %w[
Sunday
Monday
Tuesday
Wednesday
Thursday
... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/rule.rb | Ruby | apache-2.0 | 185 | master | 7,040 | # frozen_string_literal: true
module RRule
class Rule
include Enumerable
attr_reader :dtstart, :tz, :exdate
def initialize(rrule, dtstart: Time.now, tzid: 'UTC', exdate: [], max_year: nil)
@tz = tzid
@rrule = rrule
@dtstart = dtstart.is_a?(Date) ? dtstart : floor_to_seconds_in_timezon... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/weekday.rb | Ruby | apache-2.0 | 185 | master | 392 | # frozen_string_literal: true
module RRule
class Weekday
attr_reader :index, :ordinal
def initialize(index, ordinal = nil)
@index = index
@ordinal = ordinal
end
def self.parse(weekday)
match = /([+-]?\d+)?([A-Z]{2})/.match(weekday)
index = RRule::WEEKDAYS.index(match[2])
... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/filters/by_month_day.rb | Ruby | apache-2.0 | 185 | master | 507 | # frozen_string_literal: true
module RRule
class ByMonthDay
def initialize(by_month_days, context)
@context = context
@positive_month_days, @negative_month_days = by_month_days.partition { |mday| mday > 0 }
end
def reject?(i)
!positive_month_days.include?(context.month_day_by_day_of_ye... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/filters/by_week_day.rb | Ruby | apache-2.0 | 185 | master | 543 | # frozen_string_literal: true
module RRule
class ByWeekDay
def initialize(weekdays, context)
@by_week_days = weekdays.map(&:index)
@context = context
end
def reject?(i)
masked?(i) && !matches_by_week_days?(i)
end
private
def masked?(i)
context.day_of_year_mask.blank... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/filters/by_month.rb | Ruby | apache-2.0 | 185 | master | 309 | # frozen_string_literal: true
module RRule
class ByMonth
def initialize(by_months, context)
@by_months = by_months
@context = context
end
def reject?(i)
!by_months.include?(context.month_by_day_of_year[i])
end
private
attr_reader :by_months, :context
end
end |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/filters/by_year_day.rb | Ruby | apache-2.0 | 185 | master | 635 | # frozen_string_literal: true
module RRule
class ByYearDay
def initialize(by_year_days, context)
@by_year_days = by_year_days
@context = context
end
def reject?(i)
!by_year_days.empty? &&
((i < context.year_length_in_days && !by_year_days.include?(i + 1) && !by_year_days.includ... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/filters/by_week_number.rb | Ruby | apache-2.0 | 185 | master | 427 | # frozen_string_literal: true
module RRule
class ByWeekNumber
def initialize(by_week_numbers, context)
@by_week_numbers = by_week_numbers
@context = context
end
def reject?(i)
!by_week_numbers.include?(context.week_number_by_day_of_year[i]) && !by_week_numbers.include?(context.negative... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/simple_weekly.rb | Ruby | apache-2.0 | 185 | master | 584 | # frozen_string_literal: true
module RRule
class SimpleWeekly < Frequency
def next_occurrences
correct_current_date_if_needed
this_occurrence = current_date
@current_date += context.options[:interval].weeks
generator.process_timeset(this_occurrence, timeset)
end
def correct_curre... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/daily.rb | Ruby | apache-2.0 | 185 | master | 247 | # frozen_string_literal: true
module RRule
class Daily < Frequency
def possible_days
[current_date.yday - 1] # convert to 0-indexed
end
private
def advance_by
{ days: context.options[:interval] }
end
end
end |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/hourly.rb | Ruby | apache-2.0 | 185 | master | 337 | # frozen_string_literal: true
module RRule
class Hourly < Frequency
def possible_days
[current_date.yday - 1] # convert to 0-indexed
end
def timeset
super.map { |time| time.merge(hour: current_date.hour) }
end
private
def advance_by
{ hours: context.options[:interval] }
... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/minutely.rb | Ruby | apache-2.0 | 185 | master | 367 | # frozen_string_literal: true
module RRule
class Minutely < Frequency
def possible_days
[current_date.yday - 1] # convert to 0-indexed
end
def timeset
super.map { |time| time.merge(hour: current_date.hour, minute: current_date.min) }
end
private
def advance_by
{ minutes: ... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/monthly.rb | Ruby | apache-2.0 | 185 | master | 338 | # frozen_string_literal: true
module RRule
class Monthly < Frequency
def possible_days
# yday is 1-indexed, need results 0-indexed
(current_date.beginning_of_month.yday - 1..current_date.end_of_month.yday - 1).to_a
end
private
def advance_by
{ months: context.options[:interval] }
... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/yearly.rb | Ruby | apache-2.0 | 185 | master | 242 | # frozen_string_literal: true
module RRule
class Yearly < Frequency
def possible_days
(0...context.year_length_in_days).to_a
end
private
def advance_by
{ years: context.options[:interval] }
end
end
end |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/secondly.rb | Ruby | apache-2.0 | 185 | master | 393 | # frozen_string_literal: true
module RRule
class Secondly < Frequency
def possible_days
[current_date.yday - 1] # convert to 0-indexed
end
def timeset
super.map { |time| time.merge(hour: current_date.hour, minute: current_date.min, second: current_date.sec) }
end
private
def ad... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/frequency.rb | Ruby | apache-2.0 | 185 | master | 1,736 | # frozen_string_literal: true
module RRule
class Frequency
attr_reader :current_date, :filters, :generator, :timeset
def initialize(context, filters, generator, timeset, start_date: nil)
@context = context
@current_date = start_date.presence || context.dtstart
@filters = filters
@gen... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/frequencies/weekly.rb | Ruby | apache-2.0 | 185 | master | 697 | # frozen_string_literal: true
module RRule
class Weekly < Frequency
def possible_days
i = current_date.yday - 1
possible_days = []
7.times do
possible_days.push(i)
i += 1
break if context.weekday_by_day_of_year[i] == context.options[:wkst]
end
possible_days
... |
github | square/ruby-rrule | https://github.com/square/ruby-rrule | lib/rrule/generators/generator.rb | Ruby | apache-2.0 | 185 | master | 856 | # frozen_string_literal: true
module RRule
class Generator
attr_reader :context
def initialize(context)
@context = context
end
def process_timeset(date, timeset)
return [date] if timeset.blank?
timeset.map do |time|
hour_sets = (
Array.wrap(time[:hour]).sort.map... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.