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
r7kamura/chatroid
https://github.com/r7kamura/chatroid
lib/chatroid/timer/event.rb
Ruby
mit
46
master
1,069
class Chatroid module Timer class Event # `every` is a Hash object which may have following keys: # :sec # :min # :hour # # `block` will be executed at times specified by `every` # # Example: "Hello, world!" will be printed at 14:00 and 14:30 every day # event...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
spree_faq.gemspec
Ruby
bsd-3-clause
46
master
780
Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_faq' s.version = '3.0.5' s.summary = 'Adds an easy faq page to your spree site' s.description = 'With this gem you get an faq page and the management tools to make it very easy to update your faq and reduce the de...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
Guardfile
Ruby
bsd-3-clause
46
master
745
guard 'rspec', :cli => '--color --format doc' do watch('spec/spec_helper.rb') { "spec" } watch('config/routes.rb') { "spec/routing" } watch('app/controllers/application_controller.rb') { "spec/controllers" } watch(%r{^spec/.+_spec\.rb$}) watch(%r{^app/(.+)\.rb...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
Rakefile
Ruby
bsd-3-clause
46
master
654
require 'rake' require 'rake/testtask' require 'rake/packagetask' require 'rubygems/package_task' require 'rspec/core/rake_task' require 'spree_core/testing_support/common_rake' RSpec::Core::RakeTask.new spec = eval(File.read('spree_faq.gemspec')) Gem::PackageTask.new(spec) do |p| p.gem_spec = spec end desc "Rele...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
Gemfile
Ruby
bsd-3-clause
46
master
406
source 'http://rubygems.org' gem 'sqlite3' group :development do gem 'guard' gem 'guard-rspec' gem 'rb-inotify', :require => false gem 'rb-fsevent', :require => false gem 'rb-fchange', :require => false gem 'libnotify' end group :test do gem 'rspec-rails', '= 2.6.1' gem 'faker' gem 'factory_girl' e...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
app/overrides/faq_admin_tab.rb
Ruby
bsd-3-clause
46
master
273
Deface::Override.new(:virtual_path => "layouts/admin", :name => "faq_admin_tab", :insert_bottom => "[data-hook='admin_tabs']", :text => "<%= tab(:question_categories, :label => :question_categories_admin) %>")
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
app/models/question_category.rb
Ruby
bsd-3-clause
46
master
213
class QuestionCategory < ActiveRecord::Base acts_as_list has_many :questions validates :name, :presence => true, :uniqueness => true accepts_nested_attributes_for :questions, :allow_destroy => true end
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
app/controllers/faqs_controller.rb
Ruby
bsd-3-clause
46
master
219
class FaqsController < Spree::BaseController helper 'spree/base' def index @categories = QuestionCategory.all :include => :questions end def default_title I18n.t 'frequently_asked_questions' end end
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
app/controllers/admin/question_categories_controller.rb
Ruby
bsd-3-clause
46
master
408
class Admin::QuestionCategoriesController < Admin::BaseController resource_controller helper 'spree/base' new_action.response do |format| format.html format.js end update.response do |format| format.html { redirect_to admin_question_categories_path } end create.response do |format| form...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
spec/spec_helper.rb
Ruby
bsd-3-clause
46
master
933
# This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../dummy/config/environment", __FILE__) require 'rspec/rails' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subd...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
spec/controllers/faqs_controller_spec.rb
Ruby
bsd-3-clause
46
master
286
require 'spec_helper' require 'faqs_controller' describe FaqsController do it "should response to index" do QuestionCategory.should_receive(:all).and_return(:categories) get :index assigns(:categories).should eql(:categories) response.should be_success end end
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
spec/controllers/admin/question_categories_controller_spec.rb
Ruby
bsd-3-clause
46
master
310
require 'spec_helper' require 'admin/question_categories_controller' describe Admin::QuestionCategoriesController do #Delete this example and add some real ones it "should use Admin::QuestionCategoriesController" do controller.should be_an_instance_of(Admin::QuestionCategoriesController) end end
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
spec/models/question_category_spec.rb
Ruby
bsd-3-clause
46
master
1,028
require 'spec_helper' require 'question_category' describe QuestionCategory do before(:each) do @valid_attributes = { :name => "value for name", :position => 1 } end it "should create a new instance given valid attributes" do QuestionCategory.create!(@valid_attributes) end it "shoul...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
spec/models/question_spec.rb
Ruby
bsd-3-clause
46
master
1,248
require 'spec_helper' require 'question' describe Question do before(:each) do QuestionCategory.create! :name => 'foo' @valid_attributes = { :question_category_id => 1, :question => "value for question", :answer => "value for answer", :position => 1 } end it "should create a...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
lib/spree_faq/engine.rb
Ruby
bsd-3-clause
46
master
554
module SpreeFaq class Engine < Rails::Engine engine_name 'spree_faq' config.autoload_paths += %W(#{config.root}/lib) def self.activate Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c| Rails.application.config.cache_classes ? require(c) : load(c) end ...
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
db/migrate/20090526213550_create_question_categories.rb
Ruby
bsd-3-clause
46
master
261
class CreateQuestionCategories < ActiveRecord::Migration def self.up create_table :question_categories do |t| t.string :name t.integer :position t.timestamps end end def self.down drop_table :question_categories end end
github
joshnuss/spree-faq
https://github.com/joshnuss/spree-faq
db/migrate/20090526213535_create_questions.rb
Ruby
bsd-3-clause
46
master
299
class CreateQuestions < ActiveRecord::Migration def self.up create_table :questions do |t| t.integer :question_category_id t.text :question t.text :answer t.integer :position t.timestamps end end def self.down drop_table :questions end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
boxwerk.gemspec
Ruby
mit
46
main
2,152
# frozen_string_literal: true require_relative 'lib/boxwerk/version' Gem::Specification.new do |spec| spec.name = 'boxwerk' spec.version = Boxwerk::VERSION spec.authors = ['David Cristofaro'] spec.email = ['david@dtcristo.com'] spec.summary = 'Ruby package system with Box-powered boundary enforcement' sp...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
Rakefile
Ruby
mit
46
main
1,251
# frozen_string_literal: true require 'bundler/gem_tasks' STREE_FILES = '**/*.rb **/Rakefile' EXAMPLES_DIR = File.join(__dir__, 'examples') EXAMPLE_DIRS = Dir.glob(File.join(EXAMPLES_DIR, '*')).select { |d| File.directory?(d) }.sort task :test do $LOAD_PATH.unshift(File.join(__dir__, 'test')) Dir.glob('test/bo...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk.rb
Ruby
mit
46
main
1,166
# frozen_string_literal: true require_relative 'boxwerk/autoloader_mixin' require_relative 'boxwerk/box_manager' require_relative 'boxwerk/cli' require_relative 'boxwerk/constant_resolver' require_relative 'boxwerk/gem_resolver' require_relative 'boxwerk/gemfile_require_parser' require_relative 'boxwerk/global_context...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/package_resolver.rb
Ruby
mit
46
main
3,324
# frozen_string_literal: true require 'yaml' require 'pathname' module Boxwerk # Discovers packages by scanning for package.yml files and provides # ordering for boot. Supports boxwerk.yml configuration for package_paths. class PackageResolver attr_reader :packages, :root def initialize(root_path, conf...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/zeitwerk_scanner.rb
Ruby
mit
46
main
6,038
# frozen_string_literal: true require 'zeitwerk' module Boxwerk # Uses Zeitwerk's file system scanner and inflector to discover constants # in a directory. Zeitwerk's autoload registration cannot be used directly # inside Ruby::Box (autoloads register in the box where the code was # defined, not where it's ca...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/package.rb
Ruby
mit
46
main
2,306
# frozen_string_literal: true module Boxwerk # Data class representing a package. Reads the standard package.yml format. class Package attr_reader :name, :config def initialize(name:, config: {}) @name = name @config = config end def root? @name == '.' end def dependenc...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/box_manager.rb
Ruby
mit
46
main
14,766
# frozen_string_literal: true module Boxwerk class BoxManager attr_reader :boxes, :gem_resolver, :file_indexes, :default_autoload_dirs, :package_dirs_info def initialize(root_path) @root_path = root_path @boxes = {} # package name -> Ruby::Box @file_indexes = {} # package name -> {const_na...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/cli.rb
Ruby
mit
46
main
28,897
# frozen_string_literal: true require 'rbconfig' require 'stringio' module Boxwerk module CLI class << self attr_accessor :exe_path def run(argv, exe_path: nil) @exe_path = exe_path if argv.empty? print_usage exit 1 end case argv[0] when ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/constant_resolver.rb
Ruby
mit
46
main
8,432
# frozen_string_literal: true module Boxwerk # Resolves constants from dependency packages without namespace wrapping. # # When package A depends on package B, B's constants are accessible # directly in A (e.g. Invoice, not Finance::Invoice). A const_missing # handler searches all direct dependencies in orde...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/global_context.rb
Ruby
mit
46
main
2,614
# frozen_string_literal: true module Boxwerk # Runtime context for the root box, accessible via +Boxwerk.global+ from # any box context (global boot, package boot, or application code). class GlobalContext # @return [GlobalContext::Autoloader] Autoloader configuration for the root box. attr_reader :autol...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/privacy_checker.rb
Ruby
mit
46
main
5,276
# frozen_string_literal: true require 'zeitwerk' module Boxwerk # Enforces privacy rules at runtime. # Reads enforce_privacy, public_path, and private_constants from package.yml. # Files with `# pack_public: true` sigil are treated as public. module PrivacyChecker DEFAULT_PUBLIC_PATH = 'public/' PUBLI...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/gemfile_require_parser.rb
Ruby
mit
46
main
1,185
# frozen_string_literal: true module Boxwerk # Lightweight Gemfile parser that extracts autorequire directives. # # Evaluates a Gemfile in a sandbox that only captures `gem` calls, # avoiding Bundler::Dsl side-effects. Handles: # gem 'name' → nil (require the gem name) # gem 'name', re...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/package_context.rb
Ruby
mit
46
main
3,318
# frozen_string_literal: true module Boxwerk # Runtime context for the current package, accessible via +Boxwerk.package+. # Available during +boot.rb+ execution and throughout the application. class PackageContext # @return [String] The package name (e.g. +"packs/orders"+ or +"."+ for root). attr_reader ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/setup.rb
Ruby
mit
46
main
5,821
# frozen_string_literal: true module Boxwerk module Setup class << self def run(start_dir: Dir.pwd, packages: nil, config: {}) root_path = find_root(start_dir) resolver = Boxwerk::PackageResolver.new(root_path, config_overrides: config) config = resolver.boxwerk_config eage...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/autoloader_mixin.rb
Ruby
mit
46
main
2,141
# frozen_string_literal: true module Boxwerk # Shared autoload configuration API included by both # {GlobalContext::Autoloader} and {PackageContext::Autoloader}. # # Provides the four public methods available in boot scripts: # {#push_dir}, {#collapse}, {#ignore}, and {#setup}. module AutoloaderMixin #...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
lib/boxwerk/gem_resolver.rb
Ruby
mit
46
main
8,054
# frozen_string_literal: true require 'bundler' module Boxwerk # Resolves per-package gem dependencies from lockfiles. # # Parses lockfiles with Bundler::LockfileParser and resolves gem load paths # for $LOAD_PATH isolation per box. Unlike Bundler itself, this resolver can # find gems outside the current bu...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/minimal/main.rb
Ruby
mit
46
main
372
# frozen_string_literal: true # Boxwerk Minimal Example puts "Foo: #{Foo.call}" puts "Bar: #{Bar.call}" # Bar depends on Baz, so Bar can access Baz puts "Bar uses Baz: #{Bar.baz_call}" # Baz is NOT a direct dependency of root — blocked begin Baz.call abort 'ERROR: Baz should not be accessible' rescue NameError ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/Rakefile
Ruby
mit
46
main
496
# frozen_string_literal: true require_relative 'config/application' Rails.application.load_tasks task :test do Dir .glob('test/**/*_test.rb') .reject { |f| f.include?('e2e') } .sort .each { |f| require_relative f } end task :e2e do # Disconnect AR so forked subprocess doesn't inherit stale SQLit...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/config/application.rb
Ruby
mit
46
main
291
# frozen_string_literal: true module Example class Application < Rails::Application config.load_defaults 8.1 config.api_only = true config.eager_load = true # Boxwerk handles autoloading for packs config.autoload_paths = [] config.eager_load_paths = [] end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/config/routes.rb
Ruby
mit
46
main
216
# frozen_string_literal: true Rails.application.routes.draw do resources :users, only: %i[index show create] resources :products, only: %i[index show create] resources :orders, only: %i[index show create] end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/global/boot.rb
Ruby
mit
46
main
598
# frozen_string_literal: true # Global boot — runs in root box before package boxes are created. # Require and eager load Rails frameworks so they are available in all boxes. require 'rails' require 'active_record/railtie' require 'action_controller/railtie' require 'rails/command' # Eager load Rails internals so ch...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/test/integration_test.rb
Ruby
mit
46
main
1,398
# frozen_string_literal: true require_relative 'test_helper' class IntegrationTest < RailsTestCase def test_user_creation user = User.create!(name: 'Alice', email: 'alice@example.com') assert_equal 'Alice', user.name end def test_product_creation product = Product.create!(name: 'Widget', price_cent...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/test/e2e_test.rb
Ruby
mit
46
main
4,058
#!/usr/bin/env ruby # frozen_string_literal: true # Rails example e2e tests. # Usage: RUBY_BOX=1 ruby examples/rails/test/e2e_test.rb require 'open3' require 'fileutils' require 'net/http' require 'timeout' require 'socket' class RailsE2ERunner attr_reader :pass_count, :fail_count def initialize @pass_count...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/test/test_helper.rb
Ruby
mit
46
main
679
# frozen_string_literal: true require 'minitest/autorun' require 'fileutils' # Connect to a separate test database db_path = File.join(__dir__, '..', 'db', 'test.sqlite3') FileUtils.rm_f(db_path) ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: db_path) # Run migrations ActiveRecord::MigrationCo...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/db/schema.rb
Ruby
mit
46
main
1,573
# 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
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/db/migrate/003_create_orders.rb
Ruby
mit
46
main
293
# frozen_string_literal: true class CreateOrders < ActiveRecord::Migration[8.1] def change create_table :orders do |t| t.references :user, null: false t.references :product, null: false t.integer :quantity, null: false, default: 1 t.timestamps end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/db/migrate/002_create_products.rb
Ruby
mit
46
main
255
# frozen_string_literal: true class CreateProducts < ActiveRecord::Migration[8.1] def change create_table :products do |t| t.string :name, null: false t.integer :price_cents, null: false, default: 0 t.timestamps end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/db/migrate/001_create_users.rb
Ruby
mit
46
main
230
# frozen_string_literal: true class CreateUsers < ActiveRecord::Migration[8.1] def change create_table :users do |t| t.string :name, null: false t.string :email, null: false t.timestamps end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/products/test/product_test.rb
Ruby
mit
46
main
894
# frozen_string_literal: true require_relative '../../../test/test_helper' class ProductTest < RailsTestCase def test_create_product product = Product.create!(name: 'Widget', price_cents: 1999) assert_equal 'Widget', product.name assert_equal 1999, product.price_cents end def test_name_required ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/products/controllers/products_controller.rb
Ruby
mit
46
main
379
# frozen_string_literal: true class ProductsController < ApplicationController def index render json: Product.all end def show render json: Product.find(params[:id]) end def create product = Product.create!(product_params) render json: product, status: :created end private def produ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/products/models/product.rb
Ruby
mit
46
main
223
# frozen_string_literal: true class Product < ApplicationRecord validates :name, presence: true validates :price_cents, numericality: { greater_than: 0 } def price format('$%.2f', price_cents / 100.0) end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/orders/controllers/orders_controller.rb
Ruby
mit
46
main
428
# frozen_string_literal: true class OrdersController < ApplicationController def index render json: Order.includes(:user, :product).all end def show render json: Order.includes(:user, :product).find(params[:id]) end def create order = Order.create!(order_params) render json: order, status: ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/orders/services/order_processor.rb
Ruby
mit
46
main
222
# frozen_string_literal: true # Private: internal order processing logic. class OrderProcessor def self.process(order) "Order ##{order.id}: #{order.quantity}x #{order.product.name} for #{order.user.name}" end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/orders/test/order_test.rb
Ruby
mit
46
main
1,221
# frozen_string_literal: true require_relative '../../../test/test_helper' class OrderTest < RailsTestCase def setup super @user = User.create!(name: 'Alice', email: 'alice@example.com') @product = Product.create!(name: 'Widget', price_cents: 1000) end def test_create_order order = Order.create...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/orders/models/order.rb
Ruby
mit
46
main
226
# frozen_string_literal: true class Order < ApplicationRecord belongs_to :user belongs_to :product validates :quantity, numericality: { greater_than: 0 } def total_cents product.price_cents * quantity end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/users/controllers/users_controller.rb
Ruby
mit
46
main
349
# frozen_string_literal: true class UsersController < ApplicationController def index render json: User.all end def show render json: User.find(params[:id]) end def create user = User.create!(user_params) render json: user, status: :created end private def user_params params.per...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/rails/packs/users/test/user_test.rb
Ruby
mit
46
main
761
# frozen_string_literal: true require_relative '../../../test/test_helper' class UserTest < RailsTestCase def test_create_user user = User.create!(name: 'Alice', email: 'alice@example.com') assert_equal 'Alice', user.name assert_equal 'alice@example.com', user.email end def test_name_required u...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/main.rb
Ruby
mit
46
main
1,157
# frozen_string_literal: true puts '' puts Config::SHOP_NAME.colorize(:yellow).bold puts '─' * 40 # Build the menu latte = Menu::Item.new(name: 'Latte', price_cents: 550) espresso = Menu::Item.new(name: 'Espresso', price_cents: 350) muffin = Menu::Item.new(name: 'Blueberry Muffin', price_cents: 425, category: :food...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/test/integration_test.rb
Ruby
mit
46
main
4,349
# frozen_string_literal: true require 'minitest/autorun' class IntegrationTest < Minitest::Test # Direct dependencies accessible def test_menu_item_accessible item = Menu::Item.new(name: 'Test', price_cents: 100) assert_equal 'Test', item.name end def test_order_accessible order = Orders::Order.n...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/global/config.rb
Ruby
mit
46
main
297
# frozen_string_literal: true # Global configuration available in all package boxes. # Defined in global/ so it's autoloaded in the global context before # package boxes are created. module Config SHOP_NAME = ENV.fetch('SHOP_NAME', 'Cosmic Coffee') CURRENCY = '$' POINTS_PER_DOLLAR = 1 end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/global/boot.rb
Ruby
mit
46
main
429
# frozen_string_literal: true # Runs in the global context after global gems are loaded but before # package boxes are created. Use this for global initialization. require 'dotenv/load' puts "Booting #{Config::SHOP_NAME}..." # Add extra root-level autoload dirs via Boxwerk.global.autoloader. # Constants loaded here...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/kitchen/boot.rb
Ruby
mit
46
main
359
# frozen_string_literal: true # Add services/ as an additional autoload directory Boxwerk.package.autoloader.push_dir('services') # Monkey-patch String with a kitchen-specific helper. # This patch is isolated to the kitchen box — it won't leak # into other packages or the global context. class String def to_order_t...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/kitchen/lib/kitchen/barista.rb
Ruby
mit
46
main
395
# frozen_string_literal: true module Kitchen class Barista attr_reader :name def initialize(name: nil) @name = name || Faker::Name.first_name end def prepare(menu_item) ticket = menu_item.name.to_order_ticket "#{@name} is preparing #{ticket} (#{PrepService.queue_count} in queue)" ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/kitchen/test/barista_test.rb
Ruby
mit
46
main
939
# frozen_string_literal: true require 'minitest/autorun' class BaristaTest < Minitest::Test def test_prepare item = Menu::Item.new(name: 'Latte', price_cents: 550) barista = Kitchen::Barista.new(name: 'Alex') assert_equal 'Alex is preparing 🎫 LATTE (3 in queue)', barista.prepare(item) end def test...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/loyalty/lib/loyalty/card.rb
Ruby
mit
46
main
441
# frozen_string_literal: true module Loyalty class Card attr_reader :member_name, :points def initialize(member_name: nil) @member_name = member_name || Faker::Name.name @points = 0 Loyalty.cards << self end def earn(amount_cents) @points += amount_cents / 100 end d...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/loyalty/test/card_test.rb
Ruby
mit
46
main
835
# frozen_string_literal: true require 'minitest/autorun' class CardTest < Minitest::Test def test_earn_points card = Loyalty::Card.new(member_name: 'Alice') card.earn(550) assert_equal 5, card.points end def test_to_s card = Loyalty::Card.new(member_name: 'Bob') card.earn(1200) assert_e...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/menu/lib/menu/recipe.rb
Ruby
mit
46
main
236
# frozen_string_literal: true module Menu class Recipe attr_reader :item, :steps def initialize(item:, steps:) @item = item @steps = steps end def instruction steps.join(' → ') end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/menu/test/item_test.rb
Ruby
mit
46
main
1,101
# frozen_string_literal: true require 'minitest/autorun' class ItemTest < Minitest::Test def test_price_formatting item = Menu::Item.new(name: 'Latte', price_cents: 550) assert_equal '$5.50', item.price end def test_to_s item = Menu::Item.new(name: 'Espresso', price_cents: 350) assert_equal 'Es...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/stats/lib/stats/summary.rb
Ruby
mit
46
main
550
# frozen_string_literal: true module Stats class Summary def self.print puts '' puts '── Stats ──'.colorize(:magenta).bold puts " Menu items: #{Menu.items.size}".colorize(:green) puts " Orders placed: #{Orders.orders.size}".colorize(:green) puts " Loyalty members: #{Loyalty....
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/orders/test/order_test.rb
Ruby
mit
46
main
1,270
# frozen_string_literal: true require 'minitest/autorun' class OrderTest < Minitest::Test def test_empty_order order = Orders::Order.new assert_equal 0, order.total_cents end def test_add_items item = Menu::Item.new(name: 'Latte', price_cents: 550) order = Orders::Order.new order.add(item, ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/orders/lib/orders/order.rb
Ruby
mit
46
main
572
# frozen_string_literal: true # pack_public: true module Orders class Order attr_reader :items def initialize @items = [] Orders.orders << self end def add(menu_item, quantity: 1) @items << LineItem.new(menu_item: menu_item, quantity: quantity) self end def total_ce...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/orders/lib/orders/line_item.rb
Ruby
mit
46
main
429
# frozen_string_literal: true module Orders class LineItem attr_reader :menu_item, :quantity def initialize(menu_item:, quantity:) @menu_item = menu_item @quantity = quantity end def total_cents menu_item.price_cents * quantity end def to_s " #{quantity}x #{menu_it...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/analytics/boot.rb
Ruby
mit
46
main
372
# frozen_string_literal: true # Collapse formatters/ so its constants are promoted to the Analytics namespace # (e.g. Analytics::CsvFormatter instead of Analytics::Formatters::CsvFormatter). Boxwerk.package.autoloader.collapse('lib/analytics/formatters') # Ignore legacy/ so its files are not autoloaded at all. Boxwer...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/analytics/lib/analytics/legacy/old_report.rb
Ruby
mit
46
main
218
# frozen_string_literal: true # Legacy files are ignored by the autoloader (not autoloaded). # They can still be explicitly required when needed. module Analytics module Legacy class OldReport end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/analytics/lib/analytics/concerns/reportable.rb
Ruby
mit
46
main
243
# frozen_string_literal: true # Concerns dir for mixins — collapsed so modules are at Analytics:: namespace. module Analytics module Concerns module Reportable def report_name self.class.name end end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/analytics/lib/analytics/formatters/csv_formatter.rb
Ruby
mit
46
main
294
# frozen_string_literal: true # This file is in a collapse_dir — Analytics::Formatters is collapsed so # this class is accessible as Analytics::CsvFormatter (not Formatters::CsvFormatter). module Analytics class CsvFormatter def format(report) "csv: #{report}" end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/packs/analytics/test/analytics_test.rb
Ruby
mit
46
main
1,343
# frozen_string_literal: true require 'minitest/autorun' class AnalyticsTest < Minitest::Test def test_report_accessible report = Analytics::Report.new('Sales') assert_equal 'Report: Sales', report.to_s end def test_csv_formatter_collapsed # collapse_dirs on lib/analytics/formatters — CsvFormatter ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
examples/complex/lib/currency_formatter.rb
Ruby
mit
46
main
287
# frozen_string_literal: true # Shared utility available in all package boxes via the global autoloader. # Loaded via Boxwerk.global.autoloader.push_dir in global/boot.rb. module CurrencyFormatter def self.format(cents) sprintf("#{Config::CURRENCY}%.2f", cents / 100.0) end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/e2e_test.rb
Ruby
mit
46
main
24,285
#!/usr/bin/env ruby # frozen_string_literal: true # End-to-end test runner for Boxwerk. # Runs outside of minitest to test the full CLI → Box stack. # Each test creates a temporary project, runs boxwerk commands via subprocess, # and validates output and exit codes. # # Usage: RUBY_BOX=1 ruby test/e2e/run.rb require ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/gem_resolver_test.rb
Ruby
mit
46
main
11,319
# frozen_string_literal: true require 'test_helper' require 'tmpdir' require 'fileutils' module Boxwerk class GemResolverTest < Minitest::Test def setup @tmpdir = Dir.mktmpdir end def teardown FileUtils.rm_rf(@tmpdir) end def test_returns_nil_for_package_without_gemfile pkg_d...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/zeitwerk_scanner_test.rb
Ruby
mit
46
main
5,354
# frozen_string_literal: true require 'test_helper' require 'tmpdir' require 'fileutils' class ZeitwerkScannerTest < Minitest::Test def setup @tmpdir = Dir.mktmpdir end def teardown FileUtils.rm_rf(@tmpdir) end def test_scan_flat_files write_file('greeter.rb', 'class Greeter; end') write_f...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/version_test.rb
Ruby
mit
46
main
297
# frozen_string_literal: true require 'test_helper' module Boxwerk class VersionTest < Minitest::Test def test_that_it_has_a_version_number refute_nil ::Boxwerk::VERSION end def test_version_format assert_match(/^\d+\.\d+\.\d+$/, ::Boxwerk::VERSION) end end end
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/package_resolver_test.rb
Ruby
mit
46
main
6,498
# frozen_string_literal: true require 'test_helper' require 'tmpdir' require 'fileutils' module Boxwerk class PackageResolverTest < Minitest::Test def setup @tmpdir = Dir.mktmpdir end def teardown FileUtils.rm_rf(@tmpdir) end def test_discovers_root_package create_package(@tm...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/setup_test.rb
Ruby
mit
46
main
6,369
# frozen_string_literal: true require 'test_helper' require 'tmpdir' require 'fileutils' module Boxwerk class SetupTest < Minitest::Test def setup @tmpdir = Dir.mktmpdir Setup.reset end def teardown FileUtils.rm_rf(@tmpdir) Setup.reset end def test_run_with_implicit_roo...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/privacy_checker_test.rb
Ruby
mit
46
main
5,044
# frozen_string_literal: true require 'test_helper' require 'tmpdir' require 'fileutils' module Boxwerk class PrivacyCheckerTest < Minitest::Test def setup @tmpdir = Dir.mktmpdir end def teardown FileUtils.rm_rf(@tmpdir) end def test_enforces_privacy_when_true pkg = create_pa...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/constant_resolver_test.rb
Ruby
mit
46
main
2,163
# frozen_string_literal: true require 'test_helper' module Boxwerk class ConstantResolverTest < Minitest::Test def test_build_resolver_returns_proc resolver = ConstantResolver.build_resolver([]) assert_kind_of Proc, resolver end def test_nameerror_includes_hint_for_non_dependency pkg ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/integration/isolation_test.rb
Ruby
mit
46
main
11,341
# frozen_string_literal: true require_relative 'test_helper' module Boxwerk # Tests for core box isolation: direct constant access, transitive prevention, # sibling isolation, dependency chains, diamond deps, constant caching. class IsolationTest < Minitest::Test include IntegrationTestHelper def test_...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/integration/privacy_test.rb
Ruby
mit
46
main
4,755
# frozen_string_literal: true require_relative 'test_helper' module Boxwerk # Tests for privacy enforcement: public path, pack_public sigil, # private_constants, and descriptive error messages. class PrivacyIntegrationTest < Minitest::Test include IntegrationTestHelper def test_privacy_blocks_private_c...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/integration/package_boot_test.rb
Ruby
mit
46
main
10,002
# frozen_string_literal: true require_relative 'test_helper' module Boxwerk # Tests for per-package boot.rb scripts that run in the package box # context during boot, before dependency wiring. class PackageBootTest < Minitest::Test include IntegrationTestHelper def test_package_boot_script_runs_in_box ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/integration/gem_isolation_test.rb
Ruby
mit
46
main
7,010
# frozen_string_literal: true require_relative 'test_helper' module Boxwerk # Tests for per-package gem isolation via Gemfile and $LOAD_PATH isolation. class GemIsolationIntegrationTest < Minitest::Test include IntegrationTestHelper def test_per_package_gem_loading_with_real_gem a_dir = create_pack...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/integration/packwerk_parity_test.rb
Ruby
mit
46
main
4,570
# frozen_string_literal: true require_relative 'test_helper' module Boxwerk # Tests that verify Boxwerk runtime enforcement matches what Packwerk # would catch via static analysis. For each scenario, we verify: # 1. The package dependency graph is set up correctly # 2. Boxwerk enforces the same constraint at ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/integration/nested_constants_test.rb
Ruby
mit
46
main
3,580
# frozen_string_literal: true require_relative 'test_helper' module Boxwerk # Tests for nested module/class constants and intra-package structure. class NestedConstantsIntegrationTest < Minitest::Test include IntegrationTestHelper def test_nested_module_constant a_dir = create_package_dir('a') ...
github
dtcristo/boxwerk
https://github.com/dtcristo/boxwerk
test/boxwerk/integration/test_helper.rb
Ruby
mit
46
main
1,342
# frozen_string_literal: true require 'test_helper' require 'tmpdir' require 'fileutils' module Boxwerk # Shared helpers for integration tests that create packages in a tmpdir # and boot the system with real Ruby::Box isolation. module IntegrationTestHelper def setup @tmpdir = Dir.mktmpdir Setup...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
is_reviewable.gemspec
Ruby
mit
46
master
2,760
# Generated by jeweler # DO NOT EDIT THIS FILE # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec` # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{is_reviewable} s.version = "0.1.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
Rakefile
Ruby
mit
46
master
2,091
# coding: utf-8 require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' NAME = "is_reviewable" SUMMARY = %Q{Rails: Make an ActiveRecord resource ratable/reviewable (rate + text), without the usual extra code-smell.} HOMEPAGE = "http://github.com/grimen/#{NAME}" AUTHOR = "Jonas Grimfelt" EMAIL...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
test/test_helper.rb
Ruby
mit
46
master
1,272
# coding: utf-8 require 'rubygems' def smart_require(lib_name, gem_name, gem_version = '>= 0.0.0') begin require lib_name if lib_name rescue LoadError if gem_name gem gem_name, gem_version require lib_name if lib_name end end end smart_require 'test/unit', 'test-unit', '= 1.2.3' smart_re...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
test/is_reviewable_test.rb
Ruby
mit
46
master
8,379
# coding: utf-8 require 'test_helper' class IsReviewableTest < Test::Unit::TestCase def setup @review = ::Review.new @user = ::User.create @user_2 = ::User.create @user_3 = ::User.create @guest = ::Guest.create @account = ::Account.create @regular_post = ::Post.create @re...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
generators/is_reviewable_migration/is_reviewable_migration_generator.rb
Ruby
mit
46
master
272
# coding: utf-8 class IsReviewableMigrationGenerator < Rails::Generator::Base def manifest record do |m| m.migration_template 'reviews_migration.rb', File.join('db', 'migrate'), :migration_file_name => 'is_reviewable_migration' end end end
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
generators/is_reviewable_migration/templates/reviews_migration.rb
Ruby
mit
46
master
773
# coding: utf-8 class IsReviewableMigration < ActiveRecord::Migration def self.up create_table :reviews do |t| t.references :reviewable, :polymorphic => true t.references :reviewer, :polymorphic => true t.string :ip, :limit => 24 t.float :rati...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
generators/is_reviewable_model/is_reviewable_model_generator.rb
Ruby
mit
46
master
207
# coding: utf-8 class IsReviewableModelGenerator < Rails::Generator::Base def manifest record do |m| m.template 'review_model.rb', File.join('app', 'models', 'review.rb') end end end
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
lib/is_reviewable.rb
Ruby
mit
46
master
1,127
# coding: utf-8 require File.join(File.dirname(__FILE__), *%w[is_reviewable review]) require File.join(File.dirname(__FILE__), *%w[is_reviewable reviewable]) require File.join(File.dirname(__FILE__), *%w[is_reviewable reviewer]) require File.join(File.dirname(__FILE__), *%w[is_reviewable support]) module IsReviewable ...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
lib/is_reviewable/reviewable.rb
Ruby
mit
46
master
15,596
# coding: utf-8 unless defined?(::Review) class Review < ::IsReviewable::Review end end module IsReviewable module Reviewable ASSOCIATION_CLASS = ::Review CACHABLE_FIELDS = [ :reviews_count, :average_rating ].freeze DEFAULTS = { :accept_ip => false, :scale ...
github
grimen/is_reviewable
https://github.com/grimen/is_reviewable
lib/is_reviewable/support.rb
Ruby
mit
46
master
1,658
module IsReviewable module Support extend self # Shortcut method for generating conditions hash for polymorphic belongs_to-associations. # def polymorphic_conditions_for(object_or_type, field, *match) match = [:id, :type] if match.blank? # Note: {} is equivalent to Hash.new which...