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
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/recipes/api.rb
Ruby
mit
233
master
795
class Recipes::Api < Rails::AppBuilder def ask api_support = answer(:api) { Ask.confirm("Do you want to enable API support?") } set :api, api_support end def create add_power_api if get(:api) end def install ask create end def installed? gem_exists?(/power_api/) end private...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/recipes/mjml.rb
Ruby
mit
233
master
847
class Recipes::Mjml < Rails::AppBuilder def create return if get(:email_service).to_s.downcase.to_sym == :none gather_gem 'mjml-rails' after(:gem_install) do run 'yarn add mjml' mjml_config end end def installed? gem_exists?(/mjml-rails/) end def install create end end...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/recipes/file_storage.rb
Ruby
mit
233
master
3,477
class Recipes::FileStorage < Rails::AppBuilder def ask storages = { active_storage: 'ActiveStorage', shrine: 'Shrine', none: 'None, thanks' } storage = answer(:storage) do storages.keys[Ask.list('Which storage are you going to use?', storages.values)] end set(:storage, st...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/recipes/coverage.rb
Ruby
mit
233
master
895
class Recipes::Coverage < Rails::AppBuilder def create load_gems configure_rails_helper append_to_file('.gitignore', "/coverage/*\n") recipe = self after(:vite_install) do recipe.setup_coverage_dependencies end end def installed? gem_exists?(/simplecov/) end def install ...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/recipes/devise.rb
Ruby
mit
233
master
1,547
class Recipes::Devise < Rails::AppBuilder def ask use_devise = answer(:devise) do Ask.confirm "Do you want to use Devise for authentication? (required for ActiveAdmin)" end if use_devise set(:authentication, use_devise) ask_for_devise_model end end def create add_devise if ...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/recipes/seeds.rb
Ruby
mit
233
master
860
class Recipes::Seeds < Rails::AppBuilder def create recipe = self copy_env_seed_file if selected?(:admin_mode) after(:admin_install, wrap_in_action: :seeds_config) do recipe.override_seed_files end end end def install copy_env_seed_file admin = load_recipe(:admin) ...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/recipes/cleanup.rb
Ruby
mit
233
master
269
class Recipes::Cleanup < Rails::AppBuilder def create erase_comments "config/application.rb" erase_comments "config/environments/production.rb" erase_comments "config/environments/test.rb" erase_comments "config/environments/development.rb" end end
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/generators/application.rb
Ruby
mit
233
master
712
require "rails/generators" require "rails/generators/rails/app/app_generator" require "inquirer" require "potassium/recipe" module Potassium class ApplicationGenerator < Rails::Generators::AppGenerator class << self attr_accessor :cli_options end def finish_template require_relative "../help...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/generators/recipe.rb
Ruby
mit
233
master
625
require "rails/generators" require "rails/generators/rails/app/app_generator" require "inquirer" require "potassium/recipe" class Rails::AppBuilder include Rails::ActionMethods end module Potassium class RecipeGenerator < Rails::Generators::NamedBase class << self attr_accessor :cli_options end ...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/cli/commands/install.rb
Ruby
mit
233
master
2,004
require 'levenshtein' require 'inquirer' require 'potassium/generators/recipe' require 'potassium/recipe' module Potassium::CLI desc "Installs a new feature or library" command :install do |c| c.switch "force", desc: "Whether to force the recipe installation", default_value: false c.action do |...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/cli/commands/create.rb
Ruby
mit
233
master
1,291
require 'potassium/cli_options' module Potassium::CLI extend Potassium::CliOptions desc 'Create a new Potassium Rails project.' arg 'app_path' command :create do |c| c.default_desc 'Create a new project.' create_options.each { |opts| c.send(opts.delete(:type), opts.delete(:name), opts) } c.action...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/variable-helpers.rb
Ruby
mit
233
master
460
module VariableHelpers def set(key, value) @_data ||= {} @_data[key] = value end def selected?(key, value = nil) value ? equals?(key, value) : get(key) end def get(key) @_data ||= {} @_data[key] end def equals?(key, value) get(key) == value end def exists?(key) equals?(...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/callback-helpers.rb
Ruby
mit
233
master
1,352
module CallbackHelpers def after(action_name, wrap_in_action: false, &action) ensure_callbacks_variables_for_action(action_name) if get(:executed_actions).include?(action_name) instance_exec(&wrap_action(action, wrap_in_action)) else add_callback(action_name, :after, wrap_action(action, wrap_...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/template-dsl.rb
Ruby
mit
233
master
915
module TemplateDSL def self.extend_dsl(object, source_path: __FILE__) require_relative './template-helpers' require_relative './variable-helpers' require_relative './environment-helpers' require_relative './gem-helpers' require_relative './docker-helpers' require_relative './callback-helpers' ...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/docker-helpers.rb
Ruby
mit
233
master
1,156
class DockerHelpers def initialize(compose_path) @compose_path = compose_path @compose = YAML.safe_load(File.read(compose_path)) end def add_link(target_service, linked_service) service = @compose['services'][target_service] unless service['links'].is_a? Array service['links'] = [] end ...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/gem-helpers.rb
Ruby
mit
233
master
1,898
module GemHelpers def gem_exists?(regexp) File.open("Gemfile").each_line.any? { |line| line =~ regexp } end def gather_gem(name, *attributes) ensure_variable(:gems, {}) current_gem_groups = get(:current_gem_groups) || [:base] get(:gems)[current_gem_groups] ||= [] get(:gems)[current_gem_group...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/info-helpers.rb
Ruby
mit
233
master
209
module InfoHelpers def success(message) say(message, :green) true end def error(message) say(message, :red) false end def info(message) say(message, :yellow) true end end
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/environment-helpers.rb
Ruby
mit
233
master
347
module EnvironmentHelpers def set_env(key, value) ensure_variable(:default_env, {}) get(:default_env)[key] = value ENV[key] = value end def get_env(key) ensure_variable(:default_env, {}) get(:default_env)[key] end def default_env(hash = {}) hash.each do |key, value| set_env(key...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/rubocop-helpers.rb
Ruby
mit
233
master
215
require "rubocop" module RubocopHelpers def run_rubocop options, paths = RuboCop::Options.new.parse(["-A"]) runner = RuboCop::Runner.new(options, RuboCop::ConfigStore.new) runner.run(paths) end end
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/readme-helpers.rb
Ruby
mit
233
master
2,140
module ReadmeHelpers def add_readme_section(header, section, iterpolation_values = {}) section_data = readme_section_data(header, section, iterpolation_values) add_readme_header(header, iterpolation_values) insert_into_readme(section_data[:header_title]) do <<~HERE ### #{section_data[:titl...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/template-helpers.rb
Ruby
mit
233
master
2,591
module TemplateHelpers def app_name @app_name || app_name_from_file end def node_version "#{Potassium::NODE_VERSION}.x" end def ruby_version Semantic::Version.new(Potassium::RUBY_VERSION).instance_eval { "#{major}.#{minor}" } end def load_recipe(recipe_name) @recipes ||= {} @recipes...
github
platanus/potassium
https://github.com/platanus/potassium
lib/potassium/helpers/answer-helpers.rb
Ruby
mit
233
master
435
module AnswerHelpers def answer(key, &fallback) found = get(:answers)[key] found.nil? ? fallback.call : found end def load_answers set(:answers, extract_answers(self.class.cli_options)) end private def extract_answers(options) options.except( "version-check", :"version-check", ...
github
palkan/acli
https://github.com/palkan/acli
Rakefile
Ruby
mit
233
master
1,911
require "fileutils" MRUBY_VERSION = "3.0.0" task :mruby do sh "git clone --branch=#{MRUBY_VERSION} --depth=1 https://github.com/mruby/mruby" end APP_NAME = ENV["APP_NAME"] || "acli" APP_ROOT = ENV["APP_ROOT"] || Dir.pwd # avoid redefining constants in mruby Rakefile mruby_root = File.expand_path(ENV["MRUBY_ROOT"] ...
github
palkan/acli
https://github.com/palkan/acli
.rbnext.rb
Ruby
mit
233
master
606
module MRubyNext refine MRuby::Gem::Specification do # Add transpiled files to the list of Ruby files instead of source files def setup_ruby_next!(next_dir: ".rbnext") lib_root = File.join(@dir, "mrblib") next_root = Pathname.new(next_dir).absolute? ? next_dir : File.join(lib_root, next_dir) ...
github
palkan/acli
https://github.com/palkan/acli
mrbgem.rake
Ruby
mit
233
master
1,096
require_relative ".rbnext" using MRubyNext MRuby::Gem::Specification.new("acli") do |spec| spec.license = "MIT" spec.author = "Vladimir Dementyev" spec.summary = "acli" spec.bins = ["acli"] spec.setup_ruby_next! spec.add_dependency "mruby-exit", core: "mruby-exit" spec.add_dependency "mruby-string-...
github
palkan/acli
https://github.com/palkan/acli
build_config.rb
Ruby
mit
233
master
1,595
def gem_config(conf) conf.gembox 'default' # be sure to include this gem (the cli app) conf.gem(File.expand_path(File.dirname(__FILE__))) libressl_dir = ENV["LIBRESSL_DIR"] libressl_dir ||= if RUBY_PLATFORM =~ /darwin/i "#{ENV["HOMEBREW_PREFIX"] || "/usr/local" }/opt/libressl" else # Ou...
github
palkan/acli
https://github.com/palkan/acli
etc/server.rb
Ruby
mit
233
master
2,096
#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "rails", "~> 6.0" gem "puma", "~> 4.0" end require "rails" require "global_id" require "action_controller/railtie" require "action_view/railtie" require "action_cable/engine" require...
github
palkan/acli
https://github.com/palkan/acli
test/client_test.rb
Ruby
mit
233
master
1,402
module Acli class ClientTest < MTest::Unit::TestCase class FakeSocket def close @closed = true end def closed? @closed end end def test_handle_incoming_ping client = Client.new("", nil) assert_nil client.last_ping_at client.handle_incoming(%({"t...
github
palkan/acli
https://github.com/palkan/acli
test/commands_test.rb
Ruby
mit
233
master
2,542
module Acli class TestCommands < MTest::Unit::TestCase class TestClient attr_reader :identifier attr_accessor :last_seen_stream, :last_seen_epoch def initialize(identifier = "test") @identifier = identifier end def close @closed = true end def closed? ...
github
palkan/acli
https://github.com/palkan/acli
test/utils_test.rb
Ruby
mit
233
master
1,368
module Acli class UtilsTest < MTest::Unit::TestCase def test_serialize assert_equal true, Utils.serialize('t') assert_equal true, Utils.serialize('y') assert_equal true, Utils.serialize('yes') assert_equal false, Utils.serialize('f') assert_equal false, Utils.serialize('n') as...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/commands.rb
Ruby
mit
233
master
4,352
module Acli class Commands COMMANDS = { "s" => "subscribe", "s+" => "isubscribe", "p" => "perform", "p+" => "iperform", "h" => "history", "?" => "print_help", "q" => "quit" } def self.is?(str) str =~ /^\\[\w\?]+\+?/ end attr_reader :client, :logger...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/coders.rb
Ruby
mit
233
master
472
module Acli module Coders module JSON def self.encode(data) data.to_json end def self.decode(str) ::JSON.parse(str) end def self.frame_format :text_frame end end module Msgpack def self.encode(data) MessagePack.pack(data) e...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/socket.rb
Ruby
mit
233
master
2,019
module Acli class Socket attr_reader :ws, :tls, :logger alias tls? tls def initialize(uri, headers: nil, protocol: "actioncable-v1-json", logger: NoopLogger.new) @logger = logger @tls = uri.scheme == "https" connection_class = tls? ? WebSocket::WssConnection : WebSocket::WsConnection ...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/poller.rb
Ruby
mit
233
master
1,170
module Acli class Poller attr_reader :poll, :stdin, :socket_fd, :client def initialize @poll = Poll.new @stdin = poll.add(STDIN_FILENO, Poll::In) end def add_client(client) @client = client @socket_fd = client.socket.setup_poller(poll) end def listen expect_st...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/utils.rb
Ruby
mit
233
master
1,250
module Acli module Utils def exit_with_error(e, code = 1) puts "Error: #{e.message}\n#{e.backtrace.join("\n")}" exit code end def prompt(message = "Type something: ") print message STDIN.gets.chomp end def serialize(str) case str when /\A(true|t|yes|y)\z/i ...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/core_ext.rb
Ruby
mit
233
master
911
# frozen_string_literal: true # Generated by Ruby Next v0.12.0 using the following command: # # ruby-next core_ext --name=deconstruct --name=patternerror -o mrblib/acli/core_ext.rb # class Array def deconstruct self end end class Hash def deconstruct_keys(_) self end end class Object class NoMat...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/cli.rb
Ruby
mit
233
master
3,699
module Acli DEFAULT_CABLE_PATH = "/cable" class Error < StandardError; end class ClonnectionClosedError < Error; end class Cli attr_reader :logger def initialize(argv) @options = parse_options(argv) end def run @logger = @options.delete(:debug) ? DebugLogger.new : NoopLogger.new ...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/websockets_ext.rb
Ruby
mit
233
master
1,522
module WebSocket class WsConnection attr_accessor :custom_headers, :protocol, :logger def http_handshake key = WebSocket.create_key headers = [ "Host: #{@host}:#{@port}", "Connection: Upgrade", "Upgrade: websocket", "Sec-WebSocket-Version: 13", "Sec-WebSoc...
github
palkan/acli
https://github.com/palkan/acli
mrblib/acli/client.rb
Ruby
mit
233
master
3,712
module Acli class Client attr_reader :identifier, :socket, :commands, :quit_after, :quit_after_messages, :channel_to_subscribe, :connected, :url, :coder, :logger, :pong alias connected? connected attr_accessor :received_count, :last_ping_at, :last_seen_stream, :last_seen_...
github
palkan/acli
https://github.com/palkan/acli
bintest/acli.rb
Ruby
mit
233
master
9,457
require_relative "../mrblib/acli/version" require "socket" require "json" require "childprocess" BIN_PATH = File.join(File.dirname(__FILE__), "../mruby/bin/acli") class AcliProcess attr_reader :process, :wio, :rio def initialize(*args, bin: BIN_PATH) @rio, @wio = IO.pipe @process = ChildProcess.build(bin...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
pallets.gemspec
Ruby
mit
233
master
857
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pallets/version' Gem::Specification.new do |spec| spec.name = 'pallets' spec.version = Pallets::VERSION spec.authors = ['Andrei Horak'] spec.email = ['linkynd...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
Gemfile
Ruby
mit
233
master
238
source 'https://rubygems.org' gemspec gem 'rake' gem 'appsignal' group :test do gem 'rspec' # Better RSpec formatting gem 'fuubar' end group :development, :test do gem 'pry-byebug' # Time travel in style gem 'timecop' end
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/configuration_spec.rb
Ruby
mit
233
master
646
require 'spec_helper' describe Pallets::Configuration do describe '#pool_size' do before do subject.concurrency = 12 end context 'when explicitly set' do before do subject.pool_size = 123 end it 'returns the set value' do expect(subject.pool_size).to eq(123) ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/manager_spec.rb
Ruby
mit
233
master
3,893
require 'spec_helper' describe Pallets::Manager do # Be explicit in the number of workers that we test subject { Pallets::Manager.new(concurrency: 2) } let(:scheduler_class) { class_double('Pallets::Scheduler').as_stubbed_const } let(:scheduler) { instance_spy('Pallets::Scheduler') } let(:worker_class) { cl...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/spec_helper.rb
Ruby
mit
233
master
207
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'pallets' require 'pallets/cli' require 'pallets/middleware/appsignal_instrumenter' require 'timecop' Pallets.logger.level = Logger::FATAL
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/context_spec.rb
Ruby
mit
233
master
1,090
require 'spec_helper' describe Pallets::Context do it 'is a Hash' do expect(subject).to be_a(Hash) end describe '#[]=' do it 'buffers the given value' do subject['foo'] = 'bar' expect(subject.buffer).to match('foo' => 'bar') end it 'does not alter the Hash interface' do subjec...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/util_spec.rb
Ruby
mit
233
master
898
require 'spec_helper' describe Pallets::Util do subject { described_class } describe '.constantize' do context 'with valid input' do { 'Pallets' => Pallets, '::Pallets' => ::Pallets, 'Pallets::Util' => Pallets::Util, 'Pa...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/cli_spec.rb
Ruby
mit
233
master
6,444
require 'spec_helper' describe Pallets::CLI do # Stub the global state so we can test what values are set, while allowing # the CLI to read the default values let(:configuration) do instance_spy('Pallets::Configuration', backend: :redis, backend_args: {}, blocking_timeout: 5, concurre...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/graph_spec.rb
Ruby
mit
233
master
2,363
require 'spec_helper' describe Pallets::Graph do describe '#add' do it 'adds node and its dependencies' do subject.add('Foo', ['Bar']) expect(subject.send(:nodes)).to match('Foo' => ['Bar']) end context 'with a node that already exists' do before do subject.add('Foo', []) ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/pool_spec.rb
Ruby
mit
233
master
752
require 'spec_helper' describe Pallets::Pool do it 'initializes the correct number of items' do pool = Pallets::Pool.new(10) { :foo } expect(pool.size).to eq(10) end it 'raises an error if no block is provided' do expect { Pallets::Pool.new(10) }.to raise_error(ArgumentError) end describe '#exe...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/logger_spec.rb
Ruby
mit
233
master
3,313
require 'spec_helper' describe Pallets::Logger do subject { Pallets::Logger.new(output) } before do subject.formatter = formatter end let(:output) { StringIO.new } let(:formatter) { instance_spy('Logger::Formatter') } { 'debug' => 'DEBUG', 'info' => 'INFO', 'warn' => 'WARN', 'error' ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/scheduler_spec.rb
Ruby
mit
233
master
3,370
require 'spec_helper' describe Pallets::Scheduler do subject { Pallets::Scheduler.new(manager, backend) } let(:manager) { instance_spy('Pallets::Manager') } let(:backend) { instance_spy('Pallets::Backends::Base') } describe '#start' do before do allow(Pallets.configuration).to receive(:scheduler_po...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/workflow_spec.rb
Ruby
mit
233
master
3,673
require 'spec_helper' describe Pallets::Workflow do let(:backend) { instance_spy('Pallets::Backends::Base') } let(:context_class) { class_double('Pallets::Context').as_stubbed_const } let(:context) { instance_spy('Pallets::Context', buffer: { foo: :bar }) } let(:context_hash) { { foo: :bar } } class TestWor...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/worker_spec.rb
Ruby
mit
233
master
14,262
require 'spec_helper' describe Pallets::Worker do subject { Pallets::Worker.new(manager, backend) } let(:manager) { instance_spy('Pallets::Manager') } let(:backend) { instance_spy('Pallets::Backends::Base') } describe '#start' do before do allow(Thread).to receive(:new).and_yield allow(subjec...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/dsl/workflow_spec.rb
Ruby
mit
233
master
4,742
require 'spec_helper' describe Pallets::DSL::Workflow do # Set the subject to workflow class that extends the DSL subject { Class.new(Pallets::Workflow) { extend Pallets::DSL::Workflow } } before do allow(Pallets.configuration).to receive(:max_failures).and_return(3) end describe '#task' do context...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/middleware/stack_spec.rb
Ruby
mit
233
master
1,176
require 'spec_helper' describe Pallets::Middleware::Stack do it 'is an Array' do expect(subject).to be_an(Array) end describe '#invoke' do # Records all events in the order they occur let(:rec) { [] } let(:block) { -> { rec << :block } } context 'with no middleware' do it 'calls the b...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/middleware/appsignal_instrumenter_spec.rb
Ruby
mit
233
master
2,936
require 'spec_helper' describe Pallets::Middleware::AppsignalInstrumenter do subject { described_class } describe '.call' do let(:worker) { double(id: 'foo') } let(:job) do { 'task_class' => 'Foo', 'workflow_class' => 'Bar' } end let(:context) do { 'foo' => 'bar' ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/middleware/job_logger_spec.rb
Ruby
mit
233
master
736
require 'spec_helper' describe Pallets::Middleware::JobLogger do subject { described_class } describe '.call' do let(:worker) { double(id: 'foo') } let(:job) { {} } let(:context) { {} } it 'yields to the block' do expect { |b| subject.call(worker, job, context, &b) }.to yield_control en...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/serializers/json_spec.rb
Ruby
mit
233
master
1,375
require 'spec_helper' describe Pallets::Serializers::Json do let(:json_class) { class_double('JSON').as_stubbed_const } it 'properly serializes and deserializes data' do expect(subject.load(subject.dump('foo' => 'bar'))).to eq('foo' => 'bar') end it 'properly serializes and deserializes context data' do ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/serializers/msgpack_spec.rb
Ruby
mit
233
master
1,366
require 'spec_helper' describe Pallets::Serializers::Msgpack do let(:msgpack_class) { class_double('MessagePack').as_stubbed_const } it 'properly serializes and deserializes data' do expect(subject.load(subject.dump('foo'))).to eq('foo') end it 'properly serializes and deserializes context data' do e...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
spec/backends/redis_spec.rb
Ruby
mit
233
master
12,330
require 'spec_helper' describe Pallets::Backends::Redis do subject do Pallets::Backends::Redis.new( blocking_timeout: 1, failed_job_lifespan: 100, failed_job_max_count: 1, job_timeout: 10, pool_size: 1, db: 15 ) end let(:redis) { ::Redis.new(db: 15) } before do ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
examples/do_groceries.rb
Ruby
mit
233
master
996
require 'pallets' class DoGroceries < Pallets::Workflow task 'EnterShop' task 'GetShoppingCart' => 'EnterShop' task 'PutMilk' => 'GetShoppingCart' task 'PutBread' => 'GetShoppingCart' task 'Pay' => ['PutMilk', 'PutBread'] task 'GoHome' => 'Pay' end class EnterShop < Pallets::Task def run puts "Enter...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
examples/config_savvy.rb
Ruby
mit
233
master
1,541
require 'pallets' class AnnounceProcessing def self.call(worker, job, context) puts "Starting to process job..." yield end end Pallets.configure do |c| # Harness 4 Pallets workers per process c.concurrency = 4 # The default one, though c.backend = :redis # Useful to connect to a hosted Redis in...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
examples/aliases.rb
Ruby
mit
233
master
551
require 'pallets' class Aliases < Pallets::Workflow task 'StartSmtpServer' task 'SendEmail', as: 'SayHello', depends_on: 'StartSmtpServer' task 'SendEmail', as: 'SayGoodbye', depends_on: 'StartSmtpServer' task 'StopSmtpServer' => ['SayHello', 'SayGoodbye'] end class StartSmtpServer < Pallets::Task def run ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
examples/appsignal.rb
Ruby
mit
233
master
599
require 'pallets' require 'pallets/middleware/appsignal_instrumenter' Appsignal.config = Appsignal::Config.new( File.expand_path(File.dirname(__FILE__)), "development" ) Appsignal.start Appsignal.start_logger Pallets.configure do |c| c.middleware << Pallets::Middleware::AppsignalInstrumenter end class Appsigna...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets.rb
Ruby
mit
233
master
1,695
require "pallets/version" require 'pallets/backends/base' require 'pallets/backends/redis' require 'pallets/configuration' require 'pallets/context' require 'pallets/dsl/workflow' require 'pallets/errors' require 'pallets/graph' require 'pallets/logger' require 'pallets/manager' require 'pallets/middleware/job_logger'...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/manager.rb
Ruby
mit
233
master
1,604
module Pallets class Manager attr_reader :workers, :scheduler def initialize(concurrency: Pallets.configuration.concurrency) @backend = Pallets.backend @workers = concurrency.times.map { Worker.new(self, @backend) } @scheduler = Scheduler.new(self, @backend) @lock = Mutex.new @n...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/cli.rb
Ruby
mit
233
master
3,980
require 'optparse' $stdout.sync = true module Pallets class CLI def initialize parse_options setup_signal_handlers @manager = Manager.new @signal_queue = Queue.new end def run Pallets.logger.info 'Starting the awesome Pallets <3' Pallets.logger.info "Running on #{RU...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/worker.rb
Ruby
mit
233
master
3,397
module Pallets class Worker def initialize(manager, backend) @manager = manager @backend = backend @current_job = nil @needs_to_stop = false @thread = nil end def start @thread ||= Thread.new { work } end def graceful_shutdown @needs_to_stop = true e...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/context.rb
Ruby
mit
233
master
357
module Pallets # Hash-like class that additionally holds a buffer for all write operations # that occur after initialization class Context < Hash def []=(key, value) buffer[key] = value super end def merge!(other_hash) buffer.merge!(other_hash) super end def buffer ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/workflow.rb
Ruby
mit
233
master
1,751
module Pallets class Workflow extend DSL::Workflow attr_reader :context def self.build(&block) Class.new(self).tap do |workflow_class| workflow_class.instance_eval(&block) end end def initialize(context_hash = {}) @id = nil # Passed in context hash needs to be bu...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/pool.rb
Ruby
mit
233
master
483
module Pallets class Pool def initialize(size) raise ArgumentError, 'Pool needs a block to initialize' unless block_given? @queue = Queue.new @size = size size.times { @queue << yield } end def size @queue.size end def execute raise ArgumentError, 'Pool needs...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/logger.rb
Ruby
mit
233
master
1,223
require 'logger' require 'time' module Pallets class Logger < ::Logger # Overwrite severity methods to add metadata capabilities %i[debug info warn error fatal unknown].each do |severity| define_method severity do |message| metadata = Thread.current[:pallets_log_metadata] return super(m...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/util.rb
Ruby
mit
233
master
637
module Pallets module Util extend self def generate_id(str) initials = str.gsub(/[^A-Z]+([A-Z])/, '\1')[0,3] random = SecureRandom.hex(5) "#{initials}#{random}" end def constantize(str) names = str.split('::') # Raise the "usual" NameError Object.const_get(str) i...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/graph.rb
Ruby
mit
233
master
962
require 'tsort' module Pallets class Graph include TSort def initialize @nodes = {} end def add(node, dependencies) raise WorkflowError, "Task #{node} is already defined in this workflow. "\ "Use `task '#{node}', as: 'FooBar'` to define an "\ ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/configuration.rb
Ruby
mit
233
master
2,452
module Pallets class Configuration # Backend to use for handling workflows attr_accessor :backend # Arguments used to initialize the backend attr_accessor :backend_args # Number of seconds to block while waiting for jobs attr_accessor :blocking_timeout # Number of workers to process job...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/scheduler.rb
Ruby
mit
233
master
1,305
module Pallets class Scheduler def initialize(manager, backend) @manager = manager @backend = backend @needs_to_stop = false @thread = nil end def start @thread ||= Thread.new { wait_initial_bit; work } end def shutdown @needs_to_stop = true return unle...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/errors.rb
Ruby
mit
233
master
312
module Pallets # Generic class for all Pallets-related errors class PalletsError < StandardError end # Raised when a workflow is not properly defined class WorkflowError < PalletsError end # Raised when Pallets needs to shutdown # NOTE: Do not rescue it! class Shutdown < Interrupt end end
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/backends/base.rb
Ruby
mit
233
master
937
module Pallets module Backends class Base # Picks a job that is ready for processing def pick raise NotImplementedError end def get_context(wfid) raise NotImplementedError end # Saves a job after successfully processing it def save(wfid, jid, job, contex...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/backends/redis.rb
Ruby
mit
233
master
4,238
require 'redis' module Pallets module Backends class Redis < Base QUEUE_KEY = 'queue' RELIABILITY_QUEUE_KEY = 'reliability-queue' RELIABILITY_SET_KEY = 'reliability-set' RETRY_SET_KEY = 'retry-set' GIVEN_UP_SET_KEY = 'given-up-set' WORKFLOW_QUEUE_KEY = 'workflow-queue:%s' ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/middleware/stack.rb
Ruby
mit
233
master
370
module Pallets module Middleware # Array-like class that acts like a stack and additionally provides the # means to wrap an operation with callable objects class Stack < Array def invoke(*args, &block) reverse.inject(block) do |memo, middleware| lambda { middleware.call(*args, &mem...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/middleware/appsignal_instrumenter.rb
Ruby
mit
233
master
1,452
require 'appsignal' module Pallets module Middleware class AppsignalInstrumenter extend Appsignal::Hooks::Helpers def self.call(worker, job, context) job_status = nil transaction = Appsignal::Transaction.create( SecureRandom.uuid, Appsignal::Transaction::BACKGROUN...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/middleware/job_logger.rb
Ruby
mit
233
master
1,043
module Pallets module Middleware class JobLogger def self.call(worker, job, context) start_time = current_time Pallets.logger.with_metadata(extract_metadata(worker.id, job)) do begin Pallets.logger.info 'Started' result = yield Pallets.logger.in...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/serializers/json.rb
Ruby
mit
233
master
208
require 'json' module Pallets module Serializers class Json < Base def dump(data) JSON.generate(data) end def load(data) JSON.parse(data) end end end end
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/serializers/msgpack.rb
Ruby
mit
233
master
375
require 'msgpack' module Pallets module Serializers class Msgpack < Base def dump(data) MessagePack.pack(data) end def load(data) # Strings coming from the backend are UTF-8 (Encoding.default_external) # while msgpack dumps ASCII-8BIT MessagePack.unpack(data.for...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/serializers/base.rb
Ruby
mit
233
master
511
module Pallets module Serializers class Base def dump(data) raise NotImplementedError end def load(data) raise NotImplementedError end alias_method :dump_job, :dump alias_method :load_job, :load # Context hashes only need their values (de)serialized ...
github
linkyndy/pallets
https://github.com/linkyndy/pallets
lib/pallets/dsl/workflow.rb
Ruby
mit
233
master
1,093
module Pallets module DSL module Workflow def task(arg=nil, as: nil, depends_on: nil, max_failures: nil, **kwargs) # Have to work more to keep Pallets' nice DSL valid in Ruby 2.7 arg = !kwargs.empty? ? kwargs : arg raise ArgumentError, 'Task is incorrectly defined. It must receive '\...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
Rakefile
Ruby
mit
233
master
955
# -*- coding: utf-8 -*- $:.unshift("/Library/RubyMotion/lib") $:.unshift("~/.rubymotion/rubymotion-templates") require "motion/project/template/ios" require "motion/project/template/gem/gem_tasks" require "bundler/setup" require "motion_print" require "webstub" Bundler.require Motion::Project::App.setup do |app| #...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
redpotion.gemspec
Ruby
mit
233
master
1,211
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "project/version" Gem::Specification.new do |spec| spec.name = "redpotion" spec.authors = ["Infinite Red"] spec.email = ["hello@infinite.red"] spec.description = %q{RedPotion - The best combination of RubyMo...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/app_delegate.rb
Ruby
mit
233
master
671
class AppDelegate < PM::Delegate include CDQ include ContributorsModule status_bar true, animation: :fade def on_load(app, options) cdq.setup return true if RUBYMOTION_ENV == 'test' init_contributors if Contributor.count < contributors.count open HomeScreen.new(nav_bar: true) end # R...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/models/contributor.rb
Ruby
mit
233
master
226
class Contributor < CDQManagedObject scope :starts_with_s, where(:name).begins_with('s').sort_by(:name) def cell { cell_class: ContributorCell, properties: { name: name } } end end
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/views/task_cell.rb
Ruby
mit
233
master
235
class TaskCell < PM::TableViewCell def on_load apply_style :cell find(self.contentView).tap do |q| @title = q.append!(UILabel, :cell_title) end end def my_title=(value) @title.text = value end end
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/views/collection_cell.rb
Ruby
mit
233
master
223
class CollectionCell < UICollectionViewCell def on_load find(self).apply_style :collection_cell find(self.contentView).tap do |q| q.append(UILabel, :title).get.text = rand(100).to_s end end end
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/views/contributor_cell.rb
Ruby
mit
233
master
506
class ContributorCell < ProMotion::TableViewCell def on_load apply_style :cell find(self.contentView).tap do |q| @title = q.append!(UILabel, :cell_title) @button = q.append!(UIButton, :github_button) end end def name=(value) @title.text = value # TODO: this is being called twi...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/views/metal_table_cell.rb
Ruby
mit
233
master
237
class MetalTableCell < UITableViewCell def on_load find(self.contentView).tap do |q| @name = q.append!(UILabel, :cell_name) end end def update(data) @name.text = "#{data[:name]} is #{data[:num]}" end end
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/stylesheets/contributor_screen_stylesheet.rb
Ruby
mit
233
master
486
class ContributorScreenStylesheet < ApplicationStylesheet def root_view(st) st.background_color = color.white end def cell(st) st.background_color = color.white end def cell_title(st) st.frame = {t: 5, w: device_width / 2, h: 20, l: 5} st.background_color = color.white st.color = colo...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/stylesheets/example_controller_stylesheet.rb
Ruby
mit
233
master
425
class ExampleControllerStylesheet < ApplicationStylesheet def setup # Add stylesheet specific setup stuff here. # Add application specific setup stuff in application_stylesheet.rb end def root_view(st) st.background_color = color.purple end def hello_world(st) st.frame = {w: 200, h: 30, cen...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/stylesheets/tasks_screen_stylesheet.rb
Ruby
mit
233
master
334
class TasksScreenStylesheet < ApplicationStylesheet def root_view(st) st.background_color = color.gray end def cell(st) st.background_color = color.green end def cell_title(st) st.frame = {t: 5, w: 200, h: 20, centered: :horizontal} st.background_color = color.white st.color = color.red...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/stylesheets/metal_table_screen_stylesheet.rb
Ruby
mit
233
master
439
class MetalTableScreenStylesheet < ApplicationStylesheet def setup end def root_view(st) st.background_color = color.gray end def cell_height 80 # Anything visual should be in the stylesheet end def cell(st) st.background_color = color.yellow end def cell_name(st) st.frame = {t:...
github
infinitered/redpotion
https://github.com/infinitered/redpotion
app/stylesheets/home_screen_stylesheet.rb
Ruby
mit
233
master
1,459
class HomeScreenStylesheet < ApplicationStylesheet def root_view(st) st.background_color = color.white end def hello_world(st) st.frame = {w: 200, h: 30, centered: :both} st.color = color.black st.font = font.large st.text = "Hello world" end def section(st) st.frame = {t: 100, w: 2...