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
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
test/dropkiq/drop_class_analyzer_test.rb
Ruby
mit
19
master
1,494
require "test_helper" class DropkiqDropClassAnalyzerTest < Minitest::Test include TestDatabase include TestRecords def setup setup_test_scaffolding @analyzer = Dropkiq::DropClassAnalyzer.new(PersonDrop) @analyzer.analyze end def teardown teardown_test_scaffolding end # Dropkiq::DropCl...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
test/dropkiq/drop_method_analyzer_test.rb
Ruby
mit
19
master
7,318
require "test_helper" class DropkiqDropMethodAnalyzerTest < Minitest::Test include TestDatabase include TestRecords def setup setup_test_scaffolding @class_analyzer = Dropkiq::DropClassAnalyzer.new(PersonDrop) @class_analyzer.analyze end def teardown teardown_test_scaffolding end # Co...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq.rb
Ruby
mit
19
master
462
require "liquid" require 'active_record' require "dropkiq/version" require "dropkiq/constants" require "dropkiq/drop_class_analyzer" require "dropkiq/drop_method_analyzer" require "dropkiq/drop_method_name_classifier" require "dropkiq/drop_method_instance_simulator" require 'dropkiq/railtie' if defined?(Rails) Dir[F...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq/drop_method_analyzer.rb
Ruby
mit
19
master
3,067
module Dropkiq class DropMethodAnalyzer CHANGEME = "CHANGEME" attr_accessor :drop_class_analyzer, :drop_method, :dropkiq_type, :foreign_table_name, :sample_drop delegate :active_record_class, to: :drop_class_analyzer def initialize(drop_class_analyzer, drop_method, sample_drop=nil) self...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq/drop_class_analyzer.rb
Ruby
mit
19
master
1,909
module Dropkiq class DropClassAnalyzer attr_accessor :liquid_drop_class, :table_name, :active_record_class, :drop_method_params def initialize(liquid_drop_class) self.liquid_drop_class = liquid_drop_class end def analyze self.active_record_class = find_active_record_class sel...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq/constants.rb
Ruby
mit
19
master
514
module Dropkiq DEFAULT_DROP_PATH = "/app/drops" DEFAULT_MODEL_PATH = "/app/models" DEFAULT_LIQUID_DROP_CLASSES = [ Liquid::ForloopDrop, Liquid::TablerowloopDrop ] BOOLEAN_TYPE = "ColumnTypes::Boolean" DATE_TIME_TYPE = "ColumnTypes::DateTime" HAS_MANY_TYPE = "ColumnTypes::HasMany" HAS_ONE_TY...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq/drop_method_name_classifier.rb
Ruby
mit
19
master
1,336
module Dropkiq class DropMethodNameClassifier attr_accessor :drop_method def initialize(drop_method) self.drop_method = drop_method.to_s end def classify if numeric_type_match? Dropkiq::NUMERIC_TYPE elsif boolean_type_match? Dropkiq::BOOLEAN_TYPE elsif text_ty...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq/railtie.rb
Ruby
mit
19
master
264
# lib/railtie.rb require 'dropkiq' require 'rails' module Dropkiq class Railtie < Rails::Railtie railtie_name :dropkiq rake_tasks do path = File.expand_path(__dir__) Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f } end end end
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq/drop_method_instance_simulator.rb
Ruby
mit
19
master
1,427
module Dropkiq class DropMethodInstanceSimulator attr_accessor :drop_method, :sample_drop attr_accessor :dropkiq_type, :foreign_table_name def initialize(drop_method, sample_drop=nil) self.drop_method = drop_method.to_s self.sample_drop = sample_drop end def classify value = be...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/dropkiq/tasks/dropkiq/schema.rake
Ruby
mit
19
master
1,271
require 'stringio' namespace :dropkiq do desc "Generate the fixture schema based on Liquid::Drop classes" task :schema do require "#{Rails.root}/config/environment.rb" Dir.glob("#{Rails.root}#{Dropkiq::DEFAULT_DROP_PATH}/**/*.rb").each { |f| load f } # http://alphahydrae.com/2013/09/capturing-output-...
github
akdarrah/dropkiq-gem
https://github.com/akdarrah/dropkiq-gem
lib/tasks/dropkiq_models_migrate.rake
Ruby
mit
19
master
296
# https://coderwall.com/p/qhdhgw/adding-a-post-execution-hook-to-the-rails-db-migrate-task namespace :db do def run_dropkiq_schema puts "\nRunning `bundle exec rake dropkiq:schema` ...\n\n" Rake::Task['dropkiq:schema'].invoke end task :migrate do run_dropkiq_schema end end
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
ts_schema.gemspec
Ruby
mit
19
main
886
# frozen_string_literal: true require_relative "lib/ts_schema/version" Gem::Specification.new do |spec| spec.name = "ts_schema" spec.version = TsSchema::VERSION spec.authors = ["Avram Walden"] spec.email = ["aviemet@gmail.com"] spec.homepage = "https://github.com/aviemet" spec.summ...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
Gemfile
Ruby
mit
19
main
393
# frozen_string_literal: true source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Specify your gem's dependencies in ts_schema.gemspec. gemspec gem "pg" gem "rake", "~> 13.0" # Start debugger with binding.b [https://github.com/ruby/debug] # gem "debug", ">= 1.0.0" gem "p...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
Rakefile
Ruby
mit
19
main
248
# frozen_string_literal: true require "bundler/setup" require "bundler/gem_tasks" require "ts_schema" # require "rails/plugin/test" # RSpec::Core::RakeTask.new(:test) require "rubocop/rake_task" RuboCop::RakeTask.new task default: %i[rubocop]
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/ts_schema_test.rb
Ruby
mit
19
main
848
require "test_helper" class TsSchemaTest < ActiveSupport::TestCase test "it loads custom config values from initializer" do assert TsSchema.configuration.case assert TsSchema.configuration.output assert TsSchema.configuration.auto_generate assert TsSchema.configuration.types assert TsSchema.confi...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/install_generator_test.rb
Ruby
mit
19
main
313
require "test_helper" class InstallGeneratorTest < Rails::Generators::TestCase tests TsSchema::Generators::InstallGenerator destination File.expand_path('tmp', __dir__) setup :prepare_destination test "it creats a file" do run_generator assert_file "config/initializers/ts_schema.rb" end end
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/test_helper.rb
Ruby
mit
19
main
718
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] require "rails/test_help" # Load fixtures from the engine if ActiveSupport::TestCase.respond_to?(:fixture_path=)...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/schema_generator_test.rb
Ruby
mit
19
main
4,232
require "test_helper" class SchemaGeneratorTest < ActiveSupport::TestCase test "map_column_types generates a hash with mapped column schema values" do generator = TsSchema::SchemaGenerator.new map = generator.map_column_types(Example) [ {:name => "id", :ts_type => "number"}, {:name => "col_st...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/db/schema.rb
Ruby
mit
19
main
3,195
# 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. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/db/migrate/20220402132543_create_fours.rb
Ruby
mit
19
main
249
class CreateFours < ActiveRecord::Migration[7.0] def change create_table :fours do |t| t.references :example, null: false, foreign_key: true t.references :three, null: false, foreign_key: true t.timestamps end end end
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/db/migrate/20220401195333_create_examples.rb
Ruby
mit
19
main
648
class CreateExamples < ActiveRecord::Migration[7.0] def change create_table :examples do |t| t.string :col_string, null: false t.text :col_text, null: false t.integer :col_integer, null: false t.integer :col_enum, null: false t.bigint :col_bigint, null: false t.float :col_float, n...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/db/migrate/20220402132906_create_fives.rb
Ruby
mit
19
main
233
class CreateFives < ActiveRecord::Migration[7.0] def change create_table :fives do |t| t.timestamps end create_table :examples_fives, id: false do |t| t.belongs_to :example t.belongs_to :part end end end
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/db/migrate/20220408205725_create_overrides.rb
Ruby
mit
19
main
229
class CreateOverrides < ActiveRecord::Migration[7.0] def change create_table :overrides do |t| t.string :encrypted_password, null: false t.string :omit t.string :deep t.timestamps end end end
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/config/application.rb
Ruby
mit
19
main
1,214
require_relative "boot" require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "active_storage/engine" require "action_controller/railtie" # require "action_mailer/railtie" require "action_mailbox/engine" require "action_text/...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/config/environments/production.rb
Ruby
mit
19
main
3,178
require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your applica...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/config/environments/test.rb
Ruby
mit
19
main
2,125
require "active_support/core_ext/integer/time" # 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 suite and is wiped # and recreated between test runs. Don't rely on the data the...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/config/environments/development.rb
Ruby
mit
19
main
2,190
require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for developme...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/config/initializers/ts_schema.rb
Ruby
mit
19
main
717
TsSchema.setup do |config| # Options: camel|snake|pascal # config.case = :camel # Customize output path and file name # config.output = Rails.root.join('app', 'assets', 'javascripts', 'schema.d.ts') # Whether to generate the schema file on migrations and rollbacks # config.auto_generate = true # Add cu...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/config/initializers/config/initializers/ts_schema.rb
Ruby
mit
19
main
722
TsSchema.setup do |config| # Options: camel|snake|pascal config.case = :camel # Customize output path and file name config.output = Rails.root.join('app', 'frontend', 'types', 'schema.d.ts') # Whether to generate the schema file on migrations and rollbacks config.auto_generate = true # Add custom type ...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
test/dummy/app/models/example.rb
Ruby
mit
19
main
240
class Example < ApplicationRecord enum col_enum: { zero: 0, one: 1, two: 2, } has_one :one has_one :two, through: :one has_many :fours has_many :threes, through: :fours has_and_belongs_to_many :fives, class_name: "Five" end
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
lib/ts_schema.rb
Ruby
mit
19
main
948
# frozen_string_literal: true require "ts_schema/version" require "ts_schema/railtie" require "ts_schema/configuration" require "ts_schema/schema_generator" module TsSchema class << self def setup(&block) configuration.assign(&block) end def configuration @configuration ||= Configuration.n...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
lib/generators/install_generator.rb
Ruby
mit
19
main
445
# frozen_string_literal: true require 'rails/generators' require 'rails/generators/base' module TsSchema module Generators class InstallGenerator < Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) desc "Creates ts_schmea.rb in config/initializers with default options."...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
lib/generators/templates/ts_schema.rb
Ruby
mit
19
main
3,051
# frozen_string_literal: true TsSchema.setup do |config| # Case options for field names: camel|snake|pascal # # config.case = :camel # Customize output path and file name # # config.output = Rails.root.join('app', 'assets', 'javascripts', 'schema.d.ts') # Whether to generate the schema file after runni...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
lib/tasks/ts_schema_tasks.rake
Ruby
mit
19
main
557
# frozen_string_literal: true require "rake" require "ts_schema" namespace :ts_schema do desc "Generates a schema file in the default javascripts location, or the location specified in the ts_config initializer options" task generate: :environment do TsSchema.output_file end end namespace :db do def auto...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
lib/ts_schema/schema_generator.rb
Ruby
mit
19
main
4,491
# frozen_string_literal: true require 'fileutils' module TsSchema class SchemaGenerator attr_accessor :config, :models def initialize(config = nil) @config = config || TsSchema::Configuration.new @config.field_overrides = @config.field_overrides.stringify_keys @config.field_type_overrides...
github
aviemet/ts_schema
https://github.com/aviemet/ts_schema
lib/ts_schema/configuration.rb
Ruby
mit
19
main
1,252
# frozen_string_literal: true require "pathname" module TsSchema class Configuration DEFAULTS = { case: :camel, output: -> { Rails.root.join('app', 'assets', 'javascripts', 'schema.d.ts') }, auto_generate: true, types: ->{ YAML.load_file("#{File.expand_path(__dir__)}/conversion_table.yml...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
electric_sheep.gemspec
Ruby
mit
19
master
2,857
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'electric_sheep/version' Gem::Specification.new do |spec| spec.name = "electric_sheep" spec.version = ElectricSheep::VERSION spec.authors = [ "Be...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
Guardfile
Ruby
mit
19
master
243
guard :minitest do # with Minitest::Spec watch(%r{^spec/(.*)_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^spec/spec_helper\.rb$}) { 'spec' } watch(%r{^spec/support/(.*)\.rb$}) { 'spec' } end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
Rakefile
Ruby
mit
19
master
288
require "bundler/gem_tasks" require 'rake/testtask' require 'rubocop/rake_task' Rake::TestTask.new do |t| t.libs << 'spec' t.pattern = "spec/**/*_spec.rb" end RuboCop::RakeTask.new do |task| task.patterns = ['lib/**/*.rb', 'spec/**/*.rb'] end task :default => [:test, :rubocop]
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep.rb
Ruby
mit
19
master
1,555
require 'electric_sheep/version' require 'git_rev' require 'active_support' require 'active_support/core_ext' require 'electric_sheep/queue' require 'electric_sheep/rescueable' require 'electric_sheep/config' require 'electric_sheep/spawn' require 'electric_sheep/helpers' require 'electric_sheep/crypto' require 'elect...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/command.rb
Ruby
mit
19
master
1,190
module ElectricSheep module Command extend ActiveSupport::Concern include Runnable attr_reader :shell delegate :stat_file, :stat_directory, :stat_filesystem, to: :shell def initialize(job, logger, shell, input, metadata) @job = job @logger = logger @shell = shell @input ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/config.rb
Ruby
mit
19
master
270
module ElectricSheep class Config include Queue attr_reader :hosts attr_accessor :encryption_options, :decryption_options, :ssh_options def initialize @hosts = Metadata::Hosts.new @ssh_options = Metadata::SshOptions.new end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/notifier.rb
Ruby
mit
19
master
433
module ElectricSheep module Notifier extend ActiveSupport::Concern include Agent attr_reader :job, :hosts def initialize(job, hosts, logger, metadata) @job = job @logger = logger @metadata = metadata @hosts = hosts end module ClassMethods def register(options =...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/spawn.rb
Ruby
mit
19
master
640
require 'posix/spawn' module ElectricSheep module Spawn class << self def exec(cmd, logger = nil) result = {} child = POSIX::Spawn::Child.new(cmd) result[:out] = child_output(child, logger) result[:err] = child_error(child) result[:exit_status] = child.status ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/runnable.rb
Ruby
mit
19
master
688
module ElectricSheep module Runnable extend ActiveSupport::Concern include Agent attr_reader :input protected def file_resource(host, opts = {}) file_system_resource(:file, host, opts) end def directory_resource(host, opts = {}) file_system_resource(:directory, host, opts) ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources.rb
Ruby
mit
19
master
432
require 'electric_sheep/resources/resource' require 'electric_sheep/resources/hosted' require 'electric_sheep/resources/stat' require 'electric_sheep/resources/named' require 'electric_sheep/resources/extended' require 'electric_sheep/resources/file_system' require 'electric_sheep/resources/directory' require 'electric...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/transport.rb
Ruby
mit
19
master
2,335
module ElectricSheep module Transport extend ActiveSupport::Concern include Runnable def initialize(job, logger, hosts, input, metadata) @job = job @logger = logger @input = input @metadata = metadata @hosts = hosts end def run! in_sessions do input.lo...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/rescueable.rb
Ruby
mit
19
master
325
module ElectricSheep module Rescueable def logger raise 'Undefined logger, please override' end def rescued(fail_on_error = false, &_) yield false rescue Exception => ex logger.error ex.message logger.debug ex Kernel.exit 1 if fail_on_error true end end...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/master.rb
Ruby
mit
19
master
4,577
module ElectricSheep class Master attr_reader :spawners, :should_stop def initialize(options) @config = options[:config] @logger = options[:logger] @workers = [1, options[:workers]].compact.max @pidfile = File.expand_path(options[:pidfile]) if options[:pidfile] @spawners = Spawn...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/dsl.rb
Ruby
mit
19
master
4,158
module ElectricSheep class Dsl module RaiseOnMethodMissing # rubocop:disable MethodMissing def method_missing(m, *_) raise SheepException, "Unknown command '#{m}' in Sheepfile" end end module Encrypted def encrypted(value) Metadata::Encrypted.new(@config.decryption...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/cli.rb
Ruby
mit
19
master
4,793
require 'thor' require 'electric_sheep' module ElectricSheep module CryptoCLI extend ActiveSupport::Concern included do desc 'encrypt SECRET', 'Encrypt SECRET using the provided public key' option :key, aliases: %w(-k), required: true, desc: 'The GPG public...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/runner.rb
Ruby
mit
19
master
2,770
module ElectricSheep module Runner class SingleRun include Rescueable attr_reader :job attr_reader :logger def initialize(config, logger, job) @config = config @logger = logger @job = job end def run! has_been_rescued = rescue_job noti...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/queue.rb
Ruby
mit
19
master
275
module ElectricSheep module Queue delegate :size, to: :queue def add(item) queue << item item end def iterate queue.each do |item| yield item if block_given? end end def queue @queue ||= [] end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/agent.rb
Ruby
mit
19
master
207
module ElectricSheep module Agent extend ActiveSupport::Concern include Metadata::Options attr_reader :logger protected def option(name) @metadata.send(name) end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/agents.rb
Ruby
mit
19
master
1,929
require 'electric_sheep/agent' require 'electric_sheep/runnable' require 'electric_sheep/command' require 'electric_sheep/transport' module ElectricSheep module Agents module Register AGENT_TYPES = [:command, :notifier, :transport].freeze class << self delegate :defaults_for, to: :store ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata.rb
Ruby
mit
19
master
763
require 'electric_sheep/metadata/options' require 'electric_sheep/metadata/base' require 'electric_sheep/metadata/configured' require 'electric_sheep/metadata/typed' require 'electric_sheep/metadata/monitor' require 'electric_sheep/metadata/crypto_options' require 'electric_sheep/metadata/encrypted' require 'electric_s...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/crypto.rb
Ruby
mit
19
master
4,557
require 'openssl' require 'base64' require 'fileutils' module ElectricSheep module Crypto class << self def gpg GPG end end module GPG module Encryptor include Helpers::ShellSafe BASE_COMMAND = 'gpg --batch'.freeze def initialize(executor) @e...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/logger.rb
Ruby
mit
19
master
319
require 'colorize' require 'lumberjack' module Lumberjack class Template alias boring_call call COLORS = [ :cyan, :green, :yellow, :red, :red, :white ].freeze define_method :call do |entry| boring_call(entry).send(COLORS[entry.severity]) end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/interactors/base.rb
Ruby
mit
19
master
1,171
module ElectricSheep module Interactors class Base delegate :expand_path, to: :directories attr_reader :session, :directories def initialize(host, job, logger = nil) @host = host @job = job @logger = logger @directories = Helpers::Directories.new(host, job, self...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/interactors/ssh_interactor.rb
Ruby
mit
19
master
5,542
module ElectricSheep module Interactors class SshInteractor < Base include ShellStat include Helpers::ShellSafe HOST_KEY_VERIFIERS = { standard: :very, strict: :secure }.freeze def initialize(host, job, user, logger = nil) super(host, job, logger) @user = user end ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/interactors/shell_stat.rb
Ruby
mit
19
master
484
module ElectricSheep module Interactors module ShellStat extend ActiveSupport::Concern included do alias_method :stat_file, :stat_filesystem alias_method :stat_directory, :stat_filesystem end def stat_filesystem(resource) exec("du -bs #{expand_path(resource.path)}...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/interactors/shell_interactor.rb
Ruby
mit
19
master
292
module ElectricSheep module Interactors class ShellInteractor < Base include ShellStat def exec(*cmd) _exec(*cmd) do |cmd_as_string| Spawn.exec(cmd_as_string, @logger) end end protected def build_session; end end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources/file_system.rb
Ruby
mit
19
master
283
module ElectricSheep module Resources class FileSystem < Resource include Named include Hosted def initialize(opts = {}) if (path = opts.delete(:path)) opts.merge!(normalize_path(path)) end super end end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources/named.rb
Ruby
mit
19
master
1,035
require 'pathname' module ElectricSheep module Resources module Named extend ActiveSupport::Concern included do option :parent, required: true option :basename, required: true end def path ::File.join [parent, name].compact end def name name_...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources/extended.rb
Ruby
mit
19
master
267
module ElectricSheep module Resources module Extended extend ActiveSupport::Concern include Named included do option :extension end protected def name_items (super << extension) end end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources/s3_object.rb
Ruby
mit
19
master
534
module ElectricSheep module Resources class S3Object < Resource include Extended option :directory option :bucket, required: true option :region def initialize(opts = {}) if (path = opts.delete(:path)) opts.merge!(normalize_path(path)) end super ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources/resource.rb
Ruby
mit
19
master
776
module ElectricSheep module Resources class Resource < Metadata::Base include Metadata::Typed attr_reader :timestamp, :transient alias timestamp? timestamp alias transient? transient def timestamp!(origin) @timestamp = if origin.timestamp? origin.time...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources/stat.rb
Ruby
mit
19
master
303
module ElectricSheep module Resources class Stat extend ActiveSupport::NumberHelper attr_accessor :size def initialize(size = nil) @size = size end def humanize size && self.class.number_to_human_size(size) || 'Unknown' end end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/resources/hosted.rb
Ruby
mit
19
master
218
module ElectricSheep module Resources module Hosted extend ActiveSupport::Concern delegate :to_location, to: :host included do option :host, required: true end end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/util/ssh_host_keys.rb
Ruby
mit
19
master
3,898
require 'electric_sheep/spawn' require 'fileutils' require 'table_print' require 'openssl' module ElectricSheep module Util class SshHostKeys class << self include Helpers::ShellSafe def refresh(config, logger, force) keys = config.hosts.all.map do |_, host| fetch_ser...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/delete_source.rb
Ruby
mit
19
master
353
module ElectricSheep module Commands module DeleteSource extend ActiveSupport::Concern included do option :delete_source end protected def delete_source!(input_path) return unless option(:delete_source) shell.exec "rm -rf #{input_path}" input.transi...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/encrypt.rb
Ruby
mit
19
master
1,390
module ElectricSheep module Commands class Encrypt include Command include Helpers::ShellSafe include DeleteSource register as: 'encrypt' option :public_key, required: true def perform! logger.info "Encrypting \"#{input.basename}\"" file_resource(host, extens...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/database.rb
Ruby
mit
19
master
299
require 'electric_sheep/commands/database/mongodb_dump' require 'electric_sheep/commands/database/sql_dump' require 'electric_sheep/commands/database/mysql_dump' require 'electric_sheep/commands/database/postgresql_dump' module ElectricSheep module Commands module Database end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/database/sql_dump.rb
Ruby
mit
19
master
451
module ElectricSheep module Commands module Database module SQLDump extend ActiveSupport::Concern include Command included do option :user option :password, secret: true option :exclude_tables end def excluded_tables tables = ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/database/mysql_dump.rb
Ruby
mit
19
master
1,748
module ElectricSheep module Commands module Database class MySQLDump include SQLDump register as: 'mysql_dump' option :user option :password, secret: true def perform! logger.info "Creating a dump of the \"#{input.basename}\" " \ 'My...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/database/mongodb_dump.rb
Ruby
mit
19
master
1,383
require 'json' module ElectricSheep module Commands module Database class MongoDBDump include Command register as: 'mongodb_dump' option :user option :password, secret: true def perform! logger.info "Creating a dump of the \"#{input.basename}\" " \ ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/database/postgresql_dump.rb
Ruby
mit
19
master
2,226
module ElectricSheep module Commands module Database class PostgreSQLDump include SQLDump register as: 'postgresql_dump' option :sudo_as option :login_host def perform! logger.info "Creating a dump of the \"#{input.basename}\" " \ 'P...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/commands/compression/tar_gz.rb
Ruby
mit
19
master
1,245
module ElectricSheep module Commands module Compression class TarGz include ElectricSheep::Command include DeleteSource register as: 'tar_gz' option :exclude def perform! logger.info "Compressing #{input.path} to #{input.basename}.tar.gz" file_re...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/helpers/directories.rb
Ruby
mit
19
master
1,055
require 'pathname' require 'fileutils' module ElectricSheep module Helpers class Directories include ShellSafe def initialize(host, job, interactor) @host = host @job = job @interactor = interactor end def mk_job_directory! safe = shell_safe(job_directory...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/helpers/fs_util.rb
Ruby
mit
19
master
1,268
module ElectricSheep module Helpers module FSUtil class << self TMPDIR = '/tmp'.freeze def tempname t = Time.now.strftime('%Y%m%d') "tmp#{t}-#{Process.pid}-#{rand(0x100000000).to_s(36)}" end def tempdir(executor, &block) path = expand_path(exec...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/shell/remote_shell.rb
Ruby
mit
19
master
600
module ElectricSheep module Shell class RemoteShell < Base def initialize(host, job, input, user, logger) # rubocop:enable Metrics/ParameterLists super(host, job, input, logger) @user = user end def interactor @interactor ||= Interactors::SshInteractor.new( ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/shell/base.rb
Ruby
mit
19
master
927
module ElectricSheep module Shell class Base include Helpers::ShellSafe alias safe shell_safe delegate :expand_path, :exec, to: :interactor delegate :stat_file, :stat_directory, :stat_filesystem, to: :interactor attr_reader :interactor, :host, :input def initialize(host, job...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/shell/local_shell.rb
Ruby
mit
19
master
376
require 'session' module ElectricSheep module Shell class LocalShell < Base def perform!(metadata) @logger.info 'Starting a local shell session' super end protected def interactor @interactor ||= Interactors::ShellInteractor.new( @host, @job, ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/notifiers/template.rb
Ruby
mit
19
master
1,654
require 'erb' module ElectricSheep module Notifiers class Template def initialize(type) # Trim mode omit newline for lines starting with <% and ending in %> @renderer = ERB.new(template(type), nil, '<>') end def render(context) @renderer.result(Binding.new(context).get_...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/notifiers/email.rb
Ruby
mit
19
master
1,732
require 'mail' require 'premailer' module ElectricSheep module Notifiers class Email include Notifier register as: 'email' option :from, required: true option :to, required: true # Delivery method option :using, required: true # Delivery options option :with ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/transports/s3.rb
Ruby
mit
19
master
3,749
require 'fog' module ElectricSheep module Transports class S3 include Transport register as: 's3' option :access_key_id, required: true option :secret_key, required: true, secret: true option :region DEFAULT_REGION = 'us-east-1'.freeze def remote_interactor @...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/transports/scp.rb
Ruby
mit
19
master
481
require 'net/scp' module ElectricSheep module Transports class SCP include Transport register as: 'scp' option :as def remote_interactor @remote_interactor ||= Interactors::SshInteractor.new( input.local? ? host(option(:to)) : input.host, @job, opt...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/encrypted.rb
Ruby
mit
19
master
291
module ElectricSheep module Metadata class Encrypted def initialize(options, cipher_text) @options = options @cipher_text = cipher_text end def decrypt Crypto.gpg.string(Spawn).decrypt(@options.with, @cipher_text) end end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/shell.rb
Ruby
mit
19
master
368
module ElectricSheep module Metadata class Shell < Configured include Pipe include Monitor def validate iterate do |command| unless command.validate errors.add :base, "Invalid command \"#{command.agent}\"", command.errors end ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/job.rb
Ruby
mit
19
master
1,098
module ElectricSheep module Metadata class Job < Configured include Pipe include Monitor option :id, required: true option :description option :private_key option :private_key_data attr_reader :starts_with def start_with!(resource) @starts_with = resource...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/schedule.rb
Ruby
mit
19
master
2,206
require 'parse-cron' module ElectricSheep module Metadata module Schedule class Base < Metadata::Base attr_reader :scheduled_at def initialize(*args) super update! end def expired? Time.now >= scheduled_at end def update!; end...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/base.rb
Ruby
mit
19
master
1,108
module ElectricSheep module Metadata class Base include Options def initialize(opts = {}) @options = opts end def errors @errors ||= Errors.new end def validate options.each do |option, opts| ensure_present(option) if opts[:required] ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/options.rb
Ruby
mit
19
master
1,059
module ElectricSheep module Metadata module Options extend ActiveSupport::Concern def options self.class.options end def option(name) return unless option?(name) decrypt(fetch_option(name)) end def option?(method) options.include?(method) ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/remote_shell.rb
Ruby
mit
19
master
399
module ElectricSheep module Metadata class RemoteShell < Shell option :host, required: true option :user, required: true def validate ensure_known_host super end protected def ensure_known_host return unless host && config.hosts.get(host).nil? ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/pipe.rb
Ruby
mit
19
master
3,427
module ElectricSheep module Metadata module Pipe include Queue include Monitor attr_reader :input, :start_location, :last_product def pipelined(resource, parent = nil, &block) @report = parent.report unless parent.nil? init(resource) monitored do iterate...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/crypto_options.rb
Ruby
mit
19
master
435
module ElectricSheep module Metadata module CryptoOptions extend ActiveSupport::Concern included do option :with, required: true end end class EncryptOptions < Base include CryptoOptions # TODO: Validate the provided key is a private key end class DecryptOp...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/configured.rb
Ruby
mit
19
master
207
module ElectricSheep module Metadata class Configured < Base attr_reader :config def initialize(config, opts = {}) @config = config super(opts) end end end end
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/hosts.rb
Ruby
mit
19
master
1,568
module ElectricSheep module Metadata class BaseHost < Base option :working_directory def working_directory option(:working_directory) || '$HOME/.electric_sheep' end end class Host < BaseHost option :id, required: true # TODO: Validate hostname is valid option ...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/monitor.rb
Ruby
mit
19
master
566
module ElectricSheep module Metadata module Monitor extend ActiveSupport::Concern included do attr_reader :execution_time, :status end def monitored start = Time.now output = yield if block_given? @status = :success output rescue Exception =>...
github
jefmathiot/electric_sheep
https://github.com/jefmathiot/electric_sheep
lib/electric_sheep/metadata/transport.rb
Ruby
mit
19
master
280
module ElectricSheep module Metadata class Transport < Agent include Monitor option :action, required: true option :to, required: true def copy? action == :copy end def move? action == :move end end end end