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
noff/snek
https://github.com/noff/snek
db/migrate/20180614163708_create_ahoy_visits_and_events.rb
Ruby
mit
19
master
1,170
class CreateAhoyVisitsAndEvents < ActiveRecord::Migration[5.2] def change create_table :ahoy_visits do |t| t.string :visit_token t.string :visitor_token # the rest are recommended but optional # simply remove any you don't want # user t.references :user # standard ...
github
noff/snek
https://github.com/noff/snek
db/migrate/20180721063938_add_indice_to_large_tables.rb
Ruby
mit
19
master
260
class AddIndiceToLargeTables < ActiveRecord::Migration[5.2] def change add_index :battles, :initiator_snek_id add_index :battles, :arena_id add_index :battles, :mode add_index :saved_battles, :user_id add_index :sneks, :user_id end end
github
noff/snek
https://github.com/noff/snek
db/migrate/20180605195344_create_subscription_payments.rb
Ruby
mit
19
master
249
class CreateSubscriptionPayments < ActiveRecord::Migration[5.2] def change create_table :subscription_payments do |t| t.integer :paid_subscription_id t.integer :user_id t.integer :amount t.timestamps end end end
github
noff/snek
https://github.com/noff/snek
db/migrate/20180614165753_add_visits_to_models.rb
Ruby
mit
19
master
230
class AddVisitsToModels < ActiveRecord::Migration[5.2] def change add_column :sneks, :visit_id, :bigint add_column :battles, :visit_id, :bigint add_index :sneks, :visit_id add_index :battles, :visit_id end end
github
noff/snek
https://github.com/noff/snek
db/migrate/20180522193419_add_style_to_snek.rb
Ruby
mit
19
master
410
class AddStyleToSnek < ActiveRecord::Migration[5.2] def change add_column :sneks, :color, :string add_column :sneks, :pattern, :string add_column :sneks, :pattern_color, :string Snek.all.each do |snek| snek.update color: SnekStyle::COLORS.sample, pattern: SnekStyle::PATTERNS.sa...
github
noff/snek
https://github.com/noff/snek
db/migrate/20180605195220_create_paid_subscriptions.rb
Ruby
mit
19
master
281
class CreatePaidSubscriptions < ActiveRecord::Migration[5.2] def change create_table :paid_subscriptions do |t| t.integer :user_id t.integer :amount t.date :paid_till t.boolean :renewable t.string :stripe_id t.timestamps end end end
github
noff/snek
https://github.com/noff/snek
db/migrate/20180417084512_devise_create_users.rb
Ruby
mit
19
master
1,391
# frozen_string_literal: true class DeviseCreateUsers < ActiveRecord::Migration[5.2] def change create_table :users do |t| ## Database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" ## Recoverable t.stri...
github
noff/snek
https://github.com/noff/snek
db/migrate/20180423213833_create_active_admin_comments.rb
Ruby
mit
19
master
419
class CreateActiveAdminComments < ActiveRecord::Migration::Current def self.up create_table :active_admin_comments do |t| t.string :namespace t.text :body t.references :resource, polymorphic: true t.references :author, polymorphic: true t.timestamps end add_index :active_ad...
github
noff/snek
https://github.com/noff/snek
db/migrate/20180528131331_add_indice.rb
Ruby
mit
19
master
225
class AddIndice < ActiveRecord::Migration[5.2] def change add_index :battle_rounds, :battle_id add_index :battles, :aasm_state add_index :snek_battles, :snek_id add_index :snek_battles, :battle_id end end
github
noff/snek
https://github.com/noff/snek
config/routes.rb
Ruby
mit
19
master
1,001
Rails.application.routes.draw do get 'ratings/top' get 'ratings/activity' get 'ratings/national' get 'billing' => 'billing#index' put 'billing/addcard' post 'billing/webhook', defaults: {format: :json} devise_for :admin_users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) devise_for :users, ...
github
noff/snek
https://github.com/noff/snek
config/deploy.rb
Ruby
mit
19
master
2,657
# config valid for current version and patch releases of Capistrano lock "~> 3.11.2" set :application, "snek" set :repo_url, "git@github.com:noff/snek.git" # Default branch is :master # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp # Default deploy_to directory is /var/www/my_app_name set :deploy_to, "/home/r...
github
noff/snek
https://github.com/noff/snek
config/application.rb
Ruby
mit
19
master
783
require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module SnekFite class Application < Rails::Application # Initialize configuration defaults for originally generated Rails ...
github
noff/snek
https://github.com/noff/snek
config/schedule.rb
Ruby
mit
19
master
597
# Use this file to easily define all of your cron jobs. # # It's helpful, but not entirely necessary to understand cron before proceeding. # http://en.wikipedia.org/wiki/Cron # Example: # # set :output, "/path/to/my/cron_log.log" # # every 2.hours do # command "/usr/bin/some_great_command" # runner "MyModel.some_m...
github
noff/snek
https://github.com/noff/snek
config/environments/production.rb
Ruby
mit
19
master
4,011
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 application in memory, allowing both threaded web serve...
github
noff/snek
https://github.com/noff/snek
config/environments/development.rb
Ruby
mit
19
master
2,256
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 on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
noff/snek
https://github.com/noff/snek
config/initializers/simple_form.rb
Ruby
mit
19
master
7,134
# frozen_string_literal: true # # Uncomment this and change the path if necessary to include your own # components. # See https://github.com/plataformatec/simple_form#custom-components to know # more about custom components. # Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f } # # Use this setup bloc...
github
noff/snek
https://github.com/noff/snek
config/initializers/active_admin.rb
Ruby
mit
19
master
9,398
ActiveAdmin.setup do |config| # == Site Title # # Set the title that is displayed on the main layout # for each of the active admin pages. # config.site_title = "Snek" # Set the link url for the title. For example, to take # users to your main site. Defaults to no link. # # config.site_title_link =...
github
noff/snek
https://github.com/noff/snek
config/initializers/rollbar.rb
Ruby
mit
19
master
3,460
Rollbar.configure do |config| # Without configuration, Rollbar is enabled in all environments. # To disable in specific environments, set config.enabled=false. # Need this to CI work if Rails.env.production? config.access_token = Rails.application.credentials.rollbar[:server] end # Here we'll disable ...
github
noff/snek
https://github.com/noff/snek
config/initializers/devise.rb
Ruby
mit
19
master
13,775
# frozen_string_literal: true # Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render inv...
github
noff/snek
https://github.com/noff/snek
config/initializers/simple_form_bootstrap.rb
Ruby
mit
19
master
20,166
# frozen_string_literal: true # Please do not make direct changes to this file! # This generator is maintained by the community around simple_form-bootstrap: # https://github.com/rafaelfranca/simple_form-bootstrap # All future development, tests, and organization should happen there. # Background history: https://gith...
github
noff/snek
https://github.com/noff/snek
config/deploy/production.rb
Ruby
mit
19
master
2,523
role :app, %w{148.251.233.13} role :web, %w{148.251.233.13} role :db, %w{148.251.233.13} set :stage, :production set :log_level, :info set :ssh_options, { user: 'rails', forward_agent: true, port: 21212 } set :application, 'snek.mkechinov.ru' set :deploy_to, "/home/rails/#{fetch(:application)}" set :...
github
noff/snek
https://github.com/noff/snek
app/decorators/feed_decorator.rb
Ruby
mit
19
master
355
class FeedDecorator < Draper::Decorator delegate_all # Define presentation-specific methods here. Helpers are accessed through # `helpers` (aka `h`). You can override attributes, for example: # # def created_at # helpers.content_tag :span, class: 'time' do # object.created_at.strftime("%a %m/...
github
noff/snek
https://github.com/noff/snek
app/decorators/rating_decorator.rb
Ruby
mit
19
master
357
class RatingDecorator < Draper::Decorator delegate_all # Define presentation-specific methods here. Helpers are accessed through # `helpers` (aka `h`). You can override attributes, for example: # # def created_at # helpers.content_tag :span, class: 'time' do # object.created_at.strftime("%a %...
github
noff/snek
https://github.com/noff/snek
app/decorators/billing_decorator.rb
Ruby
mit
19
master
358
class BillingDecorator < Draper::Decorator delegate_all # Define presentation-specific methods here. Helpers are accessed through # `helpers` (aka `h`). You can override attributes, for example: # # def created_at # helpers.content_tag :span, class: 'time' do # object.created_at.strftime("%a ...
github
noff/snek
https://github.com/noff/snek
app/decorators/snek_decorator.rb
Ruby
mit
19
master
355
class SnekDecorator < Draper::Decorator delegate_all # Define presentation-specific methods here. Helpers are accessed through # `helpers` (aka `h`). You can override attributes, for example: # # def created_at # helpers.content_tag :span, class: 'time' do # object.created_at.strftime("%a %m/...
github
noff/snek
https://github.com/noff/snek
app/decorators/paid_subscription_decorator.rb
Ruby
mit
19
master
367
class PaidSubscriptionDecorator < Draper::Decorator delegate_all # Define presentation-specific methods here. Helpers are accessed through # `helpers` (aka `h`). You can override attributes, for example: # # def created_at # helpers.content_tag :span, class: 'time' do # object.created_at.strf...
github
noff/snek
https://github.com/noff/snek
app/mailers/stats_mailer.rb
Ruby
mit
19
master
212
class StatsMailer < ApplicationMailer default from: "info@snek.app" layout 'mailer' def weekly(snek) @snek = snek mail(to: @snek.user.email, subject: "#{snek.short_name} weekly stats") end end
github
noff/snek
https://github.com/noff/snek
app/mailers/notify_mailer.rb
Ruby
mit
19
master
228
class NotifyMailer < ApplicationMailer def stripe mail to: Rails.application.credentials.notification_email, subject: 'Stripe Event', body: params[:event], content_type: 'text/plain' end end
github
noff/snek
https://github.com/noff/snek
app/admin/battles.rb
Ruby
mit
19
master
444
ActiveAdmin.register Battle do index do id_column column :aasm_state column :created_at column :updated_at end show do attributes_table do row :id row :snek row :aasm_state row :created_at row :updated_at end panel 'Sneks' do table_for battle.snek...
github
noff/snek
https://github.com/noff/snek
app/admin/saved_battles.rb
Ruby
mit
19
master
225
ActiveAdmin.register SavedBattle do scope 'All', :all index do selectable_column id_column column :user column :battle column :created_at column :updated_at actions end filter :user end
github
noff/snek
https://github.com/noff/snek
app/admin/paid_subscriptions.rb
Ruby
mit
19
master
506
ActiveAdmin.register PaidSubscription do permit_params :amount, :paid_till, :renewable, :product scope 'All', :all index do selectable_column id_column column :user column :amount column :paid_till column :renewable column :stripe_id column :product column :created_at ac...
github
noff/snek
https://github.com/noff/snek
app/admin/subscription_payments.rb
Ruby
mit
19
master
240
ActiveAdmin.register SubscriptionPayment do scope 'All', :all index do selectable_column id_column column :paid_subscription column :user column :amount column :created_at actions end filter :user end
github
noff/snek
https://github.com/noff/snek
app/admin/sneks.rb
Ruby
mit
19
master
818
ActiveAdmin.register Snek do permit_params :name, :color, :pattern, :pattern_color scope 'All', :all scope 'Autofight', :for_autofight index do selectable_column id_column column :name column :user column :created_at column :current_battles_count actions do |snek| link_to 'R...
github
noff/snek
https://github.com/noff/snek
app/admin/dashboard.rb
Ruby
mit
19
master
907
ActiveAdmin.register_page "Dashboard" do menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") } content title: proc{ I18n.t("active_admin.dashboard") } do div class: "blank_slate_container", id: "dashboard_default_message" do span class: "blank_slate" do span I18n.t("active_admin.dash...
github
noff/snek
https://github.com/noff/snek
app/admin/users.rb
Ruby
mit
19
master
1,185
ActiveAdmin.register User do permit_params :email index do selectable_column id_column column :email column :sneks do |u| u.sneks.count end column :crowns column :current_sign_in_at column :sign_in_count column :created_at column :crowns do |c| link_to 'Grant cro...
github
noff/snek
https://github.com/noff/snek
app/services/snek_score.rb
Ruby
mit
19
master
412
class SnekScore def initialize(snek) @snek = snek end def activity @snek.snek_battles.where('created_at >= ?', 2.weeks.ago).sum(:score) end def efficiency @snek.snek_battles.where('created_at >= ?', 2.weeks.ago).count >= 10 ? @snek.snek_battles.where('created_at >= ?', 2.weeks.ago).sum(:score)....
github
noff/snek
https://github.com/noff/snek
app/services/battle_image.rb
Ruby
mit
19
master
8,137
class BattleImage include Magick include BattleHelper attr_accessor :battle, :padding, :width, :height, :arena_width, :arena_height, :cell_size, :arena def initialize(battle) @battle = battle end def for_facebook @width = 1200 @height = 630 @padding = 30 # Calculate elements size ...
github
noff/snek
https://github.com/noff/snek
app/services/snek_style.rb
Ruby
mit
19
master
336
module SnekStyle COLORS = %w[blue dark_blue dark_brown green grey light_brown lime_green mint orange pink pumpkin purple red sky_blue white yellow].freeze PATTERNS = %w[1 2 3 4 5 6 7 8] PATTERN_COLORS = %w[black blue dark_blue dark_brown green grey light_brown lime_green mint orange pink pumpkin purple red sky_b...
github
noff/snek
https://github.com/noff/snek
app/services/daily_rating_calculator.rb
Ruby
mit
19
master
1,684
class DailyRatingCalculator attr_accessor :date class << self def perform_today DailyRatingCalculator.new(Date.current).perform end end def initialize(date) @date = date end def perform sneks = Snek.select(:id, :name).map { |snek| {snek: snek, activity_score: SnekScore.new(snek).a...
github
noff/snek
https://github.com/noff/snek
app/services/snek_math/position.rb
Ruby
mit
19
master
12,095
module SnekMath class Position # Local error for exit from nested loops class NotMatchedPattern < StandardError; end; attr_reader :snek, :position # @param snek [Snek] # @param position [Array] def initialize(snek, position) @snek = snek @position = position end # Get n...
github
noff/snek
https://github.com/noff/snek
app/services/snek_math/pattern.rb
Ruby
mit
19
master
1,645
module SnekMath class Pattern attr_reader :matrix # @param pattern [Array] 2-dimensional array from snek rules def initialize(pattern) @source_matrix = SnekMath::Matrix.new pattern[0].length, pattern.length, nil pattern.each_with_index do |row, y| row.each_with_index do |cell, x| ...
github
noff/snek
https://github.com/noff/snek
app/services/snek_math/matrix.rb
Ruby
mit
19
master
5,781
module SnekMath class Matrix attr_reader :area class << self def from_json(json) m = self::new(json.first.length, json.length, nil) json.each_with_index do |row, y| row.each_with_index do |cell, x| m.set(x, y, cell) end end m end ...
github
noff/snek
https://github.com/noff/snek
app/controllers/paid_subscriptions_controller.rb
Ruby
mit
19
master
1,620
class PaidSubscriptionsController < ApplicationController before_action :authenticate_user! def create if current_user.stripe_id.nil? redirect_to billing_path, alert: 'Add your bank card, please' return end product = params[:product] product_price = PaidSubscription.product_price(prod...
github
noff/snek
https://github.com/noff/snek
app/controllers/welcome_controller.rb
Ruby
mit
19
master
472
class WelcomeController < ApplicationController def index @with_hero_unit = true @top_sneks = Snek.all.map { |snek| {snek: snek, score: SnekScore.new(snek).activity, battles: snek.snek_battles.count } }.sort { |a,b| a[:score] <=> b[:score] }.reverse.delete_if { |s| s[:score] == 0 }.take(10) ahoy.track('...
github
noff/snek
https://github.com/noff/snek
app/controllers/application_controller.rb
Ruby
mit
19
master
813
class ApplicationController < ActionController::Base before_action :set_locale def set_locale locale = 'en' if locale_valid?(params[:locale]) locale = params[:locale] else if cookies[:locale].present? && locale_valid?(cookies[:locale]) locale = cookies[:locale] else b...
github
noff/snek
https://github.com/noff/snek
app/controllers/battles_controller.rb
Ruby
mit
19
master
3,252
class BattlesController < ApplicationController protect_from_forgery before_action :authenticate_user!, only: [:create] def index @battles = Battle.order(id: :desc).page(params[:page] || 0) end def create @snek = current_user.sneks.find(params[:snek_id]) if @snek.too_much_battles? redir...
github
noff/snek
https://github.com/noff/snek
app/controllers/ratings_controller.rb
Ruby
mit
19
master
1,802
class RatingsController < ApplicationController def top @top_sneks = Snek.all.map { |snek| {snek: snek, score: SnekScore.new(snek).efficiency, battles: snek.snek_battles.count, change: 0, position: 0 } }.sort { |a,b| a[:score] <=> b[:score] }.reverse.delete_if { |s| s[:score] == 0 }.take(100) @top_sneks.eac...
github
noff/snek
https://github.com/noff/snek
app/controllers/sneks_controller.rb
Ruby
mit
19
master
2,486
class SneksController < ApplicationController before_action :authenticate_user! def index @sneks = current_user.sneks end def new @snek = current_user.sneks.build ahoy.track 'New Snek Form' end def create @snek = current_user.sneks.new @snek.name = params[:snek][:name].strip if @s...
github
noff/snek
https://github.com/noff/snek
app/controllers/billing_controller.rb
Ruby
mit
19
master
2,596
class BillingController < ApplicationController before_action :authenticate_user!, except: [:webhook] protect_from_forgery except: [:webhook] def index ahoy.track 'Visited Billing' end def webhook payload = request.body.read sig_header = request.env['HTTP_STRIPE_SIGNATURE'] event = nil ...
github
noff/snek
https://github.com/noff/snek
app/controllers/saved_battles_controller.rb
Ruby
mit
19
master
748
class SavedBattlesController < ApplicationController before_action :authenticate_user! def create battle = Battle.find params[:battle_id] unless current_user.saved_battles.where(battle_id: battle.id).exists? current_user.saved_battles.create battle_id: battle.id end redirect_to battle end ...
github
noff/snek
https://github.com/noff/snek
app/controllers/users/registrations_controller.rb
Ruby
mit
19
master
2,223
# frozen_string_literal: true class Users::RegistrationsController < Devise::RegistrationsController # before_action :configure_sign_up_params, only: [:create] # before_action :configure_account_update_params, only: [:update] # GET /resource/sign_up def new ahoy.track 'Registration Form' super end ...
github
noff/snek
https://github.com/noff/snek
app/jobs/perform_battle_job.rb
Ruby
mit
19
master
298
class PerformBattleJob < ApplicationJob queue_as :default def perform(battle, options = {}) return if battle.reload.finished? # If failed in previous attempt, restart it if battle.running? battle.restart! true, options else battle.start! options end end end
github
noff/snek
https://github.com/noff/snek
app/models/snek.rb
Ruby
mit
19
master
5,097
class Snek < ApplicationRecord visitable belongs_to :user has_many :started_battles, foreign_key: "initiator_snek_id", class_name: 'Battle' has_many :snek_battles has_many :daily_ratings validates :name, uniqueness: { case_sensitive: false }, presence: t...
github
noff/snek
https://github.com/noff/snek
app/models/paid_subscription.rb
Ruby
mit
19
master
672
class PaidSubscription < ApplicationRecord PRODUCTS = [ {product: 'pro_snek', price: 300} ].freeze scope :paid, -> { where('paid_till >= ?', Date.current) } class << self # Returns product's price in cents # @return Integer def product_price(product) PRODUCTS.each do |product_data| ...
github
noff/snek
https://github.com/noff/snek
app/models/daily_rating.rb
Ruby
mit
19
master
291
class DailyRating < ApplicationRecord belongs_to :snek validates :date, :activity_score, :activity_position, :efficiency_score, :efficiency_position, presence: true validates :activity_position, :efficiency_position, numericality: {greater_than_or_equal_to: 0, only_integer: true} end
github
noff/snek
https://github.com/noff/snek
app/models/user.rb
Ruby
mit
19
master
406
class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :sneks has_many :saved_battles has_many :...
github
noff/snek
https://github.com/noff/snek
app/models/battle.rb
Ruby
mit
19
master
12,166
class Battle < ApplicationRecord include AASM visitable paginates_per 50 belongs_to :snek, class_name: "Snek", foreign_key: "initiator_snek_id", validate: false has_many :snek_battles has_many :battle_rounds has_many :saved_battles belongs_to :arena aasm no_direct_assignment: true do state :draf...
github
noff/snek
https://github.com/noff/snek
app/models/arena.rb
Ruby
mit
19
master
7,203
class Arena < ApplicationRecord validates :name, :area, presence: true has_many :battles # Convert arena area to matrix # @return SnekMath::Matrix def get_matrix matrix = SnekMath::Matrix.new(area[0].length, area.length, 'empty') area.each_with_index do |row, y| row.each_with_index do |cell, x|...
github
noff/snek
https://github.com/noff/snek
app/models/admin_user.rb
Ruby
mit
19
master
258
class AdminUser < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable end
github
noff/snek
https://github.com/noff/snek
app/helpers/battle_helper.rb
Ruby
mit
19
master
312
module BattleHelper def battle_name(battle) case battle.mode when BattleMode::DEFAULT "Battle ##{battle.id}" when BattleMode::DUEL "Duel ##{battle.id}" when BattleMode::BATTLE_ROYALE "👑 Battle Royale ##{battle.id}" else "Battle ##{battle.id}" end end end
github
shvets/selenium
https://github.com/shvets/selenium
Rakefile
Ruby
mit
19
master
807
#!/usr/bin/env rake $LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__)) require "rspec/core/rake_task" require "selenium/version" require "gemspec_deps_gen/gemspec_deps_gen" version = Selenium::VERSION project_name = File.basename(Dir.pwd) task :gen do generator = GemspecDepsGen.new generator.ge...
github
shvets/selenium
https://github.com/shvets/selenium
lib/selenium/starter.rb
Ruby
mit
19
master
1,279
require 'jar_wrapper' require 'selenium/version' module Selenium class Starter SELENIUM_SERVER_VERSION = "2.37.0" USAGE= <<-TEXT Usage: selenium help - this help selenium install - installs selenium selenium - runs the selenium server TEXT attr_reader :wrapper ...
github
netenglabs/automatic-for-the-people
https://github.com/netenglabs/automatic-for-the-people
2t-clos-dual-attach/instance_defs.rb
Ruby
bsd-3-clause
19
main
754
NUM_SPINES = 2 NUM_LEAVES = 4 NUM_EXIT_LEAVES = 2 NUM_DCEDGE_RTRS = 1 # Hardcoded NUM_FIREWALL = 1 # Hardcoded NUM_SERVERS_PER_LEAF = 2 SPINE_NOS = "cumulus" LEAF_NOS = "cumulus" EXIT_NOS = "cumulus" DCEDGE_NOS = "cumulus" FIREWALL_NOS = "ubuntu" # Using generic/ubuntu1804 # IP addr...
github
netenglabs/automatic-for-the-people
https://github.com/netenglabs/automatic-for-the-people
2t-clos-dual-attach/nos_defs.rb
Ruby
bsd-3-clause
19
main
495
NOS_MEM = { "cumulus" => 2048, "nxos" => 6144, "junos" => 2048, "eos" => 2048, "iosxr" => 7168 } NOS_BOX = { "cumulus" => "CumulusCommunity/cumulus-vx", "nxos" => "cisco/nxosv", "junos" => "juniper/vqfx10k-re", "eos" => "arista/veos", "iosxr" => "cisco/iosxrv9k", } NOS_VERSION = { "cumulus" => "...
github
netenglabs/automatic-for-the-people
https://github.com/netenglabs/automatic-for-the-people
2t-clos-dual-attach/Vagrantfile
Ruby
bsd-3-clause
19
main
22,380
def get_mac(oui="48:47:00") "Generate a MAC address" nic = (1..3).map{"%0.2x"%rand(256)}.join(":") return "#{oui}:#{nic}" end require './instance_defs.rb' require './nos_defs.rb' Vagrant.require_version ">= 2.1.0" Vagrant.configure("2") do |config| simid = 2 config.vm.provider :libvirt do |domain| doma...
github
netenglabs/automatic-for-the-people
https://github.com/netenglabs/automatic-for-the-people
2t-clos-single-attach/instance_defs.rb
Ruby
bsd-3-clause
19
main
799
NUM_SPINES = 2 NUM_LEAVES = 2 NUM_EXIT_LEAVES = 2 NUM_DCEDGE_RTRS = 1 # Hardcoded NUM_FIREWALL = 1 # Hardcoded NUM_SERVERS_PER_LEAF = 2 SPINE_NOS = "cumulus" LEAF_NOS = "cumulus" EXIT_NOS = "cumulus" DCEDGE_NOS = "cumulus" FIREWALL_NOS = "ubuntu" # Using generic/ubuntu1804 # IP addr...
github
netenglabs/automatic-for-the-people
https://github.com/netenglabs/automatic-for-the-people
2t-clos-single-attach/topo-kvm.rb
Ruby
bsd-3-clause
19
main
20,188
def get_mac(oui="28:b7:ad") "Generate a MAC address" nic = (1..3).map{"%0.2x"%rand(256)}.join(":") return "#{oui}:#{nic}" end require './instance_defs.rb' require './nos_defs.rb' Vagrant.require_version ">= 2.1.0" Vagrant.configure("2") do |config| config.vm.provider :libvirt do |domain| domain.managemen...
github
netenglabs/automatic-for-the-people
https://github.com/netenglabs/automatic-for-the-people
2t-clos-single-attach/Vagrantfile
Ruby
bsd-3-clause
19
main
20,205
def get_mac(oui="28:b7:ad") "Generate a MAC address" nic = (1..3).map{"%0.2x"%rand(256)}.join(":") return "#{oui}:#{nic}" end require './instance_defs.rb' require './nos_defs.rb' Vagrant.require_version ">= 2.1.0" Vagrant.configure("2") do |config| wbid = 3 config.vm.provider :libvirt do |domain| domai...
github
netenglabs/automatic-for-the-people
https://github.com/netenglabs/automatic-for-the-people
2t-clos-single-attach/nos_defs.rb
Ruby
bsd-3-clause
19
main
270
NOS_MEM = { "cumulus" => 768, "nxos" => 6144, "junos" => 2048, "eos" => 2048 } NOS_BOX = { "cumulus" => "CumulusCommunity/cumulus-vx", "nxos" => "cisco/nxosv", "junos" => "juniper/vqfx10k-re", "eos" => "arista/veos" } SERVER_BOX = "generic/ubuntu1804"
github
delano/tryouts
https://github.com/delano/tryouts
Gemfile
Ruby
mit
19
main
764
# Gemfile source 'https://rubygems.org' gemspec group :development do # Run with RUBY_DEBUG_IRB_CONSOLE=true to get proper interactive console gem 'debug', require: false gem 'rubocop', '~> 1.81.1', require: false gem 'rubocop-performance', require: false gem 'rubocop-rspec', require: false gem 'rubocop...
github
delano/tryouts
https://github.com/delano/tryouts
tryouts.gemspec
Ruby
mit
19
main
1,332
# tryouts.gemspec require_relative 'lib/tryouts/version' Gem::Specification.new do |spec| spec.name = 'tryouts' spec.version = Tryouts::VERSION spec.summary = 'Ruby tests that read like documentation.' spec.description = 'A simple test framework for Ruby ...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts.rb
Ruby
mit
19
main
2,477
# lib/tryouts.rb # # frozen_string_literal: true require 'stringio' require 'timeout' TRYOUTS_LIB_HOME = __dir__ unless defined?(TRYOUTS_LIB_HOME) require_relative 'tryouts/console' require_relative 'tryouts/test_batch' require_relative 'tryouts/version' require_relative 'tryouts/parsers/legacy_parser' require_relat...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/test_batch.rb
Ruby
mit
19
main
24,683
# lib/tryouts/test_batch.rb # # frozen_string_literal: true require 'stringio' require_relative 'expectation_evaluators/registry' class Tryouts # Factory for creating fresh context containers for each test class FreshContextFactory def initialize @containers_created = 0 end def create_container...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/test_case.rb
Ruby
mit
19
main
5,671
# lib/tryouts/test_case.rb # # frozen_string_literal: true # Modern data structures using Ruby 3.2+ Data classes class Tryouts # Core data structures TestCase = Data.define(:description, :code, :expectations, :line_range, :path, :source_lines, :first_expectation_line) do def empty? code.empty? end ...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/test_runner.rb
Ruby
mit
19
main
7,107
# lib/tryouts/test_runner.rb # # frozen_string_literal: true require 'concurrent' require_relative 'parsers/legacy_parser' require_relative 'parsers/enhanced_parser' require_relative 'test_batch' require_relative 'translators/rspec_translator' require_relative 'translators/minitest_translator' require_relative 'file_p...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/test_executor.rb
Ruby
mit
19
main
3,174
# lib/tryouts/test_executor.rb # # frozen_string_literal: true require_relative 'test_batch' class Tryouts class TestExecutor def initialize(file, testrun, options, output_manager, translator, global_tally) @file = file @testrun = testrun @options = options @outpu...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/failure_collector.rb
Ruby
mit
19
main
3,044
# lib/tryouts/failure_collector.rb # # frozen_string_literal: true require_relative 'console' class Tryouts # Collects and organizes failed test results across files for summary display # Similar to RSpec's failure summary at the end of test runs class FailureCollector # Data structure for a single failure ...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/parser_warning.rb
Ruby
mit
19
main
1,200
# lib/tryouts/parser_warning.rb # # frozen_string_literal: true class Tryouts # Data structure for parser warnings ParserWarning = Data.define(:type, :message, :line_number, :context, :suggestion) do def self.unnamed_test(line_number:, context:) new( type: :unnamed_test, message: "Test ca...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli.rb
Ruby
mit
19
main
1,781
# lib/tryouts/cli.rb # # frozen_string_literal: true require 'optparse' require_relative 'cli/opts' require_relative 'cli/formatters' require_relative 'cli/line_spec_parser' require_relative 'test_runner' class Tryouts class CLI def initialize @options = { framework: :direct, verbose: fal...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/test_result_aggregator.rb
Ruby
mit
19
main
4,644
# lib/tryouts/test_result_aggregator.rb # # frozen_string_literal: true require_relative 'failure_collector' require 'concurrent' class Tryouts # Centralized test result aggregation to ensure counting consistency # across all formatters and eliminate counting discrepancies class TestResultAggregator def ini...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/file_processor.rb
Ruby
mit
19
main
2,821
# lib/tryouts/file_processor.rb # # frozen_string_literal: true require_relative 'parsers/legacy_parser' require_relative 'parsers/enhanced_parser' require_relative 'test_executor' require_relative 'cli/modes/inspect' require_relative 'cli/modes/generate' class Tryouts class FileProcessor # Supported parser typ...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/console.rb
Ruby
mit
19
main
5,920
# lib/tryouts/console.rb # # frozen_string_literal: true require 'pathname' class Tryouts module Console # ANSI escape sequence numbers for text attributes unless defined? ATTRIBUTES ATTRIBUTES = { normal: 0, bright: 1, dim: 2, underline: 4, blink: 5, re...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/parsers/legacy_parser.rb
Ruby
mit
19
main
12,335
# lib/tryouts/parsers/legacy_parser.rb # # frozen_string_literal: true require_relative '../test_case' require_relative 'base_parser' class Tryouts # Legacy parser using line-by-line regex parsing for compatibility # # The LegacyParser provides a simpler, more straightforward approach to parsing # tryout file...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/parsers/enhanced_parser.rb
Ruby
mit
19
main
12,892
# lib/tryouts/parsers/enhanced_parser.rb # # frozen_string_literal: true require_relative '../test_case' require_relative 'base_parser' class Tryouts # Enhanced parser using Prism's native comment extraction for robust parsing # # The EnhancedParser is the default parser that provides syntax-aware comment # e...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/parsers/base_parser.rb
Ruby
mit
19
main
4,462
# lib/tryouts/parsers/base_parser.rb # # frozen_string_literal: true require 'prism' require_relative 'shared_methods' require_relative '../parser_warning' class Tryouts module Parsers # Base class for all tryout parsers providing common functionality # # BaseParser establishes the foundation for parsi...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/parsers/shared_methods.rb
Ruby
mit
19
main
16,620
# lib/tryouts/parsers/shared_methods.rb # # frozen_string_literal: true require_relative '../parser_warning' class Tryouts module Parsers module SharedMethods # Check if a description token at given index is followed by actual test content # (code + expectations), indicating it's a real test case vs...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/opts.rb
Ruby
mit
19
main
9,759
# lib/tryouts/cli/opts.rb # # frozen_string_literal: true class Tryouts class CLI HELP = <<~HELP Framework Defaults: Tryouts: Shared context (state persists across tests) RSpec: Fresh context (each test isolated) Minitest: Fresh context (each test isolated) Example...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/tty_detector.rb
Ruby
mit
19
main
3,528
# lib/tryouts/cli/tty_detector.rb # # frozen_string_literal: true require 'tty-screen' class Tryouts class CLI # TTY detection utility for determining live formatter availability module TTYDetector STATUS_LINES = 4 # Lines needed for live formatter status area # Check if TTY features are avail...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/line_spec_parser.rb
Ruby
mit
19
main
3,501
# lib/tryouts/cli/line_spec_parser.rb # # frozen_string_literal: true class Tryouts class CLI class LineSpecParser # Parse a file path with optional line specification # Supports formats: # - file.rb:19 (single line) # - file.rb:19-45 (range) # - file.rb:L19 (...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters.rb
Ruby
mit
19
main
423
# lib/tryouts/cli/formatters.rb # # frozen_string_literal: true require_relative 'formatters/base' require_relative 'formatters/compact' require_relative 'formatters/quiet' require_relative 'formatters/verbose' require_relative 'formatters/test_run_state' require_relative 'formatters/tty_status_display' require_relati...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/live_status_manager.rb
Ruby
mit
19
main
4,069
# lib/tryouts/cli/formatters/live_status_manager.rb # # frozen_string_literal: true require_relative 'test_run_state' require_relative 'tty_status_display' class Tryouts class CLI # Centralized manager for live status display across all formatters # Replaces the decorator pattern with inhouse integration ...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/quiet.rb
Ruby
mit
19
main
3,852
# lib/tryouts/cli/formatters/quiet.rb # # frozen_string_literal: true class Tryouts class CLI # Minimal output formatter - only shows essential information class QuietFormatter include FormatterInterface def initialize(options = {}) super @show_errors = options.fetch(:show...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/factory.rb
Ruby
mit
19
main
1,773
# lib/tryouts/cli/formatters/factory.rb # # frozen_string_literal: true require_relative '../tty_detector' class Tryouts class CLI # Factory for creating formatters and output managers class FormatterFactory def self.create_output_manager(options = {}) formatter = create_formatter(options) ...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/output_manager.rb
Ruby
mit
19
main
5,529
# lib/tryouts/cli/formatters/output_manager.rb # # frozen_string_literal: true require_relative 'live_status_manager' class Tryouts class CLI # Output manager that coordinates all output through formatters class OutputManager attr_reader :formatter, :live_status_manager def initialize(formatter...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/token_budget.rb
Ruby
mit
19
main
4,671
# lib/tryouts/cli/formatters/token_budget.rb # # frozen_string_literal: true class Tryouts class CLI # Token budget tracking for agent-optimized output class TokenBudget DEFAULT_LIMIT = 5000 BUFFER_PERCENT = 0.05 # 5% buffer to avoid going over attr_reader :limit, :used, :remaining ...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/base.rb
Ruby
mit
19
main
4,662
# lib/tryouts/cli/formatters/base.rb # # frozen_string_literal: true require_relative 'output_manager' class Tryouts class CLI # Enhanced interface for all test output formatting module FormatterInterface attr_reader :stdout, :stderr, :current_indent def initialize(options = {}) @stdout...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/verbose.rb
Ruby
mit
19
main
15,927
# lib/tryouts/cli/formatters/verbose.rb # # frozen_string_literal: true class Tryouts class CLI # Detailed formatter with comprehensive output and clear visual hierarchy class VerboseFormatter include FormatterInterface def initialize(options = {}) super @line_width = options...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/tty_status_display.rb
Ruby
mit
19
main
8,695
# lib/tryouts/cli/formatters/tty_status_display.rb # # frozen_string_literal: true require 'tty-cursor' require 'tty-screen' require 'pastel' require 'io/console' class Tryouts class CLI # Encapsulates TTY manipulation for live status display with fallback class TTYStatusDisplay STATUS_LINES = 5 # Li...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/agent.rb
Ruby
mit
19
main
29,247
# lib/tryouts/cli/formatters/agent.rb # # frozen_string_literal: true require_relative 'token_budget' class Tryouts class CLI # TOPAZ (Test Output Protocol for AI Zealots) Formatter # # Language-agnostic test output format designed for LLM context management. # This formatter implements the TOPAZ v1...
github
delano/tryouts
https://github.com/delano/tryouts
lib/tryouts/cli/formatters/test_run_state.rb
Ruby
mit
19
main
2,842
# lib/tryouts/cli/formatters/test_run_state.rb # # frozen_string_literal: true class Tryouts class CLI # Immutable state tracking for test runs using modern Ruby Data.define class TestRunState < Data.define( :total_tests, :passed, :failed, :errors, :files_completed, :total...