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 | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20200410205940_create_pay_subscriptions.pay.rb | Ruby | mit | 231 | master | 539 | # frozen_string_literal: true
# This migration comes from pay (originally 20170205020145)
class CreatePaySubscriptions < ActiveRecord::Migration[4.2]
def change
create_table :pay_subscriptions do |t|
t.references :owner
t.string :name, null: false
t.string :processor, null: false
t.string... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20160925200618_add_role_to_users.rb | Ruby | mit | 231 | master | 249 | # frozen_string_literal: true
class AddRoleToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :trialing, :boolean, null: false, default: true
add_column :users, :past_due, :boolean, null: false, default: false
end
end |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20160918210017_create_invoices.rb | Ruby | mit | 231 | master | 400 | # frozen_string_literal: true
class CreateInvoices < ActiveRecord::Migration[5.2]
def change
create_table :invoices do |t|
t.integer :user_id
t.string :stripe_id
t.integer :amount
t.string :currency
t.string :number
t.datetime :paid_at
t.text :lines
t.timestamps n... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20200410205943_add_status_to_pay_subscriptions.pay.rb | Ruby | mit | 231 | master | 539 | # frozen_string_literal: true
# This migration comes from pay (originally 20190816015720)
class AddStatusToPaySubscriptions < ActiveRecord::Migration[4.2]
def self.up
add_column :pay_subscriptions, :status, :string
# Any existing subscriptions should be marked as 'active'
# This won't actually make them... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20200618220501_add_owner_type_to_pay.rb | Ruby | mit | 231 | master | 378 | # frozen_string_literal: true
class AddOwnerTypeToPay < ActiveRecord::Migration[6.0]
def change
# add_column :pay_charges, :owner_type, :string
add_column :pay_subscriptions, :owner_type, :string
# Backfill owner_type column to match your Billable model
Pay::Charge.update_all owner_type: "User"
... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20171209213316_create_active_storage_tables.active_storage.rb | Ruby | mit | 231 | master | 939 | # frozen_string_literal: true
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
def change
create_table :active_storage_blobs do |t|
t.string :key, null: false
t.string :filename, null: false
t.stri... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20200410210020_add_pay_to_users.rb | Ruby | mit | 231 | master | 712 | # frozen_string_literal: true
class AddPayToUsers < ActiveRecord::Migration[6.0]
def change
# Remove old payment columns on User
remove_column :users, :stripe_id
remove_column :users, :stripe_subscription_id
remove_column :users, :trialing
remove_column :users, :past_due
remove_column :users,... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20200618161145_create_plans_again.rb | Ruby | mit | 231 | master | 482 | # frozen_string_literal: true
class CreatePlansAgain < ActiveRecord::Migration[6.0]
def change
remove_column :products, :amount, :integer
create_table :plans do |t|
t.belongs_to :product
t.string :name, null: false
t.integer :amount, null: false
t.string :currency, null: false, defau... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20180123041906_add_current_period_end_to_users.rb | Ruby | mit | 231 | master | 214 | # frozen_string_literal: true
class AddCurrentPeriodEndToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :current_period_end, :datetime
add_index :users, :current_period_end
end
end |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20160918210014_devise_create_users.rb | Ruby | mit | 231 | master | 1,534 | # frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: false
# Names are good
t.string :first_name, null: false
t.string :last_name, ... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20200701012054_add_confirmable_to_devise.rb | Ruby | mit | 231 | master | 1,008 | # frozen_string_literal: true
class AddConfirmableToDevise < ActiveRecord::Migration[6.0]
# Note: You can't use change, as User.update_all will fail in the down migration
def up
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20160918210016_add_stripe_data_to_users.rb | Ruby | mit | 231 | master | 395 | # frozen_string_literal: true
class AddStripeDataToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :stripe_id, :string
add_column :users, :stripe_subscription_id, :string
add_column :users, :card_last4, :string
add_column :users, :card_exp_month, :integer
add_column :users, :ca... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20200410205942_create_pay_charges.pay.rb | Ruby | mit | 231 | master | 543 | # frozen_string_literal: true
# This migration comes from pay (originally 20170727235816)
class CreatePayCharges < ActiveRecord::Migration[4.2]
def change
create_table :pay_charges do |t|
t.references :owner, polymorphic: true
t.string :processor, null: false
t.string :processor_id, null: false... |
github | archonic/limestone | https://github.com/archonic/limestone | db/migrate/20180127230250_create_products.rb | Ruby | mit | 231 | master | 245 | # frozen_string_literal: true
class CreateProducts < ActiveRecord::Migration[5.2]
def change
create_table :products do |t|
t.string :name, null: false
t.integer :amount, null: false
t.string :stripe_id
end
end
end |
github | archonic/limestone | https://github.com/archonic/limestone | spec/spec_helper.rb | Ruby | mit | 231 | master | 4,801 | # frozen_string_literal: true
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, withou... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/rails_helper.rb | Ruby | mit | 231 | master | 2,974 | # frozen_string_literal: true
ENV["RAILS_ENV"] = "test"
require "simplecov"
SimpleCov.start "rails"
require "spec_helper"
require File.expand_path("../config/environment", __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/models/product_spec.rb | Ruby | mit | 231 | master | 292 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Product, type: :model do
describe "factory" do
it "has a valid factory" do
expect(build(:product)).to be_valid
end
end
describe "validations" do
it { should validate_presence_of(:name) }
end
end |
github | archonic/limestone | https://github.com/archonic/limestone | spec/models/plan_spec.rb | Ruby | mit | 231 | master | 610 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Plan, type: :model do
describe "factory" do
let(:product) { create(:product) }
it "has a valid factory" do
expect(build(:plan, product: product)).to be_valid
end
end
describe "validations" do
it { should belong_to(:produc... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/models/user_spec.rb | Ruby | mit | 231 | master | 977 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe User, type: :model do
it "has a valid factory" do
expect(create(:user)).to be_valid
end
# Validations
it { should validate_presence_of(:first_name) }
it { should validate_presence_of(:last_name) }
it { should validate_presence_of(:em... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/requests/pages_spec.rb | Ruby | mit | 231 | master | 1,397 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe PagesController, type: :request do
describe "pricing" do
subject do
get pricing_path
response
end
it "renders" do
expect(subject).to have_http_status(:success)
end
end
describe "about" do
subject do
... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/requests/subscriptions_spec.rb | Ruby | mit | 231 | master | 4,155 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe SubscriptionsController, type: :request do
let(:product) { create(:product) }
let(:plan) { create(:plan, product: product) }
let(:plan_annual) { create(:plan, :basic_annual, product: product) }
let(:product_pro) { create(:product, :pro) }
... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/requests/avatar_spec.rb | Ruby | mit | 231 | master | 1,243 | # frozen_string_literal: true
require "rails_helper"
require "sidekiq/testing"
RSpec.describe AvatarsController, type: :request do
include ActionDispatch::TestProcess::FixtureFile
let(:user) { create(:user) }
let(:file) { fixture_file_upload("money_sloth.png", "image/png") }
describe "#update" do
subjec... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/requests/admin/dashboard_spec.rb | Ruby | mit | 231 | master | 1,264 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe "Administrate Dashboards", type: :request do
let(:admin) { create(:user, :admin) }
let(:user) { create(:user) }
context "as admin" do
before { sign_in admin }
describe UserDashboard do
subject do
get admin_users_path
... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/requests/users/users_registrations_spec.rb | Ruby | mit | 231 | master | 3,545 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Users::RegistrationsController, type: :request do
before do
# Allow public registration before testing it
Flipper.enable :public_registration
end
describe "POST /profile" do
let(:plan) { create(:plan) }
context "with valid par... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/support/request_spec_helper.rb | Ruby | mit | 231 | master | 461 | # frozen_string_literal: true
module RequestSpecHelper
include Warden::Test::Helpers
def self.included(base)
base.before(:each) { Warden.test_mode! }
base.after(:each) { Warden.test_reset! }
end
def sign_in(resource)
login_as(resource, scope: warden_scope(resource))
end
def sign_out(resource... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/support/database_cleaner.rb | Ruby | mit | 231 | master | 420 | # frozen_string_literal: true
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:eac... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/helpers/icon_spec.rb | Ruby | mit | 231 | master | 647 | # frozen_string_literal: true
require "rails_helper"
describe IconHelper do
let(:user) { create(:user, :avatared) }
describe "avatar" do
it "returns avatar" do
expect(avatar(user)).to match "circular-icon sm avatar-img"
expect(avatar(user)).to match "money_sloth.png"
end
it "has text bac... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/factories/products.rb | Ruby | mit | 231 | master | 317 | # frozen_string_literal: true
FactoryBot.define do
factory :product do
name { "Basic" }
stripe_id { STRIPE_TEST_PRODUCT_BASIC_ID }
initialize_with { Product.where(name: name).first_or_initialize }
trait :pro do
name { "Pro" }
stripe_id { STRIPE_TEST_PRODUCT_PRO_ID }
end
end
end |
github | archonic/limestone | https://github.com/archonic/limestone | spec/factories/plans.rb | Ruby | mit | 231 | master | 873 | # frozen_string_literal: true
FactoryBot.define do
factory :plan do
name { "Basic Monthly" }
amount { 900 }
interval { "month" }
currency { "USD" }
stripe_id { STRIPE_TEST_PLAN_BASIC_MONTH_ID }
initialize_with { Plan.where(name: name).first_or_initialize }
association :product
trait ... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/factories/subscriptions.rb | Ruby | mit | 231 | master | 1,670 | # frozen_string_literal: true
FactoryBot.define do
factory :subscription, class: Pay::Subscription do
association :owner, factory: :user
name { "[test] Basic" }
processor { "stripe" }
# See subscriptions_spec.rb for example of how to create a valid subscription ID
processor_id { "sub_xxx" }
p... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/factories/users.rb | Ruby | mit | 231 | master | 1,695 | # frozen_string_literal: true
FactoryBot.define do
factory :user do
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
email { Faker::Internet.email }
password { "password" }
password_confirmation { "password" }
confirmed_at { 5.minutes.ago }
trial_ends_at { 1.hour... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/mailers/user_mailer_spec.rb | Ruby | mit | 231 | master | 1,092 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe UserMailer, type: :mailer do
let(:user) { create(:user) }
describe "welcome_email" do
let(:mail) { UserMailer.welcome_email(user) }
it "renders" do
expect(mail.body).to match "Welcome"
end
end
describe "billing_updated" do... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/services/create_admin_service_spec.rb | Ruby | mit | 231 | master | 347 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe CreateAdminService, type: :service do
describe "#call" do
before { create(:plan) }
it "creates the admin" do
expect(User.count).to eq 0
CreateAdminService.call
expect(User.count).to eq 1
expect(User.first.admin?).to... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/services/stripe_plan_service_spec.rb | Ruby | mit | 231 | master | 660 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe StripePlanService, type: :service do
let(:product) { create(:product) }
let(:plan) { create(:plan, product: product) }
describe "#create" do
context "with existing stripe_id" do
it "avoids contacting Stripe" do
expect(Stripe:... |
github | archonic/limestone | https://github.com/archonic/limestone | spec/services/stripe_product_service_spec.rb | Ruby | mit | 231 | master | 635 | # frozen_string_literal: true
require "rails_helper"
RSpec.describe StripeProductService, type: :service do
let(:product) { create(:product) }
describe "#create" do
context "with existing stripe_id" do
it "avoids contacting Stripe" do
expect(Stripe::Product).to_not receive(:create)
Stri... |
github | archonic/limestone | https://github.com/archonic/limestone | config/application.rb | Ruby | mit | 231 | master | 2,551 | # frozen_string_literal: true
require_relative "boot"
# 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 "... |
github | archonic/limestone | https://github.com/archonic/limestone | config/routes.rb | Ruby | mit | 231 | master | 1,626 | # frozen_string_literal: true
require "sidekiq/web"
Rails.application.routes.draw do
# Administrate
constraints CanAccessAdmin do
namespace :admin do
root controller: "users", action: :index
resources :users do
post :impersonate, on: :member
end
get :stop_impersonating, to: :st... |
github | archonic/limestone | https://github.com/archonic/limestone | config/puma.rb | Ruby | mit | 231 | master | 3,619 | # frozen_string_literal: true
# Bind on a specific TCP address. We won't bother using unix sockets because
# nginx will be running in a different Docker container.
bind "tcp://#{ENV['BIND_ON']}"
# Puma supports threading. Requests are served through an internal thread pool.
# Even on MRI, it is beneficial to leverage... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/flipper.rb | Ruby | mit | 231 | master | 316 | # frozen_string_literal: true
require "flipper"
require "flipper/adapters/redis"
# FEATURES:
# public_registration
Flipper.configure do |config|
config.default do
client = Redis.new(url: "#{ENV['REDIS_BASE_URL']}flipper")
adapter = Flipper::Adapters::Redis.new(client)
Flipper.new adapter
end
end |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/admin_access.rb | Ruby | mit | 231 | master | 223 | # frozen_string_literal: true
class CanAccessAdmin
def self.matches?(request)
current_user = request.env["warden"].user
current_user.present? && current_user.respond_to?(:admin?) && current_user.admin?
end
end |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/content_security_policy.rb | Ruby | mit | 231 | master | 540 | # frozen_string_literal: true
# This is required in Rails 5.2 due to it being a restricted CSP environment
# https://github.com/rails/webpacker#development
# https://github.com/rails/rails/pull/31162
# if Rails.env.development?
# p.script_src :self, :https, :unsafe_eval
# p.connect_src :self, :https, 'http://0.0.0... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/pundit.rb | Ruby | mit | 231 | master | 532 | # frozen_string_literal: true
# Extends the ApplicationController to add Pundit for authorization.
# Modify this file to change the behavior of a 'not authorized' error.
# Be sure to restart your server when you modify this file.
module PunditHelper
extend ActiveSupport::Concern
included do
include Pundit
... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/constants.rb | Ruby | mit | 231 | master | 852 | # frozen_string_literal: true
# Application wide constants
TRIAL_PERIOD_DAYS = ENV["TRIAL_PERIOD_DAYS"] || 14
# Write stripe events to seperate log
STRIPE_LOG_PATH = "log/stripe.log"
# NOTE To test against live stripe, create your test product on stripe, and set your ENV vars
STRIPE_TEST_PRODUCT_BASIC_ID = ENV["STRI... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/simple_form_bootstrap.rb | Ruby | mit | 231 | master | 5,563 | # frozen_string_literal: true
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.error_notification_class = "alert alert-danger"
config.button_class = "btn btn-primary"
config.boolean_label_class = nil
config.wrappers :vertical_form, tag: "div", class:... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/sidekiq.rb | Ruby | mit | 231 | master | 659 | # frozen_string_literal: true
sidekiq_config = { url: ENV["ACTIVE_JOB_URL"] }
Sidekiq.configure_server do |config|
config.redis = sidekiq_config
# NOTE docker-compose uses an AOF file which grows indefinitely
# This increases startup time until the AOF is rewritten or the volume is deleted
# run `docker-comp... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/timeout.rb | Ruby | mit | 231 | master | 337 | # frozen_string_literal: true
# Set timeouts via ENV vars
# service_timeout: 15 # RACK_TIMEOUT_SERVICE_TIMEOUT
# wait_timeout: 30 # RACK_TIMEOUT_WAIT_TIMEOUT
# wait_overtime: 60 # RACK_TIMEOUT_WAIT_OVERTIME
# service_past_wait: false # RACK_TIMEOUT_SERVICE_PAST_WAIT
Rack::Timeout::Logger.level... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/devise.rb | Ruby | mit | 231 | master | 13,378 | # frozen_string_literal: true
# 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 secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render inv... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/assets.rb | Ruby | mit | 231 | master | 455 | # frozen_string_literal: true
# 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 << Emoji.image... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/pay.rb | Ruby | mit | 231 | master | 1,136 | # frozen_string_literal: true
Pay.setup do |config|
config.chargeable_class = "Pay::Charge"
config.chargeable_table = "pay_charges"
# For use in the receipt/refund/renewal mailers
config.business_name = "Limestone"
config.business_address = "1234 Whatever Street"
config.application_name = "Limestone App"
... |
github | archonic/limestone | https://github.com/archonic/limestone | config/initializers/loggers/stripe_logger.rb | Ruby | mit | 231 | master | 651 | # frozen_string_literal: true
# Custom Post logger
require "singleton"
class StripeLogger < Logger
include Singleton
def initialize
super(Rails.root.join(STRIPE_LOG_PATH))
self.formatter = formatter
end
# Optional, but good for prefixing timestamps automatically
def formatter
proc { |severity,... |
github | archonic/limestone | https://github.com/archonic/limestone | config/environments/production.rb | Ruby | mit | 231 | master | 4,303 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false
# Code is not reloaded ... |
github | archonic/limestone | https://github.com/archonic/limestone | config/environments/development.rb | Ruby | mit | 231 | master | 3,344 | # frozen_string_literal: true
Rails.application.configure do
# NOTE Required to inline mail delivery so it can be picked up by letter_opener
require "sidekiq/testing/inline"
# Settings specified here will take precedence over those in config/application.rb.
# Verifies that versions and hashed value of the pac... |
github | archonic/limestone | https://github.com/archonic/limestone | config/environments/staging.rb | Ruby | mit | 231 | master | 291 | # frozen_string_literal: true
require_relative "production.rb"
Rails.application.configure do
# Overwrite any production settings here, or if you want to start from
# scratch then remove line 1.
# Use AWS for active storage for staging
config.active_storage.service = :amazon
end |
github | archonic/limestone | https://github.com/archonic/limestone | config/environments/test.rb | Ruby | mit | 231 | master | 1,908 | # frozen_string_literal: true
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 "s... |
github | cldwalker/bond | https://github.com/cldwalker/bond | Rakefile | Ruby | mit | 231 | master | 889 | require 'rake'
require 'fileutils'
def gemspec
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
end
def gem_file
"#{gemspec.name}-#{gemspec.version}#{ENV['GEM_PLATFORM'] == 'java' ? '-java' : ''}.gem"
end
desc "Build the gem"
task :gem=>:gemspec do
sh "gem build .gemspec"
FileUtils.mkdir_p 'pkg'... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond.rb | Ruby | mit | 231 | master | 7,549 | require 'bond/m'
require 'bond/version'
require 'bond/readline'
require 'bond/readlines/rawline'
require 'bond/readlines/ruby'
require 'bond/readlines/jruby'
require 'bond/agent'
require 'bond/search'
require 'bond/input'
require 'bond/rc'
require 'bond/mission'
require 'bond/missions/default_mission'
require 'bond/mis... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/completion.rb | Ruby | mit | 231 | master | 766 | # any object's methods
complete :object=>"Object"
# method arguments
complete :all_methods=>true
complete :all_operator_methods=>true
# classes and constants
complete(:name=>:constants, :anywhere=>'([A-Z][^. \(]*)::([^: .]*)') {|e|
receiver = e.matched[2]
candidates = eval("#{receiver}.constants | #{receiver}.metho... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/rc.rb | Ruby | mit | 231 | master | 1,710 | module Bond
# Namespace in which completion files, ~/.bondrc and ~/.bond/completions/*.rb, are evaluated. Methods in this module
# and Search are the DSL in completion files and can be used within completion actions.
#
# === Example ~/.bondrc
# # complete arguments for any object's :respond_to?
# comple... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/mission.rb | Ruby | mit | 231 | master | 6,139 | module Bond
# Occurs when a mission is incorrectly defined.
class InvalidMissionError < StandardError; end
# Occurs when a mission fails.
class FailedMissionError < StandardError
# Mission that failed
attr_reader :mission
def initialize(mission); @mission = mission; end #@private
end
# Represen... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/readline.rb | Ruby | mit | 231 | master | 1,217 | # This is the default readline plugin for Bond. A valid plugin must be an object
# that responds to methods setup and line_buffer as described below.
class Bond::Readline
DefaultBreakCharacters = " \t\n\"\\'`><=;|&{("
# Loads the readline-like library and sets the completion_proc to the given agent.
def self.set... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/input.rb | Ruby | mit | 231 | master | 1,234 | module Bond
# A string representing the last word the user has typed. This string is passed to a mission
# action to generate possible completions. This string contains a number of attributes from the
# matching mission, useful in generating completions.
class Input < String
# Actual object a user has just ... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/agent.rb | Ruby | mit | 231 | master | 4,107 | module Bond
# Every time a completion is attempted, the Agent searches its missions for
# the first one that matches the user input. Using either the found mission
# or Agent.default_mission, the Agent executes the mission's action.
class Agent
# The array of missions that will be searched when a completio... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/m.rb | Ruby | mit | 231 | master | 4,203 | module Bond
# Takes international quagmires (a user's completion setup) and passes them on
# as missions to an Agent.
module M
extend self
# See {Bond#complete}
def complete(options={}, &block)
if (result = agent.complete(options, &block)).is_a?(String)
$stderr.puts "Bond Error: "+resul... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/search.rb | Ruby | mit | 231 | master | 3,104 | module Bond
# Contains search methods used to filter possible completions given what the user has typed for that completion.
# For a search method to be used by Bond.complete it must end in '_search' and take two arguments: the Input
# string and an array of possible completions.
#
# ==== Creating a search me... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/missions/operator_method_mission.rb | Ruby | mit | 231 | master | 950 | module Bond
# A mission which completes arguments for any module/class method that is an
# operator i.e. '>' or '*'. Takes same Bond.complete options as
# MethodMission. The only operator method this mission doesn't complete is
# '[]='. The operator '[]' should cover the first argument completion of '[]='
# ... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/missions/anywhere_mission.rb | Ruby | mit | 231 | master | 607 | # A mission which completes anywhere i.e. even after non word break characters
# such as '[' or '}'. With options :prefix and :anywhere, this mission matches
# on the following regexp condition /:prefix?(:anywhere)$/ and passes the first
# capture group to the mission action.
class Bond::AnywhereMission < Bond::Missio... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/missions/method_mission.rb | Ruby | mit | 231 | master | 7,549 | module Bond
# A mission which completes arguments for any module/class method that isn't an operator method.
# To create this mission or OperatorMethodMission, :method or :methods must be passed to Bond.complete.
# A completion for a given module/class effects any object that has it as an ancestor. If an object
... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/missions/object_mission.rb | Ruby | mit | 231 | master | 1,600 | # A mission which completes an object's methods. For this mission to match, the
# condition must match and the current object must have an ancestor that matches
# :object. Note: To access to the current object being completed on within an
# action, use the input's object attribute.
#
# ==== Bond.complete Options:
# [:... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/missions/default_mission.rb | Ruby | mit | 231 | master | 927 | # This is the mission called when none of the others match.
class Bond::DefaultMission < Bond::Mission
ReservedWords = [
"BEGIN", "END", "alias", "and", "begin", "break", "case", "class", "def", "defined?", "do", "else", "elsif", "end", "ensure",
"false", "for", "if", "in", "module", "next", "nil", "not", "or... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/completions/activerecord.rb | Ruby | mit | 231 | master | 823 | attribute_imethods = %w{attribute_for_inspect column_for_attribute decrement} +
%w{increment update_attribute toggle update_attributes []}
complete(:methods=>attribute_imethods, :class=>"ActiveRecord::Base#") {|e| e.object.attribute_names }
attribute_cmethods = %w{attr_accessible attr_protected attr_readonly create ... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/completions/object.rb | Ruby | mit | 231 | master | 944 | instance_meths = %w{instance_variable_get instance_variable_set remove_instance_variable instance_variable_defined?}
complete(:methods=>instance_meths, :class=>"Object#") {|e| e.object.instance_variables }
complete(:method=>"Object#instance_of?", :search=>:modules) { objects_of(Class) }
complete(:methods=>%w{is_a? kind... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/completions/hash.rb | Ruby | mit | 231 | master | 215 | complete(:methods=>%w{delete fetch store, [] has_key? key? include? member? values_at},
:class=>"Hash#") {|e| e.object.keys }
complete(:methods=>%w{index value? has_value?}, :class=>"Hash#") {|e| e.object.values } |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/completions/kernel.rb | Ruby | mit | 231 | master | 716 | complete(:methods=>%w{Kernel#raise Kernel#fail}) { objects_of(Class).select {|e| e < StandardError } }
complete(:methods=>%w{Kernel#system Kernel#exec}) {|e|
ENV['PATH'].split(File::PATH_SEPARATOR).uniq.map {|e|
File.directory?(e) ? Dir.entries(e) : []
}.flatten.uniq - ['.', '..']
}
complete(:method=>"Kernel#re... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/completions/module.rb | Ruby | mit | 231 | master | 970 | complete(:methods=>%w{const_get const_set const_defined? remove_const}, :class=>"Module#") {|e| e.object.constants }
complete(:methods=>%w{class_variable_defined? class_variable_get class_variable_set remove_class_variable},
:class=>"Module#") {|e| e.object.class_variables }
complete(:methods=>%w{instance_method meth... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/completions/bond.rb | Ruby | mit | 231 | master | 307 | complete(:methods=>%w{Bond.complete Bond.recomplete}) {
["on", "method", "methods", "class", "object", "anywhere", "prefix", "search", "action", "place", "name"]
}
complete(:methods=>['Bond.start', 'Bond.restart']) {
%w{gems readline default_mission default_search eval_binding debug eval_debug bare}
} |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/readlines/ruby.rb | Ruby | mit | 231 | master | 323 | # A pure ruby readline which requires {rb-readline}[https://github.com/luislavena/rb-readline].
class Bond::Ruby < Bond::Readline
def self.readline_setup
require 'readline'
rescue LoadError
abort "Bond Error: rb-readline gem is required for this readline plugin" +
" -> gem install rb-readline"
end
e... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/readlines/jruby.rb | Ruby | mit | 231 | master | 341 | # Readline for Jruby
class Bond::Jruby < Bond::Readline
def self.readline_setup
require 'readline'
require 'jruby'
class << Readline
ReadlineExt = org.jruby.ext.readline.Readline
def line_buffer
ReadlineExt.s_get_line_buffer(JRuby.runtime.current_context, JRuby.reference(self))
e... |
github | cldwalker/bond | https://github.com/cldwalker/bond | lib/bond/readlines/rawline.rb | Ruby | mit | 231 | master | 494 | # A pure ruby readline which requires {rawline}[http://github.com/h3rald/rawline].
class Bond::Rawline < Bond::Readline
def self.setup(agent)
require 'rawline'
Rawline.completion_append_character = nil
Rawline.basic_word_break_characters= " \t\n\"\\'`><;|&{("
Rawline.completion_proc = agent
rescue L... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/bond_test.rb | Ruby | mit | 231 | master | 4,069 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "Bond" do
describe "start" do
def start(options={}, &block)
Bond.start({:readline=>valid_readline}.merge(options), &block)
end
before { M.instance_eval("@started = @agent = @config = nil"); M.expects(:load_completions) }
it "pri... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/operator_method_mission_test.rb | Ruby | mit | 231 | master | 1,850 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "operator method mission" do
before_all { MethodMission.reset }
before { Bond.agent.reset; Bond.complete(:all_operator_methods=>true) }
describe "operator" do
before { complete(:method=>"Hash#[]") { %w{ab cd ae} } }
it "completes" do
... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/m_test.rb | Ruby | mit | 231 | master | 1,124 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "M" do
describe "#load_gems" do
before { $: << '/dir' }
after { $:.pop }
def mock_file_exists(file)
File.expects(:exist?).at_least(1).returns(false).with {|e| e != file }
File.expects(:exist?).times(1).returns(true).with {|e| ... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/anywhere_mission_test.rb | Ruby | mit | 231 | master | 969 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "anywhere mission" do
before { Bond.agent.reset }
describe "normally" do
before { complete(:anywhere=>':[^:\s.]*') {|e| %w{:ab :bd :ae} } }
it "completes at beginning" do
tab(":a").should == %w{:ab :ae}
end
it "completes in ... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/test_helper.rb | Ruby | mit | 231 | master | 1,388 | require 'bacon'
require 'bacon/bits'
require 'mocha-on-bacon'
require 'bond'
require 'rbconfig'
module TestHelpers
extend self
def mock_irb
unless Object.const_defined?(:IRB)
eval %[
module ::IRB
class<<self; attr_accessor :CurrentContext; end
module InputCompletor; Completion... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/completion_test.rb | Ruby | mit | 231 | master | 4,730 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "Completion" do
before_all {
reset
M.load_file File.dirname(__FILE__) + '/../lib/bond/completion.rb'
M.load_dir File.dirname(__FILE__) + '/../lib/bond'
}
it "completes global variables anywhere" do
tab("blah $LOA").should.satisfy ... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/method_mission_test.rb | Ruby | mit | 231 | master | 7,230 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "method mission" do
before_all { MethodMission.reset }
before { Bond.agent.reset; Bond.complete(:all_methods=>true) }
describe "method" do
before { complete(:method=>'Array#index') {|e| %w{ab cd ef ad} } }
it "completes" do
tab('[]... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/agent_test.rb | Ruby | mit | 231 | master | 7,870 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "Agent" do
describe "#call" do
before { Bond.agent.reset }
it "chooses default mission if no missions match" do
complete(:on=>/bling/) {|e| [] }
Bond.agent.default_mission.expects(:execute).with {|e| e.is_a?(Input) }
tab 'bl... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/object_mission_test.rb | Ruby | mit | 231 | master | 1,698 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "ObjectMission" do
before { Bond.agent.reset }
describe "object mission" do
it "with default action completes" do
complete(:object=>"String")
complete(:on=>/man/) { %w{upper upster upful}}
tab("'man'.up").sort.should == [".upca... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/search_test.rb | Ruby | mit | 231 | master | 4,408 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "Search" do
before { Bond.agent.reset }
describe "mission with search" do
it "false completes" do
complete(:on=>/cool '(.*)/, :search=>false) {|e| %w{coco for puffs}.grep(/#{e.matched[1]}/) }
tab("cool 'ff").should == ['puffs']
... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/completions_test.rb | Ruby | mit | 231 | master | 2,413 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "completions for" do
before_all {
reset
complete(:all_methods=>true)
complete(:all_operator_methods=>true)
M.load_file File.dirname(__FILE__) + '/../lib/bond/completion.rb'
M.load_dir File.dirname(__FILE__) + '/../lib/bond'
}
... |
github | cldwalker/bond | https://github.com/cldwalker/bond | test/mission_test.rb | Ruby | mit | 231 | master | 1,564 | require File.join(File.dirname(__FILE__), 'test_helper')
describe "Mission" do
describe "mission" do
before { Bond.agent.reset }
it "completes" do
complete(:on=>/bling/) {|e| %w{ab cd fg hi}}
complete(:method=>'cool') {|e| [] }
tab('some bling f').should == %w{fg}
end
it "with rege... |
github | cldwalker/bond | https://github.com/cldwalker/bond | ext/readline_line_buffer/extconf.rb | Ruby | mit | 231 | master | 775 | # placate rubygems when running `make install`
def dummy_makefile
File.open(File.join(File.dirname(__FILE__), "Makefile"), "w") {|f|
f.puts %[install:\n\techo "This is a dummy extension"]
}
end
if RUBY_VERSION >= '1.9.2' || RUBY_PLATFORM[/java|mswin|mingw|bccwin|wince/i] ||
ARGV.include?('--without-readline'... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | approvals.gemspec | Ruby | mit | 231 | main | 1,190 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require 'approvals/version'
Gem::Specification.new do |s|
s.name = "approvals"
s.version = Approvals::VERSION
s.licenses = ['MIT']
s.authors = ["Llewellyn Falco", "Sam Livingston-Gray"]
s.email = ["llewellyn.falco... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/dotfile_spec.rb | Ruby | mit | 231 | main | 590 | require 'spec_helper'
require 'tempfile'
describe Approvals::Dotfile do
let(:dotfile) { Tempfile.create('.approvals').tap(&:close).path }
before(:each) do
allow(Approvals::Dotfile).to receive(:path).and_return dotfile
Approvals::Dotfile.reset
end
it "appends the text" do
Approvals::Dotfile.append... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/approvals_spec.rb | Ruby | mit | 231 | main | 4,814 | require 'spec_helper'
describe Approvals do
let(:namer) { |example| Approvals::Namers::RSpecNamer.new(example) }
it "fails" do
dev_null = Gem.win_platform? ? 'nul' : '/dev/null'
allow(Approvals::Dotfile).to receive(:path).and_return(dev_null)
expect do
Approvals.verify "this one doesn't exist"... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/filter_spec.rb | Ruby | mit | 231 | main | 2,536 | require 'spec_helper'
describe Approvals::Filter do
it "When no filters were supplied, it leaves the h_or_a alone" do
filter = Approvals::Filter.new({})
input = {some: 'hash'}
output = filter.apply(input)
expect(input).to equal output
end
it "replaces fields which match a filter" do
filte... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/system_command_spec.rb | Ruby | mit | 231 | main | 350 | require 'spec_helper'
describe Approvals::SystemCommand, "#exists?" do
it "does" do
program = Approvals::SystemUtils.windows? ? "where" : "ls"
expect(Approvals::SystemCommand.exists?(program)).to be_truthy
end
it "does not" do
expect(Approvals::SystemCommand.exists?("absolutelydoesnotexistonyoursys... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/executable_spec.rb | Ruby | mit | 231 | main | 439 | require 'spec_helper'
describe Approvals::Executable do
it "reflects the its value in inspect" do
executable = Approvals::Executable.new('SELECT 1')
expect(executable.inspect).to eq 'SELECT 1'
end
it "takes a block" do
executable = Approvals::Executable.new('SELECT 1') do |command|
"execute q... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/configuration_spec.rb | Ruby | mit | 231 | main | 638 | require 'spec_helper'
describe Approvals::Configuration do
it "defaults to 'fixtures/approvals/'" do
expect(Approvals.configuration.approvals_path).to eq('fixtures/approvals/')
end
describe "when set" do
before(:each) do
# begin-snippet: config-example
Approvals.configure do |config|
... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/combination_approvals_spec.rb | Ruby | mit | 231 | main | 740 | require 'spec_helper'
describe Approvals do
def some_function(a1,b1,c1)
"#{b1+c1} #{a1}s"
end
let(:namer) { |example| Approvals::Namers::RSpecNamer.new(example) }
specify "2 combos" do
a = ["foo", "bar"]
b = [1,3,5]
c = [2,4]
Approvals::CombinationApprovals.verify_all_combinations(a,b, c... |
github | approvals/ApprovalTests.Ruby | https://github.com/approvals/ApprovalTests.Ruby | spec/namers_spec.rb | Ruby | mit | 231 | main | 465 | require 'spec_helper'
describe Approvals::Namers do
it "uses the RSpecNamer" do |example|
approval = Approvals::Approval.new("naming with rspec namer", :namer => Approvals::Namers::RSpecNamer.new(example))
expect(approval.name).to eq("approvals_namers_uses_the_rspecnamer")
end
it "uses the DefaultNamer... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.