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 | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | config/environments/production.rb | Ruby | mit | 45 | main | 3,816 | # frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better perfor... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | config/environments/staging.rb | Ruby | mit | 45 | main | 3,808 | # frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better perfor... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | config/environments/test.rb | Ruby | mit | 45 | main | 2,393 | # frozen_string_literal: true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.applic... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/schema.rb | Ruby | mit | 45 | main | 19,547 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds.rb | Ruby | mit | 45 | main | 689 | # Do not add any seed command to this file. Instead, go to /db/seeds/ where you
# will find:
# - development.rb
# - production.rb
#
# Add your seed code into one of those depending on the environment where you wish
# for it to execute.
#
# The intent is to keep seeds separated by environment to avoid any accidental
# e... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250930164152_add_index_to_announcements_created_at.rb | Ruby | mit | 45 | main | 219 | class AddIndexToAnnouncementsCreatedAt < ActiveRecord::Migration[8.0]
disable_ddl_transaction!
def change
add_index :announcements, :created_at, order: { created_at: :desc }, algorithm: :concurrently
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250929233511_drop_delayed_jobs_table.rb | Ruby | mit | 45 | main | 624 | # frozen_string_literal: true
class DropDelayedJobsTable < ActiveRecord::Migration[8.0]
def up
drop_table :delayed_jobs, if_exists: true
end
def down
create_table "delayed_jobs" do |t|
t.integer "priority", default: 0, null: false
t.integer "attempts", default: 0, null: false
t.text "h... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250605233500_add_type_to_users.rb | Ruby | mit | 45 | main | 273 | # frozen_string_literal: true
# Adds a type column to the users table to support STI
class AddTypeToUsers < ActiveRecord::Migration[8.0]
def change
add_column :users, :type, :string, default: "User", null: false
change_column_null :users, :type, false
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250703151425_add_index_to_number_on_quarters.rb | Ruby | mit | 45 | main | 207 | class AddIndexToNumberOnQuarters < ActiveRecord::Migration[8.0]
disable_ddl_transaction!
def change
add_index :quarters, [:school_year_id, :number], unique: true, algorithm: :concurrently
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20251116135149_convert_portfolio_transaction_reason_to_enum.rb | Ruby | mit | 45 | main | 2,274 | class ConvertPortfolioTransactionReasonToEnum < ActiveRecord::Migration[8.1]
def up
add_column :portfolio_transactions, :reason_enum, :integer
safety_assured do
execute <<-SQL
UPDATE portfolio_transactions SET reason_enum = 0 WHERE reason = 'Earnings from Math';
UPDATE portfolio_transac... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250829013912_add_action_to_orders.rb | Ruby | mit | 45 | main | 220 | class AddActionToOrders < ActiveRecord::Migration[8.0]
def change
add_column :orders, :action, :string, null: false, default: "sell"
change_column_default :orders, :action, from: "sell", to: nil
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250522020802_remove_year_and_school_from_classrooms.rb | Ruby | mit | 45 | main | 214 | class RemoveYearAndSchoolFromClassrooms < ActiveRecord::Migration[7.2]
def change
remove_reference :classrooms, :year, foreign_key: true
remove_reference :classrooms, :school, foreign_key: true
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250526201022_change_year_column_to_name_and_update_type.rb | Ruby | mit | 45 | main | 284 | class ChangeYearColumnToNameAndUpdateType < ActiveRecord::Migration[7.2]
def up
rename_column :years, :year, :name
change_column :years, :name, :string, null: false
end
def down
change_column :years, :name, :integer
rename_column :years, :name, :year
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20251001164806_create_solid_queue.rb | Ruby | mit | 45 | main | 6,312 | class CreateSolidQueue < ActiveRecord::Migration[8.0]
safety_assured do
create_table "solid_queue_blocked_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "queue_name", null: false
t.integer "priority", default: 0, null: false
t.string "concurrency_key", null: false
... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250703133137_create_grade_entries.rb | Ruby | mit | 45 | main | 486 | class CreateGradeEntries < ActiveRecord::Migration[8.0]
def change
create_table :grade_entries do |t|
t.references :grade_book, null: false, foreign_key: true
t.references :user, null: false, foreign_key: true
t.string :math_grade, null: true
t.string :reading_grade, null: true... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240601215111_remove_portfolio_stocks_index.rb | Ruby | mit | 45 | main | 381 | # standard:disable Rails/ReversibleMigration
class RemovePortfolioStocksIndex < ActiveRecord::Migration[7.1]
def change
remove_index :portfolio_stocks, name: "index_portfolio_stocks_on_portfolio_and_stock"
add_index :portfolio_stocks, [:portfolio_id, :stock_id], name: "index_portfolio_stocks_on_portfolio_and... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20251229212809_create_classroom_enrollments.rb | Ruby | mit | 45 | main | 745 | class CreateClassroomEnrollments < ActiveRecord::Migration[8.1]
def change
create_table :classroom_enrollments do |t|
t.references :student, null: false, foreign_key: { to_table: :users }
t.references :classroom, null: false, foreign_key: true
t.datetime :enrolled_at, null: false
t.datetim... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240312195258_create_classrooms.rb | Ruby | mit | 45 | main | 300 | class CreateClassrooms < ActiveRecord::Migration[7.1]
def change
create_table :classrooms do |t|
t.string :name
t.references :year, null: false, foreign_key: true
t.references :school, null: false, foreign_key: true
t.string :grade
t.timestamps
end
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240531151002_remove_cash_balance_from_portfolios.rb | Ruby | mit | 45 | main | 225 | # standard:disable Rails/ReversibleMigration
class RemoveCashBalanceFromPortfolios < ActiveRecord::Migration[7.1]
def change
remove_column :portfolios, :cash_balance
end
end
# rubocop:enable Rails/ReversibleMigration |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20260401160551_backfill_teacher_username_from_email.rb | Ruby | mit | 45 | main | 328 | class BackfillTeacherUsernameFromEmail < ActiveRecord::Migration[8.1]
def up
User.where(type: "Teacher").find_each do |teacher|
teacher.update_column(:username, teacher.email) if teacher.email.present?
end
end
def down
# No safe way to reverse — username values before migration are unknown
en... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250701215852_create_grade_books.rb | Ruby | mit | 45 | main | 392 | class CreateGradeBooks < ActiveRecord::Migration[8.0]
def change
create_table :grade_books do |t|
t.references :quarter, null: false, foreign_key: true
t.references :classroom, null: false, foreign_key: true
t.string :status, null: false, default: 'draft'
t.timestamps
end
add_... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240424154028_remove_company_and_add_to_stock.rb | Ruby | mit | 45 | main | 1,251 | # standard:disable Rails/ReversibleMigration
class RemoveCompanyAndAddToStock < ActiveRecord::Migration[7.1]
def change
remove_reference :stocks, :company, foreign_key: true
drop_table :companies
add_column :stocks, :stock_exchange, :string
add_column :stocks, :company_name, :string
add_column ... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20251205031119_create_grades.rb | Ruby | mit | 45 | main | 1,062 | class CreateGrades < ActiveRecord::Migration[8.1]
def change
create_table :grades do |t|
t.string :name, null: false
t.integer :level, null: false
t.timestamps
end
add_index :grades, :level, unique: true
add_index :grades, :name, unique: true
reversible do |dir|
dir.up do... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240424040256_create_table_relations.rb | Ruby | mit | 45 | main | 1,320 | class CreateTableRelations < ActiveRecord::Migration[7.1]
def change
add_reference :users, :classroom, foreign_key: true
create_table :portfolios do |t|
t.references :user, null: false, foreign_key: true
t.float :cash_balance
t.float :current_position
t.json :transactions
t.tim... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250701215851_create_quarters.rb | Ruby | mit | 45 | main | 222 | class CreateQuarters < ActiveRecord::Migration[8.0]
def change
create_table :quarters do |t|
t.string :name
t.references :school_year, null: false, foreign_key: true
t.timestamps
end
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250913190649_drop_transaction_fee_from_orders.rb | Ruby | mit | 45 | main | 206 | class DropTransactionFeeFromOrders < ActiveRecord::Migration[8.0]
def change
safety_assured do
remove_column :orders, :transaction_fee_cents, :integer, default: 0, null: false
end
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250919210900_create_portfolio_snapshots.rb | Ruby | mit | 45 | main | 368 | class CreatePortfolioSnapshots < ActiveRecord::Migration[8.0]
def change
create_table :portfolio_snapshots do |t|
t.references :portfolio, null: false, foreign_key: true
t.date :date, null: false
t.integer :worth_cents, null: false
t.timestamps
end
add_index :portfolio_snapshots,... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240531160059_create_orders.rb | Ruby | mit | 45 | main | 296 | class CreateOrders < ActiveRecord::Migration[7.1]
def change
create_table :orders do |t|
t.references :user, null: false, foreign_key: true
t.references :stock, null: false, foreign_key: true
t.decimal :shares
t.integer :status
t.timestamps
end
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250510110558_change_price_to_price_cents_on_stocks.rb | Ruby | mit | 45 | main | 385 | class ChangePriceToPriceCentsOnStocks < ActiveRecord::Migration[7.2]
def change
reversible do |dir|
dir.up do
rename_column :stocks, :price, :price_cents
change_column :stocks, :price_cents, :integer
end
dir.down do
rename_column :stocks, :price_cents, :price
cha... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240601194906_change_float_to_big_decimal_portfolio_stocks.rb | Ruby | mit | 45 | main | 356 | # standard:disable Rails/ReversibleMigration
class ChangeFloatToBigDecimalPortfolioStocks < ActiveRecord::Migration[7.1]
def change
change_column :portfolio_stocks, :shares, :decimal, precision: 15, scale: 2
change_column :portfolio_stocks, :purchase_price, :decimal, precision: 15, scale: 2
end
end
# ruboc... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20251205032708_create_classroom_grades.rb | Ruby | mit | 45 | main | 347 | class CreateClassroomGrades < ActiveRecord::Migration[8.1]
def change
create_table :classroom_grades do |t|
t.references :classroom, null: false, foreign_key: true
t.references :grade, null: false, foreign_key: true
t.timestamps
end
add_index :classroom_grades, [:classroom_id, :grade_i... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250913114000_add_index_discarded_at_to_users.rb | Ruby | mit | 45 | main | 208 | # frozen_string_literal: true
class AddIndexDiscardedAtToUsers < ActiveRecord::Migration[8.0]
disable_ddl_transaction!
def change
add_index :users, :discarded_at, algorithm: :concurrently
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240601143331_create_delayed_jobs.rb | Ruby | mit | 45 | main | 1,397 | # standard:disable Rails/ReversibleMigrationMethodDefinition
class CreateDelayedJobs < ActiveRecord::Migration[7.1]
def self.up
create_table :delayed_jobs do |table|
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
table.integer :attempts, default: ... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240318210728_devise_create_users.rb | Ruby | mit | 45 | main | 1,466 | # frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[7.1]
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: true, default: ""
t.string :username, null: false, default: ""
t.string :encrypted_password, null: false, default: ... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250510100430_rename_amount_to_amount_cents_on_portfolio_transactions.rb | Ruby | mit | 45 | main | 647 | class RenameAmountToAmountCentsOnPortfolioTransactions < ActiveRecord::Migration[7.2]
def change
reversible do |dir|
dir.up do
rename_column(:portfolio_transactions, :amount, :amount_cents)
change_column(
:portfolio_transactions,
:amount_cents,
:integer,
... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240601200045_add_portfolio_stock_and_transaction_to_order.rb | Ruby | mit | 45 | main | 255 | class AddPortfolioStockAndTransactionToOrder < ActiveRecord::Migration[7.1]
def change
add_reference :orders, :portfolio_stock, null: true, foreign_key: true
add_reference :orders, :portfolio_transaction, null: true, foreign_key: true
end
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20240206214633_create_school_years.rb | Ruby | mit | 45 | main | 327 | class CreateSchoolYears < ActiveRecord::Migration[7.1]
def change
create_table :school_years do |t|
t.references :school, null: false, foreign_key: true
t.references :year, null: false, foreign_key: true
t.timestamps
end
add_index :school_years, [:school_id, :year_id], unique: true
e... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250703151816_create_teacher_classrooms.rb | Ruby | mit | 45 | main | 377 | class CreateTeacherClassrooms < ActiveRecord::Migration[8.0]
def change
create_table :teacher_classrooms do |t|
t.references :teacher, null: false, foreign_key: { to_table: :users }
t.references :classroom, null: false, foreign_key: true
t.timestamps
end
add_index :teacher_classroo... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20251221203546_migrate_classroom_grade_to_classroom_grades.rb | Ruby | mit | 45 | main | 1,077 | class MigrateClassroomGradeToClassroomGrades < ActiveRecord::Migration[8.1]
class Classroom < ActiveRecord::Base
self.table_name = "classrooms"
end
class Grade < ActiveRecord::Base
self.table_name = "grades"
end
class ClassroomGrade < ActiveRecord::Base
self.table_name = "classroom_grades"
end... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/migrate/20250608160040_fix_student_email_constraints.rb | Ruby | mit | 45 | main | 1,059 | class FixStudentEmailConstraints < ActiveRecord::Migration[8.0]
def up
# Remove the existing unique index on email
remove_index :users, :email if index_exists?(:users, :email)
# Change email column to allow null and remove default empty string
change_column :users, :email, :string, null: true, defaul... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/production.rb | Ruby | mit | 45 | main | 766 | # Add the seed actions for the production environment to this file.
puts "Production seed running."
start_time = Time.now
puts ""
# ---------------------- Add your seed code in this block ----------------------
# Create years
puts "Creating years..."
load(Rails.root.join("db", "seeds", "partials", "years.rb"))
puts ... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/development.rb | Ruby | mit | 45 | main | 2,111 | # Add the seed actions for the development environment to this file.
puts "Development seed running."
start_time = Time.now
puts ""
# ---------------------- Add your seed code in this block ----------------------
# The order of these seed files can be important due to model dependencies.
# Create years
puts "Creati... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/portfolio_transactions.rb | Ruby | mit | 45 | main | 3,542 | # frozen_string_literal: true
# Create transactions for Student user
student = User.find_by(email: "student@example.com")
if student
portfolio = Portfolio.find_or_create_by(user: student)
# Initial deposit to give student starting balance
PortfolioTransaction.create(
portfolio: portfolio,
transaction_t... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/grade_books_entries.rb | Ruby | mit | 45 | main | 811 | # For each quarter, spin up a GradeBook for this classroom
school_years = SchoolYear.first
classroom = Classroom.first
Quarter
.where(school_year: school_years)
.order(:number)
.each do |quarter|
book = GradeBook.find_or_create_by!(
quarter: quarter,
classroom: classroom
)
puts "Seeded Gr... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/years.rb | Ruby | mit | 45 | main | 202 | current_year = Date.current.year
start_year = current_year - 3
end_year = current_year + 10
(start_year..end_year).each do |i|
year = Year.find_or_create_by(name: "#{i} - #{i + 1}")
year.save!
end |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/stocks.rb | Ruby | mit | 45 | main | 8,035 | # frozen_string_literal: true
active_seed_stocks = [
{ ticker: "BAC", stock_exchange: "NYSE", company_name: "Bank of America Corporation", company_website: "https://www.bankofamerica.com", description: "Bank of America Corporation operates as a bank holding company for Bank of America, N.A., which provides var... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/portfolio_snapshots.rb | Ruby | mit | 45 | main | 1,620 | # frozen_string_literal: true
mike = User.find_by(email: "mike@example.com")
if mike
portfolio = Portfolio.find_by(user: mike)
if portfolio
# Create 6 months of historical snapshots with realistic value progression
# Starting 5 months ago and ending with current month
base_value = 150_00 # $150.00 st... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/users.rb | Ruby | mit | 45 | main | 1,946 | # Teacher
teacher = User.find_or_initialize_by(email: "teacher@example.com")
unless teacher.persisted?
teacher.attributes = {
name: "Teacher Name",
password: "password",
password_confirmation: "password",
admin: false,
type: "Teacher",
classroom: Classroom.first
}
teacher.save
puts "Crea... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/quarters.rb | Ruby | mit | 45 | main | 588 | # Create 4 quarters for the first school year
school_year = SchoolYear.find_by(school: School.first, year: Year.first)
if school_year
(1..4).each do |n|
Quarter.find_or_create_by!(
school_year: school_year,
number: n
) do |q|
q.update(name: "Quarter #{n}")
end
end
puts "Quarters cre... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/orders.rb | Ruby | mit | 45 | main | 4,226 | # frozen_string_literal: true
# Pending buy orders
student = User.find_by(email: "student@example.com")
mike = User.find_by(email: "mike@example.com")
students = [student, mike].compact
if students.any?
stocks = Stock.limit(5)
students.each do |student_user|
if student_user&.portfolio
portfolio_balanc... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/grades.rb | Ruby | mit | 45 | main | 416 | # Create grade levels 5-8
Classroom::GRADE_RANGE.each do |level|
# Create the grade name with proper ordinal (5th, 6th, 7th, etc.)
grade_name = "#{level.ordinalize} Grade"
grade = Grade.find_or_create_by(level: level) do |g|
g.name = grade_name
end
# Update name if it's not following the convention... |
github | rubyforgood/stocks-in-the-future | https://github.com/rubyforgood/stocks-in-the-future | db/seeds/partials/classrooms.rb | Ruby | mit | 45 | main | 283 | # frozen_string_literal: true
grade = Grade.find_by!(level: 6)
classroom = Classroom.find_or_initialize_by(name: "Smith's Sixth Grade", school_year: SchoolYear.first)
classroom.trading_enabled = true
classroom.grades << grade unless classroom.grades.include?(grade)
classroom.save! |
github | lab2023/katip | https://github.com/lab2023/katip | katip.gemspec | Ruby | mit | 45 | develop | 1,081 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'katip/version'
Gem::Specification.new do |spec|
spec.name = 'katip'
spec.version = Katip::VERSION
spec.authors = %w[lab2023]
spec.email = %w[info@lab2023.com]... |
github | lab2023/katip | https://github.com/lab2023/katip | spec/tag_spec.rb | Ruby | mit | 45 | develop | 1,279 | require 'spec_helper'
repo = File.join(File.dirname(__FILE__), 'katip-sample-repo')
describe 'Tag system' do
before do
Dir.chdir repo
end
it 'creates the change log with the given tag range' do
change_logger = Katip::ChangeLogger.new 'CHANGELOG.md', '0.1.0', '0.4.0'
change_logger.log_changes
o... |
github | lab2023/katip | https://github.com/lab2023/katip | spec/basics_spec.rb | Ruby | mit | 45 | develop | 1,484 | require 'spec_helper'
require 'digest'
repo = File.join(File.dirname(__FILE__), 'katip-sample-repo')
describe 'Katip application' do
before do
Dir.chdir repo
end
it 'creates the change log with default name' do
change_logger = Katip::ChangeLogger.new
change_logger.log_changes
expect(File.exists... |
github | lab2023/katip | https://github.com/lab2023/katip | lib/tasks/katip.rake | Ruby | mit | 45 | develop | 226 | namespace :katip do
desc 'Create change log'
task :create => [:environment] do
file_name = ENV['file'] || 'CHANGELOG.md'
change_logger = Katip::ChangeLogger.new(file_name)
change_logger.log_changes
end
end |
github | lab2023/katip | https://github.com/lab2023/katip | lib/katip/change_logger.rb | Ruby | mit | 45 | develop | 3,136 | # encoding: utf-8
require 'katip'
require 'katip/change_logger'
module Katip
class ChangeLogger
COMMIT_URL='../../commit/'
ISSUE_URL='../../issues/'
# initialize
#
# @param [String] file_name with path
def initialize(file_name='CHANGELOG.md', from=nil, to=nil)
@file_name = file_name
... |
github | nex3/dynamicmatic | https://github.com/nex3/dynamicmatic | Rakefile | Ruby | mit | 45 | master | 869 | begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "dynamicmatic"
gemspec.summary = "Dynamic StaticMatic pages with Sinatra."
gemspec.description = <<DESCRIPTION
DynamicMatic is a tiny Sinatra extension that integrates Sinatra with StaticMatic.
It allows most of your site to be stati... |
github | nex3/dynamicmatic | https://github.com/nex3/dynamicmatic | dynamicmatic.gemspec | Ruby | mit | 45 | master | 1,767 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{dynamicmatic}
s.version = "0.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requi... |
github | nex3/dynamicmatic | https://github.com/nex3/dynamicmatic | lib/sinatra/dynamicmatic.rb | Ruby | mit | 45 | master | 1,306 | require 'sinatra/base'
require 'staticmatic'
require File.dirname(__FILE__) + '/dynamicmatic/middleware'
module Sinatra
module DynamicMatic
def self.registered(app)
app.set :lock, true
app.set :public, Proc.new {app.root && File.join(app.root, 'site')}
# If we're in development, don't serve th... |
github | nex3/dynamicmatic | https://github.com/nex3/dynamicmatic | lib/sinatra/dynamicmatic/middleware.rb | Ruby | mit | 45 | master | 260 | module Sinatra
module DynamicMatic
class Middleware
def initialize(app)
@app = app
@server = StaticMatic::Server.new(app.send(:staticmatic), @app)
end
def call(env)
@server.call(env)
end
end
end
end |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | snabberb.gemspec | Ruby | mit | 45 | master | 1,486 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'snabberb/version'
Gem::Specification.new do |spec|
spec.name = 'snabberb'
spec.version = Snabberb::VERSION
spec.authors = ['Toby Mao']
spec.email =... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | opal/snabberb/component.rb | Ruby | mit | 45 | master | 9,862 | # frozen_string_literal: true
module Snabberb
class Component
attr_accessor :node
attr_reader :root
%x{
const VOID = new Set([
'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'keygen',
'link',
'meta... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | lib/snabberb.rb | Ruby | mit | 45 | master | 1,534 | # frozen_string_literal: true
require 'json'
require 'opal'
require 'snabberb/version'
Opal.append_path(File.expand_path('../opal', __dir__))
module Snabberb
def self.wrap(obj)
case obj
when Hash
wrap_h(obj)
when Array
wrap_a(obj)
when Numeric, TrueClass, FalseClass
obj
when n... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | examples/rack/config.ru | Ruby | mit | 45 | master | 546 | # frozen_string_literal: true
require 'bundler'
Bundler.require
# Instructions: bundle in this directory
# then run `bundle exec rackup` to start the server
# and browse to http://localhost:9292
# the directory where the code is (add to opal load path )
Opal.append_path('app')
run(Opal::SimpleServer.new do |s|
# ... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | examples/rack/app/application.rb | Ruby | mit | 45 | master | 1,372 | # frozen_string_literal: true
require 'opal'
require 'snabberb'
class Row < Snabberb::Component
needs :index
needs :value
needs :selected_id, default: nil, store: true
def selected?
@index == @selected_id
end
def render
onclick = lambda do
store(:selected_id, selected? ? nil : @index)
... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | examples/roda/config.ru | Ruby | mit | 45 | master | 1,271 | # frozen_string_literal: true
require 'execjs'
require 'opal'
require 'roda'
require 'snabberb'
require 'tilt/opal'
class OpalTemplate < Opal::TiltTemplate
def evaluate(_scope, _locals)
builder = Opal::Builder.new(stubs: 'opal')
builder.append_paths('assets/js')
builder.append_paths('build')
opal_p... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | examples/roda/assets/js/application.rb | Ruby | mit | 45 | master | 2,704 | # frozen_string_literal: true
require 'compiled-opal'
require 'polyfill'
require 'snabberb'
require 'set'
class Tile < Snabberb::Component
def render
h(:g, { attrs: { transform: 'rotate(60)' } }, [
h(:path, attrs: { d: 'm 0 87 L 0 -87', stroke: 'black', 'stroke-width' => 8 }),
h(:path, attrs: { d: '... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | spec/test_component.rb | Ruby | mit | 45 | master | 292 | # frozen_string_literal: true
class TestComponent < Snabberb::Component
needs :groceries
def render
props = {
style: { width: '100%' },
}
groceries = @groceries.map do |name, count|
h(:div, "#{name} - #{count}")
end
h(:div, props, groceries)
end
end |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | spec/snabberb_spec.rb | Ruby | mit | 45 | master | 6,153 | # frozen_string_literal: true
require 'execjs'
require 'opal'
require 'spec_helper'
describe Snabberb do
before :all do
builder = Opal::Builder.new
builder.build('opal')
builder.build('snabberb')
@js_context = ExecJS.compile(builder.to_s)
end
def evaluate(script)
@js_context.eval(Opal.compi... |
github | tobymao/snabberb | https://github.com/tobymao/snabberb | spec/spec_helper.rb | Ruby | mit | 45 | master | 269 | # frozen_string_literal: true
require 'snabberb'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
config.expect_with :rspec do |c|
c.syntax = :expect
end
end |
github | openware/kite | https://github.com/openware/kite | kite.gemspec | Ruby | apache-2.0 | 45 | master | 1,176 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'kite/version'
Gem::Specification.new do |spec|
spec.name = "kite"
spec.version = Kite::VERSION
spec.authors = ['Louis Bellet', 'Camille Meulien', 'Valentine Shatravenko... |
github | openware/kite | https://github.com/openware/kite | ci/bump.rb | Ruby | apache-2.0 | 45 | master | 6,287 | require 'rubygems/version'
require 'net/http'
require 'json'
require 'uri'
#
# Returns bot's username in GitHub.
#
# @return [String]
def bot_username
ENV.fetch('BOT_USERNAME', 'kite-bot')
end
#
# Returns bot's displayed name in commits.
#
# @return [String]
def bot_name
ENV.fetch('BOT_NAME', 'Kite Bot')
end
#
#... |
github | openware/kite | https://github.com/openware/kite | lib/kite.rb | Ruby | apache-2.0 | 45 | master | 305 | require 'erb'
require 'yaml'
require 'ipaddr'
require 'git'
require 'thor'
require 'kite/version'
require 'kite/helpers'
require 'kite/error'
require 'kite/base'
require 'kite/generate'
require 'kite/module'
require 'kite/terraform'
require 'kite/configuration'
require 'kite/core'
require 'kite/cloud' |
github | openware/kite | https://github.com/openware/kite | lib/kite/terraform.rb | Ruby | apache-2.0 | 45 | master | 1,269 | module Kite
class Terraform
def initialize(core, options)
@core = core
@env_name = options[:env]
end
def run(command, *args)
exit_status = 0
STDERR.puts "Loading env"
load_env
script = "terraform #{command} #{args.join " "}"
STDERR.puts script
Dir.chdir("... |
github | openware/kite | https://github.com/openware/kite | lib/kite/helpers.rb | Ruby | apache-2.0 | 45 | master | 1,134 | module Kite::Helpers
# Check config/cloud.yml file to be complete
def check_cloud_config(config)
raise Kite::Error, 'The config/cloud.yml is not filled out!' unless config.find { |key, hash| hash.find { |k, v| v.nil? } }.nil?
end
def cloud_valid?(path)
valid = Dir.children(path).include? 'config'
v... |
github | openware/kite | https://github.com/openware/kite | lib/kite/module.rb | Ruby | apache-2.0 | 45 | master | 3,928 | module Kite
class Module < Base
include Kite::Helpers
method_option :env, type: :string, desc: "Environment", required: true, default: ENV['KITE_ENV']
method_option :version, type: :string, desc: "Version", aliases: '-v', required: false
method_option :method, type: :string, desc: "Module import... |
github | openware/kite | https://github.com/openware/kite | lib/kite/configuration.rb | Ruby | apache-2.0 | 45 | master | 676 | module Kite
class Configuration < Base
include Kite::Helpers
method_option :env, type: :string, desc: "Environment", required: true, default: ENV['KITE_ENV']
desc 'get QUERY', 'Returns value for specified QUERY'
def get(query)
@env = options[:env]
@path = cloud_path
vars_paths = Dir... |
github | openware/kite | https://github.com/openware/kite | lib/kite/core.rb | Ruby | apache-2.0 | 45 | master | 1,080 | module Kite
class Core < Base
include Kite::Helpers
desc "new CLOUD_PATH", "Generate Cloud infrastructure skeleton from configuration"
# Creates a cloud infrastructure skeleton with a given name
def new(cloud_name)
target = Kite::Cloud.new(self, cloud_name)
target.prepare
end
de... |
github | openware/kite | https://github.com/openware/kite | lib/kite/generate.rb | Ruby | apache-2.0 | 45 | master | 2,264 | module Kite
# Subcommand for generating environments, services etc.
class Generate < Base
include Kite::Helpers
method_option :name, type: :string, desc: "Task name", required: true
desc "task", "Generate task IaC from configuration"
def task()
say "Generating task #{ options[:name] } IaC", :... |
github | openware/kite | https://github.com/openware/kite | lib/kite/cloud.rb | Ruby | apache-2.0 | 45 | master | 404 | # Class responsible for creating a new cloud infrastructure skeleton
class Kite::Cloud
def initialize(core, cloud_name)
@core = core
@name = cloud_name
@core.destination_root = nil
end
def name
@name
end
def core
@core
end
def prepare
core.directory('skel', name)
core.insid... |
github | openware/kite | https://github.com/openware/kite | lib/kite/base.rb | Ruby | apache-2.0 | 45 | master | 251 | # Base class including all Thor-related configuration
class Kite::Base < Thor
include Thor::Actions
def self.exit_on_failure?
true
end
def self.source_root
File.expand_path(File.join(File.dirname(__FILE__), "../../tpl"))
end
end |
github | openware/kite | https://github.com/openware/kite | lib/kite/helpers/concourse.rb | Ruby | apache-2.0 | 45 | master | 970 | require 'json'
require 'open3'
module Kite
module Helpers
# Helpers for concourse scripts
module Concourse
def self.params(data)
JSON.parse data
end
def self.log(msg)
msg.split("\n").each { |line| $stderr.puts("[LOG] --- #{line}") }
end
def self.respond(data)
... |
github | openware/kite | https://github.com/openware/kite | spec/spec_helper.rb | Ruby | apache-2.0 | 45 | master | 1,740 | if ENV["COVERAGE"] == "true"
require 'simplecov'
require 'codecov'
SimpleCov.start do
load_profile "test_frameworks"
add_group "Templates", "tpl"
add_group "Lib", "lib"
track_files "{lib,bin,tpl}/**/*.{rb,erb}"
end
SimpleCov.formatter = SimpleCov::Formatter::Codecov
end
require "bundler/setup... |
github | openware/kite | https://github.com/openware/kite | spec/config_spec.rb | Ruby | apache-2.0 | 45 | master | 1,129 | require 'spec_helper'
describe Kite do
include TmpDirIsolation
let(:opts) { { raise_error: false } }
it 'needs folder with kite structure' do
expect(capture(:stderr) do
run "#{ KITE_BIN } config get key --env test", opts
end.strip).to eq "Invalid path: \"#{Dir.pwd}\""
end
describe 'has valid... |
github | openware/kite | https://github.com/openware/kite | spec/kite_spec.rb | Ruby | apache-2.0 | 45 | master | 282 | require "spec_helper"
require 'tmpdir'
RSpec.describe Kite do
it "has a version number" do
expect(Kite::VERSION).not_to be nil
end
it "can initialize a cloud" do
tc = Kite::Cloud.new(Kite::Core.new, 'test_cloud')
expect(tc.name).not_to be 'test_cloud'
end
end |
github | openware/kite | https://github.com/openware/kite | tpl/skel/lib/tasks/git.rake | Ruby | apache-2.0 | 45 | master | 493 | def for_each_submodule &block
status = %x{git submodule status}
status.each {|line| yield line.split()[1] }
end
def for_each_submodule_dir &block
for_each_submodule { |dir| Dir.chdir(dir) { yield dir } }
end
def get_branch(status = `git status`)
branch = nil
if match = Regexp.new("^# On branch (.*)").match(... |
github | jamesgolick/munin_plugin | https://github.com/jamesgolick/munin_plugin | Rakefile | Ruby | mit | 45 | master | 1,338 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "munin_plugin"
gem.summary = %Q{Friendly API for creating munin plugins in ruby.}
gem.description = %Q{Friendly API for creating munin plugins in ruby.}
gem.email = "jamesgolick@gmail.com"
gem.homep... |
github | jamesgolick/munin_plugin | https://github.com/jamesgolick/munin_plugin | munin_plugin.gemspec | Ruby | mit | 45 | master | 1,243 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{munin_plugin}
s.version = "0.1.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requi... |
github | jamesgolick/munin_plugin | https://github.com/jamesgolick/munin_plugin | lib/munin_plugin.rb | Ruby | mit | 45 | master | 1,323 | class MuninPlugin
class Attribute
attr_reader :name, :args
def initialize(*args)
if args.first.is_a?(Attribute)
@name = [args.shift.name, args.shift].join(".")
else
@name = args.first
end
@args = args
end
def method_missing(method, *args, &block)
@name ... |
github | watir/watir-rails | https://github.com/watir/watir-rails | watir-rails.gemspec | Ruby | mit | 45 | master | 1,089 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/watir/rails/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Jarmo Pertman"]
gem.email = ["jarmo.p@gmail.com"]
gem.description = %q{Use Watir (http://github.com/watir/watir) in Rails.}
gem.summary = %q{Use Watir... |
github | watir/watir-rails | https://github.com/watir/watir-rails | lib/watir/rails.rb | Ruby | mit | 45 | master | 4,477 | require "uri"
require "net/http"
require "rack"
require "watir"
require "rails"
require File.expand_path("rails/browser.rb", File.dirname(__FILE__))
require File.expand_path("rails/middleware.rb", File.dirname(__FILE__))
module Watir
class Rails
class << self
private :new
attr_reader :port, :middle... |
github | watir/watir-rails | https://github.com/watir/watir-rails | lib/watir/rails/browser.rb | Ruby | mit | 45 | master | 1,159 | module Watir
# Reopened Watir::Browser class for working with Rails
class Browser
# @private
alias_method :_original_initialize, :initialize
# Will start Rails instance for Watir automatically and then invoke the
# original Watir::Browser#initialize method.
def initialize(*args)
Rails.boo... |
github | watir/watir-rails | https://github.com/watir/watir-rails | lib/watir/rails/middleware.rb | Ruby | mit | 45 | master | 940 | module Watir
class Rails
# @private
class Middleware
class PendingRequestsCounter
attr_reader :value
def initialize
@value = 0
@mutex = Mutex.new
end
def increment
@mutex.synchronize { @value += 1 }
end
def decrement
... |
github | watir/watir-rails | https://github.com/watir/watir-rails | spec/spec_helper.rb | Ruby | mit | 45 | master | 850 | require "simplecov"
if ENV["LCOV_REPORT_PATH"]
require "simplecov-lcov"
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
root_dir = File.expand_path('..', __dir__)
c.single_report_path = File.expand_path(ENV.fetch('LCOV_REPORT_PATH'), root_dir)
end
SimpleCov.form... |
github | watir/watir-rails | https://github.com/watir/watir-rails | spec/watir/rails_spec.rb | Ruby | mit | 45 | master | 4,866 | require "spec_helper"
describe Watir::Rails do
before do
allow(described_class).to receive(:warn)
described_class.ignore_exceptions = nil
described_class.instance_eval { @middleware = @port = @server_thread = @host = @app = nil }
end
let(:thread) { described_class.instance_variable_get(:@server_thre... |
github | watir/watir-rails | https://github.com/watir/watir-rails | spec/watir/rails/browser_spec.rb | Ruby | mit | 45 | master | 2,503 | require "spec_helper"
describe Watir::Browser do
before { allow(Watir::Rails).to receive_messages(ignore_exceptions?: true) }
context "#initialize" do
it "starts Rails before opening the browser" do
expect(Watir::Rails).to receive(:boot)
expect_any_instance_of(Watir::Browser).to receive(:_original... |
github | watir/watir-rails | https://github.com/watir/watir-rails | spec/watir/rails/middleware_spec.rb | Ruby | mit | 45 | master | 762 | require "spec_helper"
describe Watir::Rails::Middleware do
let(:app) { double("app") }
let(:middleware) { described_class.new app }
context "#call" do
it "/__identify__ returns app id" do
expect(app).not_to receive(:call)
expect(middleware.call("PATH_INFO" => "/__identify__")).to eq([200, {}, [a... |
github | aim2bpg/rubree | https://github.com/aim2bpg/rubree | Gemfile | Ruby | mit | 45 | main | 3,233 | source "https://rubygems.org"
ruby file: ".ruby-version"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 8.1.3", group: [:default, :wasm]
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
gem "propshaft", group: [:default, :wasm]
# Use sqlite3 ... |
github | aim2bpg/rubree | https://github.com/aim2bpg/rubree | spec/rails_helper.rb | Ruby | mit | 45 | main | 3,308 | # This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
# Un... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.