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 | mirego/killswitch | https://github.com/mirego/killswitch | app/models/organization.rb | Ruby | bsd-3-clause | 48 | main | 392 | class Organization < ApplicationRecord
# Associations
has_many :applications, -> { ascendingly }, dependent: :destroy, inverse_of: :organization
# FriendlyId
extend FriendlyId
friendly_id :name, use: :slugged
# Validations
validates :name, presence: true
# Camaraderie
acts_as_organization
# Scop... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/models/concerns/keyable.rb | Ruby | bsd-3-clause | 48 | main | 290 | module Keyable
extend ActiveSupport::Concern
KEY_LENGTH = 32
included do
before_validation :generate_key, if: lambda { key.blank? }
validates :key, presence: true, length: { is: KEY_LENGTH * 2 }
end
def generate_key
self.key = SecureRandom.hex(KEY_LENGTH)
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/models/concerns/welcomeable.rb | Ruby | bsd-3-clause | 48 | main | 369 | module Welcomeable
extend ActiveSupport::Concern
included do
# Callbacks
after_commit :send_welcome_email!, on: :create, if: lambda { !skip_welcome_email && reset_password_token.blank? }
# Accessors
attr_accessor :skip_welcome_email
end
def send_welcome_email!
UserMailer.welcome_email(id,... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/tasks/sample_data.rake | Ruby | bsd-3-clause | 48 | main | 1,245 | namespace :sample_data do
task create: :environment do
Rails.logger = Logger.new(STDOUT)
# Example organization
example_organization = Organization.where(name: 'Example inc.', super_admin: true).first_or_create
# Admin user
email = ENV["KILLSWITCH_SAMPLE_DATA_EMAIL"] or raise "KILLSWITCH_SAMPLE_... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/utilities/boolean_environment_variable.rb | Ruby | bsd-3-clause | 48 | main | 252 | class BooleanEnvironmentVariable
def initialize(value)
@value = value
end
# rubocop:disable Naming/PredicateMethod
def as_bool
[nil, '', '0', 'false'].exclude?(@value.try(:downcase))
end
# rubocop:enable Naming/PredicateMethod
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/utilities/asset_host.rb | Ruby | bsd-3-clause | 48 | main | 325 | class AssetHost
def initialize(configuration)
@host = configuration.domain
@port = configuration.port
@protocol = configuration.protocol
options = { host: @host, scheme: @protocol }
options[:port] = @port if @port.present?
@uri = URI::Generic.build(options)
end
delegate :to_s, to: :@uri... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/helpers/html_helper.rb | Ruby | bsd-3-clause | 48 | main | 788 | module HtmlHelper
def logo(options = {})
render partial: 'shared/logo', locals: { options: }
end
def icon(name, label = nil)
content_tag(:i, '', class: "fa fa-#{name.to_s.tr('_', '-')}") + label.presence.try(:prepend, ' ')
end
def nav_active_item?(item)
' class="active"'.html_safe if item == co... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/helpers/error_helper.rb | Ruby | bsd-3-clause | 48 | main | 537 | module ErrorHelper
def render_error_messages(record)
return unless record.errors.any?
render partial: 'shared/error_messages', locals: { record: }
end
# Return an exception's bracktrace formatted into a nice
# plain list. It also wraps lines from the application
# directory in <span> elements.
def... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/helpers/devise_helper.rb | Ruby | bsd-3-clause | 48 | main | 216 | module DeviseHelper
# Overwrite Devise error messages helper
def devise_error_messages!
return unless resource.errors.any?
render partial: 'shared/error_messages', locals: { record: resource }
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/helpers/mailer_helper.rb | Ruby | bsd-3-clause | 48 | main | 550 | module MailerHelper
# Return the value of the `style` attribute for an element,
# based on default styles.
def inline_styles(to_merge = {})
defaults = {
# rubocop:disable Style/HashSyntax
:'font-family' => 'Helvetica, Arial, sans-serif',
:'font-weight' => 300,
:'font-size' => '14px',
... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/presenters/project_presenter.rb | Ruby | bsd-3-clause | 48 | main | 425 | class ProjectPresenter < Bourgeois::Presenter
def to_model
self
end
def curl_example(opts = {})
url_opts = opts.merge!(key:, version: '_VERSION_')
api_url = view.api_url(url_opts).gsub('_VERSION_', '$version')
%(echo -n 'Enter a version number: '; read version; curl -H "Accept-Language: #{I18n.l... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/presenters/behavior_presenter.rb | Ruby | bsd-3-clause | 48 | main | 1,629 | class BehaviorPresenter < Bourgeois::Presenter
# Structs
Dropdown = Struct.new(:id, :label)
def to_model
self
end
def self.version_operators
@_version_operators ||= Behavior::VERSION_OPERATORS.keys.map do |operator|
Dropdown.new(id: operator, label: version_operator_label(operator))
end
... |
github | mirego/killswitch | https://github.com/mirego/killswitch | app/presenters/membership_presenter.rb | Ruby | bsd-3-clause | 48 | main | 526 | class MembershipPresenter < Bourgeois::Presenter
# Structs
Dropdown = Struct.new(:id, :label)
def to_model
self
end
def self.membership_types
@_service_types ||= Camaraderie.membership_types.map do |type|
Dropdown.new(id: type, label: membership_type_label(type))
end
end
def human_mem... |
github | mirego/killswitch | https://github.com/mirego/killswitch | spec/spec_helper.rb | Ruby | bsd-3-clause | 48 | main | 1,087 | ENV['RAILS_ENV'] = 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Rails.root.glob('spec/support/**/*.rb').each { |f| require f }
# Checks for pending migration... |
github | mirego/killswitch | https://github.com/mirego/killswitch | spec/services/behavior_sorter_spec.rb | Ruby | bsd-3-clause | 48 | main | 594 | require 'spec_helper'
describe BehaviorSorter do
describe :reorder! do
let(:project) { create(:project) }
let(:behaviors) { create_list(:behavior, 10, project:) }
let(:sorter) { BehaviorSorter.new(project) }
before { sorter.reorder! order.map(&:to_s) }
context 'with reverse order' do
let(... |
github | mirego/killswitch | https://github.com/mirego/killswitch | spec/services/behavior_dispatcher_spec.rb | Ruby | bsd-3-clause | 48 | main | 7,641 | require 'spec_helper'
describe BehaviorDispatcher do
describe :InstanceMethods do
describe :dispatch! do
let(:request) { ActionDispatch::TestRequest.new('action_dispatch.request.parameters' => params) }
let(:dispatcher) { BehaviorDispatcher.new }
context 'with all required and valid parameters... |
github | mirego/killswitch | https://github.com/mirego/killswitch | spec/factories/behaviors.rb | Ruby | bsd-3-clause | 48 | main | 303 | FactoryBot.define do
factory :behavior do
# Attributes
version_number { "#{Random.rand(1..10)}.#{Random.rand(1..9)}.#{Random.rand(1..9)}" }
version_operator { Behavior::VERSION_OPERATORS.keys.sample }
language { nil }
data { '{"action":"ok"}' }
association :project
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | spec/models/behavior_spec.rb | Ruby | bsd-3-clause | 48 | main | 1,738 | require 'spec_helper'
describe Behavior do
describe :Factories do
subject { create(:behavior) }
it { should be_valid }
end
describe :InstanceMethods do
let(:behavior) { build(:behavior) }
describe :language= do
context 'when passed a non-blank value' do
before { behavior.language ... |
github | mirego/killswitch | https://github.com/mirego/killswitch | spec/requests/api/behaviors_requests_spec.rb | Ruby | bsd-3-clause | 48 | main | 1,057 | require 'spec_helper'
describe API::BehaviorsController, type: :request do
describe 'GET /killswitch' do
subject { response }
before { get '/killswitch', params: }
context 'with missing “version” parameter' do
let(:params) { {} }
it { expect(response.status).to eq 400 }
end
context ... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/routes.rb | Ruby | bsd-3-clause | 48 | main | 991 | Killswitch::Application.routes.draw do
root to: 'web/home#show'
devise_for :users, controllers: { sessions: 'web/sessions', passwords: 'web/passwords' }
get '/ping', to: ->(_env) do
response = { status: 'ok', version: Killswitch::Application::VERSION }
[200, { 'Content-Type' => 'application/json' }, [res... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/application.rb | Ruby | bsd-3-clause | 48 | main | 3,060 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
require File.expand_path('../../app/utilities/asset_host', __FILE__)
require File.expand_path('../../app/utilities/boolean_environment_variable', __FILE__)
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/puma.rb | Ruby | bsd-3-clause | 48 | main | 326 | # Port
port ENV.fetch('PORT', 3000)
# Environment
environment ENV.fetch('RACK_ENV')
# Workers count
workers ENV.fetch('PUMA_WORKERS', 0)
# Threads count per worker
min_threads = ENV.fetch('PUMA_MIN_THREADS', 0)
max_threads = ENV.fetch('PUMA_MAX_THREADS', 5)
threads min_threads, max_threads
# Preload the app
preload... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/content_security_policy.rb | Ruby | bsd-3-clause | 48 | main | 375 | # Be sure to restart your server when you modify this file.
Rails.application.configure do
config.content_security_policy do |policy|
policy.default_src :self, :https
policy.font_src :self, :https, :data
policy.img_src :self, :https, :data
policy.object_src :none
policy.script_src :self,... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/inflections.rb | Ruby | bsd-3-clause | 48 | main | 637 | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflec... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/camaraderie.rb | Ruby | bsd-3-clause | 48 | main | 273 | Camaraderie.configure do |config|
# The different types of memberships
config.membership_types = %w(admin)
# The class name of the organization model
config.organization_class = 'Organization'
# The class name of the user model
config.user_class = 'User'
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/assets.rb | Ruby | bsd-3-clause | 48 | main | 617 | # 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 = '1.0'
# Add additional assets to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Rails.applic... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/sentry.rb | Ruby | bsd-3-clause | 48 | main | 478 | if Rails.application.config_for(:settings)[:sentry_dsn].present?
Sentry.init do |config|
config.dsn = Rails.application.config_for(:settings)[:sentry_dsn]
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
config.excluded_exceptions += %w(
ActionController::RoutingError
Active... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/devise.rb | Ruby | bsd-3-clause | 48 | main | 12,961 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The controller used as parent for SessionsController and
# PasswordsController
config.parent_controller = 'Web::ApplicationController'
# The... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/friendly_id.rb | Ruby | bsd-3-clause | 48 | main | 3,131 | # FriendlyId Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `friendly_id` class method or defining
# methods in your model.
#
# To learn more, check out... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/initializers/devise_security.rb | Ruby | bsd-3-clause | 48 | main | 1,873 | # frozen_string_literal: true
Devise.setup do |config|
# ==> Security Extension
# Configure security extension for devise
# Should the password expire (e.g 3.months)
# config.expire_password_after = false
# Need 1 char each of: A-Z, a-z, 0-9, and a punctuation mark or symbol
# You may use "digits" in pla... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/environments/production.rb | Ruby | bsd-3-clause | 48 | main | 3,432 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better performance and memory savings (ignor... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/environments/test.rb | Ruby | bsd-3-clause | 48 | main | 2,412 | # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings... |
github | mirego/killswitch | https://github.com/mirego/killswitch | config/environments/development.rb | Ruby | bsd-3-clause | 48 | main | 2,924 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager load code on boot.
config.eager... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/schema.rb | Ruby | bsd-3-clause | 48 | main | 5,278 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20150610135602_add_organization_cache_counters.rb | Ruby | bsd-3-clause | 48 | main | 234 | class AddOrganizationCacheCounters < ActiveRecord::Migration[4.2]
def change
add_column :organizations, :memberships_count, :integer, default: 0
add_column :organizations, :applications_count, :integer, default: 0
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131230183006_add_camaraderie.rb | Ruby | bsd-3-clause | 48 | main | 833 | class AddCamaraderie < ActiveRecord::Migration[4.2]
def up
create_table :memberships do |t|
t.references :user
t.references :organization
t.string :membership_type
t.timestamps
end
add_index "memberships", ["organization_id", "membership_type"], name: "index_memberships_on_organi... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131112140005_create_behaviors.rb | Ruby | bsd-3-clause | 48 | main | 283 | class CreateBehaviors < ActiveRecord::Migration[4.2]
def change
create_table :behaviors do |t|
t.references :project
t.string :version
t.string :version_operator
t.string :language
t.json :data, default: '{}'
t.timestamps
end
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131224184148_remove_a_lot_of_indexes.rb | Ruby | bsd-3-clause | 48 | main | 1,261 | class RemoveALotOfIndexes < ActiveRecord::Migration[4.2]
def up
remove_index "applications", ["slug", "deleted_at"]
remove_index "behaviors", ["id", "deleted_at"]
remove_index "projects", ["application_id"]
remove_index "projects", ["key"]
remove_index "projects", ["slug", "deleted_at"]
remove... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20260423112300_add_lockable_to_users.rb | Ruby | bsd-3-clause | 48 | main | 295 | class AddLockableToUsers < ActiveRecord::Migration[8.0]
def change
add_column :users, :failed_attempts, :integer, default: 0, null: false
add_column :users, :unlock_token, :string
add_column :users, :locked_at, :datetime
add_index :users, :unlock_token, unique: true
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131231152100_add_recoverable_fields_to_users.rb | Ruby | bsd-3-clause | 48 | main | 205 | class AddRecoverableFieldsToUsers < ActiveRecord::Migration[4.2]
def change
change_table :users do |t|
t.string :reset_password_token
t.datetime :reset_password_sent_at
end
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131119114353_devise_create_users.rb | Ruby | bsd-3-clause | 48 | main | 655 | class DeviseCreateUsers < ActiveRecord::Migration[4.2]
def change
create_table(:users) do |t|
t.string :name
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Rememberable
t.datetime :r... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131224184526_create_organizations.rb | Ruby | bsd-3-clause | 48 | main | 397 | class CreateOrganizations < ActiveRecord::Migration[4.2]
def change
create_table :organizations do |t|
t.string :name
t.string :slug
t.timestamps
end
Organization.create(name: 'Mirego')
add_column :applications, :organization_id, :integer
Application.all.each do |application|... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131120155642_add_deleted_at_to_models.rb | Ruby | bsd-3-clause | 48 | main | 654 | class AddDeletedAtToModels < ActiveRecord::Migration[4.2]
def change
add_column :applications, :deleted_at, :datetime
add_index :applications, [:slug, :deleted_at], name: "index_applications_on_slug_and_deleted_at"
add_column :projects, :deleted_at, :datetime
add_index :projects, [:slug, :deleted_at]... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20131112125627_add_slugs_to_applications_and_projects.rb | Ruby | bsd-3-clause | 48 | main | 261 | class AddSlugsToApplicationsAndProjects < ActiveRecord::Migration[4.2]
def change
add_column :applications, :slug, :string
add_column :projects, :slug, :string
add_index :applications, :slug, unique: true
add_index :projects, :slug
end
end |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20140219181729_create_versions.rb | Ruby | bsd-3-clause | 48 | main | 479 | class CreateVersions < ActiveRecord::Migration[4.2]
def self.up
create_table :versions do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit
t.text :object
t.datetime :created_at
en... |
github | mirego/killswitch | https://github.com/mirego/killswitch | db/migrate/20250314190743_add_old_passwords_table.rb | Ruby | bsd-3-clause | 48 | main | 431 | class AddOldPasswordsTable < ActiveRecord::Migration[6.1]
def change
create_table :old_passwords do |t|
t.string :encrypted_password, null: false
t.string :password_archivable_type, null: false
t.integer :password_archivable_id, null: false
t.datetime :created_at
end
add_index :ol... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | active_loaders.gemspec | Ruby | mit | 48 | master | 1,311 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'active_loaders/version'
Gem::Specification.new do |spec|
spec.name = "active_loaders"
spec.version = ActiveLoaders::VERSION
spec.authors = ["Jan Berdajs"]
spec.email ... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | spec/sequel_serializer_spec.rb | Ruby | mit | 48 | master | 1,994 | require 'spec_helper'
module SequelSerializerSpec
describe "Serializer (Sequel)", :sequel do
class Comment < Sequel::Model
many_to_one :post
end
class Post < Sequel::Model
many_to_one :blog
one_to_many :comments
datasource_module do
query :author_name do
"posts... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | spec/test_methods_spec.rb | Ruby | mit | 48 | master | 1,585 | require 'spec_helper'
module TestMethodsSpec
describe "Test Methods" do
include ActiveLoaders::Test
class Post < ActiveRecord::Base
belongs_to :blog
end
class Blog < ActiveRecord::Base
has_many :posts
end
class PostSerializer < ActiveModel::Serializer
attributes :id, :titl... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | spec/skip_select_spec.rb | Ruby | mit | 48 | master | 2,420 | require 'spec_helper'
module SkipSelectSpec
describe "skip_select", :activerecord do
class Comment < ActiveRecord::Base
belongs_to :post
end
class Post < ActiveRecord::Base
belongs_to :blog
has_many :comments
datasource_module do
query :author_name do
"posts.au... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | spec/serializer_spec.rb | Ruby | mit | 48 | master | 1,776 | require 'spec_helper'
module SerializerSpec
describe "Serializer", :activerecord do
class Comment < ActiveRecord::Base
belongs_to :post
end
class Post < ActiveRecord::Base
belongs_to :blog
has_many :comments
datasource_module do
query :author_name do
"posts.aut... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | spec/spec_helper.rb | Ruby | mit | 48 | master | 919 | ENV["RAILS_ENV"] ||= 'test'
require 'rspec/core'
require 'rspec/expectations'
require 'rspec/mocks'
require 'database_cleaner'
require 'pry'
require 'active_support/all'
require 'active_record'
require 'sequel'
require 'datasource'
require 'active_loaders'
require 'active_loaders/test'
require 'active_model_serializer... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | spec/sequel_skip_select_spec.rb | Ruby | mit | 48 | master | 2,637 | require 'spec_helper'
module SequelSkipSelectSpec
describe "skip_select (Sequel)", :sequel do
class Comment < Sequel::Model
many_to_one :post
end
class Post < Sequel::Model
many_to_one :blog
one_to_many :comments
datasource_module do
query :author_name do
"post... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | spec/support/db.rb | Ruby | mit | 48 | master | 1,398 | db_path = File.expand_path("../../db.sqlite3")
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: db_path)
Sequel::Model.db = Sequel.sqlite(db_path)
Sequel::Model.plugin :active_model
ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define(:version => 0) do
create_table :blogs, :force ... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | lib/active_loaders/test.rb | Ruby | mit | 48 | master | 4,237 | require 'set'
module ActiveLoaders
module Test
Error = Class.new(StandardError)
def test_serializer_queries(serializer_klass, model_klass, ignore_columns: [], skip_columns_check: false, allow_queries_per_record: 0)
records = get_all_records(model_klass, serializer_klass)
fail "Not enough records ... |
github | kundi/active_loaders | https://github.com/kundi/active_loaders | lib/active_loaders/datasource_adapter.rb | Ruby | mit | 48 | master | 6,717 | require "active_model/serializer"
require "datasource"
module ActiveLoaders
module Adapters
module ActiveModelSerializers
module ArraySerializer
def initialize_with_loaders(objects, options = {})
datasource_class = options.delete(:datasource)
adapter = Datasource.orm_adapters.fi... |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | Rakefile | Ruby | mit | 48 | master | 564 | require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the forgot_password plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the forgot_passwor... |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | generators/forgot_password/forgot_password_generator.rb | Ruby | mit | 48 | master | 6,053 | require File.expand_path(File.dirname(__FILE__) + "/lib/insert_routes.rb")
class ForgotPasswordGenerator < Rails::Generator::NamedBase
attr_reader :controller_name,
:controller_class_path,
:controller_file_path,
:controller_class_nesting,
... |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | generators/forgot_password/lib/insert_routes.rb | Ruby | mit | 48 | master | 1,997 | Rails::Generator::Commands::Create.class_eval do
def route_resource(*resources)
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
sentinel = 'ActionController::Routing::Routes.draw do |map|'
logger.route "map.resource #{resource_list}"
unless options[:pretend]
gsub_file 'config/... |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | generators/forgot_password/templates/model.rb | Ruby | mit | 48 | master | 688 | require 'digest/sha1'
class <%= class_name %> < ActiveRecord::Base
belongs_to :<%= user_model_name %>
attr_accessor :email
validates_presence_of :email
validates_format_of :email, :unless => Proc.new{|p|p.email.blank?}, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => 'is not a valid email add... |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | generators/forgot_password/templates/mailer.rb | Ruby | mit | 48 | master | 708 | class <%= class_name %>Mailer < ActionMailer::Base
def forgot_password(password)
setup_email(password.<%= user_model_name %>)
@subject += 'You have requested to change your password'
@body[:url] = "http://YOURSITE/change_password/#{password.reset_code}"
end
def reset_password(<%= user_model_na... |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | generators/forgot_password/templates/migration.rb | Ruby | mit | 48 | master | 312 | class <%= migration_name %> < ActiveRecord::Migration
def self.up
create_table "<%= table_name %>" do |t|
t.integer :<%= user_model_name %>_id
t.string :reset_code
t.datetime :expiration_date
t.timestamps
end
end
def self.down
drop_table "<%= table_name %>"
end
end |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | generators/forgot_password/templates/controller.rb | Ruby | mit | 48 | master | 2,565 | class <%= controller_class_name %>Controller < ApplicationController
def new
@<%= file_name %> = <%= class_name %>.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @<%= file_name %> }
end
end
def create
@<%= file_name %> = <%= class_name %>.new(... |
github | greenisus/forgot_password | https://github.com/greenisus/forgot_password | lib/forgot_password/rails_commands.rb | Ruby | mit | 48 | master | 989 | Rails::Generator::Commands::Create.class_eval do
def route_resource(*resources)
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
sentinel = 'ActionController::Routing::Routes.draw do |map|'
logger.route "map.resource #{resource_list}"
unless options[:pretend]
gsub_file 'config/... |
github | pedrofurtado/qrcode_pix_ruby | https://github.com/pedrofurtado/qrcode_pix_ruby | qrcode_pix_ruby.gemspec | Ruby | mit | 48 | master | 1,568 | # frozen_string_literal: true
require_relative 'lib/qrcode_pix_ruby/version'
Gem::Specification.new do |spec|
spec.name = 'qrcode_pix_ruby'
spec.version = QrcodePixRuby::VERSION
spec.authors = ['Pedro Furtado', 'Marcio de Jesus', 'William Radi', 'Le... |
github | pedrofurtado/qrcode_pix_ruby | https://github.com/pedrofurtado/qrcode_pix_ruby | Rakefile | Ruby | mit | 48 | master | 204 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RuboCop::RakeTask.new
RSpec::Core::RakeTask.new(:spec)
task default: %i[rubocop spec] |
github | pedrofurtado/qrcode_pix_ruby | https://github.com/pedrofurtado/qrcode_pix_ruby | demo/config.ru | Ruby | mit | 48 | master | 7,745 | # frozen_string_literal: true
require 'qrcode_pix_ruby'
def generate_html_with(env)
qrcode_data = Rack::Request.new(env).params
payload = ''
data_uri = ''
pix = QrcodePixRuby::Payload.new
unless qrcode_data.empty?
qrcode_data.keys.each do |key|
v = qrcode_data[key]
pix.public... |
github | pedrofurtado/qrcode_pix_ruby | https://github.com/pedrofurtado/qrcode_pix_ruby | lib/qrcode_pix_ruby/payload.rb | Ruby | mit | 48 | master | 4,174 | # frozen_string_literal: true
require 'rqrcode'
module QrcodePixRuby
class PayloadArgumentError < ArgumentError; end
class Payload
ID_PAYLOAD_FORMAT_INDICATOR = '00'
ID_POINT_OF_INITIATION_METHOD = '01'
ID_MERCHANT_ACCOUNT_INFORMATION = '26'
ID_MERCHANT_A... |
github | pedrofurtado/qrcode_pix_ruby | https://github.com/pedrofurtado/qrcode_pix_ruby | spec/spec_helper.rb | Ruby | mit | 48 | master | 454 | # frozen_string_literal: true
if ENV['CODECOV_TOKEN']
require 'simplecov'
SimpleCov.start
require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov
end
require 'qrcode_pix_ruby'
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
RSpec.configure do |config|
config.example_status_persiste... |
github | pedrofurtado/qrcode_pix_ruby | https://github.com/pedrofurtado/qrcode_pix_ruby | spec/qrcode_pix_ruby_spec.rb | Ruby | mit | 48 | master | 9,627 | # frozen_string_literal: true
RSpec.describe QrcodePixRuby do
let(:attributes) { {} }
let(:payload) { subject.payload }
let(:base64) { subject.base64 }
describe 'Attributes validation' do
subject { QrcodePixRuby::Payload.new(**attributes) }
let(:error) { QrcodePixRuby::PayloadArgumentError }
co... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | Gemfile | Ruby | mit | 48 | master | 313 | source 'https://rubygems.org'
gemspec
group :development do
gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant.git', tag: 'v1.8.4'
end
group :plugins do
gem 'vagrant-bhyve', path: '.'
#gem 'vagrant-sshfs', '1.1.0'
#gem 'vagrant-mutate', :git => 'https://github.com/swills/vagrant-mutate'
end |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | vagrant-bhyve.gemspec | Ruby | mit | 48 | master | 939 | # coding: utf-8
require File.expand_path('../lib/vagrant-bhyve/version', __FILE__)
Gem::Specification.new do |spec|
spec.name = "vagrant-bhyve"
spec.version = VagrantPlugins::ProviderBhyve::VERSION
spec.authors = ["Tong Li"]
spec.email = ["jesa7955@gmail.com"]
spec.summary ... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | spec/vagrant-bhyve/bhyve_spec.rb | Ruby | mit | 48 | master | 210 | require 'spec_helper'
describe Vagrant::Bhyve do
it 'has a version number' do
expect(Vagrant::Bhyve::VERSION).not_to be nil
end
it 'does something useful' do
expect(false).to eq(true)
end
end |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve.rb | Ruby | mit | 48 | master | 577 | require "pathname"
module VagrantPlugins
module ProviderBhyve
lib_path = Pathname.new(File.expand_path("../vagrant-bhyve", __FILE__))
autoload :Action, lib_path.join('action')
autoload :Executor, lib_path.join('executor')
autoload :Driver, lib_path.join('driver')
autoload :Errors, lib_path.join('... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action.rb | Ruby | mit | 48 | master | 5,534 | require "pathname"
require "vagrant/action/builder"
module VagrantPlugins
module ProviderBhyve
module Action
include Vagrant::Action::Builtin
action_root = Pathname.new(File.expand_path('../action', __FILE__))
autoload :Boot, action_root.join('boot')
autoload :CreateBridge, action_root.j... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/provider.rb | Ruby | mit | 48 | master | 4,209 | require "vagrant"
require "log4r"
module VagrantPlugins
module ProviderBhyve
autoload :Driver, 'vagrant-bhyve/driver'
class Provider < Vagrant.plugin('2', :provider)
def initialize(machine)
@logger = Log4r::Logger.new("vagrant::provider::bhyve")
@machine = machine
end
def driver
retur... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/driver.rb | Ruby | mit | 48 | master | 23,609 | require "log4r"
require "fileutils"
require "digest/md5"
require "io/console"
require "ruby_expect"
module VagrantPlugins
module ProviderBhyve
class Driver
# This executor is responsible for actually executing commands, including
# bhyve, dnsmasq and other shell utils used to get VM's state
... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/config.rb | Ruby | mit | 48 | master | 1,689 | require "vagrant"
module VagrantPlugins
module ProviderBhyve
class Config < Vagrant.plugin('2', :config)
# Guest like CentOS-6 requires a customized grub config file
#attr_accessor :grub_config_file
# Some arguments required by grub-bhyve
#attr_accessor :grub_run_partition
#... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/plugin.rb | Ruby | mit | 48 | master | 2,165 | begin
require "vagrant"
rescue LoadError
raise "The Vagrant Bhyve plugin must be run within Vagrant."
end
#############################################################
# TBD some version check #
#############################################################
module VagrantPlugins
module ProviderBhyve
cl... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/executor.rb | Ruby | mit | 48 | master | 997 | require "vagrant/util/busy"
require "vagrant/util/subprocess"
module VagrantPlugins
module ProviderBhyve
module Executor
# This class is used to execute commands as subprocess.
class Exec
# When we need the command's exit code we should set parameter
# exit_code to true, otherwise this method will... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/errors.rb | Ruby | mit | 48 | master | 1,245 | require "vagrant"
module VagrantPlugins
module ProviderBhyve
module Errors
class VagrantBhyveError < Vagrant::Errors::VagrantError
error_namespace('vagrant_bhyve.errors')
end
class SystemVersionIsTooLow < VagrantBhyveError
error_key(:system_version_too_low)
end
class MissingPopc... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/wait_until_up.rb | Ruby | mit | 48 | master | 1,142 | require "log4r"
require "vagrant/util/retryable"
module VagrantPlugins
module ProviderBhyve
module Action
class WaitUntilUP
include Vagrant::Util::Retryable
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::wait_until_up")
@app = app
end
def call(env)
@driver = env... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/shutdown.rb | Ruby | mit | 48 | master | 458 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class Shutdown
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::shutdown")
@app = app
end
def call(env)
@machine = env[:machine]
@ui = env[:ui]
@driver = @machine.provider.driver
@... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/prepare_nfs_valid_ids.rb | Ruby | mit | 48 | master | 392 | require "log4r"
require "securerandom"
require "digest/md5"
module VagrantPlugins
module ProviderBhyve
module Action
class PrepareNFSValidIds
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::prepare_nfs_valid_ids")
@app = app
end
def call(env)
env[:nfs_valid_ids] =... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/create_bridge.rb | Ruby | mit | 48 | master | 753 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class CreateBridge
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::create_bridge")
@app = app
end
def call(env)
@machine = env[:machine]
@ui = env[:ui]
@driver = @machine.provider.dri... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/create_tap.rb | Ruby | mit | 48 | master | 676 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class CreateTap
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::create_tap")
@app = app
end
def call(env)
@machine = env[:machine]
@driver = @machine.provider.driver
env[:ui].detail I1... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/setup.rb | Ruby | mit | 48 | master | 552 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class Setup
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::setup")
@app = app
end
def call(env)
@driver = env[:machine].provider.driver
env[:ui].info I18n.t('vagrant_bhyve.action.vm.setup... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/prepare_nfs_settings.rb | Ruby | mit | 48 | master | 1,016 | require "log4r"
require "securerandom"
require "digest/md5"
module VagrantPlugins
module ProviderBhyve
module Action
class PrepareNFSSettings
include Vagrant::Action::Builtin::MixinSyncedFolders
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::prepare_nfs_settings")
@ap... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/boot.rb | Ruby | mit | 48 | master | 451 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class Boot
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::boot")
@app = app
end
def call(env)
@machine = env[:machine]
@driver = @machine.provider.driver
env[:ui].detail I18n.... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/load.rb | Ruby | mit | 48 | master | 521 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class Load
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::load")
@app = app
end
def call(env)
@machine = env[:machine]
@driver = @machine.provider.driver
firmware = @driver.get_attr('... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/forward_ports.rb | Ruby | mit | 48 | master | 1,250 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class ForwardPorts
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::forward_ports")
@app = app
end
def call(env)
@machine = env[:machine]
@driver = @machine.provi... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/cleanup.rb | Ruby | mit | 48 | master | 389 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class Cleanup
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::cleanup")
@app = app
end
def call(env)
env[:ui].info I18n.t('vagrant_bhyve.action.vm.halt.cleaning_up')
env[:machine].provider... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/destroy.rb | Ruby | mit | 48 | master | 383 | require "log4r"
module VagrantPlugins
module ProviderBhyve
module Action
class Destroy
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::destroy")
@app = app
end
def call(env)
env[:ui].info I18n.t('vagrant_bhyve.action.vm.destroying')
env[:machine].provider.drive... |
github | jesa7955/vagrant-bhyve | https://github.com/jesa7955/vagrant-bhyve | lib/vagrant-bhyve/action/import.rb | Ruby | mit | 48 | master | 697 | require "log4r"
require "securerandom"
require "digest/md5"
module VagrantPlugins
module ProviderBhyve
module Action
class Import
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_bhyve::action::import")
@app = app
end
def call(env)
@machine = env[:machine]
@driver = @machine.... |
github | arthurnn/cheatly | https://github.com/arthurnn/cheatly | Rakefile | Ruby | mit | 48 | master | 234 | #!/usr/bin/env rake
require "bundler/gem_tasks"
require "rake/testtask"
desc 'Run tests'
Rake::TestTask.new do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
task :default => :test |
github | arthurnn/cheatly | https://github.com/arthurnn/cheatly | cheatly.gemspec | Ruby | mit | 48 | master | 1,124 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'cheatly/version'
Gem::Specification.new do |spec|
spec.name = "cheatly"
spec.version = Cheatly::VERSION
spec.authors = ["Arthur Neves"]
spec.email = ["arthurn... |
github | arthurnn/cheatly | https://github.com/arthurnn/cheatly | test/sheet_test.rb | Ruby | mit | 48 | master | 1,017 | require 'test_helper'
class SheetTest < MiniTest::Test
def test_sheet_list
sheets = Cheatly::Sheet.all
assert sheets.is_a?(Array)
assert sheets.any?
end
def test_sheet_find
assert Cheatly::Sheet.find("bash")
assert Cheatly::LocalSheet.find("bash")
end
def test_sheet_not_found
assert... |
github | arthurnn/cheatly | https://github.com/arthurnn/cheatly | test/cli_test.rb | Ruby | mit | 48 | master | 909 | require 'test_helper'
class CliTest < MiniTest::Test
def test_list
begin
cli = Cheatly::CLI.new([], nopaginate: true, test: true)
cli.list
rescue Exception => e
raise "#{e.message}"
end
begin
cli = Cheatly::CLI.new([], local: true, nopaginate: true, test: true)
cli.lis... |
github | arthurnn/cheatly | https://github.com/arthurnn/cheatly | lib/cheatly/sheet.rb | Ruby | mit | 48 | master | 1,056 | module Cheatly
class Sheet
attr_accessor :title, :body, :persisted
def initialize(title, body = nil, options = {})
@title, @body = title, body
@persisted = options[:persisted] || false
end
def to_s
body.to_s
end
def create
adapter.create(title, body)
@persisted... |
github | arthurnn/cheatly | https://github.com/arthurnn/cheatly | lib/cheatly/cli.rb | Ruby | mit | 48 | master | 2,607 | require "pager"
require "optparse"
require "redcarpet"
require "thor"
require "cheatly/version"
require "cheatly/sheet"
require "cheatly/adapter/file"
require "cheatly/adapter/github"
require "cheatly/renderer"
module Cheatly
class CLI < Thor
include Pager
class_option :local, type: :boolean, aliases: "-l"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.