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
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/rails_helper.rb
Ruby
mit
46
develop
622
ENV["RAILS_ENV"] = "test" require File.expand_path("../../config/environment", __FILE__) require "rspec/rails" require "shoulda/matchers" Dir[Rails.root.join("spec/support/**/*.rb")].each { |file| require file } module Features # Extend this module in spec/support/features/*.rb include Formulaic::Dsl end RSpec...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/spec_helper.rb
Ruby
mit
46
develop
646
require "webmock/rspec" require 'vcr' # http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.syntax = :expect end config.mock_with :rspec do |mocks| mocks.syntax = :expect mocks.verify_partial_doubles = true...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/factories/quizzes.rb
Ruby
mit
46
develop
314
FactoryGirl.define do factory :quiz do title "My awesome Quizz" owner_email "lagrangemartin@gmail.com" factory :quiz_with_questions_and_answers do after(:build) do |quiz| quiz.questions << FactoryGirl.create_list(:question_with_answers, 4, quiz: quiz) end end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/factories/sessions.rb
Ruby
mit
46
develop
221
FactoryGirl.define do factory :session do quiz nil access_key "MyString" after(:build) do |session| session.participants << FactoryGirl.create_list(:participant, 4, session: session) end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/factories/questions.rb
Ruby
mit
46
develop
452
FactoryGirl.define do factory :question do title "Which color is the sky ?" factory :question_with_answers do after(:build) do |question| question.answers << FactoryGirl.build(:answer, title: 'blue', :question => question, correct: true) %w[red white green].each do |color| question.an...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/controllers/quizzes_controller_spec.rb
Ruby
mit
46
develop
6,353
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/controllers/sessions_controller_spec.rb
Ruby
mit
46
develop
5,679
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/controllers/participants_controller_spec.rb
Ruby
mit
46
develop
6,030
require 'rails_helper' # This spec was generated by rspec-rails when you ran the scaffold generator. # It demonstrates how one might use RSpec to specify the controller code that # was generated by Rails when you ran the scaffold generator. # # It assumes that the implementation code is generated by the rails scaffold...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/models/session_spec.rb
Ruby
mit
46
develop
3,958
require 'rails_helper' RSpec.describe Session, :type => :model, :vcr => {:cassette_name => 'models/session'} do let(:quiz) { FactoryGirl.create :quiz_with_questions_and_answers } let(:quiz_session) { FactoryGirl.create :session, quiz: quiz } let(:ordered_questions) {quiz.questions.rank(:row_order)} describe...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/models/participant_spec.rb
Ruby
mit
46
develop
1,698
require 'rails_helper' RSpec.describe Participant, :type => :model do let(:quiz) { FactoryGirl.create :quiz_with_questions_and_answers } let(:quiz_session) { FactoryGirl.create :session, quiz: quiz } let(:participant1) { quiz_session.participants[0] } let(:participant2) { quiz_session.participants[1] } l...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
spec/models/question_spec.rb
Ruby
mit
46
develop
1,489
require 'rails_helper' RSpec.describe Question, :type => :model do let(:quiz) { FactoryGirl.create :quiz_with_questions_and_answers } let(:ordered_questions) {quiz.questions.rank(:row_order)} describe "#row_order_index" do it 'should be in the right row_order_index' do expect(quiz.questions.count).to e...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/schema.rb
Ruby
mit
46
develop
4,135
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative sou...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/migrate/20150717225943_create_delayed_jobs.rb
Ruby
mit
46
develop
1,301
class CreateDelayedJobs < ActiveRecord::Migration def self.up create_table :delayed_jobs, force: true do |table| table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue table.integer :attempts, default: 0, null: false # Provides for retries, but still fail...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/migrate/20150723013007_add_starting_date_and_current_question_index_field_to_session.rb
Ruby
mit
46
develop
220
class AddStartingDateAndCurrentQuestionIndexFieldToSession < ActiveRecord::Migration def change add_column :sessions, :starting_date, :datetime add_column :sessions, :current_question_index, :integer end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/migrate/20150718151435_create_answers.rb
Ruby
mit
46
develop
225
class CreateAnswers < ActiveRecord::Migration def change create_table :answers do |t| t.string :title t.references :question, index: true, foreign_key: true t.timestamps null: false end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/migrate/20150725172533_create_participant_answers.rb
Ruby
mit
46
develop
319
class CreateParticipantAnswers < ActiveRecord::Migration def change create_table :participant_answers do |t| t.references :participant, index: true, foreign_key: true t.references :answer, index: true, foreign_key: true t.integer :response_time t.timestamps null: false end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/migrate/20150718143320_create_questions.rb
Ruby
mit
46
develop
222
class CreateQuestions < ActiveRecord::Migration def change create_table :questions do |t| t.text :title t.references :quiz, index: true, foreign_key: true t.timestamps null: false end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/migrate/20150719060401_create_sessions.rb
Ruby
mit
46
develop
228
class CreateSessions < ActiveRecord::Migration def change create_table :sessions do |t| t.references :quiz, index: true, foreign_key: true t.string :access_key t.timestamps null: false end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
db/migrate/20150719152929_create_participants.rb
Ruby
mit
46
develop
328
class CreateParticipants < ActiveRecord::Migration def change create_table :participants do |t| t.references :session, index: true, foreign_key: true t.string :email t.string :authorization_key t.string :authorization_password t.string :name t.timestamps null: false end ...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/controllers/quizzes_controller.rb
Ruby
mit
46
develop
1,483
class QuizzesController < ApplicationController before_action :set_quiz, only: [:show, :edit, :update, :destroy] # GET /quizzes def index @quizzes = Quiz.all end # GET /quizzes/1 def show end # GET /quizzes/new def new @quiz = Quiz.new 1.times do question = @quiz.questions.build...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/controllers/quiz_sessions_controller.rb
Ruby
mit
46
develop
808
class QuizSessionsController < QuizApplicationController def show @participant = Participant.find_by(authorization_key: params[:authorization_key], authorization_password: params[:authorization_password] ) @session = Session.find_by(access_key: params[:session_key]) if @participant.nil? || (@session.id != @...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/controllers/sessions_controller.rb
Ruby
mit
46
develop
2,018
class SessionsController < ApplicationController before_action :set_session, only: [:show, :edit, :update, :destroy, :start, :switch_to_next_question] before_action :set_quiz, only: [:new, :create] # GET /sessions/1 def show end # GET /sessions/new def new @session = Session.new @session.partici...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/controllers/participants_controller.rb
Ruby
mit
46
develop
1,312
class ParticipantsController < ApplicationController before_action :set_participant, only: [:show, :edit, :update, :destroy] # GET /participants/1 def show end # GET /participants/new def new @participant = Participant.new end # GET /participants/1/edit def edit end # POST /participants ...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/helpers/application_helper.rb
Ruby
mit
46
develop
231
module ApplicationHelper def quiz_session_path(participant) path = "/quiz_sessions/#{participant.session.access_key}/#{participant.authorization_key}/#{participant.authorization_password}" "http://"+ ENV['HOST']+path end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/models/participant.rb
Ruby
mit
46
develop
2,555
require "live_quiz/pub_nub" class Participant < ActiveRecord::Base belongs_to :session has_many :participant_answers validates :email, email: true validates :email, uniqueness: { scope: :session, message: "cannot be used more than one time" } validates :email, :authorization_key, :authorization_password,...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/models/session.rb
Ruby
mit
46
develop
5,838
require "live_quiz/pub_nub" class Session < ActiveRecord::Base belongs_to :quiz before_validation :generate_access_key, on: :create validates :quiz, presence: true has_many :participants, dependent: :destroy accepts_nested_attributes_for :participants, reject_if: :all_blank, allow_destroy: true validate ...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/models/quiz.rb
Ruby
mit
46
develop
947
class Quiz < ActiveRecord::Base validates :owner_email, email: true validates :owner_email, :title, :access_key, :access_password, presence: true validates :access_key, :access_password, uniqueness: true, on: :create before_validation :generate_access_key, :generate_access_password, on: :create has_many :questi...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/models/participant_answer.rb
Ruby
mit
46
develop
374
class ParticipantAnswer < ActiveRecord::Base belongs_to :participant belongs_to :answer validates :participant, :answer, presence: true validate :answer do if participant.have_already_answered_the_question?(answer.question) errors.add('answer', "could not be created because the question have already b...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
app/models/question.rb
Ruby
mit
46
develop
1,295
class Question < ActiveRecord::Base include RankedModel belongs_to :quiz has_many :answers, dependent: :destroy has_many :participant_answers, through: :answers accepts_nested_attributes_for :answers, reject_if: :all_blank, allow_destroy: true ranks :row_order , with_same: :quiz_id validates :titl...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
lib/live_quiz/pub_nub.rb
Ruby
mit
46
develop
588
require "pubnub" require 'singleton' module LiveQuiz class PubNub include Singleton attr_accessor :pubnub def initialize() @pubnub = Pubnub.new( publish_key: ENV['PUBNUB_PUBLISH_KEY'], subscribe_key: ENV['PUBNUB_SUBSCRIBE_KEY'], secret_key: ENV['PUBNUB_SECRET_KEY'], connect_c...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
lib/tasks/bundler_audit.rake
Ruby
mit
46
develop
287
if Rails.env.development? || Rails.env.test? require "bundler/audit/cli" namespace :bundler do desc "Updates the ruby-advisory-db and runs audit" task :audit do %w(update check).each do |command| Bundler::Audit::CLI.start [command] end end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
lib/tasks/development_seeds.rake
Ruby
mit
46
develop
303
if Rails.env.development? || Rails.env.test? require "factory_girl" namespace :dev do desc "Seed data for development environment" task prime: "db:setup" do include FactoryGirl::Syntax::Methods # create(:user, email: "user@example.com", password: "password") end end end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/smtp.rb
Ruby
mit
46
develop
300
SMTP_SETTINGS = { address: ENV.fetch("SMTP_ADDRESS"), # example: "smtp.sendgrid.net" authentication: :plain, domain: ENV.fetch("SMTP_DOMAIN"), # example: "heroku.com" enable_starttls_auto: true, password: ENV.fetch("SMTP_PASSWORD"), port: "587", user_name: ENV.fetch("SMTP_USERNAME") }
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/routes.rb
Ruby
mit
46
develop
506
Rails.application.routes.draw do resources :participants resources :participants resources :quizzes, constraints: { access_password: /^\d/ } do resources :sessions, only: [:new, :create,:show, :edit] end resources :sessions, only: [:show, :edit, :update, :destroy] do member do get 'start' ...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/unicorn.rb
Ruby
mit
46
develop
919
# https://devcenter.heroku.com/articles/rails-unicorn worker_processes (ENV["UNICORN_WORKERS"] || 3).to_i timeout (ENV["UNICORN_TIMEOUT"] || 15).to_i preload_app true before_fork do |_server, _worker| Signal.trap "TERM" do puts "Unicorn master intercepting TERM, sending myself QUIT instead" Process.kill "QU...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/application.rb
Ruby
mit
46
develop
1,855
require File.expand_path('../boot', __FILE__) require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie" # requi...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/environments/production.rb
Ruby
mit
46
develop
3,707
require Rails.root.join("config/smtp") Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in m...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/environments/test.rb
Ruby
mit
46
develop
1,872
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # 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 suit...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/environments/staging.rb
Ruby
mit
46
develop
236
require_relative "production" Mail.register_interceptor( RecipientInterceptor.new(ENV.fetch("EMAIL_RECIPIENTS")) ) Rails.application.configure do # ... config.action_mailer.default_url_options = { host: ENV.fetch("HOST") } end
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/environments/development.rb
Ruby
mit
46
develop
1,717
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/initializers/assets.rb
Ruby
mit
46
develop
521
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = (ENV["ASSETS_VERSION"] || "1.0") # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_pat...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/initializers/simple_form.rb
Ruby
mit
46
develop
6,505
# Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| # Wrappers are used by the form builder to generate a # complete input. You can remove any component from the # wrapper, change the order or even add your own to the # stack. The options given below are used to...
github
supertinou/livequiz
https://github.com/supertinou/livequiz
config/initializers/errors.rb
Ruby
mit
46
develop
570
require "net/http" require "net/smtp" # Example: # begin # some http call # rescue *HTTP_ERRORS => error # notify_hoptoad error # end HTTP_ERRORS = [ EOFError, Errno::ECONNRESET, Errno::EINVAL, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Timeout::Error ] SMTP_SER...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
hasten.gemspec
Ruby
mit
46
master
1,020
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'hasten/version' Gem::Specification.new do |spec| spec.name = "hasten" spec.version = Hasten::VERSION spec.authors = ["Derrick Parkhurst"] spec.email = ["derri...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
Gemfile
Ruby
mit
46
master
218
source 'https://rubygems.org' gem 'rspec', '~> 2.13.0', :group => :test gem 'rake', '10.3.2', :group => [:development, :test] gem 'mysql2', :group => [:developoment, :test] gem 'faker', :group => [:development, :test]
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
Rakefile
Ruby
mit
46
master
270
require 'rspec/core/rake_task' require 'bundler/gem_tasks' RSpec::Core::RakeTask.new(:spec) task :default => :spec namespace :gem do task :build do `gem build jiragit.gemspec` end task :install => [:build] do `gem install pkg/jiragit*.gem` end end
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
spec/dump_spec.rb
Ruby
mit
46
master
2,446
require './spec/spec_helper' describe Hasten::Dump do context "with indexed tables" do let(:in_io) { StringIO.new(<<-EOS) CREATE TABLE `test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `q1` int(11) DEFAULT NULL, `q2` int(11) DEFAULT NULL, PRIMARY KEY (`id`), ...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
spec/command_spec.rb
Ruby
mit
46
master
1,988
require './spec/spec_helper' describe Hasten::Command do it "strips whitespace from sql" do subject << " SET TIME_ZONE='+00:00'; " expect(subject.sql).to eq "SET TIME_ZONE='+00:00'" end it "extracts conditional sql" do subject << "/*!40103 SET TIME_ZONE='+00:00' */;" expect(subject.sql).to eq...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
spec/view_spec.rb
Ruby
mit
46
master
651
require './spec/spec_helper' describe Hasten::View do it "identifies delimited view names" do subject << <<-EOC CREATE VIEW `test` AS SELECT * FROM `section1` UNION SELECT * FROM `section2`; EOC expect(subject.name).to eq('test') end it "identifies delimited view names...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
spec/table_spec.rb
Ruby
mit
46
master
937
require './spec/spec_helper' describe Hasten::Table do it "identifies delimited table names" do subject << <<-EOC CREATE TABLE `test` ( `id` int(11) NOT NULL AUTO_INCREMENT, `q1` int(11) DEFAULT NULL, `q2` int(11) DEFAULT NULL, PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFA...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
test/benchmark.rb
Ruby
mit
46
master
2,408
#!/usr/bin/env ruby require 'mysql2' require 'faker' require 'benchmark' def client @client ||= Mysql2::Client.new( :host => "localhost", :username => "root", :socket => "/var/lib/mysql/mysql.sock" ) end def setup_database_and_table client.query("DROP DATABASE IF EXISTS `hasten`") client.query("C...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
lib/hasten.rb
Ruby
mit
46
master
257
require "hasten/version" require "hasten/modes" require "hasten/command" require "hasten/commands/table" require "hasten/commands/view" require "hasten/commands/insert" require "hasten/commands/other" require "hasten/commands/classes" require "hasten/dump"
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
lib/hasten/command.rb
Ruby
mit
46
master
788
module Hasten class Command < Array def complete? last.match(/;$/) || last.match(/^--/) || last.match(/^\s*$/) end def <<(items) if items.respond_to? :each items.each { |item| self.push item } else self.push items end end def type COMMA...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
lib/hasten/dump.rb
Ruby
mit
46
master
1,459
module Hasten class Dump attr_accessor :command def initialize(io_in, io_out) @io_in = io_in @io_out = io_out end def execute while self.command = parse_command dump_command end dump_indexes end private attr_reader :io_in, :io_out def ta...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
lib/hasten/modes.rb
Ruby
mit
46
master
2,933
module Hasten # By default, MySQL runs with autocommit mode enabled. This means that # as soon as you execute a statement that updates (modifies) a table, # MySQL stores the update on disk to make it permanent. # # To disable autocommit mode explicitly, use the following statement: # SET autocommit=0; ...
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
lib/hasten/commands/view.rb
Ruby
mit
46
master
249
module Hasten class View < Command def self.match?(sql) sql.match(/^(CREATE|REPLACE).*?VIEW\s+(.*?)\s+AS/i) || sql.match(/^VIEW\s+(.*?)\s+AS/i) end def name sql.match(/VIEW\s+`*(.*?)`.*?AS/i)[1] end end end
github
thirtysixthspan/hasten
https://github.com/thirtysixthspan/hasten
lib/hasten/commands/table.rb
Ruby
mit
46
master
928
module Hasten class Table < Command def self.match?(sql) sql.match(/^CREATE\s+(TEMPORARY\s+)*TABLE/i) end def name sql[/(?<=`).*?(?=`)/] end def without_indexes revised = reject &index_line revised[-2].gsub!(/,$/,'') revised end def indexes self ...
github
rjocoleman/labelary
https://github.com/rjocoleman/labelary
labelary.gemspec
Ruby
mit
46
master
1,149
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'labelary/version' Gem::Specification.new do |spec| spec.name = 'labelary' spec.version = Labelary::VERSION spec.authors = ['Robert Coleman'] spec.email = ['gi...
github
rjocoleman/labelary
https://github.com/rjocoleman/labelary
lib/labelary.rb
Ruby
mit
46
master
284
require 'active_support' require 'faraday' require 'faraday/multipart' require 'labelary/label' require 'labelary/image' require 'labelary/client' require 'labelary/configuration' require 'labelary/version' module Labelary def self.font Labelary.configuration.font end end
github
rjocoleman/labelary
https://github.com/rjocoleman/labelary
lib/labelary/label.rb
Ruby
mit
46
master
1,058
module Labelary class Label def self.render(**args) self.new(**args).render end def initialize(dpmm: nil, width: nil, height: nil, index: nil, zpl:, content_type: nil, font: nil) @zpl ||= zpl @dpmm ||= dpmm || config.dpmm @width ||= width || config.width @height ||=...
github
rjocoleman/labelary
https://github.com/rjocoleman/labelary
lib/labelary/configuration.rb
Ruby
mit
46
master
705
module Labelary class << self attr_accessor :configuration end def self.configuration @configuration ||= Configuration.new end def self.configure yield configuration end class Configuration attr_accessor *[ :url, :api_key, :http_adapter, :dpmm, :width, ...
github
rjocoleman/labelary
https://github.com/rjocoleman/labelary
lib/labelary/client.rb
Ruby
mit
46
master
502
module Labelary class Client def self.connection(*args) self.new(*args).connection end def connection @connection ||= Faraday.new(url: config.url) do |faraday| faraday.request :multipart faraday.response :json, content_type: /\bjson$/ faraday.headers['X-API-Key'] = con...
github
rjocoleman/labelary
https://github.com/rjocoleman/labelary
lib/labelary/image.rb
Ruby
mit
46
master
863
module Labelary class Image def self.encode(**args) self.new(**args).encode end def initialize(path:nil, mime_type:, filename:nil, file_io:nil) if path.present? @file = Faraday::UploadIO.new path, mime_type elsif file_io.present? && filename.present? @file = Faraday::Upl...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
Appraisals
Ruby
mit
46
main
749
appraise "rails-6.1" do gem 'activemodel', '~> 6.1.0' gem 'actionpack', '~> 6.1.0' gem 'concurrent-ruby', '1.3.4' end appraise "rails-7.0" do gem 'activemodel', '~> 7.0.0' gem 'actionpack', '~> 7.0.0' gem 'concurrent-ruby', '1.3.4' end appraise "rails-7.1" do gem 'activemodel', '~> 7.1.0' gem 'actionp...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
subroutine.gemspec
Ruby
mit
46
main
1,521
# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "subroutine/version" Gem::Specification.new do |spec| spec.name = "subroutine" spec.version = Subroutine::VERSION spec.authors = ["Mike Nelson"] spec.email ...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/test_helper.rb
Ruby
mit
46
main
376
# frozen_string_literal: true require "subroutine" require "minitest/autorun" require "minitest/unit" if Minitest::VERSION.to_i < 6 require "minitest/reporters" require "mocha/minitest" require "byebug" require "action_controller" Minitest::Reporters.use!([Minitest::Reporters::DefaultReporter.new]) class TestCase ...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/subroutine/outputs_test.rb
Ruby
mit
46
main
4,109
# frozen_string_literal: true require 'test_helper' module Subroutine class OutputsTest < TestCase class MissingOutputOp < ::Subroutine::Op def perform output :foo, 'bar' end end class LazyOutputOp < ::Subroutine::Op outputs :foo, lazy: true outputs :baz, lazy: true, typ...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/subroutine/fields_test.rb
Ruby
mit
46
main
8,050
# frozen_string_literal: true require "test_helper" require "subroutine/fields" module Subroutine class FieldsTest < TestCase class Whatever include Subroutine::Fields string :foo, default: "foo" string :qux, default: "qux" string :protekted, mass_assignable: false integer :bar...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/subroutine/type_caster_test.rb
Ruby
mit
46
main
15,958
# frozen_string_literal: true require 'test_helper' module Subroutine class TypeCasterTest < TestCase def op @op ||= TypeCastOp.new end def test_integer_inputs op.integer_input = nil assert_nil op.integer_input op.integer_input = 'foo' assert_equal 0, op.integer_input ...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/subroutine/auth_test.rb
Ruby
mit
46
main
4,565
# frozen_string_literal: true require "test_helper" module Subroutine class AuthTest < TestCase def user @user ||= ::User.new(id: 4, email_address: "doug@example.com") end def test_it_throws_an_error_if_authorization_is_not_defined assert_raises ::Subroutine::Auth::AuthorizationNotDeclared...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/subroutine/association_test.rb
Ruby
mit
46
main
12,513
# frozen_string_literal: true require "test_helper" module Subroutine class AssociationTest < TestCase def doug @doug ||= ::User.new(id: 1, email_address: "doug@example.com") end def fred @fred ||= ::User.new(id: 2, email_address: "fred@example.com") end def murphy @murphy |...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/subroutine/base_test.rb
Ruby
mit
46
main
9,420
# frozen_string_literal: true require "test_helper" module Subroutine class OpTest < TestCase def test_simple_fields_definition op = ::SignupOp.new assert_equal %i[email password], op.field_configurations.keys.sort end def test_inherited_fields op = ::AdminSignupOp.new assert_e...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
test/support/ops.rb
Ruby
mit
46
main
8,057
# frozen_string_literal: true require "subroutine/auth" require "subroutine/association_fields" ## Models ## class User include ::ActiveModel::Model attr_accessor :id attr_accessor :email_address attr_accessor :password validates :email_address, presence: true def self.all self end def self....
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine.rb
Ruby
mit
46
main
1,722
# frozen_string_literal: true require "active_model" require "active_support" require "active_support/concern" require "active_support/core_ext/hash/indifferent_access" require "active_support/core_ext/module/redefine_method" require "active_support/core_ext/object/deep_dup" require "active_support/core_ext/object/dup...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/fields.rb
Ruby
mit
46
main
8,666
# frozen_string_literal: true require "subroutine/type_caster" require "subroutine/fields/configuration" require "subroutine/fields/mass_assignment_error" module Subroutine module Fields extend ActiveSupport::Concern def self.allowed_input_classes @allowed_input_classes ||= begin out = [Hash...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/auth.rb
Ruby
mit
46
main
4,243
# frozen_string_literal: true require "subroutine/auth/authorization_not_declared_error" require "subroutine/auth/not_authorized_error" module Subroutine module Auth extend ActiveSupport::Concern included do class_attribute :authorization_checks self.authorization_checks = [] class_attr...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/association_fields.rb
Ruby
mit
46
main
6,825
# frozen_string_literal: true require "subroutine/association_fields/configuration" require "subroutine/association_fields/association_type_mismatch_error" module Subroutine module AssociationFields extend ActiveSupport::Concern included do class << self alias_method :field_without_associat...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/failure.rb
Ruby
mit
46
main
248
# frozen_string_literal: true module Subroutine class Failure < StandardError attr_reader :record def initialize(record) @record = record errors = @record.errors.full_messages.join(', ') super(errors) end end end
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/op.rb
Ruby
mit
46
main
3,328
# frozen_string_literal: true require "subroutine/failure" require "subroutine/fields" require "subroutine/outputs" module Subroutine class Op include ::ActiveModel::Validations include ::ActiveModel::Validations::Callbacks include ::Subroutine::Fields include ::Subroutine::Outputs class << se...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/type_caster.rb
Ruby
mit
46
main
4,850
# frozen_string_literal: true require 'date' require 'time' require 'bigdecimal' require 'securerandom' require 'active_support/json' require 'active_support/core_ext/date_time/acts_like' require 'active_support/core_ext/date_time/calculations' require 'active_support/core_ext/object/acts_like' require 'active_support...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/outputs.rb
Ruby
mit
46
main
3,515
# frozen_string_literal: true require "subroutine/outputs/configuration" require "subroutine/outputs/output_not_set_error" require "subroutine/outputs/unknown_output_error" require "subroutine/outputs/invalid_output_type_error" module Subroutine module Outputs extend ActiveSupport::Concern class LazyExecu...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/auth/authorization_not_declared_error.rb
Ruby
mit
46
main
268
# frozen_string_literal: true module Subroutine module Auth class AuthorizationNotDeclaredError < ::StandardError def initialize(msg = nil) super(msg || "Authorization management has not been declared on this class") end end end end
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/auth/not_authorized_error.rb
Ruby
mit
46
main
467
# frozen_string_literal: true module Subroutine module Auth class NotAuthorizedError < ::StandardError def initialize(msg = nil) msg = I18n.t("errors.#{msg}", default: "Sorry, you are not authorized to perform this action.") if msg.is_a?(Symbol) msg ||= I18n.t("errors.unauthorized", defaul...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/fields/mass_assignment_error.rb
Ruby
mit
46
main
232
# frozen_string_literal: true module Subroutine module Fields class MassAssignmentError < ::StandardError def initialize(field_name) super("`#{field_name}` is not mass assignable") end end end end
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/fields/configuration.rb
Ruby
mit
46
main
2,826
# frozen_string_literal: true module Subroutine module Fields class Configuration < ::SimpleDelegator PROTECTED_GROUP_IDENTIFIERS = %i[all original default].freeze NO_GROUPS = [].freeze def self.from(field_name, options) case options when Subroutine::Fields::Configuration ...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/outputs/invalid_output_type_error.rb
Ruby
mit
46
main
303
# frozen_string_literal: true module Subroutine module Outputs class InvalidOutputTypeError < StandardError def initialize(name:, expected_type:, actual_type:) super("Invalid output type for '#{name}' expected #{expected_type} but got #{actual_type}") end end end end
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/outputs/output_not_set_error.rb
Ruby
mit
46
main
260
# frozen_string_literal: true module Subroutine module Outputs class OutputNotSetError < StandardError def initialize(name) super("Expected output '#{name}' to be set upon completion of perform but was not.") end end end end
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/outputs/configuration.rb
Ruby
mit
46
main
865
# frozen_string_literal: true module Subroutine module Outputs class Configuration < ::SimpleDelegator def self.from(field_name, options) case options when Subroutine::Outputs::Configuration options.class.new(field_name, options) else new(field_name, options) ...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/outputs/unknown_output_error.rb
Ruby
mit
46
main
210
# frozen_string_literal: true module Subroutine module Outputs class UnknownOutputError < StandardError def initialize(name) super("Unknown output '#{name}'") end end end end
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/association_fields/component_configuration.rb
Ruby
mit
46
main
342
# frozen_string_literal: true require "subroutine/fields/configuration" module Subroutine module AssociationFields class ComponentConfiguration < ::Subroutine::Fields::Configuration def behavior :association_component end def association_name config[:association_name] e...
github
guideline-tech/subroutine
https://github.com/guideline-tech/subroutine
lib/subroutine/association_fields/configuration.rb
Ruby
mit
46
main
2,661
# frozen_string_literal: true require "subroutine/fields/configuration" require "subroutine/association_fields/component_configuration" module Subroutine module AssociationFields class Configuration < ::Subroutine::Fields::Configuration def validate! super if config[:as] && foreign_key ...
github
tamtam180/apache_log_gen
https://github.com/tamtam180/apache_log_gen
apache-loggen.gemspec
Ruby
apache-2.0
46
master
834
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'apache-loggen/version' Gem::Specification.new do |gem| gem.name = "apache-loggen" gem.version = LogGenerator::VERSION gem.authors = ["tamtam180"] gem.email ...
github
tamtam180/apache_log_gen
https://github.com/tamtam180/apache_log_gen
lib/apache-loggen/base.rb
Ruby
apache-2.0
46
master
12,210
# -*- encoding: utf-8 -*- require 'rubygems' require 'time' require 'fileutils' require 'optparse' require 'json' module LogGenerator class Base def generate(context, config) # must override exit 1 end end class Apache < Base RECORDS = 5000 HOSTS = RECORDS/4 PAGES = RECORDS/4 ...
github
valerijaspasojevic/jekyll-compress-images
https://github.com/valerijaspasojevic/jekyll-compress-images
jekyll-compress-images.gemspec
Ruby
mit
46
master
827
Gem::Specification.new do |s| s.name = 'jekyll-compress-images' s.version = '1.2' s.licenses = ['MIT'] s.summary = "Jekyll plugin for compress/optimize images (jpg, png, gif, svg)" s.description = "Plugin for compress/optimize images (jpg, png, gif, svg). If you are struggle how to install m...
github
valerijaspasojevic/jekyll-compress-images
https://github.com/valerijaspasojevic/jekyll-compress-images
lib/jekyll-compress-images.rb
Ruby
mit
46
master
1,500
require "image_optim" require "image_optim_pack" require 'yaml' module Jekyll class CompressImages < Generator safe true def generate(site) config = YAML::load_file "_config.yml" config = config["compress_images"] || {} @config = default_options.merge! config imageoptim_options = Y...
github
codeforamerica/asap_pdf
https://github.com/codeforamerica/asap_pdf
Gemfile
Ruby
apache-2.0
46
main
1,477
source "https://rubygems.org" gem "rails", "~> 8.1.3" gem "propshaft" gem "pg" gem "puma", ">= 5.0" gem "jsbundling-rails" gem "turbo-rails" gem "stimulus-rails" gem "cssbundling-rails", "~> 1.4.3" gem "csv" gem "httpparty" gem "rubyzip" gem "smarter_csv" gem "chartkick" gem "tzinfo-data", platforms: %i[windows jruby...
github
codeforamerica/asap_pdf
https://github.com/codeforamerica/asap_pdf
Rakefile
Ruby
apache-2.0
46
main
304
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require_relative "config/application" Rails.application.load_tasks Rake::Task["db:test:prepare"].clear task "db:test:prepare" => ["db:prepare"]
github
codeforamerica/asap_pdf
https://github.com/codeforamerica/asap_pdf
db/seeds.rb
Ruby
apache-2.0
46
main
292
require "csv" require "zip" require "rake" # Create a test user for development if Rails.env.development? Rake::Task["users:create_admin"].invoke("admin@codeforamerica.org", "password") Rake::Task["documents:bootstrap"].invoke Rake::Task["documents:update_department"].invoke("1") end
github
codeforamerica/asap_pdf
https://github.com/codeforamerica/asap_pdf
db/migrate/20250711141619_change_admin_roles.rb
Ruby
apache-2.0
46
main
219
class ChangeAdminRoles < ActiveRecord::Migration[8.0] def change change_table :user do |t| rename_column :users, :is_admin, :is_site_admin add_column :users, :is_user_admin, :boolean end end end
github
codeforamerica/asap_pdf
https://github.com/codeforamerica/asap_pdf
db/migrate/20250808220738_add_document_inference_active_flag.rb
Ruby
apache-2.0
46
main
285
class AddDocumentInferenceActiveFlag < ActiveRecord::Migration[8.0] def up add_column :document_inferences, :is_active, :boolean remove_index :document_inferences, [:document_id, :inference_type] end def down remove_column :document_inferences, :is_active end end