repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
ploch/rbot | plugins/mlb.rb | # mlb
# by <NAME> <<EMAIL>> 2007-01-23
#
# display mlb scores
require 'uri/common'
require 'yaml'
require 'tzinfo'
require '0lib_rbot'
class MlbPlugin < Plugin
include PluginLib
def initialize
super
@mymlb = "mymlb => get results for your teams, mymlb [clear] [ team [team...] ] => save your fav teams"
end
... |
ploch/rbot | plugins/test/plugin_test.rb | #!/usr/bin/env ruby
require File.dirname(__FILE__) + '/plugin_stub'
plugin = load_plugin("tiny_weather")
plugin.do_tiny_weather(Msg.new, { :zip => 11375 })
|
ploch/rbot | plugins/nfl.rb | <filename>plugins/nfl.rb
# nfl
# by <NAME> <<EMAIL>> 2008-09-23
#
# display nfl scores
require 'uri/common'
require 'yaml'
require 'tzinfo'
require '0lib_rbot'
class NflPlugin < Plugin
include PluginLib
def initialize
super
@mynfl = "mynfl => get results for your teams, mynfl [clear] [ team [team...] ] => sav... |
ploch/rbot | plugins/debt.rb | # we gots debt and lots of it!
# by <NAME> <<EMAIL>> 2008-10-09
#
# lookup the national debt
require 'rubygems'
require 'scrapi'
class DebtPlugin < Plugin
include PluginLib
def help(plugin, topic="")
return "debt => get current national debt"
end
def do_debt(m,params)
debt = get_national_debt(... |
ploch/rbot | plugins/nhl.rb | <reponame>ploch/rbot<gh_stars>1-10
# nhl
# by <NAME> <<EMAIL>> 2007-01-23
#
# display nhl scores
require 'yahoo_sports'
require '0lib_rbot'
class NhlPlugin < Plugin
include PluginLib
def help(plugin, topic="")
"nhl => get last nights results, nhl <team> => get results of last game for <team>"
end
# get ... |
ploch/rbot | plugins/fmylife.rb | <gh_stars>1-10
# fmylife!
# by <NAME> <<EMAIL>> 2009-03-20
#
# scrape from fmylife.com
require 'rubygems'
require 'scrapi'
require '0lib_rbot'
class FMyLifePlugin < Plugin
include PluginLib
def initialize
super
@url = 'http://www.fmylife.com/'
end
def help(plugin, topic="")
return "fml => get random ... |
ploch/rbot | plugins/stocks.rb | <reponame>ploch/rbot
# stocks
# by <NAME> <brian -at- ploch.net>
# by <NAME> <<EMAIL>> 2007-01-23
#
# stock lookup.
#
# initial lookup by ploch. symbol lookup added by chetan. also the eliteness.
require 'rubygems'
require 'yahoofinance'
require 'json'
require '0lib_rbot'
class StocksPlugin < Plugin
include Plug... |
ploch/rbot | plugins/tiny_weather.rb | # tiny weather script
# by <NAME> <<EMAIL>> 2009-03-20
#
# scrapes weather.com
require 'rubygems'
require 'scrapi'
require '0lib_rbot'
class TinyWeatherPlugin < Plugin
include PluginLib
def initialize
super
end
def help(plugin, topic="")
return "tw [zip] => get hourly forecast from ... |
ploch/rbot | plugins/quietube.rb | <reponame>ploch/rbot
# quietube
# by <NAME> <<EMAIL>> 2009-11-24
#
# posts shortened quietube version of youtube links with optional title
require '0lib_rbot'
require 'shorturl'
class QuietubePlugin < Plugin
include PluginLib
Config.register Config::BooleanValue.new("quietube.display_title",
:default => fa... |
ploch/rbot | plugins/scrambler.rb | <reponame>ploch/rbot
# TODO:
# warn near end of game
# scores update during game
# alltime scores
# win count
require 'jcode'
require 'pathname'
class Scrambler
attr :active
attr :current_word
attr :current_word_rnd
attr :current_word_t
attr :current_hint
attr :hints
attr :hin... |
sky-uk/java-buildpack | lib/java_buildpack/framework/ruxit_agent.rb | <reponame>sky-uk/java-buildpack<filename>lib/java_buildpack/framework/ruxit_agent.rb<gh_stars>10-100
# Encoding: utf-8
# Cloud Foundry Java Buildpack
# Copyright 2013-2016 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance... |
MGat22/playingaround | web_greeter.rb | <reponame>MGat22/playingaround
require 'sinatra'
get '/:name' do
name = params[:name]
"Hello #{name}! Did you know your name has #{name.length}
letters in it and written backwards it is #{name.reverse.downcase.capitalize}?"
end |
MGat22/playingaround | hello_sinatra.rb | require 'sinatra'
get '/hello' do
"Hello Sinatra!"
end |
MGat22/playingaround | greeter.rb | <reponame>MGat22/playingaround
puts "Please enter your name:"
name = gets.chomp
puts "Hello #{name}! Did you know your name has #{name.length}
letters in it and written backwards it is #{name.reverse.downcase.capitalize}?" |
MGat22/playingaround | web_madlibs.rb | <filename>web_madlibs.rb
require 'sinatra'
get '/madlibs'do
erb :questions
end
post '/madlibs' do
animal = params[:animal]
color = params[:color]
person = params[:person]
object = params[:object]
adjective = params[:adjective]
verb = params[:verb]
"The #{adjective} #{animal} started to #{verb} because the #{p... |
MGat22/playingaround | madlibs.rb | <gh_stars>0
puts "Please enter the name of an animal:"
animal = gets.chomp
puts "Please enter a color:"
color = gets.chomp
puts "Please enter a type of person:"
person = gets.chomp
puts "Please enter an object:"
object = gets.chomp
puts "Please enter an adjective:"
adjective = gets.chomp
puts "Please enter a verb:"
ver... |
MGat22/playingaround | hello_ruby.rb | #This is my first Ruby program!
puts "Hello Ruby!"
puts 1+1
3.times do
puts "Ruby!"
end |
chainuser1/library | app/models/photo.rb | <gh_stars>0
class Photo < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader #Tells rails to use this uploader for this model
belongs_to :user,foreign_key: :user_username, primary_key: 'username', dependent: :destroy
validates :name, presence: true
validates :attachment, presence: true
end
|
chainuser1/library | db/migrate/20160316183356_create_carts.rb | <reponame>chainuser1/library
class CreateCarts < ActiveRecord::Migration
def change
create_table :carts, id: false do |t|
t.string :book_isbn
t.string :user_username
t.timestamps null: false
end
end
end
|
chainuser1/library | app/models/book.rb | class Book < ActiveRecord::Base
self.primary_key=:isbn
def to_param
isbn
end
ISBN_REGEX_CHECKER=/(ISBN[-]*(1[03])*[ ]*(: ){0,1})*(([0-9Xx][- ]*){13}|([0-9Xx][- ]*){10})/
AUTHOR_REGEX=/\A[A-z][A-z|\.|\s]+\z/
validates :isbn, presence: true,
format: {with: ISBN_REGEX_CHECKER, message: '... |
chainuser1/library | app/helpers/application_helper.rb | <reponame>chainuser1/library
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = "the Library"
if page_title.empty?
base_title
else
page_title + " | " + base_title
end
end
def profile_page_heading(heading='')
profile... |
chainuser1/library | app/controllers/welcomes_controller.rb | <reponame>chainuser1/library
class WelcomesController < ApplicationController
def index
end
def maintenance
end
end
|
chainuser1/library | app/models/profile.rb | class Profile < ActiveRecord::Base
self.primary_key='user_username'
#mutators
def fname=(fname)
self[:fname]=fname.capitalize
end
def lname=(lname)
self[:lname]=lname.capitalize
end
def address=(address)
self[:address]=address.capitalize
end
belongs_to :user, class_name: 'User',foreign_k... |
chainuser1/library | db/migrate/20160304170831_add_index_to_profiles.rb | <gh_stars>0
class AddIndexToProfiles < ActiveRecord::Migration
def change
add_foreign_key :profiles, :users, column: :user_username, primary_key: "username", on_delete: :cascade, on_update: :cascade
end
end
|
chainuser1/library | app/helpers/auths_helper.rb | <gh_stars>0
module AuthsHelper
def log_in(user)
session[:user_username]=user.username
session[:user_role]=user.role
end
def current_user
@current_user ||= User.find_by(username: session[:user_username])
end
def logged_in?
!current_user.nil?
end
def authenticate_user
if !logged_in?
... |
chainuser1/library | test/controllers/books_controller_test.rb | <filename>test/controllers/books_controller_test.rb
require 'test_helper'
class BooksControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
end
test "should get show" do
get :show
assert_response :success
end
test "should get new" do
g... |
chainuser1/library | app/models/cart.rb | <gh_stars>0
class Cart < ActiveRecord::Base
self.primary_key='id'
belongs_to :user, foreign_key: :user_username, :primary_key => 'username'
belongs_to :book, foreign_key: :book_isbn, :primary_key => 'isbn'
end
|
chainuser1/library | config/initializers/assets.rb | <gh_stars>0
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile... |
chainuser1/library | app/controllers/tasks_controller.rb | class TasksController < ApplicationController
def show_reservations
@carts=Cart.all.paginate(:per_page=>5,:page => params[:reservations]).order('created_at DESC')
end
def show_all_users
@users=User.all.paginate(:per_page=>5,:page => params[:users]).order('username ASC')
end
end
|
chainuser1/library | app/controllers/book_types_controller.rb | <reponame>chainuser1/library
class BookTypesController < ApplicationController
layout 'application'
def new
@book_type=BookType.new
end
def create
@book_type=BookType.new(params.require(:@book_type).permit(:category))
respond_to do |format|
if @book_type.save
format.json {render json:... |
chainuser1/library | test/controllers/auth_controller_test.rb | require 'test_helper'
class AuthControllerTest < ActionController::TestCase
test "should get login" do
get :login
assert_response :success
end
test "should get verify" do
get :verify
assert_response :success
end
test "should get logout" do
get :logout
assert_response :success
end
... |
chainuser1/library | app/controllers/photos_controller.rb | <reponame>chainuser1/library
class PhotosController < ApplicationController
def index
@photos=current_user.photos.paginate(:per_page=>20,:page=>params[:photos] )
end
def new
@photo=Photo.new
end
def create
@photo=Photo.new(photo_params)
respond_to do |format|
if @photo.save
forma... |
chainuser1/library | db/migrate/20160211183340_create_add_user_role_to_users.rb | class CreateAddUserRoleToUsers < ActiveRecord::Migration
def change
# create_table :add_user_role_to_users do |t|
add_column :users, :role, :integer, default: 1
end
end
|
chainuser1/library | app/views/authors/show.json.jbuilder | <reponame>chainuser1/library<filename>app/views/authors/show.json.jbuilder
json.extract! @author, :id,:name, :biography, :created_at, :updated_at
|
chainuser1/library | app/controllers/application_controller.rb | <filename>app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include AuthsHelper
include UsersHelper
require "will_paginat... |
chainuser1/library | db/migrate/20160216170423_create_add_unique_category_to_book_types.rb | <gh_stars>0
class CreateAddUniqueCategoryToBookTypes < ActiveRecord::Migration
def change
add_index :book_types,:category, unique: true
end
end
|
chainuser1/library | app/helpers/book_types_helper.rb | module BookTypesHelper
end
|
chainuser1/library | app/controllers/auths_controller.rb | class AuthsController < ApplicationController
layout 'application'
def login
if logged_in?
redirect_to root_path
else
render 'login'
end
end
def verify
user = User.find_by(username: params[:user][:username])
#render plain: user && user.authenticate(params[:user][:password]... |
chainuser1/library | app/helpers/books_helper.rb | module BooksHelper
def book_page_heading(heading='')
book_heading='Books: '
if heading.empty?
book_heading
else
heading
end
end
end
|
chainuser1/library | app/controllers/profiles_controller.rb | <filename>app/controllers/profiles_controller.rb
class ProfilesController < ApplicationController
layout 'application'
before_action :authenticate_user#, :except=>[]
before_action :set_profile,:only=>[:change,:new,:update,:manifest,:remove]
def index
end
def new
if !@profile.nil?
redirect_to manif... |
chainuser1/library | app/models/book_type.rb | <gh_stars>0
class BookType < ActiveRecord::Base
def category=(category)#mutator
self[:category]=category.capitalize
end
validates :category, presence: true,
uniqueness: true
end
|
chainuser1/library | app/controllers/users_controller.rb | class UsersController < ApplicationController
require 'bcrypt'
layout 'application'
def new
if logged_in?
redirect_to root_path
else
@user=User.new
end
end
def register
@user=User.new(user_params_register)
respond_to do |format|
if @user.save
format.htm... |
chainuser1/library | app/helpers/profiles_helper.rb | module ProfilesHelper
end |
chainuser1/library | app/models/user.rb | class User < ActiveRecord::Base
self.primary_key='username'
has_one :profile, class_name: 'Profile',primary_key: 'username',
foreign_key: 'user_username'
has_many :photos, foreign_key: :user_username, primary_key: 'username'
has_many :carts, foreign_key: :user_username, primary_key: :username,dependen... |
chainuser1/library | db/schema.rb | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritativ... |
chainuser1/library | db/migrate/20160308171211_add_unique_email_attribute_to_profiles.rb | class AddUniqueEmailAttributeToProfiles < ActiveRecord::Migration
def change
add_index :profiles,:email, unique: true
end
end
|
chainuser1/library | app/helpers/users_helper.rb | module UsersHelper
def find_dp
if logged_in?
user=User.find_by(username: current_user.username)
photos=user.photos.order('updated_at DESC').limit(1)
photos.each do |photo|
return photo.attachment_url
end
else
return nil
end
end
end
|
chainuser1/library | test/controllers/reeks_controller_test.rb | require 'test_helper'
class ReeksControllerTest < ActionController::TestCase
setup do
@reek = reeks(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:reeks)
end
test "should get new" do
get :new
assert_response :success
end
test "s... |
chainuser1/library | db/migrate/20160211175243_create_add_isbn_unique_to_books.rb | <reponame>chainuser1/library<filename>db/migrate/20160211175243_create_add_isbn_unique_to_books.rb<gh_stars>0
class CreateAddIsbnUniqueToBooks < ActiveRecord::Migration
def change
add_index :books, :isbn, unique: true
end
end
|
chainuser1/library | app/views/profiles/manifest.json.jbuilder | <reponame>chainuser1/library
json.extract! @profile, :user_username,:fname,:lname,:gender,:email,:address, :birthdate,:created_at,:updated_at
|
chainuser1/library | db/migrate/20160309181823_add_foriegn_key_to_books.rb | class AddForiegnKeyToBooks < ActiveRecord::Migration
def change
add_column :books, :author_id, :integer
add_foreign_key :books, :authors, column: :author_id, primary_key: 'id', on_delete: :cascade
end
end
|
chainuser1/library | db/migrate/20160203201937_create_users.rb | <filename>db/migrate/20160203201937_create_users.rb
class CreateUsers < ActiveRecord::Migration
def change
create_table :users, id:false do |t|
t.string :username
t.timestamps null: false
end
execute "ALTER TABLE users ADD PRIMARY KEY (username);"
end
end
|
chainuser1/library | db/migrate/20160203220336_create_add_password_digest_to_users.rb | <reponame>chainuser1/library<gh_stars>0
class CreateAddPasswordDigestToUsers < ActiveRecord::Migration
def change
add_column :users, :password_digest, :string
add_index :users, :username, unique:true
end
end
|
chainuser1/library | app/controllers/carts_controller.rb | class CartsController < ApplicationController
def index
@carts=current_user.carts
end
def create
@book=Book.find_by(isbn: params[:isbn])
@cart=@book.carts.create(user_username: current_user.username)
if @cart.save
redirect_to books_path
else
redirect_to maintenance_welc... |
chainuser1/library | app/controllers/books_controller.rb | class BooksController < ApplicationController
before_action :set_book, only: [:edit,:update,:delete,:remove,:show,:tranquility_cdn]
before_action :set_author, only: [:create,:update]
include BooksHelper
layout 'application'
def index
@books=Book.all.paginate(:per_page=>5,:page => params[:page]).order('ti... |
chainuser1/library | db/migrate/20160229194532_create_profiles.rb | <reponame>chainuser1/library
class CreateProfiles < ActiveRecord::Migration
def change
create_table :profiles , id: false do |t|
t.string :user_username
t.string :fname
t.string :lname
t.string :gender
t.string :email
t.string :address
t.date :birthdate
t.timestamp... |
tbanish/js-flashcard-backend | db/migrate/20210603183130_create_tests.rb | <gh_stars>0
class CreateTests < ActiveRecord::Migration[6.0]
def change
create_table :tests do |t|
t.integer :duration
t.float :score
t.string :correct_ids
t.string :incorrect_ids
t.integer :deck_id
t.timestamps
end
end
end
|
tbanish/js-flashcard-backend | db/migrate/20210603183954_add_correct_answers_to_cards.rb | <gh_stars>0
class AddCorrectAnswersToCards < ActiveRecord::Migration[6.0]
def change
add_column :cards, :correct_answers, :integer
end
end
|
tbanish/js-flashcard-backend | app/models/card.rb | <gh_stars>0
class Card < ApplicationRecord
belongs_to :deck
validates :answer, :question, presence: true
end
|
tbanish/js-flashcard-backend | app/models/deck.rb | class Deck < ApplicationRecord
has_many :cards, dependent: :destroy
has_many :tests
validates :subject, presence: true, uniqueness: true
end
|
tbanish/js-flashcard-backend | app/models/test.rb | class Test < ApplicationRecord
belongs_to :deck
end
|
tbanish/js-flashcard-backend | app/controllers/api/v1/tests_controller.rb | <gh_stars>0
class Api::V1::TestsController < ApplicationController
def index
tests = Test.all
render json: TestSerializer.new(tests)
end
def create
test = Test.new(test_params)
if test.save
render json: test, status: :accepted
else
render json: { errors: test.errors.full_messages... |
tbanish/js-flashcard-backend | app/controllers/api/v1/cards_controller.rb | class Api::V1::CardsController < ApplicationController
def index
cards = Card.all
render json: CardSerializer.new(cards)
end
def show
card = Card.find_by(id: params[:id])
render json: CardSerializer.new(card)
end
def create
card = Card.new(card_params)
if card.save
render json:... |
tbanish/js-flashcard-backend | app/serializers/card_serializer.rb | <filename>app/serializers/card_serializer.rb
class CardSerializer
include FastJsonapi::ObjectSerializer
attributes :question, :answer, :deck_id, :deck
end
|
tbanish/js-flashcard-backend | app/serializers/deck_serializer.rb | class DeckSerializer
include FastJsonapi::ObjectSerializer
attributes :subject, :cards
end
|
tbanish/js-flashcard-backend | app/serializers/test_serializer.rb | <filename>app/serializers/test_serializer.rb
class TestSerializer
include FastJsonapi::ObjectSerializer
attributes :duration, :score, :correct_ids, :incorrect_ids, :deck_id, :created_at
end
|
gumdal/KKGridView | KKGridView.podspec | <gh_stars>10-100
Pod::Spec.new do |s|
s.name = 'KKGridView'
s.version = '0.6.8.2'
s.license = 'MIT'
s.platform = :ios
s.summary = 'Gridview for iOS.'
s.homepage = 'https://github.com/kolinkrewinkel/KKGridView'
s.authors = { '<NAME>' => '<EMAIL>',
'<NAME>' => '<EMAIL>',
... |
promise-J/web-scraper | lib/scraper_instr.rb | class ScraperPlay
attr_reader :url
def initialize(url)
@url = url
end
def welcome(msg)
"#{msg} #{@url}"
end
def about(msg)
msg.to_s
end
def how_to_go(msg)
msg.to_s
end
def error_input(msg)
msg.to_s
end
def end_scrape(msg)
msg
end
end
|
promise-J/web-scraper | lib/scraper.rb | require 'nokogiri'
require 'open-uri'
require_relative './scraper_instr'
class Scraper < ScraperPlay
attr_reader :url
def initialize(url)
super
@url = url
end
def fetch_title
title_cat = []
first = full_page.css('div#courses .col h3').text
second = full_page.css('section#youtube .fa-... |
promise-J/web-scraper | spec/scraper_spec.rb | require_relative '../lib/scraper'
require 'nokogiri'
require 'open-uri'
WEB = Scraper.new('https://www.traversymedia.com/')
describe Scraper do
describe '#fetch_title' do
it 'should fetch the two categories of learning in the traversy media sites' do
expect(WEB.fetch_title).to eql(['Popular Udemy Courses ... |
promise-J/web-scraper | spec/scraper_instr_spec.rb | require_relative '../lib/scraper_instr'
SCRAP = ScraperPlay.new('https://www.traversymedia.com/')
describe ScraperPlay do
describe '#welcome' do
it 'should return the message passed as an augument' do
expect(SCRAP.welcome('Your selection is invalid, please try again.'))
.to eql('Your selection is i... |
promise-J/web-scraper | bin/main.rb | require_relative '../lib/scraper'
WEB = Scraper.new('https://www.traversymedia.com/')
def getting_started
puts WEB.welcome("You are welcomed to web scrapping. Let's scrap")
puts 'Are you ready to scrape? ENTER yes or no'
choice = gets.chomp
return unless choice == 'yes'
puts WEB.about('This is The Travers... |
txemagon/pert | lib/pert.rb | require "pert/version"
require "pert/node"
module Pert
def self.process
Node.process
end
def self.load_line(args)
return if args.empty?
name = args.shift
duration = args.pop
Node.new(name, duration, args)
end
def self.print
puts Node.dump
end
end
|
txemagon/pert | lib/pert/node.rb | <filename>lib/pert/node.rb
module Pert
class Node
@@first_node = nil
@@last_node = nil
@@node = Hash.new
attr_accessor :name, :sooner_time, :last_time, :following, :duration, :previous
def initialize(name, duration=0, previous=[])
@previous = []
@following = []
if !@@firs... |
txemagon/pert | pert.gemspec | <reponame>txemagon/pert
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/pert/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["txemagon"]
gem.email = ["<EMAIL>"]
gem.description = %q{Creates PERT diagramas using a task file.}
gem.summary = %q{Create a task fil... |
psparrow/attr-gather | lib/attr/gather/workflow/async_task_executor.rb | <filename>lib/attr/gather/workflow/async_task_executor.rb
# frozen_string_literal: true
require 'attr/gather/workflow/task_executor'
module Attr
module Gather
module Workflow
# @api private
class AsyncTaskExecutor < TaskExecutor
def initialize(*)
super
@executor = :io
... |
psparrow/attr-gather | lib/attr/gather/filters/contract.rb | # frozen_string_literal: true
module Attr
module Gather
module Filters
# Filters values with a dry-validation contract
class Contract < Base
class IncompatibleContractError < Error; end
attr_reader :dry_contract
# Creates a new instance of the filter
#
# @par... |
psparrow/attr-gather | lib/attr/gather/workflow/graphable.rb | # frozen_string_literal: true
module Attr
module Gather
module Workflow
# Module containing graph functionality
#
# @api public
module Graphable
# Class methods for graph functionality
module ClassMethods
# Returns the graph of tasks
#
# @retu... |
psparrow/attr-gather | spec/shared/test_container.rb | <reponame>psparrow/attr-gather
# frozen_string_literal: true
require 'dry-validation'
RSpec.shared_context 'test container' do
let(:test_container) do
container = Dry::Container.new
container.register(:fetch_from_xml_catalog) do |input|
{ fetch_from_xml_catalog_ran: input }
end
container.reg... |
psparrow/attr-gather | spec/attr/gather/workflow/task_execution_result_spec.rb | <filename>spec/attr/gather/workflow/task_execution_result_spec.rb
# frozen_string_literal: true
module Attr
module Gather
module Workflow
# @api private
RSpec.describe TaskExecutionResult do
describe '#value!' do
it 'returns the underlying result value' do
result = doubl... |
psparrow/attr-gather | lib/attr/gather/aggregators/deep_merge.rb | # frozen_string_literal: true
require 'attr/gather/aggregators/base'
module Attr
module Gather
module Aggregators
# Deep merges result hashes
#
# @api public
class DeepMerge < Base
# Initialize a new DeepMerge aggregator
#
# @param reverse [Boolean] deep merge res... |
psparrow/attr-gather | spec/attr/gather/filters_spec.rb | <reponame>psparrow/attr-gather<filename>spec/attr/gather/filters_spec.rb
# frozen_string_literal: true
module Attr
module Gather
RSpec.describe Filters do
describe '.default' do
it 'is the :noop filter' do
expect(described_class.default).to be_a(Filters::Noop)
end
end
... |
psparrow/attr-gather | lib/attr/gather/workflow.rb | # frozen_string_literal: true
require 'attr/gather/concerns/identifiable'
require 'attr/gather/workflow/task'
require 'attr/gather/workflow/task_graph'
require 'attr/gather/workflow/dsl'
require 'attr/gather/workflow/callable'
require 'attr/gather/workflow/graphable'
module Attr
module Gather
# Main mixin for f... |
psparrow/attr-gather | lib/attr/gather.rb | # frozen_string_literal: true
require 'attr/gather/version'
module Attr
module Gather
class Error < StandardError; end
# Your code goes here...
EMPTY_HASH = {}.freeze
end
end
require 'attr/gather/workflow'
require 'attr/gather/aggregators'
require 'attr/gather/filters'
|
psparrow/attr-gather | spec/attr/gather_spec.rb | <filename>spec/attr/gather_spec.rb
# frozen_string_literal: true
module Attr
RSpec.describe Gather do
it 'has a version number' do
expect(Attr::Gather::VERSION).not_to be nil
end
end
end
|
psparrow/attr-gather | lib/attr/gather/workflow/task_execution_result.rb | <reponame>psparrow/attr-gather
# frozen_string_literal: true
module Attr
module Gather
module Workflow
# A wrapper containing information and results of a task execution
#
# @!attribute [r] started_at
# @return [Time] time which the execution occured
#
# @!attribute [r] task... |
psparrow/attr-gather | lib/attr/gather/concerns/registrable.rb | <reponame>psparrow/attr-gather
# frozen_string_literal: true
module Attr
module Gather
# Makes a module registrable
module Registrable
# Error raised when item is already registered
class AlreadyRegisteredError < Error; end
# Error raised when item is not found
class NotFoundError < ... |
psparrow/attr-gather | spec/shared/task_execution_result.rb | <reponame>psparrow/attr-gather
# frozen_string_literal: true
RSpec.shared_context 'task execution result' do
def task_exeution_result(hash)
instance_double(
Attr::Gather::Workflow::TaskExecutionResult,
result: Concurrent::Promise.fulfill(hash)
)
end
end
|
psparrow/attr-gather | lib/attr/gather/workflow/callable.rb | # frozen_string_literal: true
require 'attr/gather/workflow/task_executor'
require 'attr/gather/workflow/async_task_executor'
module Attr
module Gather
module Workflow
# @api private
module Callable
# Execute a workflow
#
# When executing the workflow, tasks are processed in ... |
psparrow/attr-gather | lib/attr/gather/workflow/dsl.rb | # frozen_string_literal: true
module Attr
module Gather
module Workflow
# DSL for configuring a workflow
#
# @api public
module DSL
# Defines a task with name and options
#
# @param task_name [Symbol] the name of the task
#
# @example
# cl... |
psparrow/attr-gather | spec/attr/gather/filters/noop_spec.rb | # frozen_string_literal: true
require 'attr/gather/filters/noop'
module Attr
module Gather
module Filters
RSpec.describe Noop do
subject(:noop_filter) { described_class.new }
describe '#call' do
it 'does not remove any keys' do
res = noop_filter.call(test: true)
... |
psparrow/attr-gather | lib/attr/gather/filters/base.rb | # frozen_string_literal: true
module Attr
module Gather
module Filters
# @abstract Subclass and override {#call} to implement
# a custom Filter class.
class Base
# Applies the filter
#
# @param _input [Hash]
#
# @return [Attr::Gather::Filter::Result]
... |
psparrow/attr-gather | lib/attr/gather/filters/noop.rb | # frozen_string_literal: true
module Attr
module Gather
module Filters
# Does not perform any filtering
class Noop < Base
def call(input)
Result.new(input, [])
end
end
end
end
end
|
psparrow/attr-gather | lib/attr/gather/workflow/task_graph.rb | # frozen_string_literal: true
require 'tsort'
require 'attr/gather/workflow/dot_serializer'
module Attr
module Gather
module Workflow
# @api private
class TaskGraph
class UnfinishableError < StandardError; end
class InvalidTaskDepedencyError < StandardError; end
include TSor... |
psparrow/attr-gather | lib/attr/gather/aggregators/shallow_merge.rb | <filename>lib/attr/gather/aggregators/shallow_merge.rb<gh_stars>0
# frozen_string_literal: true
require 'attr/gather/aggregators/base'
module Attr
module Gather
module Aggregators
# Shallowly merges results
#
# @api public
class ShallowMerge < Base
# Initialize a new DeepMerge ag... |
psparrow/attr-gather | lib/attr/gather/aggregators/base.rb | # frozen_string_literal: true
module Attr
module Gather
module Aggregators
# @abstract Subclass and override {#call} to implement
# a custom Aggregator class.
#
# @!attribute [r] filter
# @return [Attr::Gather::Filters::Base] filter for the output data
class Base
a... |
psparrow/attr-gather | lib/attr/gather/filters.rb | <filename>lib/attr/gather/filters.rb
# frozen_string_literal: true
require 'attr/gather/filters/base'
require 'attr/gather/filters/result'
require 'attr/gather/filters/filtering'
require 'attr/gather/concerns/registrable'
module Attr
module Gather
# Namespace for filters
module Filters
extend Registra... |
psparrow/attr-gather | lib/attr/gather/concerns/identifiable.rb | # frozen_string_literal: true
require 'securerandom'
module Attr
module Gather
module Concerns
# Makes an entity identifiable by adding a #uuid attribute
#
# @!attribute [r] uuid
# @return [String] UUID of the result
module Identifiable
def initialize(*)
@uuid =... |
psparrow/attr-gather | lib/attr/gather/workflow/task.rb | <gh_stars>0
# frozen_string_literal: true
module Attr
module Gather
module Workflow
# @api private
class Task
attr_accessor :depends_on, :name
def initialize(name:, depends_on: [])
@name = name
@depends_on = depends_on
end
def depends_on?(other_ta... |
psparrow/attr-gather | spec/attr/gather/filters/contract_spec.rb | # frozen_string_literal: true
require 'attr/gather/filters/contract'
module Attr
module Gather
module Filters
RSpec.describe Contract do
subject(:contract_filter) { described_class.new(contract.new) }
describe '#call' do
let(:contract) do
Class.new(Dry::Validation::C... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.