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
rootstrap/activeadmin-chat
https://github.com/rootstrap/activeadmin-chat
app/channels/active_admin/chat/user_channel.rb
Ruby
mit
90
master
428
module ActiveAdmin module Chat class UserChannel < ActiveAdmin::Chat::BaseChannel private def conversation return unless user? @conversation ||= ActiveAdmin::Chat.conversation_klass.find_by( "#{ActiveAdmin::Chat.user_relation_name}_id": current_user.id ) end ...
github
rootstrap/activeadmin-chat
https://github.com/rootstrap/activeadmin-chat
app/channels/active_admin/chat/admin_channel.rb
Ruby
mit
90
master
473
module ActiveAdmin module Chat class AdminChannel < ActiveAdmin::Chat::BaseChannel private def conversation return unless admin? && conversation_id.present? @conversation ||= ActiveAdmin::Chat.conversation_klass.find_by(id: conversation_id) end def admin? current...
github
rootstrap/activeadmin-chat
https://github.com/rootstrap/activeadmin-chat
app/channels/active_admin/chat/base_channel.rb
Ruby
mit
90
master
724
module ActiveAdmin module Chat class BaseChannel < ApplicationCable::Channel def subscribed conversation ? stream_for(conversation) : reject end def speak(data) message = conversation.public_send( ActiveAdmin::Chat.message_relation_name.pluralize ).create!( ...
github
rootstrap/activeadmin-chat
https://github.com/rootstrap/activeadmin-chat
app/helpers/active_admin/chat/chat_helper.rb
Ruby
mit
90
master
344
module ActiveAdmin module Chat module ChatHelper def admin_class(message) 'admin' if message.sender.class == ActiveAdmin::Chat.admin_user_klass end def selected_class(conversation, active_conversation) 'selected' if active_conversation && active_conversation == conversation ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
Gemfile
Ruby
mit
90
main
310
source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Specify your gem's dependencies in superfeature.gemspec. gemspec gem "sqlite3" gem "sprockets-rails" # Start debugger with binding.b [https://github.com/ruby/debug] # gem "debug", ">= 1.0.0" gem "rspec-rails"
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
superfeature.gemspec
Ruby
mit
90
main
1,161
require_relative "lib/superfeature/version" Gem::Specification.new do |spec| spec.name = "superfeature" spec.version = Superfeature::VERSION spec.authors = ["Brad Gessler"] spec.email = ["bradgessler@gmail.com"] spec.homepage = "https://github.com/rubymonolith/superfeature" spec.sum...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature.rb
Ruby
mit
90
main
776
require "superfeature/version" require "superfeature/engine" if defined?(Rails) require "superfeature/limit" require "superfeature/feature" require "superfeature/plan" require "superfeature/plan/collection" require "superfeature/round" require "superfeature/discount" require "superfeature/price" module Superfeature ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/round.rb
Ruby
mit
90
main
2,084
require 'bigdecimal' module Superfeature # Rounds values to a specified ending. # For example, round to 9 gives $19, $29, $49, etc. # # Round.new(9).up(50) # => 59 (next value ending in 9) # Round.new(9).down(50) # => 49 (previous value ending in 9) # Round.new(9).nearest(50) # => 49 (closer ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/price.rb
Ruby
mit
90
main
10,402
require 'bigdecimal' module Superfeature # Immutable price object with discount support. Uses BigDecimal internally # to avoid floating-point precision errors. # # price = Price.new(49.99) # discounted = price.apply_discount("20%") # discounted.amount # => 39.99 # discounted.discount.pe...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/discount.rb
Ruby
mit
90
main
4,870
require 'bigdecimal' module Superfeature # Discount types that can be applied to a Price. # # Price(100).apply_discount(Discount::Percent.new(20)) # => 80 # Price(100).apply_discount(Discount::Fixed.new(15)) # => 85 # module Discount # Base class for all discount types class Base # Al...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/feature.rb
Ruby
mit
90
main
739
require "forwardable" module Superfeature class Feature extend Forwardable attr_reader :limit def_delegators :limit, :enabled?, :disabled? def_delegators :limit, :quantity, :maximum, :remaining, :remaining?, :exceeded? def initialize(limit: Limit::Base.new) @limit = limit end def...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/limit.rb
Ruby
mit
90
main
1,248
module Superfeature module Limit class Base def enabled? false end def disabled? not enabled? end end class Hard < Base attr_accessor :quantity, :maximum def initialize(quantity: , maximum: ) @quantity = quantity @maximum = maximum ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/plan.rb
Ruby
mit
90
main
1,439
module Superfeature class Plan class << self def features ((superclass.respond_to?(:features) ? superclass.features : []) + @features.to_a).uniq end def feature(method_name) (@features ||= []) << method_name method_name end def exclusively(method_name) ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/core_ext.rb
Ruby
mit
90
main
301
# Load all core extensions for Price # # These are opt-in. To use them: # # require "superfeature/core_ext" # # 10.to_price # => Price(10) # "49.99".to_price # => Price(49.99) # require "superfeature" require "superfeature/core_ext/numeric" require "superfeature/core_ext/string"
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/core_ext/string.rb
Ruby
mit
90
main
296
# Adds pricing extensions to String # # "49.99".to_price # => Price(49.99) # "$100".to_price # => Price(100) # class String def to_price(**options) # Strip leading $ and whitespace value = self.gsub(/\A\$?\s*/, '') Superfeature::Price.new(value, **options) end end
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/core_ext/numeric.rb
Ruby
mit
90
main
450
# Adds pricing extensions to Numeric (Integer, Float, BigDecimal) # # 100.discounted_by(20.percent_off) # => Price(80) # 100.discounted_by(20) # => Price(80) # 100.to_price # => Price(100) # class Numeric def to_price(**) Superfeature::Price.new(self, **) end def per...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/superfeature/plan/collection.rb
Ruby
mit
90
main
1,385
module Superfeature class Plan class Collection include Enumerable def initialize(plan) @plan = plan end def each(&) return enum_for(:each) unless block_given? downgrades.each(&) yield @plan upgrades.each(&) end def find(key) ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/generators/superfeature/plan/plan_generator.rb
Ruby
mit
90
main
572
require 'rails/generators' module Superfeature module Generators class PlanGenerator < Rails::Generators::NamedBase source_root File.expand_path("templates", __dir__) def create_plan_file template "plan.rb.tt", "app/plans/#{file_name}.rb" end private def file_name ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/generators/superfeature/install/install_generator.rb
Ruby
mit
90
main
751
require 'rails/generators' module Superfeature module Generators class InstallGenerator < Rails::Generators::Base source_root File.expand_path("templates", __dir__) def create_plans_directory empty_directory "app/plans" empty_directory "app/plans/features" end def copy_b...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/generators/superfeature/install/templates/paid.rb
Ruby
mit
90
main
280
module Plans class Paid < Free def name = "Paid" def price = 9.99 def description = "Full access to all features" # Override features from Base to enable them # def priority_support = super.enable def next = nil def previous = plan(Free) end end
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/generators/superfeature/install/templates/base.rb
Ruby
mit
90
main
912
module Plans class Base < Superfeature::Plan attr_reader :user def initialize(user) @user = user end # Boolean features - simple on/off flags # feature def priority_support = disable("Priority support", group: "Support") # feature def phone_support = disable("Phone support", group: "Su...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
lib/generators/superfeature/install/templates/features/base.rb
Ruby
mit
90
main
242
module Plans module Features class Base < Superfeature::Feature attr_reader :name, :group def initialize(name = nil, group: nil, **) super(**) @name = name @group = group end end end end
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/rails_helper.rb
Ruby
mit
90
main
2,816
# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require_relative './dummy/config/environment' # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production?...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/spec_helper.rb
Ruby
mit
90
main
4,599
# This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be loaded, without a need to explicitly require ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/superfeature/price_spec.rb
Ruby
mit
90
main
35,368
require 'rails_helper' RSpec.describe "Superfeature::Price() convenience method" do it 'creates a Price via module method' do price = Superfeature::Price(100) expect(price).to be_a(Superfeature::Price) expect(price.amount).to eq(100.0) end it 'passes options through' do price = Superfeature::Pri...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/superfeature/limit_spec.rb
Ruby
mit
90
main
4,837
require 'rails_helper' RSpec.describe Superfeature::Limit::Base do subject(:limit) { described_class.new } describe "#enabled?" do subject { limit.enabled? } it { is_expected.to be false } end describe "#disabled?" do subject { limit.disabled? } it { is_expected.to be true } end end RSpec....
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/superfeature/core_ext_spec.rb
Ruby
mit
90
main
2,416
require 'rails_helper' require 'superfeature/core_ext' RSpec.describe "Core extensions" do describe "Numeric#to_price" do it "converts integer to Price" do price = 10.to_price expect(price).to be_a(Superfeature::Price) expect(price.amount).to eq(10) end it "converts float to Price" do ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/superfeature/plan_spec.rb
Ruby
mit
90
main
2,763
require 'rails_helper' RSpec.describe Superfeature::Plan do let(:plan_klass) do Class.new(Superfeature::Plan) do def seats soft_limit quantity: 37, soft_limit: 100, hard_limit: 110 end def items hard_limit quantity: 6, maximum: 100 end def unlimited_storage ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/superfeature/discount_spec.rb
Ruby
mit
90
main
3,078
require 'rails_helper' module Superfeature RSpec.describe Discount do describe Discount::Fixed do it 'subtracts the fixed amount from price' do discount = Discount::Fixed.new(20) expect(discount.apply(100)).to eq(80) end it 'responds to to_discount returning self' do di...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/superfeature/feature_spec.rb
Ruby
mit
90
main
1,743
require 'rails_helper' RSpec.describe Superfeature::Feature do let(:limit) { Superfeature::Limit::Boolean.new(enabled: true) } subject(:feature) { described_class.new(limit:) } describe "#enabled?" do it "delegates to limit" do expect(limit).to receive(:enabled?) feature.enabled? end end ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/superfeature/plan/collection_spec.rb
Ruby
mit
90
main
2,628
require 'rails_helper' RSpec.describe Superfeature::Plan::Collection do before do stub_const("FreePlan", Class.new(Superfeature::Plan) do def initialize(user) = @user = user def name = "Free" def price = 0 def next = ProPlan.new(@user) end) stub_const("ProPlan", Class.new(Superfe...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/generators/plan_generator_spec.rb
Ruby
mit
90
main
2,099
require 'rails_helper' require 'generators/superfeature/plan/plan_generator' RSpec.describe Superfeature::Generators::PlanGenerator, type: :generator do include FileUtils let(:destination) { File.expand_path("../../tmp/generator_test", __dir__) } before do rm_rf(destination) mkdir_p(destination) end ...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/generators/install_generator_spec.rb
Ruby
mit
90
main
2,099
require 'rails_helper' require 'generators/superfeature/install/install_generator' RSpec.describe Superfeature::Generators::InstallGenerator, type: :generator do include FileUtils let(:destination) { File.expand_path("../../tmp/generator_test", __dir__) } before do rm_rf(destination) mkdir_p(destinatio...
github
rubymonolith/superfeature
https://github.com/rubymonolith/superfeature
spec/dummy/config/application.rb
Ruby
mit
90
main
1,249
require_relative "boot" require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" require "action_mailbox/engine" require "action_text/en...
github
brettstimmerman/jabber-bot
https://github.com/brettstimmerman/jabber-bot
Rakefile
Ruby
bsd-3-clause
90
master
2,054
#-- # Copyright (c) 2011 Brett Stimmerman <brettstimmerman@gmail.com> # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice,...
github
brettstimmerman/jabber-bot
https://github.com/brettstimmerman/jabber-bot
jabber-bot.gemspec
Ruby
bsd-3-clause
90
master
802
Gem::Specification.new do |s| s.name = 'jabber-bot' s.version = '1.3.0' s.author = 'Brett Stimmerman' s.email = 'brettstimmerman@gmail.com' s.homepage = 'http://github.com/brettstimmerman/jabber-bot' s.platform = Gem::Platform::RUBY s.summary = 'Easily create simple regex powered Jabber bots.' ...
github
brettstimmerman/jabber-bot
https://github.com/brettstimmerman/jabber-bot
sample/sample.rb
Ruby
bsd-3-clause
90
master
2,862
#!/usr/bin/env ruby #-- # Copyright (c) 2011 Brett Stimmerman <brettstimmerman@gmail.com> # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the ab...
github
brettstimmerman/jabber-bot
https://github.com/brettstimmerman/jabber-bot
lib/jabber/bot.rb
Ruby
bsd-3-clause
90
master
16,203
#-- # Copyright (c) 2011 Brett Stimmerman <brettstimmerman@gmail.com> # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice,...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
cross-link.rb
Ruby
mit
90
gh-pages
11,772
#!/usr/bin/env ruby # frozen_string_literal: true # Mostly written by ChatGPT: https://chatgpt.com/share/68dd5dce-1308-8003-94fb-9c1a1c4ff7a1 # # cross-link.rb # # Usage: # ruby cross-link.rb # ruby cross-link.rb --base /blog/ # # What it does: # 1) Finds review posts in _posts/ whose front matter title matches: #...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
Gemfile
Ruby
mit
90
gh-pages
409
source 'https://rubygems.org' gem 'jekyll', '3.10.0' group :jekyll_plugins do gem 'jekyll-redirect-from', '0.16.0' gem 'jekyll-sitemap', '1.4.0' gem 'jekyll-paginate', '1.1.0' end gem 'github-pages', '232' gem 'base64', '0.3.0' gem 'bigdecimal', '3.2.3' gem 'logger', '1.7.0' gem 'webrick', '1.9.1' # https://gith...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
goodreads_to_md.rb
Ruby
mit
90
gh-pages
22,481
#!/usr/bin/env ruby # frozen_string_literal: true # Goodreads CSV -> Markdown generator # # Usage: # ruby goodreads_to_md.rb path/to/goodreads_library_export.csv markdown_output_dir/ images_output_dir/ # # Example: # ruby goodreads_to_md.rb path/to/goodreads_library_export.csv _posts assets/img/reviews # # Env var...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/lower_case.rb
Ruby
mit
90
gh-pages
279
GLOBS = ["assets/**/*.JPG", "assets/**/*.PNG"] GLOBS.each do |glob| files = Dir[glob] puts files files.each do |file| lower_case = file.gsub(/.JPG$/, '.jpg').gsub(/.PNG$/, '.png') puts "Renaming #{file} to #{lower_case}" File.rename(file, lower_case) end end
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/update_blogger_links.rb
Ruby
mit
90
gh-pages
1,375
FILES_TO_CONVERT_GLOB = "_posts/*.md" FRONT_MATTER = "---" EXPECTED_FRONT_MATTER_COUNT = 2 BLOGGER_ORIG_PATTERN = /^blogger_orig_url: (.+?)\s/ YBRIKMAN_DOMAIN = "https://www.ybrikman.com/writing" files = Dir[FILES_TO_CONVERT_GLOB] def convert_jekyll_file_to_ybrikman_url(file_name) base_name = File.basename(file_nam...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/url_check.rb
Ruby
mit
90
gh-pages
4,271
# Wraps an HTTP client to see which domains of my blog respond to an HTTP GET. require 'net/http' BLOGGER_DOMAIN_BASE = "http://brikis98.blogspot" # From http://dishingtech.blogspot.com/2012/06/list-of-blogger-country-domains-for.html DOMAINS = [ "ca", "co.uk", "com", "com.ac", "com.ad", "com.ae", "com...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/redirect_urls.rb
Ruby
mit
90
gh-pages
3,756
# The Blogger template language is some awful XML garbage, so there doesn't seem # to be a nice way to use it to generate redirect URLs. Therefore, we generate # very manual looking code to do it the hard way and shove this into the blogger # template with a big middle finger. REDIRECT_TEMPLATE = <<eos <head> ...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/redirect_posts.rb
Ruby
mit
90
gh-pages
1,441
# I moved my blog from /writing to /blog. This script updates all posts in the _posts folder to add a redirect_from # entry to the front matter to redirect /writing/xxx to /blog/xxx. # Example: 2008-01-10-new-job.md FILE_NAME_REGEX = /(\d{4})-(\d{2})-(\d{2})-(.*?).md/ # Try to capture the closing front matter text, w...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/find_blogger_urls.rb
Ruby
mit
90
gh-pages
496
FILES_TO_CONVERT_GLOB = "_posts/*.md" FRONT_MATTER = "---" EXPECTED_FRONT_MATTER_COUNT = 2 BLOGSPOT_PATTERN = 'brikis98.blogspot' files = Dir[FILES_TO_CONVERT_GLOB] files.each do |file| front_matter_count = 0 IO.read(file).each_line do |line| if front_matter_count >= EXPECTED_FRONT_MATTER_COUNT if line....
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/external_convert.rb
Ruby
mit
90
gh-pages
6,402
EXTERNAL_POSTS = [ {:date => "2014-01-21", :url => "http://engineering.linkedin.com/play/composable-and-streamable-play-apps", :title => "Composable and Streamable Play Apps"}, {:date => "2013-12-09", :url => "http://www.quora.com/LinkedIn-6/What-is-the-current-webstack-LinkedIn-uses/answer/Yevgeniy-Brikman?srid=XP...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/blogger_convert.rb
Ruby
mit
90
gh-pages
2,370
# A script to improve on Jekyll's default Blogger import # (http://import.jekyllrb.com/docs/blogger/). It converts the HTML output from # Jekyll's import into Markdown and cleans up as much of it as possible. FILES_TO_CONVERT_GLOB = "_posts/*.html" WRAP_LENGTH = 80 TO_REPLACE = { "<br />" => "\n", "<ol>" => "", ...
github
brikis98/yevgeniy-brikman-homepage
https://github.com/brikis98/yevgeniy-brikman-homepage
_scripts/craigslist-images.rb
Ruby
mit
90
gh-pages
986
# A script to fetch the thumbnails from the craigslist posts in garage-sale.yml require 'yaml' require 'net/http' IMAGE_START = "class=\"slide first visible\"><img src=\"" garage_sale_items = YAML.load_file('_data/garage-sale.yml') new_yaml = "" garage_sale_items.each do |item| name = item["name"] url = item["...
github
obie/desiru
https://github.com/obie/desiru
desiru.gemspec
Ruby
mit
90
main
1,558
# frozen_string_literal: true require_relative 'lib/desiru/version' Gem::Specification.new do |spec| spec.name = 'desiru' spec.version = Desiru::VERSION spec.authors = ['Obie Fernandez'] spec.email = ['obiefernandez@gmail.com'] spec.summary = 'Declarative Self-Improving Ruby - A Ruby port of DSPy' spec.d...
github
obie/desiru
https://github.com/obie/desiru
Gemfile
Ruby
mit
90
main
1,343
# frozen_string_literal: true source 'https://rubygems.org' ruby '>= 3.2.0' # Specify your gem's dependencies in desiru.gemspec gemspec group :development, :test do gem 'dotenv', '~> 3.0' gem 'mock_redis', '~> 0.40' gem 'pry', '~> 0.14' gem 'pry-byebug', '~> 3.10' gem 'rack-test', '~> 2.0' gem 'rake', '...
github
obie/desiru
https://github.com/obie/desiru
examples/graphql_api.rb
Ruby
mit
90
main
5,214
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'desiru/graphql/schema_generator' require 'desiru/graphql/executor' # Configure Desiru Desiru.configure do |config| # Use OpenAI model for demonstration config.default_model = Desiru::Models::OpenAI.new( api_key...
github
obie/desiru
https://github.com/obie/desiru
examples/typed_signatures.rb
Ruby
mit
90
main
1,483
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' # Configure Desiru Desiru.configure do |config| config.default_model = Desiru::Models::OpenAI.new( model: 'gpt-3.5-turbo', api_key: ENV['OPENAI_API_KEY'] || raise('Please set OPENAI_API_KEY environment variable') ) ...
github
obie/desiru
https://github.com/obie/desiru
examples/rest_api.rb
Ruby
mit
90
main
5,834
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'rack' require 'rack/handler/webrick' # This example demonstrates how to create a REST API using Desiru's Grape integration # Configure Desiru Desiru.configure do |config| config.default_model = Desiru::Models::OpenA...
github
obie/desiru
https://github.com/obie/desiru
examples/sinatra_api.rb
Ruby
mit
90
main
3,561
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'rack' require 'rack/handler/webrick' # This example demonstrates how to create a lightweight REST API using Desiru's Sinatra integration # Configure Desiru Desiru.configure do |config| config.default_model = Desiru:...
github
obie/desiru
https://github.com/obie/desiru
examples/async_processing.rb
Ruby
mit
90
main
3,537
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'sidekiq' # Example: Asynchronous Processing with Desiru # This example demonstrates how to use background jobs for LLM operations # Configure Desiru with a mock model for demonstration Desiru.configure do |config| #...
github
obie/desiru
https://github.com/obie/desiru
examples/graphql_integration.rb
Ruby
mit
90
main
2,743
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'desiru/graphql/schema_generator' # Example: GraphQL Integration with Desiru # This demonstrates how to generate GraphQL schemas from Desiru signatures # Configure Desiru Desiru.configure do |config| config.default_m...
github
obie/desiru
https://github.com/obie/desiru
examples/rest_api_advanced.rb
Ruby
mit
90
main
8,676
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'rack' require 'rack/handler/webrick' require 'rack/throttle' require 'jwt' # Advanced REST API example with authentication, rate limiting, and custom middleware # Configure Desiru Desiru.configure do |config| config...
github
obie/desiru
https://github.com/obie/desiru
examples/rag_retrieval.rb
Ruby
mit
90
main
2,752
# frozen_string_literal: true require_relative '../lib/desiru' # Example: Using the Retrieve module for RAG (Retrieval Augmented Generation) # Create a dummy model for demonstration class DummyModel def complete(prompt, **_options) { content: "Answer based on retrieved context: #{prompt[:user]}" } end end #...
github
obie/desiru
https://github.com/obie/desiru
examples/assertions_example.rb
Ruby
mit
90
main
6,613
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' # Mock model for demonstration class MockModel def complete(_messages:, **_options) # Simple mock that returns predefined responses { choices: [{ message: { content: "Mock response" } }] } end end # Configure Desir...
github
obie/desiru
https://github.com/obie/desiru
examples/react_agent.rb
Ruby
mit
90
main
5,555
#!/usr/bin/env ruby # frozen_string_literal: true require_relative '../lib/desiru' require_relative '../lib/desiru/modules/react' require 'json' require 'net/http' # Example of using ReAct module to build a tool-using agent # Define some useful tools class WeatherTool def self.name "get_weather" end def s...
github
obie/desiru
https://github.com/obie/desiru
examples/graphql_performance_benchmark.rb
Ruby
mit
90
main
7,396
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'desiru/graphql/schema_generator' require 'desiru/graphql/executor' require 'desiru/graphql/data_loader' require 'benchmark' # Example: GraphQL Performance Benchmark with Request Deduplication # This demonstrates the pe...
github
obie/desiru
https://github.com/obie/desiru
examples/scheduled_job_example.rb
Ruby
mit
90
main
2,994
# frozen_string_literal: true require 'desiru' require 'desiru/jobs/scheduler' # Example of a scheduled job that performs periodic tasks class CleanupJob < Desiru::Jobs::Base include Desiru::Jobs::Schedulable def perform(job_id = nil) # Simulate cleanup work puts "[#{Time.now}] Running cleanup job #{job_...
github
obie/desiru
https://github.com/obie/desiru
examples/api_with_persistence.rb
Ruby
mit
90
main
4,282
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'desiru/persistence' require 'rack' # Configure Desiru Desiru.configure do |config| config.default_model = Desiru::Models::OpenAI.new( api_key: ENV['OPENAI_API_KEY'] || 'your-api-key', model: 'gpt-3.5-turbo' ...
github
obie/desiru
https://github.com/obie/desiru
examples/few_shot_learning.rb
Ruby
mit
90
main
1,680
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' # Configure Desiru Desiru.configure do |config| config.default_model = Desiru::Models::OpenAI.new( model: 'gpt-3.5-turbo', api_key: ENV['OPENAI_API_KEY'] || raise('Please set OPENAI_API_KEY environment variable') ) ...
github
obie/desiru
https://github.com/obie/desiru
examples/simple_qa.rb
Ruby
mit
90
main
1,054
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' # Configure Desiru with OpenAI model Desiru.configure do |config| config.default_model = Desiru::Models::OpenAI.new( model: 'gpt-3.5-turbo', api_key: ENV['OPENAI_API_KEY'] || raise('Please set OPENAI_API_KEY environme...
github
obie/desiru
https://github.com/obie/desiru
examples/persistence_example.rb
Ruby
mit
90
main
3,595
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'desiru' require 'desiru/persistence' # Configure persistence Desiru::Persistence.database_url = 'sqlite://desiru_example.db' # Connect and migrate puts "Setting up database..." Desiru::Persistence.connect! Desiru::Persistence.migrate!...
github
obie/desiru
https://github.com/obie/desiru
db/migrations/001_create_initial_tables.rb
Ruby
mit
90
main
2,774
# frozen_string_literal: true Sequel.migration do up do # API Requests table create_table(:api_requests) do primary_key :id String :method, null: false String :path, null: false String :remote_ip Integer :status_code, null: false Float :response_time String :headers,...
github
obie/desiru
https://github.com/obie/desiru
db/migrations/002_create_job_results.rb
Ruby
mit
90
main
1,068
# frozen_string_literal: true Sequel.migration do up do # Job Results table for persisting background job results create_table(:job_results) do primary_key :id String :job_id, null: false, unique: true String :job_class, null: false String :queue, null: false String :status, nul...
github
obie/desiru
https://github.com/obie/desiru
spec/test_basic_loading.rb
Ruby
mit
90
main
1,386
#!/usr/bin/env ruby # frozen_string_literal: true # Test if we can load the integration test file without errors $LOAD_PATH.unshift File.expand_path('../../lib', __dir__) puts "Testing basic file loading..." begin # Test loading minimal spec helper components require_relative '../lib/desiru/core/example' requi...
github
obie/desiru
https://github.com/obie/desiru
spec/minimal_test.rb
Ruby
mit
90
main
1,874
#!/usr/bin/env ruby # frozen_string_literal: true # Minimal test to verify core functionality require 'bundler/setup' require 'rspec' require 'rspec/mocks' # Add lib to load path $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) # Wrap everything in a module to avoid top-level include module Minimal...
github
obie/desiru
https://github.com/obie/desiru
spec/simple_test.rb
Ruby
mit
90
main
1,263
#!/usr/bin/env ruby # frozen_string_literal: true # Add lib to load path $LOAD_PATH.unshift File.expand_path('../lib', __dir__) require 'desiru' # Simple test to verify MultiChainComparison fixes begin puts "Testing MultiChainComparison module fixes..." # Test signature creation signature = Desiru::Signature....
github
obie/desiru
https://github.com/obie/desiru
spec/test_multi_chain.rb
Ruby
mit
90
main
1,376
#!/usr/bin/env ruby # frozen_string_literal: true require_relative 'spec_helper' # Simple test to verify MultiChainComparison fixes begin puts "Testing MultiChainComparison module fixes..." # Test basic initialization model = double('model') signature = Desiru::Signature.new('question: string -> answer: stri...
github
obie/desiru
https://github.com/obie/desiru
spec/verify_phase1_fixes.rb
Ruby
mit
90
main
5,112
#!/usr/bin/env ruby # frozen_string_literal: true # Simple verification of Phase 1 fixes require 'bundler/setup' # Add lib to load path $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'desiru' puts "🔍 Verifying Phase 1 Integration Test Fixes..." # Create a simple mock model class class ...
github
obie/desiru
https://github.com/obie/desiru
spec/phase1_test_runner.rb
Ruby
mit
90
main
4,840
#!/usr/bin/env ruby # frozen_string_literal: true # Add lib to load path $LOAD_PATH.unshift File.expand_path('../../lib', __dir__) require 'desiru' # Simple test runner to identify issues with Phase 1 integration tests puts "=== Phase 1 Integration Test Issue Analysis ===" puts "\n1. Testing Core classes exist..." ...
github
obie/desiru
https://github.com/obie/desiru
spec/test_phase1_fixes.rb
Ruby
mit
90
main
3,266
#!/usr/bin/env ruby # frozen_string_literal: true # Test specific Phase 1 fixes require 'bundler/setup' require 'rspec' # Add lib to load path $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'desiru' # Create a simple mock model class for testing class SimpleMockModel def initialize(res...
github
obie/desiru
https://github.com/obie/desiru
spec/desiru_spec.rb
Ruby
mit
90
main
723
# frozen_string_literal: true RSpec.describe Desiru do it 'has a version number' do expect(Desiru::VERSION).not_to be_nil end describe '.configure' do it 'yields configuration block' do expect { |b| described_class.configure(&b) }.to yield_with_args(Desiru::Configuration) end it 'allows s...
github
obie/desiru
https://github.com/obie/desiru
spec/test_mipro_v2.rb
Ruby
mit
90
main
1,872
#!/usr/bin/env ruby # frozen_string_literal: true require_relative '../lib/desiru' # Test script to debug MIPROv2 failures puts "Testing MIPROv2 optimizer..." # Set up basic requirements signature = Desiru::Signature.new('question: string -> answer: string') model = double('Model', call: { content: 'test response' }...
github
obie/desiru
https://github.com/obie/desiru
spec/test_single.rb
Ruby
mit
90
main
1,389
#!/usr/bin/env ruby # frozen_string_literal: true # Quick test to see if basic loading works begin require 'bundler/setup' require 'rspec' puts "Loading spec_helper..." load File.join(File.dirname(__FILE__), 'spec_helper.rb') puts "Loading phase1 test..." load File.join(File.dirname(__FILE__), 'integrati...
github
obie/desiru
https://github.com/obie/desiru
spec/run_phase1_test.rb
Ruby
mit
90
main
285
#!/usr/bin/env ruby # frozen_string_literal: true # Simple test runner for phase1_integration_spec.rb require 'rspec' require_relative 'spec_helper' # Run only one test to see the error RSpec::Core::Runner.run(['integration/phase1_integration_spec.rb', '--format', 'documentation'])
github
obie/desiru
https://github.com/obie/desiru
spec/spec_helper.rb
Ruby
mit
90
main
5,775
# frozen_string_literal: true require 'bundler/setup' require 'desiru' # Load support files Dir[File.join(__dir__, 'support', '*.rb')].each { |f| require f } # Require RedisMockHelper after support files are loaded require_relative 'support/redis_mock_helper' # Automatically use MockRedis in CI or when MOCK_REDIS e...
github
obie/desiru
https://github.com/obie/desiru
spec/verify_fixes.rb
Ruby
mit
90
main
2,999
#!/usr/bin/env ruby # frozen_string_literal: true # Add lib to load path $LOAD_PATH.unshift File.expand_path('../../lib', __dir__) # Load specific files to test the fixes require_relative '../lib/desiru/core/example' require_relative '../lib/desiru/core/prediction' require_relative '../lib/desiru/signature' require_r...
github
obie/desiru
https://github.com/obie/desiru
spec/signature_test.rb
Ruby
mit
90
main
2,236
#!/usr/bin/env ruby # frozen_string_literal: true # Add lib to load path $LOAD_PATH.unshift File.expand_path('../lib', __dir__) # Load only what we need for testing signature functionality require_relative '../lib/desiru/field' require_relative '../lib/desiru/signature' require_relative '../lib/desiru/errors' # Simp...
github
obie/desiru
https://github.com/obie/desiru
spec/targeted_test.rb
Ruby
mit
90
main
2,056
#!/usr/bin/env ruby # frozen_string_literal: true # Add lib to load path $LOAD_PATH.unshift File.expand_path('../../lib', __dir__) # Load specific files we need to test require_relative '../lib/desiru/core/example' require_relative '../lib/desiru/core/prediction' require_relative '../lib/desiru/signature' require_rel...
github
obie/desiru
https://github.com/obie/desiru
spec/support/redis_mock_helper.rb
Ruby
mit
90
main
1,746
# frozen_string_literal: true require 'mock_redis' module RedisMockHelper def self.included(base) base.let(:mock_redis_instance) { MockRedis.new } base.before do # Mock Redis.new to return our MockRedis instance allow(Redis).to receive(:new).and_return(mock_redis_instance) # Mock AsyncSt...
github
obie/desiru
https://github.com/obie/desiru
spec/support/database_helper.rb
Ruby
mit
90
main
4,761
# frozen_string_literal: true require 'sequel' require 'desiru/persistence' require 'desiru/persistence/setup' module DatabaseHelper @connection_setup = false @mutex = Mutex.new class << self def setup_connection(force_new: false) @mutex.synchronize do # Force new connection for true isolatio...
github
obie/desiru
https://github.com/obie/desiru
spec/integration/multi_chain_comparison_spec.rb
Ruby
mit
90
main
18,098
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'MultiChainComparison Module Integration' do let(:signature) do "question: string, context: string -> answer: string, reasoning: string, confidence: float, comparison_data: hash" end let(:test_inputs) do { question: "What is the c...
github
obie/desiru
https://github.com/obie/desiru
spec/integration/mipro_v2_optimizer_spec.rb
Ruby
mit
90
main
23,959
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'MIPROv2 Optimizer Integration' do let(:mock_signature) do "question: string -> answer: string" end let(:mock_model) do double('Model', complete: { content: 'Generated response' }, temperature: 0.7, resp...
github
obie/desiru
https://github.com/obie/desiru
spec/integration/core_data_containers_spec.rb
Ruby
mit
90
main
8,270
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'Core Data Containers Integration' do let(:test_data) do { question_input: "What is 2 + 2?", context_input: "Basic arithmetic", answer_output: "4", confidence_output: 0.95 } end describe 'Example and Prediction i...
github
obie/desiru
https://github.com/obie/desiru
spec/integration/trace_integration_spec.rb
Ruby
mit
90
main
8,438
# frozen_string_literal: true require "spec_helper" RSpec.describe "Trace Collection Integration" do # Set up a mock model for all tests let(:mock_model) do double('model').tap do |model| allow(model).to receive(:complete) do |*args| # Check if this is a code generation request if args.a...
github
obie/desiru
https://github.com/obie/desiru
spec/integration/trace_collection_spec.rb
Ruby
mit
90
main
14,934
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'Trace Collection System Integration' do let(:mock_signature) do "text: string -> result: string" end let(:test_inputs) { { text: "Hello world" } } let(:test_outputs) { { result: "Processed: Hello world" } } before do Desiru::Core....
github
obie/desiru
https://github.com/obie/desiru
spec/integration/phase1_integration_spec.rb
Ruby
mit
90
main
13,293
# frozen_string_literal: true require_relative "../spec_helper" RSpec.describe "Phase 1 Integration Tests" do describe "Core Infrastructure Integration" do let(:example) { Desiru::Core::Example.new(question: "What is 2+2?", answer: "4") } let(:prediction) { Desiru::Core::Prediction.new(question: "What is 3+...
github
obie/desiru
https://github.com/obie/desiru
spec/integration/compilation_infrastructure_spec.rb
Ruby
mit
90
main
16,153
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'Compilation Infrastructure Integration' do let(:mock_signature) do double('Signature', to_h: { input_fields: { text: :string }, output_fields: { result: :string } }, input_fields: { text: double(type: :string) }, ...
github
obie/desiru
https://github.com/obie/desiru
spec/integration/program_of_thought_spec.rb
Ruby
mit
90
main
16,593
# frozen_string_literal: true require 'spec_helper' RSpec.describe 'ProgramOfThought Module Integration' do let(:mock_model) do double('Model', complete: { content: generated_response }) end let(:signature) do "numbers: array, operation: string -> code: string, result: string, error: string" end l...
github
obie/desiru
https://github.com/obie/desiru
spec/desiru/assertions_spec.rb
Ruby
mit
90
main
5,121
# frozen_string_literal: true require 'spec_helper' require 'desiru/assertions' RSpec.describe Desiru::Assertions do describe '.assert' do context 'when condition is true' do it 'does not raise an error' do expect { described_class.assert(true, 'This should pass') }.not_to raise_error end ...
github
obie/desiru
https://github.com/obie/desiru
spec/desiru/signature_spec.rb
Ruby
mit
90
main
9,173
# frozen_string_literal: true require 'spec_helper' RSpec.describe Desiru::Signature do describe '#initialize' do it 'parses simple signature' do sig = described_class.new('question -> answer') expect(sig.inputs.keys).to eq(['question']) expect(sig.outputs.keys).to eq(['answer']) end ...
github
obie/desiru
https://github.com/obie/desiru
spec/desiru/async_status_spec.rb
Ruby
mit
90
main
6,558
# frozen_string_literal: true require 'spec_helper' require 'desiru/async_capable' require 'desiru/async_status' RSpec.describe 'Async Status' do describe Desiru::AsyncResult do let(:redis) { instance_double(Redis) } let(:job_id) { 'test-job-123' } let(:async_result) { described_class.new(job_id) } ...
github
obie/desiru
https://github.com/obie/desiru
spec/desiru/cache_spec.rb
Ruby
mit
90
main
5,896
# frozen_string_literal: true require 'spec_helper' RSpec.describe Desiru::Cache do let(:cache) { described_class.new } describe '#get_or_set' do it 'stores and retrieves values' do result = cache.get_or_set('key1') { 'value1' } expect(result).to eq('value1') # Should return cached value w...
github
obie/desiru
https://github.com/obie/desiru
spec/desiru/async_capable_spec.rb
Ruby
mit
90
main
5,824
# frozen_string_literal: true require 'spec_helper' require 'desiru/async_capable' RSpec.describe Desiru::AsyncCapable do let(:test_class) do Class.new do include Desiru::AsyncCapable attr_reader :signature, :model, :config, :demos def initialize(model) @signature = Desiru::Signature...