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 | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | lib/electric_sheep/metadata/agent.rb | Ruby | mit | 19 | master | 1,124 | module ElectricSheep
module Metadata
class Agent < Configured
include Typed
option :agent, required: true
def validate
ensure_known_agent
super
end
def options
if agent_klazz
agent_klazz.options.merge(super)
else
super
en... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | lib/electric_sheep/sheepfile/evaluator.rb | Ruby | mit | 19 | master | 1,019 | module ElectricSheep
module Sheepfile
class Evaluator
def initialize(main)
@main = File.expand_path(main)
@working_directory = File.dirname(@main)
end
def evaluate
load(Config.new, @main)
end
def load(config, file)
path = File.absolute_path(file, @wo... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | acceptance/Vagrantfile | Ruby | mit | 19 | master | 1,124 | Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.omnibus.chef_version = :latest
config.vm.provision :shell, inline: "sudo locale-gen #{ENV['LANG']} && " \
'sudo dpkg-reconfigure locales'
config.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--natdnshostresol... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/database_steps.rb | Ruby | mit | 19 | master | 1,619 | Then(/^a MongoDB dump of the database should have been created$/) do
files=Dir.glob(File.join('tmp', @job, 'control\*db*', 'control\*db', '*.bson')).first
raise "Dump not found" unless files
end
Then(/^a dump should exist with "(.*?)" and without "(.*?)"$/) do |contents, excluded|
file = Dir.glob(File.join('tmp'... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/encryption_steps.rb | Ruby | mit | 19 | master | 1,713 | Given(/^a secret$/) do
@secret = "password"
end
When(/^I tell the sheep to encrypt the secret$/) do
options="-a -k #{acceptance_dir}/public_key.gpg #{@secret}"
step "I successfully run `bundle exec #{electric_sheep} encrypt #{options}`"
end
Then(/^I should see the ASCII\-armored cipher text$/) do
step "the ou... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/compression_steps.rb | Ruby | mit | 19 | master | 1,220 | Then(/^an archive containing the file should have been created on the remote host$/) do
archive = "/tmp/acceptance/#{@job}/dummy-*-*.tar.gz"
assert_remote_file_exists?(archive)
ssh_run_simple("tar -ztf #{archive} | grep dummy.file", 10)
end
Then(/^an archive should have been created on the remote host$/) do
@a... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/env.rb | Ruby | mit | 19 | master | 2,463 | require 'aruba/cucumber'
require 'pathname'
require 'colorize'
require_relative 'aruba/aruba_helper'
ENV['ELECTRIC_SHEEP_ENV'] = 'test'.freeze
module ElectricSheep
module Acceptance
attr_accessor :electric_dir
def electric_sheep
File.join(electric_dir, 'bin/electric_sheep')
end
def sheepfile... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/cli_steps.rb | Ruby | mit | 19 | master | 1,643 | When(/^I'm working on configuration "(.*?)"$/) do |configuration|
@sheepfile = "#{acceptance_dir}/#{configuration}"
end
Then(/^I should be able to tell the sheep to work on job "(.*?)"$/) do |job|
options = "-c #{sheepfile} -j \"#{job}\""
@job = job
step "I successfully run `bundle exec #{electric_sheep} work ... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/transport_steps.rb | Ruby | mit | 19 | master | 3,452 | Given(/^a remote bucket$/) do
@bucket_path = "s3/my-bucket"
step "a directory named \"#{@bucket_path}\""
end
Then(/^the file should have been moved to the remote host$/) do
assert_remote_file_exists? "/tmp/acceptance/#{@job}/#{timestamped_resource(@resource_name)}"
refute_local_file_exists? @resource_name
end
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/working_directories_steps.rb | Ruby | mit | 19 | master | 477 | Given(/^a file in default directory$/) do
@directory=`echo $HOME`.strip+"/.electric_sheep/working-directories"
step "a 102400 byte file named \"dummy.file\""
end
Then(/^the file should be present in both local and remote default working directories$/) do
file="/home/vagrant/.electric_sheep/working-directories/#{... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/aruba/aruba_helper.rb | Ruby | mit | 19 | master | 328 | module Aruba
module Api
# The path to the directory which should contain all your test data
# You might want to overwrite this method to place your data else where.
#
# @return [Array]
# The directory path: Each subdirectory is a member of an array
def dirs
@dirs ||= ['tmp']
end
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | features/support/file_system_steps.rb | Ruby | mit | 19 | master | 2,332 | Given(/^a local file$/) do
step 'a local file named "dummy.file"'
end
Given(/^a local file named with special characters$/) do
step 'a local file named "dummy *.file"'
end
Given(/^a local file named "(.*?)"$/) do |file|
@resource_name = file
step "a 102400 byte file named \"#{@resource_name}\""
end
Given(/^a... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | build/Gemfile | Ruby | mit | 19 | master | 330 | source 'https://rubygems.org'
# Install omnibus software
gem 'omnibus' #, github: 'servebox/omnibus', branch: 'package-name-override'
gem 'omnibus-software', github: 'chef/omnibus-software'
# , branch: 'pin-cacerts'
gem 'git_rev'
gem 'ffi-yajl', '2.2.0' # Locked as the 2.3.0 does not build on ub... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | build/omnibus.rb | Ruby | mit | 19 | master | 1,732 | #
# This file is used to configure the electric_sheep project. It contains
# some minimal configuration examples for working with Omnibus. For a full list
# of configurable options, please see the documentation for +omnibus/config.rb+.
#
# Build internally
# ------------------------------
# By default, Omnibus uses sy... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | build/vagrant/Vagrantfile | Ruby | mit | 19 | master | 1,656 | ES_BOXES = {
ubuntu32: 'ubuntu/wily32',
ubuntu64: 'ubuntu/wily64',
# Can't use 16.04 images right now, see details here:
# https://bugs.launchpad.net/cloud-images/+bug/1565985
# ubuntu32: 'ubuntu/xenial32',
# ubuntu64: 'ubuntu/xenial64',
debian32: 'bento/debian-8.5-i386',
debian64: 'bento/debian-8.5'
}.... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | build/config/build.rb | Ruby | mit | 19 | master | 308 | def packaging_directories
@_packaging_directories={}.tap do |dirs|
dirs[:build]=File.expand_path(
File.join(File.dirname(__FILE__), '..')
)
dirs[:root]=File.expand_path(File.join(dirs[:build], '..'))
end
end
require File.join(packaging_directories[:root], 'lib/electric_sheep/version') |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | build/config/projects/electric_sheep.rb | Ruby | mit | 19 | master | 766 | require File.join(File.dirname(__FILE__), '../build')
name 'electric_sheep'
friendly_name 'Electric Sheep IO'
maintainer 'ServeBox <humans@electricsheep.io>'
homepage 'http://electricsheep.io'
license 'MIT'
build_version ElectricSheep::VERSION
install_dir '/opt/electric_sheep'
build_iteration ... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | build/config/software/electric_sheep.rb | Ruby | mit | 19 | master | 735 | require File.join(File.dirname(__FILE__), '../build')
require 'git_rev'
name "electric_sheep"
default_version ElectricSheep::VERSION
dependency "ruby"
dependency "rubygems"
dependency "bundler"
source path: packaging_directories[:root]
relative_path "electric_sheep"
build do
revision = GitRev::Sha.new(repositor... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/spec_helper.rb | Ruby | mit | 19 | master | 698 | require 'simplecov'
require 'coveralls'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter]
)
SimpleCov.start do
add_filter '/spec/'
end
ENV['ELECTRIC_SHEEP_ENV'] = 'test'
require 'electric_sheep'
require 'minitest'
require 'm... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep_spec.rb | Ruby | mit | 19 | master | 1,437 | require 'spec_helper'
describe ElectricSheep do
it 'provides the path to the gem installation' do
subject.gem_path.must_equal `pwd`.chomp
end
it 'provides the path to the templates' do
subject.template_path.must_equal "#{subject.gem_path}/templates"
end
it 'provides the version' do
subject.vers... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/master_spec.rb | Ruby | mit | 19 | master | 9,226 | require 'spec_helper'
describe ElectricSheep::Master do
describe 'spawning processes' do
let(:logger) { mock }
let(:banner) { 'Annoucement' }
let(:seq) { sequence('spawn') }
describe ElectricSheep::Master::ProcessSpawner do
let(:pidfile) do
Tempfile.new('pidfile').tap do |f|
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/dsl_spec.rb | Ruby | mit | 19 | master | 6,024 | require 'spec_helper'
describe ElectricSheep::Dsl do
let(:config) { ElectricSheep::Config.new }
let(:evaluator) { mock }
let(:dsl) { ElectricSheep::Dsl.new(config, evaluator) }
def check_properties(obj, expected)
expected.each do |key, value|
obj.send(key).must_equal value
end
end
it 'raise... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/cli_spec.rb | Ruby | mit | 19 | master | 7,712 | require 'spec_helper'
require 'electric_sheep/cli'
describe ElectricSheep::CLI do
let(:logger) { mock }
let(:config) { mock }
def expects_stdout_logger(level)
Lumberjack::Logger
.expects(:new).with(kind_of(IO), level: level)
.returns(logger)
end
def expects_file_logger(level, path = nil)
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/command_spec.rb | Ruby | mit | 19 | master | 1,671 | require 'spec_helper'
describe ElectricSheep::Command do
CommandKlazz = Class.new do
include ElectricSheep::Command
end
[:job, :logger, :shell, :resource, :metadata].each do |m|
let(m) { mock }
end
describe CommandKlazz do
let(:command) do
subject.new(job, logger, shell, resource, metadat... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/runnable_spec.rb | Ruby | mit | 19 | master | 1,772 | require 'spec_helper'
describe ElectricSheep::Runnable do
RunnableKlazz = Class.new do
include ElectricSheep::Runnable
attr_reader :logger
def initialize(job, logger, resource)
@job = job
@logger = logger
@input = resource
end
end
describe RunnableKlazz do
[:job, :logger,... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/spawn_spec.rb | Ruby | mit | 19 | master | 1,242 | require 'spec_helper'
describe ElectricSheep::Spawn do
let(:child) { mock.tap { |m| m.expects(:status).returns(127) } }
let(:cmd) { 'echo "" > /dev/null' }
before do
POSIX::Spawn::Child.expects(:new).with(cmd).returns(child)
end
it 'returns the default output' do
child.expects(:out).returns nil
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/transport_spec.rb | Ruby | mit | 19 | master | 5,925 | require 'spec_helper'
describe ElectricSheep::Transport do
let(:job) { ElectricSheep::Metadata::Job.new(id: 'some-job') }
let(:hosts) { ElectricSheep::Metadata::Hosts.new }
let(:transport) { subject.new(job, logger, hosts, resource, metadata) }
[:local_interactor, :logger, :metadata].each do |m|
let(m) ... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/notifier_spec.rb | Ruby | mit | 19 | master | 418 | require 'spec_helper'
describe ElectricSheep::Notifier do
NotifierKlazz = Class.new do
include ElectricSheep::Notifier
end
describe NotifierKlazz do
it 'makes initialization options available' do
notifier = subject.new(job = mock, hosts = mock, logger = mock, mock)
notifier.logger.must_equal... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/config_spec.rb | Ruby | mit | 19 | master | 487 | require 'spec_helper'
describe ElectricSheep::Config do
include Support::Queue
def queue_items
([0] * 2).map do
ElectricSheep::Metadata::Job.new(subject.new)
end
end
before do
@config = subject.new
end
it 'initializes an empty hosts' do
@config.hosts.must_be_instance_of ElectricShe... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/agents_spec.rb | Ruby | mit | 19 | master | 1,032 | require 'spec_helper'
describe ElectricSheep::Agents::Register do
class FakeCommand; end
class FakeTransport; end
class FakeNotifier; end
{ command: FakeCommand, transport: FakeTransport, notifier: FakeNotifier }
.each do |type, klazz|
describe "with a #{type} registered" do
before do
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/crypto_spec.rb | Ruby | mit | 19 | master | 6,290 | require 'spec_helper'
require 'shellwords'
describe ElectricSheep::Crypto do
it 'returns the GPG encryption module' do
subject.gpg.must_equal ElectricSheep::Crypto::GPG
end
end
describe ElectricSheep::Crypto::GPG do
let(:keyfile) { 'path/to/key' }
let(:executor) { mock }
let(:gpg_regexp) { %r{gpg --batc... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/runner_spec.rb | Ruby | mit | 19 | master | 7,995 | require 'spec_helper'
describe ElectricSheep::Runner do
let(:logger) { mock }
let(:config) do
ElectricSheep::Config.new
end
let(:script) { sequence('script') }
let(:job) do
ElectricSheep::Metadata::Job
.new(config, id: 'first-job',
description: 'First job description').tap ... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/helpers/directories_spec.rb | Ruby | mit | 19 | master | 1,812 | require 'spec_helper'
describe ElectricSheep::Helpers::Directories do
let(:seq) do
sequence('shell')
end
[:host, :job, :interactor].each do |var|
let(var) do
mock
end
end
let(:directories) do
subject.new(host, job, interactor)
end
describe 'expanding paths' do
it 'raises unle... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/helpers/shell_safe_spec.rb | Ruby | mit | 19 | master | 316 | require 'spec_helper'
describe ElectricSheep::Helpers::ShellSafe do
ShellSafeKlazz = Class.new do
include ElectricSheep::Helpers::ShellSafe
end
describe ShellSafeKlazz do
it 'escapes shell expressions' do
ShellSafeKlazz.new.shell_safe('"expression').must_equal '\"expression'
end
end
end |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/helpers/fs_util_spec.rb | Ruby | mit | 19 | master | 2,395 | require 'spec_helper'
describe ElectricSheep::Helpers::FSUtil do
it 'creates a random name for temp files and directories' do
subject.tempname.wont_equal subject.tempname
subject.tempname.must_match(/^tmp\d{8}-#{Process.pid}-.+/)
end
let(:executor) { mock }
let(:seq) { sequence('exec') }
def expect... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/ssh_options_spec.rb | Ruby | mit | 19 | master | 276 | require 'spec_helper'
describe ElectricSheep::Metadata::SshOptions do
include Support::Options
it do
defines_options :host_key_checking, :known_hosts
defaults_option :host_key_checking, 'standard'
defaults_option :known_hosts, '~/.ssh/known_hosts'
end
end |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/schedule_spec.rb | Ruby | mit | 19 | master | 3,770 | require 'spec_helper'
describe ElectricSheep::Metadata::Schedule do
before { Timecop.travel(Time.local(2014, 1, 1, 1, 0, 0)) }
after { Timecop.return }
def expects_scheduled_at(options, expected)
subject.new(options).tap do |subject|
subject.update!
assert_equal expected, subject.scheduled_at
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/shell_spec.rb | Ruby | mit | 19 | master | 664 | require 'spec_helper'
describe ElectricSheep::Metadata::Shell do
include Support::ShellMetadata
include Support::Options
include Support::Queue
def queue_items
([0] * 2).map do
ElectricSheep::Metadata::Command.new(config)
end
end
describe 'validating' do
it 'adds child commands errors' ... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/notifier_spec.rb | Ruby | mit | 19 | master | 591 | require 'spec_helper'
describe ElectricSheep::Metadata::Notifier do
include Support::Options
let(:config) do
ElectricSheep::Config.new
end
it do
defines_options :agent
requires :agent
end
it do
expects_validation_error(subject.new(config, agent: 'foo'), :notifier,
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/configured_spec.rb | Ruby | mit | 19 | master | 357 | require 'spec_helper'
describe ElectricSheep::Metadata::Configured do
class FakeConfigured < ElectricSheep::Metadata::Configured
option :option1
end
it 'assigns config and options' do
subject = FakeConfigured.new(config = mock, option1: 'value')
subject.config.must_equal config
subject.option(:o... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/command_spec.rb | Ruby | mit | 19 | master | 565 | require 'spec_helper'
describe ElectricSheep::Metadata::Command do
include Support::Options
let(:config) do
ElectricSheep::Config.new
end
it do
defines_options :agent
requires :agent
end
it do
expects_validation_error(subject.new(config, agent: 'foo'), :command,
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/transport_spec.rb | Ruby | mit | 19 | master | 968 | require 'spec_helper'
describe ElectricSheep::Metadata::Transport do
include Support::Hosts
include Support::Options
let(:config) do
ElectricSheep::Config.new
end
it do
defines_options :action, :agent, :to
requires :action, :agent, :to
end
it 'describes a copy' do
subject.new(config, a... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/pipe_spec.rb | Ruby | mit | 19 | master | 6,808 | require 'spec_helper'
describe ElectricSheep::Metadata::Pipe do
PipeKlazz = Class.new do
include ElectricSheep::Metadata::Pipe
end
describe PipeKlazz do
[:item1, :item2, :resource, :start_location].each do |m|
let(m) { mock }
end
let(:pipe) { subject.new }
describe 'pipelining' do
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/options_spec.rb | Ruby | mit | 19 | master | 1,208 | require 'spec_helper'
describe ElectricSheep::Metadata::Options do
OptionsKlazz = Class.new do
include ElectricSheep::Metadata::Options
def initialize(opts = {})
@options = opts
end
option :option1
option :option2, default: 'default_value'
end
describe OptionsKlazz do
it 'does no... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/remote_shell_spec.rb | Ruby | mit | 19 | master | 221 | require 'spec_helper'
describe ElectricSheep::Metadata::RemoteShell do
include Support::ShellMetadata
include Support::Options
include Support::Hosts
it do
defines_options :user
requires :user
end
end |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/crypto_options_spec.rb | Ruby | mit | 19 | master | 451 | require 'spec_helper'
describe ElectricSheep::Metadata::CryptoOptions do
include Support::Options
CryptoOptionsKlazz = Class.new(ElectricSheep::Metadata::Base) do
include ElectricSheep::Metadata::CryptoOptions
end
describe CryptoOptionsKlazz do
it do
defines_options :with
requires :with
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/encrypted_spec.rb | Ruby | mit | 19 | master | 415 | require 'spec_helper'
describe ElectricSheep::Metadata::Encrypted do
it 'decrypts cipher text' do
ElectricSheep::Crypto.gpg.expects(:string).returns(encryptor = mock)
'/path/to/private/key'.tap do |key|
encryptor.expects(:decrypt).with(key, 'CIPHER').returns('PLAIN')
decrypt_options = mock(with: ... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/job_spec.rb | Ruby | mit | 19 | master | 2,647 | require 'spec_helper'
describe ElectricSheep::Metadata::Job do
include Support::Queue
include Support::Options
let(:config) do
ElectricSheep::Config.new
end
def queue_items
[
ElectricSheep::Metadata::Shell.new(config),
ElectricSheep::Metadata::Transport.new(config)
]
end
it do
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/monitor_spec.rb | Ruby | mit | 19 | master | 1,086 | require 'spec_helper'
describe ElectricSheep::Metadata::Monitor do
MonitorKlazz = Class.new do
include ElectricSheep::Metadata::Monitor
end
describe MonitorKlazz do
it 'benchmarks the execution time' do
monitor = subject.new
monitor.monitored do
sleep 0.01
end
monitor.exe... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/agent_spec.rb | Ruby | mit | 19 | master | 2,336 | require 'spec_helper'
describe ElectricSheep::Metadata::Agent do
include Support::Options
it do
defines_options :agent
requires :agent
end
let(:config) do
ElectricSheep::Config.new
end
class AgentKlazz < ElectricSheep::Metadata::Agent
option :secret, secret: true
option :public
o... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/metadata/hosts_spec.rb | Ruby | mit | 19 | master | 2,253 | require 'spec_helper'
describe ElectricSheep::Metadata::Host do
include Support::Options
it do
defines_options :hostname, :id, :description, :ssh_port, :private_key,
:private_key_data
requires :hostname
end
it 'is remote' do
subject.new.local?.must_equal false
end
it 'use... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/resources/database_spec.rb | Ruby | mit | 19 | master | 276 | require 'spec_helper'
describe ElectricSheep::Resources::Database do
include Support::Options
include Support::Hosted
it do
defines_options :name
requires :name
end
it 'lets the world know its type' do
subject.new.type.must_equal 'database'
end
end |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/resources/stat_spec.rb | Ruby | mit | 19 | master | 256 | require 'spec_helper'
describe ElectricSheep::Resources::Stat do
it 'humanizes size' do
subject.new.tap { |stat| stat.size = 4096 }.humanize.must_equal '4 KB'
end
it 'handles nil size' do
subject.new.humanize.must_equal 'Unknown'
end
end |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/resources/file_system_spec.rb | Ruby | mit | 19 | master | 541 | require 'spec_helper'
describe ElectricSheep::Resources::FileSystem do
include Support::Options
include Support::Files::Named
include Support::Hosted
it 'defaults to local' do
subject.new.remote?.must_equal false
subject.new.local?.must_equal true
end
it 'is local when localhost' do
subject.n... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/resources/s3_object_spec.rb | Ruby | mit | 19 | master | 931 | require 'spec_helper'
describe ElectricSheep::Resources::S3Object do
include Support::Options
include Support::Files::Named
include Support::Files::Extended
it do
defines_options :directory, :bucket, :region
requires :bucket
end
it 'is remote only' do
subject.new.local?.must_equal false
end... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/resources/directory_spec.rb | Ruby | mit | 19 | master | 523 | require 'spec_helper'
describe ElectricSheep::Resources::Directory do
include Support::Files::Named
it 'indicates its type' do
subject.new.file?.must_equal false
subject.new.directory?.must_equal true
end
it 'lets the world know its type' do
subject.new.type.must_equal 'directory'
end
it 'no... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/resources/file_spec.rb | Ruby | mit | 19 | master | 585 | require 'spec_helper'
describe ElectricSheep::Resources::File do
include Support::Files::Named
include Support::Files::Extended
it 'indicates its type' do
subject.new.file?.must_equal true
subject.new.directory?.must_equal false
end
it 'lets the world know its type' do
subject.new.type.must_equ... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/resources/resource_spec.rb | Ruby | mit | 19 | master | 1,207 | require 'spec_helper'
describe ElectricSheep::Resources::Resource do
include Support::Options
let(:origin) { mock }
it 'uses original timestamp if any' do
ts = Time.now.utc.strftime('%Y%m%d-%H%M%S')
origin.expects(:timestamp?).returns(true)
origin.expects(:timestamp).returns(ts)
subject.new.tap... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/interactors/ssh_interactor_spec.rb | Ruby | mit | 19 | master | 13,952 | # encoding: utf-8
require 'spec_helper'
require 'net/ssh/test'
describe ElectricSheep::Interactors::SshInteractor do
include Net::SSH::Test
module Net
module SSH
module Test
# Avoid Net::SSH::Test::Extensions to collide with Coveralls
class << self
def remove_io_aliases
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/interactors/shell_stat_spec.rb | Ruby | mit | 19 | master | 1,003 | require 'spec_helper'
describe ElectricSheep::Interactors::ShellStat do
ShellStatKlazz = Class.new do
include ElectricSheep::Interactors::ShellStat
end
describe ShellStatKlazz do
let(:shell_stat) { subject.new }
[:file, :directory].each do |type|
before do
@resource = ElectricSheep::R... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/interactors/base_spec.rb | Ruby | mit | 19 | master | 1,940 | require 'spec_helper'
describe ElectricSheep::Interactors::Base do
class FakeInteractor < ElectricSheep::Interactors::Base
attr_accessor :returning, :directories, :session
def exec(*cmd)
_exec(*cmd) do
returning
end
end
def build_session
:session
end
end
[:host, :... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/interactors/shell_interactor_spec.rb | Ruby | mit | 19 | master | 1,313 | require 'spec_helper'
describe ElectricSheep::Interactors::ShellInteractor do
[:host, :job, :logger].each do |var|
let(var) do
mock
end
end
let(:interactor) do
subject.new(host, job, logger)
end
it 'builds a session' do
interactor.send(:build_session).must_be_nil
end
describe 'ex... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/commands/encrypt_spec.rb | Ruby | mit | 19 | master | 2,597 | require 'spec_helper'
require 'json'
describe ElectricSheep::Commands::Encrypt do
include Support::Command
it { defines_options :public_key }
let(:spawn) { ElectricSheep::Spawn }
let(:fs_util) { ElectricSheep::Helpers::FSUtil }
let(:gpg) { ElectricSheep::Crypto.gpg }
let(:seq) { sequence('encryption') }
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/commands/compression/tar_gz_spec.rb | Ruby | mit | 19 | master | 2,085 | require 'spec_helper'
describe ElectricSheep::Commands::Compression::TarGz do
include Support::Command
it { defines_options :delete_source }
it 'should have registered as "tar_gz"' do
ElectricSheep::Agents::Register.command('tar_gz').must_equal subject
end
def expects_log
logger.expects(:info).in_s... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/commands/database/mysql_dump_spec.rb | Ruby | mit | 19 | master | 3,048 | require 'spec_helper'
require 'timecop'
describe ElectricSheep::Commands::Database::MySQLDump do
include Support::Command
it { defines_options :user, :password, :exclude_tables }
it 'should have registered as the "mysql_dump" agent of type command' do
ElectricSheep::Agents::Register.command('mysql_dump').m... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/commands/database/mongodb_dump_spec.rb | Ruby | mit | 19 | master | 1,695 | require 'spec_helper'
require 'json'
describe ElectricSheep::Commands::Database::MongoDBDump do
include Support::Command
it { defines_options :user, :password }
ensure_registration 'mongodb_dump'
def expects_log
logger.expects(:info).in_sequence(seq).with(
'Creating a dump of the "$MyDatabase" Mon... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/commands/database/postgresql_dump_spec.rb | Ruby | mit | 19 | master | 4,032 | require 'spec_helper'
require 'timecop'
describe ElectricSheep::Commands::Database::PostgreSQLDump do
include Support::Command
it do
defines_options :user, :password, :sudo_as, :login_host, :exclude_tables
end
it 'should have registered as the "postgresql_dump" agent of type command' do
ElectricSheep... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/sheepfile/evaluator_spec.rb | Ruby | mit | 19 | master | 2,870 | require 'spec_helper'
describe ElectricSheep::Sheepfile::Evaluator do
let(:path) { File.expand_path('Sheepfile') }
def expects_open(file, contents)
File.expects(:open).with(file, 'rb').returns mock(read: contents)
end
def expects_readable(file)
File.expects(:exist?).with(file).returns true
File.e... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/notifiers/email_spec.rb | Ruby | mit | 19 | master | 2,269 | require 'spec_helper'
describe ElectricSheep::Notifiers::Email do
include Support::Options
let(:config) do
ElectricSheep::Config.new
end
before do
Mail::TestMailer.deliveries.clear
end
let(:resource) do
ElectricSheep::Resources::File.new(path: 'path/to/file').tap do |resource|
resource... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/notifiers/template_spec.rb | Ruby | mit | 19 | master | 2,593 | require 'spec_helper'
describe ElectricSheep::Notifiers::Template do
def create_template(name, ext, content)
Tempfile.new([name, "#{ext}.erb"].compact).tap do |tmpl|
tmpl.write content
tmpl.close
end
end
def self.ensure_rendering(ext = nil)
describe "with the '#{ext}.erb' template" do
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/transports/scp_spec.rb | Ruby | mit | 19 | master | 1,661 | require 'spec_helper'
require 'net/ssh/test'
describe ElectricSheep::Transports::SCP do
include Support::Transport
include Support::Options
it { defines_options :as }
describe 'creating a remote interactor' do
before do
metadata.stubs(:as).returns('user')
metadata.stubs(:to).returns('some-hos... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/transports/s3_spec.rb | Ruby | mit | 19 | master | 6,821 | require 'spec_helper'
require 'fileutils'
describe ElectricSheep::Transports::S3 do
include Support::Transport
it do
defines_options :access_key_id, :secret_key, :region
end
let(:s3) { subject.new(job, logger, hosts, resource, metadata) }
it 'should have registered as the "s3" transport' do
Electr... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/util/ssh_host_keys_spec.rb | Ruby | mit | 19 | master | 4,964 | require 'spec_helper'
describe ElectricSheep::Util::SshHostKeys do
def read_file(name)
File.read(File.join(File.dirname(__FILE__), name)).chomp
end
def read_pubkey(host, type)
read_file("#{host}.#{type}.pub")
end
let(:scan_keys) do
[
[
'host.one.tld ' << read_pubkey('host.one.tld'... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/shell/local_shell_spec.rb | Ruby | mit | 19 | master | 736 | require 'spec_helper'
describe ElectricSheep::Shell::LocalShell do
[:host, :job, :input, :logger].each do |var|
let(var) do
mock
end
end
let(:shell) do
subject.new(host, job, input, logger)
end
it 'initializes an interactor and cache it' do
ElectricSheep::Interactors::ShellInteractor
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/shell/base_spec.rb | Ruby | mit | 19 | master | 1,800 | require 'spec_helper'
describe ElectricSheep::Shell::Base do
[:host, :job, :logger, :input].each do |var|
let(var) do
mock
end
end
let(:config) do
ElectricSheep::Config.new
end
let(:shell) do
subject.new(host, job, input, logger).tap do |shell|
shell.instance_variable_set(:@inte... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/electric_sheep/shell/remote_shell_spec.rb | Ruby | mit | 19 | master | 921 | require 'spec_helper'
require 'net/ssh/test'
describe ElectricSheep::Shell::RemoteShell do
[:host, :job, :input, :logger].each do |var|
let(var) do
mock
end
end
let(:shell) do
subject.new(host, job, input, 'johndoe', logger)
end
it 'initializes an interactor and cache it' do
ElectricS... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/queue.rb | Ruby | mit | 19 | master | 764 | module Support
module Queue
extend ActiveSupport::Concern
included do
describe 'queuing' do
before do
configured = subject.ancestors
.include?(ElectricSheep::Metadata::Configured)
@queue = subject.new(*(configured ? [mock] : []))
@item... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/options.rb | Ruby | mit | 19 | master | 1,098 | module Support
module Options
def defines_options(*options)
options.each do |prop|
subject.options.include?(prop)
.must_equal true, "Expected #{subject.name} to define #{prop}"
end
end
def requires(*options)
options.each do |option|
args = [nil] * [subject... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/hosted.rb | Ruby | mit | 19 | master | 351 | module Support
module Hosted
extend ActiveSupport::Concern
included do
it do
defines_options :host
requires :host
end
it 'delegates conversion to location to host' do
subject.new(host: mock(to_location: location = mock)).to_location
.must_equal locati... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/shell_metadata.rb | Ruby | mit | 19 | master | 639 | module Support
module ShellMetadata
extend ActiveSupport::Concern
included do
let(:config) do
ElectricSheep::Config.new
end
it 'should be empty' do
subject_instance.size.must_equal 0
end
it 'should add commands' do
shell = subject_instance
cmd =... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/hosts.rb | Ruby | mit | 19 | master | 327 | module Support
module Hosts
def new_host
@hosts ||= ElectricSheep::Metadata::Hosts.new
host_id = next_host
@hosts.add(host_id, hostname: "#{host_id}.tld")
end
private
def next_host
@host_counter = @host_counter ? @host_counter + 1 : 1
"host-#{@host_counter}"
end
e... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/files.rb | Ruby | mit | 19 | master | 1,348 | require 'timecop'
module Support
module Files
module Named
extend ActiveSupport::Concern
include Options
included do
it do
defines_options :parent, :basename
requires :parent, :basename
end
it 'creates a path from elements' do
subject.new(... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/transport.rb | Ruby | mit | 19 | master | 337 | module Support
module Transport
extend ActiveSupport::Concern
include Options
included do
let(:job) { ElectricSheep::Metadata::Job.new(id: 'some-job') }
let(:resource) { mock }
let(:metadata) { mock }
let(:logger) { mock }
let(:hosts) { ElectricSheep::Metadata::Hosts.new }
... |
github | jefmathiot/electric_sheep | https://github.com/jefmathiot/electric_sheep | spec/support/command.rb | Ruby | mit | 19 | master | 2,994 | module Support
module Command
extend ActiveSupport::Concern
include Options
class NilMetadata
# rubocop:disable MethodMissing
def method_missing(_method, *_args, &_block)
nil
end
end
def file(path)
ElectricSheep::Resources::File.new(path: path)
end
def di... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | sentry-api.gemspec | Ruby | bsd-2-clause | 19 | master | 1,482 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'sentry-api/version'
Gem::Specification.new do |spec|
spec.name = "sentry-api"
spec.version = SentryApi::VERSION
spec.authors = ["Thierry Xing"]
spec.email = ["thierry.xing@gmail.com"]
s... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api.rb | Ruby | bsd-2-clause | 19 | master | 1,426 | require 'sentry-api/version'
require 'sentry-api/objectified_hash'
require 'sentry-api/configuration'
require 'sentry-api/error'
require 'sentry-api/page_links'
require 'sentry-api/paginated_response'
require 'sentry-api/request'
require 'sentry-api/api'
require 'sentry-api/client'
module SentryApi
extend Configurat... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/error.rb | Ruby | bsd-2-clause | 19 | master | 2,724 | module SentryApi
module Error
# Custom error class for rescuing from all Sentry errors.
class Error < StandardError;
end
# Raised when API endpoint credentials not configured.
class MissingCredentials < Error;
end
# Raised when impossible to parse response body.
class Parsing < Error... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/objectified_hash.rb | Ruby | bsd-2-clause | 19 | master | 909 | module SentryApi
# Converts hashes to the objects.
class ObjectifiedHash
# Creates a new ObjectifiedHash object.
def initialize(hash)
@hash = hash
@data = hash.inject({}) do |data, (key, value)|
value = ObjectifiedHash.new(value) if value.is_a? Hash
data[key.to_s] = value
... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/configuration.rb | Ruby | bsd-2-clause | 19 | master | 1,179 | module SentryApi
# Defines constants and methods related to configuration.
module Configuration
# An array of valid keys in the options hash when configuring a Sentry::API.
VALID_OPTIONS_KEYS = [:endpoint, :auth_token, :default_org_slug, :httparty].freeze
# The user agent that will be sent to the API e... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/request.rb | Ruby | bsd-2-clause | 19 | master | 4,382 | require 'httmultiparty'
require 'json'
module SentryApi
# @private
class Request
include HTTMultiParty
format :json
headers "Content-Type" => "application/json"
parser proc { |body, _| parse(body) }
attr_accessor :auth_token, :endpoint, :default_org_slug
# Converts the response body to an... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/page_links.rb | Ruby | bsd-2-clause | 19 | master | 802 | module SentryApi
# Parses link header.
#
# @private
class PageLinks
HEADER_LINK = 'Link'.freeze
DELIM_LINKS = ','.freeze
LINK_REGEX = /<([^>]+)>; rel=\"([^\"]+)\"; results=\"([^\"]+)\"/
METAS = %w(previous next)
attr_accessor(*METAS)
def initialize(headers)
link_header = headers[... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/api.rb | Ruby | bsd-2-clause | 19 | master | 432 | module SentryApi
# @private
class API < Request
# @private
attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
# Creates a new API.
# @raise [Error:MissingCredentials]
def initialize(options={})
options = SentryApi.options.merge(options)
(Configuration::VALID_OPTIONS_KEYS).each do |ke... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/client.rb | Ruby | bsd-2-clause | 19 | master | 287 | module SentryApi
# Wrapper for the Sentry REST API.
class Client < API
Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
include Organizations
include Projects
include Issues
include Events
include Teams
include Releases
end
end |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/paginated_response.rb | Ruby | bsd-2-clause | 19 | master | 1,560 | module SentryApi
# Wrapper class of paginated response.
class PaginatedResponse
attr_accessor :client
def initialize(array)
@array = array
end
def ==(other)
@array == other
end
def inspect
@array.inspect
end
def method_missing(name, *args, &block)
if @arra... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/client/teams.rb | Ruby | bsd-2-clause | 19 | master | 2,209 | class SentryApi::Client
module Teams
# Create a new project bound to a team.
#
# @example
# SentryApi.create_project('team-slug', {name:'team-name'})
#
# @param team_slug [String] the slug of the team
# @param [Hash] options A customizable set of options.
# @option options [String]... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/client/organizations.rb | Ruby | bsd-2-clause | 19 | master | 3,391 | class SentryApi::Client
module Organizations
# List your Organizations.
#
# @example
# SentryApi.organizations
#
# @param member [Boolean] Restrict results to organizations which you have membership
# @return [Array<SentryApi::ObjectifiedHash>]
def organizations(member=false)
... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/client/issues.rb | Ruby | bsd-2-clause | 19 | master | 1,394 | class SentryApi::Client
module Issues
# List Issues
#
# @example
# SentryApi.project_issues('project-slug', {'query': 'is:unresolved Build-version:6.5.0'})
#
# @param project_slug [String] the slug of the project the client keys belong to.
# @param [Hash] options A customizable set of op... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/client/projects.rb | Ruby | bsd-2-clause | 19 | master | 7,259 | class SentryApi::Client
module Projects
# List your Projects
#
# @example
# SentryApi.projects
#
# @return [Array<SentryApi::ObjectifiedHash>]
def projects
get("/projects/")
end
# Retrieve a Project
#
# @example
# SentryApi.project('project-slug')
#
... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/client/events.rb | Ruby | bsd-2-clause | 19 | master | 3,017 | class SentryApi::Client
module Events
# Retrieve an Issue
#
# @example
# SentryApi.issue('120732258')
#
# @param issue_id [String] the ID of the issue to retrieve.
# @return [SentryApi::ObjectifiedHash]
def issue(issue_id)
get("/issues/#{issue_id}/")
end
# List an Is... |
github | thierryxing/sentry-ruby-api | https://github.com/thierryxing/sentry-ruby-api | lib/sentry-api/client/releases.rb | Ruby | bsd-2-clause | 19 | master | 3,642 | class SentryApi::Client
module Releases
# Create a new release for the given project.
# Releases are used by Sentry to improve it’s error reporting abilities by correlating first seen events with the release that might have introduced the problem.
#
# @example
# SentryApi.create_release('proje... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.