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 | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | lib/fancy_irb/size_detector.rb | Ruby | mit | 49 | main | 362 | module FancyIrb
module SizeDetector
extend self
def width_of(data)
Unicode::DisplayWidth.of(Paint.unpaint(data.to_s))
end
def height_of(data, width)
data = data.to_s
long_lines = data.split("\n").inject(0){ |sum, line|
sum + width_of(line) / (width + 1)
}
data.c... |
github | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | lib/fancy_irb/error_capturer.rb | Ruby | mit | 49 | main | 310 | require 'stringio'
module FancyIrb
class ErrorCapturer
def initialize
@original_stdout, $stdout = $stdout, StringIO.new
@fake_stdout = $stdout
end
def error_string
@fake_stdout.string
end
def restore_original_stdout
$stdout = @original_stdout
end
end
end |
github | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | lib/fancy_irb/terminal_info.rb | Ruby | mit | 49 | main | 1,140 | require 'io/console'
module FancyIrb
module TerminalInfo
def self.lines
STDOUT.winsize[0]
rescue Errno::ENOTTY
ENV['LINES'] || ENV['ROWS'] || 25
end
def self.cols
STDOUT.winsize[1]
rescue Errno::ENOTTY
ENV['COLUMNS'] || 80
end
begin
if RbConfig::CONFIG['hos... |
github | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | lib/fancy_irb/core_ext.rb | Ruby | mit | 49 | main | 487 | # patch streams to track height & apply colors
FancyIrb.patch_stream $stdout, :stdout
FancyIrb.patch_stream $stderr, :stderr
# patch some $stdin methods to track height
FancyIrb.register_height_trackers $stdin, FancyIrb::TRACK_HEIGHT_INPUT_METHODS
# patch some ARGF methods to track height
FancyIrb.register_height_tra... |
github | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | lib/fancy_irb/implementation.rb | Ruby | mit | 49 | main | 4,650 | module FancyIrb
extend SizeDetector
@error_capturer = nil
class << self
attr_reader :error_capturer
attr_accessor :skip_next_rocket
def start(user_options = {})
set_defaults
apply_user_options(user_options)
reset_line!
extend!
true
end
# hook into IRB
def ... |
github | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | lib/fancy_irb/irb_ext.rb | Ruby | mit | 49 | main | 1,463 | module FancyIrb
module IrbExtCommon
def output_value(_omit = false)
FancyIrb.output_value(@context, @scanner)
end
def signal_status(name, *args, &block)
FancyIrb.reset_line!
super(name, *args, &block)
ensure
if name == :IN_EVAL
FancyIrb.present_and_clear_captured_error... |
github | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | spec/size_detector_spec.rb | Ruby | mit | 49 | main | 1,097 | require_relative "../lib/fancy_irb"
require_relative 'fixtures'
describe FancyIrb::SizeDetector do
include FancyIrb::SizeDetector
describe ".width_of" do
it "returns 0 when no data given" do
expect( width_of(nil) ).to eq 0
end
it "returns string length for 'normal' data" do
expect( width_... |
github | janlelis/fancy_irb | https://github.com/janlelis/fancy_irb | spec/fixtures.rb | Ruby | mit | 49 | main | 252 | require 'paint'
EXAMPLE_HEIGHT_DATA = [
["bla", 10, 0],
["\n", 10, 1],
["bla\n", 10, 1],
["bla\nblubb", 10, 1],
["bla\n\nblubb", 10, 2],
["b"*10, 10, 0],
["b"*11, 10, 1],
[Paint["b"*10, :red], 10, 0],
[Paint["b"*11, :red], 10, 1],
] |
github | synth/omniauth-microsoft_graph | https://github.com/synth/omniauth-microsoft_graph | omniauth-microsoft_graph.gemspec | Ruby | mit | 50 | main | 1,277 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'omniauth/microsoft_graph/version'
Gem::Specification.new do |spec|
spec.name = "omniauth-microsoft_graph"
spec.version = OmniAuth::MicrosoftGraph::VERSION
spec.authors ... |
github | synth/omniauth-microsoft_graph | https://github.com/synth/omniauth-microsoft_graph | spec/omniauth/strategies/microsoft_graph_oauth2_spec.rb | Ruby | mit | 50 | main | 21,488 | # frozen_string_literal: true
require 'spec_helper'
require 'json'
require 'omniauth_microsoft_graph'
require 'stringio'
describe OmniAuth::Strategies::MicrosoftGraph do
let(:request) { double('Request', params: {}, cookies: {}, env: {}) }
let(:app) do
lambda do
[200, {}, ['Hello.']]
end
end
su... |
github | synth/omniauth-microsoft_graph | https://github.com/synth/omniauth-microsoft_graph | spec/omniauth/microsoft_graph/domain_verifier_spec.rb | Ruby | mit | 50 | main | 3,713 | # frozen_string_literal: true
require 'spec_helper'
require 'omniauth/microsoft_graph/domain_verifier'
RSpec.describe OmniAuth::MicrosoftGraph::DomainVerifier do
subject(:verifier) { described_class.new(auth_hash, access_token, options) }
let(:auth_hash) do
{
'info' => { 'email' => email },
'extr... |
github | synth/omniauth-microsoft_graph | https://github.com/synth/omniauth-microsoft_graph | lib/omniauth/strategies/microsoft_graph.rb | Ruby | mit | 50 | main | 5,248 | require 'omniauth-oauth2'
module OmniAuth
module Strategies
class MicrosoftGraph < OmniAuth::Strategies::OAuth2
BASE_SCOPE_URL = 'https://graph.microsoft.com/'
BASE_SCOPES = %w[offline_access openid email profile].freeze
DEFAULT_SCOPE = 'offline_access openid email profile User.Read'.freeze
... |
github | synth/omniauth-microsoft_graph | https://github.com/synth/omniauth-microsoft_graph | lib/omniauth/microsoft_graph/domain_verifier.rb | Ruby | mit | 50 | main | 4,471 | # frozen_string_literal: true
require 'jwt' # for token signature validation
require 'omniauth' # to inherit from OmniAuth::Error
require 'oauth2' # to rescue OAuth2::Error
module OmniAuth
module MicrosoftGraph
# Verify user email domains to mitigate the nOAuth vulnerability
# https://www.descope.com/blog/po... |
github | synth/omniauth-microsoft_graph | https://github.com/synth/omniauth-microsoft_graph | example/example.rb | Ruby | mit | 50 | main | 582 | $:.push File.dirname(__FILE__) + '/../lib'
require 'microsoft_graph'
require 'sinatra'
require 'json'
set :port, 4200
client_id = ENV['AZURE_APPLICATION_CLIENT_ID']
secret = ENV['AZURE_APPLICATION_CLIENT_SECRET']
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :microsoft_graph, client_id, secret
end
... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | Gemfile | Ruby | mit | 49 | master | 213 | ruby '2.0.0'
source 'https://rubygems.org'
gem 'encryptor2'
group :development do
gem 'pry'
gem 'activerecord'
gem 'datamapper'
gem 'mocha'
gem 'sequel'
gem 'dm-sqlite-adapter'
gem 'sqlite3'
end |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | Rakefile | Ruby | mit | 49 | master | 553 | require 'rake'
require 'rake/testtask'
require 'rdoc/task'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the attr_encryptor gem.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the attr_encryptor gem.'
R... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | attr_encryptor.gemspec | Ruby | mit | 49 | master | 1,146 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'attr_encryptor/version'
require 'date'
Gem::Specification.new do |s|
s.name = 'attr_encryptor'
s.version = AttrEncryptor::Version.string
s.date = Date.today
s.summary = 'Encrypt an... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | lib/attr_encryptor.rb | Ruby | mit | 49 | master | 15,277 | require 'encryptor'
require 'openssl'
# Adds attr_accessors that encrypt and decrypt an object's attributes
module AttrEncryptor
autoload :Version, 'attr_encryptor/version'
def self.extended(base) # :nodoc:
base.class_eval do
include InstanceMethods
attr_writer :attr_encrypted_options
@attr_... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | lib/attr_encryptor/version.rb | Ruby | mit | 49 | master | 377 | module AttrEncryptor
# Contains information about this gem's version
module Version
MAJOR = 2
MINOR = 0
PATCH = 0
# Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
#
# Example
#
# Version.string # '1.0.2'
def self.string... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | lib/attr_encryptor/adapters/data_mapper.rb | Ruby | mit | 49 | master | 575 | if defined?(DataMapper)
module AttrEncryptor
module Adapters
module DataMapper
def self.extended(base) # :nodoc:
class << base
alias_method :included_without_attr_encrypted, :included
alias_method :included, :included_with_attr_encrypted
end
end
... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | lib/attr_encryptor/adapters/active_record.rb | Ruby | mit | 49 | master | 1,091 | if defined?(ActiveRecord::Base)
module AttrEncryptor
module Adapters
module ActiveRecord
def self.extended(base) # :nodoc:
base.class_eval do
class << self
alias_method_chain :attr_encrypted, :defined_attributes
alias_method_chain :attr_encryptor, :d... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | lib/attr_encryptor/adapters/sequel.rb | Ruby | mit | 49 | master | 276 | if defined?(Sequel)
module AttrEncryptor
module Adapters
module Sequel
def self.extended(base) # :nodoc:
base.attr_encrypted_options[:encode] = true
end
end
end
end
Sequel::Model.extend AttrEncryptor::Adapters::Sequel
end |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | test/sequel_test.rb | Ruby | mit | 49 | master | 1,506 | require File.expand_path('../test_helper', __FILE__)
DB = Sequel.sqlite
DB.create_table :humans do
primary_key :id
column :encrypted_email, :string
column :encrypted_email_salt, String
column :encrypted_email_iv, :string
column :password, :string
column :encrypted_credentials, :string
column :encrypted_... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | test/test_helper.rb | Ruby | mit | 49 | master | 544 | require 'test/unit'
require 'digest/sha2'
require 'rubygems'
gem 'activerecord', ENV['ACTIVE_RECORD_VERSION'] if ENV['ACTIVE_RECORD_VERSION']
require 'active_record'
require 'data_mapper'
require 'sequel'
require 'mocha/setup'
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$:.unshift(File.dirname(__FILE__)... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | test/data_mapper_test.rb | Ruby | mit | 49 | master | 1,485 | require File.expand_path('../test_helper', __FILE__)
DataMapper.setup(:default, 'sqlite3::memory:')
class Client
include DataMapper::Resource
property :id, Serial
property :encrypted_email, String
property :encrypted_email_iv, String
property :encrypted_email_salt, String
property :encrypted_credentials... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | test/attr_encrypted_test.rb | Ruby | mit | 49 | master | 11,554 | # encoding: UTF-8
require File.expand_path('../test_helper', __FILE__)
class SillyEncryptor
def self.silly_encrypt(options)
(options[:value] + options[:some_arg]).reverse
end
def self.silly_decrypt(options)
options[:value].reverse.gsub(/#{options[:some_arg]}$/, '')
end
end
class User
self.attr_encr... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | test/active_record_test.rb | Ruby | mit | 49 | master | 3,179 | require File.expand_path('../test_helper', __FILE__)
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
def create_tables
silence_stream(STDOUT) do
ActiveRecord::Schema.define(:version => 1) do
create_table :people do |t|
t.string :encrypted_email
t.st... |
github | danpal/attr_encryptor | https://github.com/danpal/attr_encryptor | test/debug_order.rb | Ruby | mit | 49 | master | 1,101 | require 'digest/sha2'
require 'rubygems'
gem 'activerecord', ENV['ACTIVE_RECORD_VERSION'] if ENV['ACTIVE_RECORD_VERSION']
require 'active_record'
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$:.unshift(File.dirname(__FILE__))
require 'attr_encrypted'
ActiveRecord::Base.establish_connection :adapter => 's... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | Rakefile | Ruby | mit | 49 | main | 230 | require "bundler/setup"
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake"
load "rails/tasks/statistics.rake"
require "bundler/gem_tasks"
task default: "app:monolith:tailwind:watch" |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | Gemfile | Ruby | mit | 49 | main | 361 | source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Specify your gem's dependencies in monolith.gemspec.
gemspec
gem "sqlite3"
gem "sprockets-rails"
# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"
gem "phlex-rails", "~> 2.1"
gem ... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | rubymonolith.gemspec | Ruby | mit | 49 | main | 1,450 | require_relative "lib/monolith/version"
Gem::Specification.new do |spec|
spec.name = "rubymonolith"
spec.version = Monolith::VERSION
spec.authors = ["Brad Gessler"]
spec.email = ["bradgessler@gmail.com"]
spec.homepage = "https://rubymonolith.org/"
spec.summary = "CLI used to cre... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/generators/monolith/install/install_generator.rb | Ruby | mit | 49 | main | 954 | require_relative "../generators/base.rb"
class Monolith::InstallGenerator < Monolith::Generators::Base
source_root File.expand_path("templates", __dir__)
desc "Installs gems and frameworks for Monolith"
def append_gemfile
gem "rubymonolith"
end
def bundle_gems
bundle_command "install"
end
def... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/generators/monolith/generators/base.rb | Ruby | mit | 49 | main | 1,586 | module Monolith
module Generators
class Base < Rails::Generators::Base
protected
# Lifted from https://github.com/bradgessler/rails/blob/bbd298d7b036c550912139b41903f9f37087befe/railties/lib/rails/generators/app_base.rb#L380-L404,
# which is not ideal. I tried to inherit `AppBase`, which also ... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/generators/monolith/content/content_generator.rb | Ruby | mit | 49 | main | 702 | require_relative "../generators/base.rb"
class Monolith::ContentGenerator < Monolith::Generators::Base
source_root File.expand_path("templates", __dir__)
desc "Installs gems to manage content"
def append_gemfile
# Manage content via Sitepress in ./app/content
gem "sitepress-rails", git: "https://github... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/generators/monolith/view/view_generator.rb | Ruby | mit | 49 | main | 421 | require_relative "../generators/base.rb"
class Monolith::ViewGenerator < Monolith::Generators::Base
source_root File.expand_path("templates", __dir__)
desc "Installs gems to manage views in Monolith"
def append_gemfile
# Encapsulate views (instead of using partials)
gem "phlex-rails"
end
def bundl... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/monolith/engine.rb | Ruby | mit | 49 | main | 809 | require "phlex-rails"
module Monolith
module Views
end
module Components
extend Phlex::Kit
end
class Engine < ::Rails::Engine
isolate_namespace Monolith
initializer "monolith.assets" do |app|
app.config.assets.paths << root.join("app/assets/builds")
end
initializer "monolith.mou... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/monolith/cli.rb | Ruby | mit | 49 | main | 1,034 | require "thor"
require "foreman"
require "foreman/engine"
require "foreman/engine/cli"
require "monolith/version"
module Monolith
class CLI < Thor
include Thor::Actions
DEFAULT_PATH = "server".freeze
desc "new [PROJECT_NAME]", "create a new Rails monolith"
def new(path = DEFAULT_PATH)
templat... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/monolith/cli/template.rb | Ruby | mit | 49 | main | 2,411 | # High-performance async web server built on fibers for better concurrency
gem "falcon"
# Remove puma (Rails default)
gsub_file "Gemfile", /^gem ["']puma["'].*$/, ""
after_bundle do
# Remove Puma configuration file
remove_file "config/puma.rb"
end
# Fast, object-oriented view components as an alternative to ERB ... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | lib/tasks/monolith_tasks.rake | Ruby | mit | 49 | main | 547 | namespace :monolith do
namespace :tailwind do
desc "Build Tailwind CSS for Monolith engine"
task :build do
system "bundle exec tailwindcss --input app/assets/stylesheets/monolith/application.tailwind.css --output app/assets/builds/monolith/tailwind.css --minify"
end
desc "Watch and rebuild Tail... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | spec/dummy/config/application.rb | Ruby | mit | 49 | main | 1,245 | 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 | rubymonolith/gems | https://github.com/rubymonolith/gems | app/components/monolith/base.rb | Ruby | mit | 49 | main | 236 | class Monolith::Components::Base < Phlex::HTML
include Phlex::Rails::Helpers::URLFor
include Phlex::Rails::Helpers::FormAuthenticityToken
include Phlex::Rails::Helpers::AssetPath
include Phlex::Rails::Helpers::TurboFrameTag
end |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/components/monolith/table.rb | Ruby | mit | 49 | main | 726 | class Monolith::Components::Table < Monolith::Components::Base
def initialize(collection)
@collection = collection
@columns = []
end
def row(header, &row)
@columns << [ header, row ]
end
def view_template(&)
vanish(&)
headers, rows = @columns.transpose
div(class: "overflow-x-auto")... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/views/monolith/layouts/base.rb | Ruby | mit | 49 | main | 654 | class Monolith::Views::Layouts::Base < Monolith::Views::Base
def around_template(&)
html do
head do
title { @title }
meta name: "viewport", content: "width=device-width,initial-scale=1"
meta charset: "utf-8"
meta name: "apple-mobile-web-app-capable", content: "yes"
me... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/home_controller.rb | Ruby | mit | 49 | main | 250 | # app/controllers/monolith/gems_controller.rb
module Monolith
class HomeController < Monolith::ApplicationController
class Show < View
def view_template
h1(class: "text-6xl") { "Welcome to Monolith!" }
end
end
end
end |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/routes_controller.rb | Ruby | mit | 49 | main | 4,456 | # app/controllers/monolith/routes_controller.rb
module Monolith
class RoutesController < Monolith::ApplicationController
def index
render Index.new.tap { _1.routes = Route.all }
end
def show
route = Route.find(params[:id].to_s)
return render plain: "Route not found", status: :not_found ... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/tables_controller.rb | Ruby | mit | 49 | main | 4,526 | # app/controllers/monolith/tables_controller.rb
module Monolith
class TablesController < Monolith::ApplicationController
before_action :set_pagination
before_action :set_table, only: :show
def index
render Index.new.tap { _1.tables = Table.all }
end
def show
not_found! unless @table
... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/gems_controller.rb | Ruby | mit | 49 | main | 7,787 | # app/controllers/monolith/gems_controller.rb
module Monolith
class GemsController < Monolith::ApplicationController
def index
render Index.new.tap { _1.gems = GemInfo.all }
end
def show
gem_info = GemInfo.find(params[:id].to_s)
return render plain: "Gem not found", status: :not_found u... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/generators_controller.rb | Ruby | mit | 49 | main | 11,346 | # app/controllers/monolith/generators_controller.rb
module Monolith
class GeneratorsController < Monolith::ApplicationController
def index
render Index.new.tap { _1.generators = Generator.all }
end
def show
generator = Generator.find(params[:id].to_s)
return render plain: "Generator not... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/application_controller.rb | Ruby | mit | 49 | main | 2,082 | require 'superview'
class Monolith::ApplicationController < ActionController::Base
layout false
include Superview::Actions
# # include Superform::Rails::StrongParameters
# include ExceptionHandler
private
def unprocessable(view)
render component(view), status: :unprocessable_entity
end
def proc... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/models_controller.rb | Ruby | mit | 49 | main | 8,919 | # app/controllers/monolith/models_controller.rb
module Monolith
class ModelsController < Monolith::ApplicationController
def index
render Index.new.tap { _1.models = Model.all }
end
def show
model = Model.find(params[:id].to_s)
return render plain: "Model not found", status: :not_found ... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/exceptions_controller.rb | Ruby | mit | 49 | main | 13,098 | # app/controllers/monolith/exceptions_controller.rb
module Monolith
class ExceptionsController < Monolith::ApplicationController
skip_before_action :verify_authenticity_token, raise: false
def show
exception = request.env['action_dispatch.exception']
if exception.nil?
return render plain... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | app/controllers/monolith/emails_controller.rb | Ruby | mit | 49 | main | 1,658 | module Monolith
class EmailsController < ApplicationController
before_action do
Rails.application.eager_load!
# @emails = ApplicationEmail.descendants
if params.key? :id
@email = @emails.find { it.to_s == params.fetch(:id) }
end
end
class Index < View
attr_writer :e... |
github | rubymonolith/gems | https://github.com/rubymonolith/gems | config/routes.rb | Ruby | mit | 49 | main | 434 | Monolith::Engine.routes.draw do
root to: "home#show"
resources :emails, only: [:index, :show]
resources :tables, only: [:index, :show]
resources :gems, only: [:index, :show]
resources :routes, only: [:index, :show]
resources :models, only: [:index, :show]
resources :generators, only: [:index, :show] do
... |
github | mbleigh/colorist | https://github.com/mbleigh/colorist | colorist.gemspec | Ruby | mit | 49 | master | 925 | Gem::Specification.new do |s|
s.name = "colorist"
s.version = "0.0.3"
s.date = "2008-08-16"
s.summary = "A library built to handle the easy conversion and simple manipulation of colors."
s.email = "michael@intridea.com"
s.homepage = "http://github.com/mbleigh/colorist"
s.description = "Colorist is a libra... |
github | mbleigh/colorist | https://github.com/mbleigh/colorist | spec/colorist/color_spec.rb | Ruby | mit | 49 | master | 2,648 | require 'spec_helper'
require 'colorist'
describe Colorist::Color do
before :each do
@color = Colorist::Color.new 0x808080
end
describe "#1 Color" do
it "should initialize default color (#000000)" do
Colorist::Color.new.to_s.should == "#000000"
end
it "should initialize the approriate color" do
... |
github | mbleigh/colorist | https://github.com/mbleigh/colorist | lib/colorist/color.rb | Ruby | mit | 49 | master | 20,288 | module Colorist
# Color is the general class for storing and manipulating a color with the
# Colorist gem. It provides methods to add, subtract, and calculate aspects
# of the color based on W3C and other standards.
class Color
attr_accessor :r, :g, :b
W3C_COLOR_NAMES = { "maroon" => 0x... |
github | mbleigh/colorist | https://github.com/mbleigh/colorist | lib/colorist/core_extensions.rb | Ruby | mit | 49 | master | 746 | class Integer
# Converts a hexadecimal number into a Color. Must be
# the equivalent of the full hexadecimal form (for example,
# <tt>0x123456</tt>).
def to_color
Colorist::Color.new(self)
end
end
class Float
# Converts a number from 0.0 to 1.0 to the grayscale equivalent
# of that brightness value. ... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | Rakefile | Ruby | bsd-3-clause | 49 | master | 483 | # 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(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'tasks/rails'
require 'bugsnag/... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | Gemfile | Ruby | bsd-3-clause | 49 | master | 1,469 | source "https://rubygems.org"
source "http://gems.github.com"
gem "bugsnag", "~> 5.5.0"
gem "rake", "~> 0.9.2.2"
gem "rdoc", "~> 3.12"
gem "rails", "2.3.18"
gem "libxml-ruby", "2.9.0", :require => "libxml"
gem "ambethia-smtp-tls", "1.1.2", :require => "smtp-tls"
gem "paperclip", "2.3.1"
gem "mime-types", "1.16",
:... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | config.ru | Ruby | bsd-3-clause | 49 | master | 251 | # Require your environment file to bootstrap Rails
require ::File.dirname(__FILE__) + '/config/environment'
# Serve static assets from RAILS_ROOT/public directory
# use Rails::Rack::Static
# Dispatch the request
run ActionController::Dispatcher.new |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | test/test_helper.rb | Ruby | bsd-3-clause | 49 | master | 795 | ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'action_view/test_case'
Mocha::Configuration.warn_when(:stubbing_non_existent_method)
Mocha::Configuration.warn_when(:stubbing_non_public_method)
class ActiveSupport::TestCase
self.use_... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | test/shoulda_macros/pagination.rb | Ruby | bsd-3-clause | 49 | master | 1,620 | class Test::Unit::TestCase
# Example:
# context "a GET to index signed in as admin" do
# setup do
# sign_in_as Factory(:admin_user)
# get :index
# end
# should_paginate_collection :users
# should_display_pagination
# end
def self.should_paginate_collection(collection_name)
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | test/shoulda_macros/forms.rb | Ruby | bsd-3-clause | 49 | master | 1,902 | class Test::Unit::TestCase
# assert_form posts_url, :put do
# assert_text_field :post, :title
# assert_text_area :post, :body
# assert_submit
# end
def assert_form(url, http_method = :post)
http_method, hidden_http_method = form_http_method(http_method)
assert_select "form[action=?][method=#{... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | test/factories/clearance.rb | Ruby | bsd-3-clause | 49 | master | 339 | Factory.sequence :email do |n|
"user#{n}@example.com"
end
Factory.define :user do |user|
user.email { Factory.next :email }
user.password { "password" }
user.password_confirmation { "password" }
end
Factory.define :email_confirmed_user, :parent => :user do |user|
user.email_conf... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | test/unit/user_test.rb | Ruby | bsd-3-clause | 49 | master | 205 | require 'test_helper'
class UserTest < ActiveSupport::TestCase
should "be valid with factories" do
assert_valid Factory.build(:user)
assert_valid Factory.build(:email_confirmed_user)
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | deploy/after_restart.rb | Ruby | bsd-3-clause | 49 | master | 287 | #send hoptoad deploy notification
run "cd #{config.release_path} && rake hoptoad:deploy TO=#{config.node[:environment][:framework_env]} USER=#{config.node[:owner_name]} REVISION=#{`cat #{config.release_path}/REVISION`}"
#restart delayed jobs
run "sudo monit restart all -g dj_pairwise2" |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/spec_helper.rb | Ruby | bsd-3-clause | 49 | master | 1,827 | # This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'spec/autorun'
require 'spec/rails'
# Requires supporting files with custom matchers and... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/factories.rb | Ruby | bsd-3-clause | 49 | master | 2,905 | Factory.define(:question) do |f|
f.sequence(:name) { |i| "Name #{i}" }
f.site {|s| s.association(:user)}
f.creator {|c| c.association(:visitor, :site => c.site)}
end
Factory.define(:aoi_question, :parent => :question) do |f|
f.sequence(:name) { |i| "Name #{i}" }
f.association :site, :factory => :user
f.crea... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/helpers/prompts_helper_spec.rb | Ruby | bsd-3-clause | 49 | master | 343 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PromptsHelper do
#Delete this example and add some real ones or delete this file
it "is included in the helper object" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(Pro... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/helpers/questions_helper_spec.rb | Ruby | bsd-3-clause | 49 | master | 347 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe QuestionsHelper do
#Delete this example and add some real ones or delete this file
it "is included in the helper object" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(Q... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/helpers/choices_helper_spec.rb | Ruby | bsd-3-clause | 49 | master | 343 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ChoicesHelper do
#Delete this example and add some real ones or delete this file
it "is included in the helper object" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(Cho... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/helpers/clicks_helper_spec.rb | Ruby | bsd-3-clause | 49 | master | 341 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ClicksHelper do
#Delete this example and add some real ones or delete this file
it "is included in the helper object" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(Clic... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/helpers/visitors_helper_spec.rb | Ruby | bsd-3-clause | 49 | master | 345 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe VisitorsHelper do
#Delete this example and add some real ones or delete this file
it "is included in the helper object" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(Vi... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/routing/prompts_routing_spec.rb | Ruby | bsd-3-clause | 49 | master | 782 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PromptsController do
before(:all) do
@aoi_clone = Factory.create(:user)
@valid_attributes = {
:site => @aoi_clone,
:creator => @aoi_clone.default_visitor
}
@q = Question.create!(@valid_attributes)
end... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/routing/choices_routing_spec.rb | Ruby | bsd-3-clause | 49 | master | 1,933 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ChoicesController do
before(:all) do
@aoi_clone = Factory.create(:user)
@valid_attributes = {
:site => @aoi_clone,
:creator => @aoi_clone.default_visitor
}
@q = Question.create!(@valid_attributes)
end... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/routing/questions_routing_spec.rb | Ruby | bsd-3-clause | 49 | master | 1,633 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe QuestionsController do
describe "route generation" do
it "maps #index" do
route_for(:controller => "questions", :action => "index").should == "/questions"
end
it "maps #new" do
route_for(:controller => "questions",... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/support/integration_support.rb | Ruby | bsd-3-clause | 49 | master | 1,837 | module IntegrationSupport
@@default_user = nil
# todo: make automatically included in integration tests
Spec::Runner.configure do |config|
config.before(:each, :type => :integration) do
# compatibility with old tests using @api_user, remove this
@api_user = self.default_user = Factory(:email_con... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/support/db_support.rb | Ruby | bsd-3-clause | 49 | master | 280 | module DBSupport
# this is useful after a before :all block fills the db with stuff
def truncate_all
(ActiveRecord::Base.connection.tables - ["schema_migrations"]).each do |table|
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table};")
end
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/controllers/choices_controller_spec.rb | Ruby | bsd-3-clause | 49 | master | 5,913 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ChoicesController do
def sign_in_as(user)
@controller.current_user = user
return user
end
#
before(:each) do
sign_in_as(@user = Factory(:email_confirmed_user))
end
#
def mock_question(... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/controllers/prompts_controller_spec.rb | Ruby | bsd-3-clause | 49 | master | 3,234 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PromptsController do
def sign_in_as(user)
@controller.current_user = user
return user
end
before(:each) do
@question = Factory.create(:aoi_question)
sign_in_as(@aoi_clone = @question.site)
@prompt = @question.... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/controllers/questions_controller_spec.rb | Ruby | bsd-3-clause | 49 | master | 1,465 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe QuestionsController do
def sign_in_as(user)
@controller.current_user = user
return user
end
before(:each) do
@question = Factory.create(:aoi_question)
sign_in_as(@user = @question.site)
end
it "responds with basi... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/visitor_spec.rb | Ruby | bsd-3-clause | 49 | master | 11,485 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Visitor do
it {should belong_to :site}
it {should have_many :questions}
it {should have_many :votes}
it {should have_many :skips}
it {should have_many :clicks}
it {should have_many :appearances}
it {should have_many :choices... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/question_spec.rb | Ruby | bsd-3-clause | 49 | master | 27,922 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Question do
include DBSupport
it {should belong_to :creator}
it {should belong_to :site}
it {should have_many :choices}
it {should have_many :prompts}
it {should have_many :votes}
it {should have_many :densities}
it {should ... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/vote_spec.rb | Ruby | bsd-3-clause | 49 | master | 6,641 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Vote do
it {should belong_to :voter}
it {should belong_to :question}
it {should belong_to :prompt}
it {should belong_to :choice}
it {should belong_to :loser_choice}
it {should have_one :appearance}
before(:each) do
@questi... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/appearance_spec.rb | Ruby | bsd-3-clause | 49 | master | 763 | require 'spec_helper'
describe Appearance do
before(:each) do
end
it {should belong_to :voter}
it {should belong_to :prompt}
it {should belong_to :question}
it {should belong_to :answerable}
it "should create a new instance given valid attributes" do
Appearance.create!(@valid_attributes)
end
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/skip_spec.rb | Ruby | bsd-3-clause | 49 | master | 360 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Skip do
it {should belong_to :prompt}
it {should belong_to :skipper}
it {should have_one :appearance}
before(:each) do
@valid_attributes = {
}
end
it "should create a new instance given valid attributes" do
Sk... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/prompt_spec.rb | Ruby | bsd-3-clause | 49 | master | 546 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Prompt do
it {should belong_to :question}
it {should belong_to :left_choice}
it {should belong_to :right_choice}
before(:each) do
@question = Factory.create(:aoi_question)
@prompt = @question.prompts.first
end
it "shou... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/flag_spec.rb | Ruby | bsd-3-clause | 49 | master | 569 | require 'spec_helper'
describe Flag do
it {should belong_to :question}
it {should belong_to :choice}
it {should belong_to :site}
it {should belong_to :visitor}
it {should validate_presence_of :choice_id}
it {should validate_presence_of :question_id}
before(:each) do
@valid_attributes = {
:expl... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/click_spec.rb | Ruby | bsd-3-clause | 49 | master | 423 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Click do
it {should belong_to :visitor}
it {should belong_to :site}
before(:each) do
@valid_attributes = {
:site_id => 1,
:visitor_id => 1,
:additional_info => "value for additional_info"
}
end
it "... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/user_spec.rb | Ruby | bsd-3-clause | 49 | master | 3,116 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe User do
it {should have_many :visitors}
before(:each) do
@aoi_clone = Factory.create(:user)
@question = Factory.create(:aoi_question)
@prompt = @question.prompts.first
end
it "should be able to create a question as ... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/models/choice_spec.rb | Ruby | bsd-3-clause | 49 | master | 5,382 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Choice do
it {should belong_to :question}
it {should belong_to :creator}
it {should have_many :flags}
it {should have_many :votes}
it {should have_many :prompts_on_the_left}
it {should have_many :prompts_on_the_right}
it {sh... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/integration/prompts_spec.rb | Ruby | bsd-3-clause | 49 | master | 6,220 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
# to do: figure out future-prompts
# clean up repeated code
describe "Prompts" do
include IntegrationSupport
describe "GET 'show'" do
before do
@question = Factory.create(:aoi_question, :site => @api_user)
@prompt = @ques... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/integration/visitors_spec.rb | Ruby | bsd-3-clause | 49 | master | 6,948 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Visitors" do
include IntegrationSupport
before do
@user = self.default_user = Factory(:email_confirmed_user)
@visitors = @user.visitors << Array.new(30){ Factory(:visitor, :site => @user) }
@questions = Array.new(3){ Factor... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/integration/choices_spec.rb | Ruby | bsd-3-clause | 49 | master | 5,017 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Choices" do
include IntegrationSupport
describe "POST 'create'" do
before(:each) do
@question = Factory.create(:aoi_question, :site => @api_user)
@visitor = Factory.create(:visitor, :site => @api_user)
end
desc... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | spec/integration/questions_spec.rb | Ruby | bsd-3-clause | 49 | master | 14,037 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "Questions" do
include IntegrationSupport
include DBSupport
before do
@user = self.default_user = Factory(:email_confirmed_user)
@choices = {}
@questions = Array.new(5){ Factory(:aoi_question, :site => @user) }.each do |q|
... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/schema.rb | Ruby | bsd-3-clause | 49 | master | 10,914 | # 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 source for your data... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/seeds.rb | Ruby | bsd-3-clause | 49 | master | 247 | # rake db:seed
# load the API user for AOI dev environment
u = User.new(:email => "pairwisetest@dkapadia.com", :password => "wheatthins")
u.save(false)
u = User.new(:email => "photocracytest@dkapadia.com", :password => "saltines")
u.save(false) |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091204144003_update_vote_count_for_questions.rb | Ruby | bsd-3-clause | 49 | master | 279 | class UpdateVoteCountForQuestions < ActiveRecord::Migration
def self.up
Question.reset_column_information
Question.find(:all).each do |q|
Question.update_counters q.id, :votes_count => q.choices.collect(&:votes_count).sum
end
end
def self.down
end
end |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20100521141751_create_flags.rb | Ruby | bsd-3-clause | 49 | master | 353 | class CreateFlags < ActiveRecord::Migration
def self.up
create_table :flags do |table|
table.string :explanation, :default => ""
table.integer :visitor_id
table.integer :choice_id
table.integer :question_id
table.integer :site_id
table.timestamps
end
end
def self.down... |
github | allourideas/pairwise-api | https://github.com/allourideas/pairwise-api | db/migrate/20091219063003_remove_extraneous_index.rb | Ruby | bsd-3-clause | 49 | master | 224 | class RemoveExtraneousIndex < ActiveRecord::Migration
def self.up
remove_index :prompts, [:left_choice_id, :right_choice_id]
end
def self.down
add_index :prompts, [:left_choice_id, :right_choice_id]
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.