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
railslink/railslink
https://github.com/railslink/railslink
app/models/slack_user.rb
Ruby
mit
93
master
2,613
# == Schema Information # # Table name: slack_users # # id :bigint not null, primary key # uid :string # email :string # username :string # first_name :string # last_name :string # tz :string # tz_offset :integer # locale ...
github
railslink/railslink
https://github.com/railslink/railslink
app/models/slack_membership_submission.rb
Ruby
mit
93
master
2,208
# == Schema Information # # Table name: slack_membership_submissions # # id :bigint not null, primary key # slack_user_id :bigint # status :integer default("pending") # first_name :string # last_name :string # email :string # location :string # introducti...
github
railslink/railslink
https://github.com/railslink/railslink
app/models/slack_channel.rb
Ruby
mit
93
master
1,249
# == Schema Information # # Table name: slack_channels # # id :bigint not null, primary key # uid :string # name :string # is_archived :boolean # is_general :boolean default(FALSE) # is_private :boolean # purpose :text # members_count :integer ...
github
railslink/railslink
https://github.com/railslink/railslink
app/models/concerns/emailable.rb
Ruby
mit
93
master
270
module Emailable extend ActiveSupport::Concern included do before_validation :sanitize_email validates :email, uniqueness: true end private def sanitize_email self.email = email.to_s.strip.downcase self.email = nil if email.blank? end end
github
railslink/railslink
https://github.com/railslink/railslink
app/presenters/slack_channel_presenter.rb
Ruby
mit
93
master
437
# frozen_string_literal: true class SlackChannelPresenter < BasePresenter def cleaned_purpose return "" if purpose.blank? channel_ids = purpose.match(/<#(C\w+)\|>/)&.captures return purpose if channel_ids.nil? channel_ids.each do |channel_id| channel = SlackChannel.find_by(uid: channel_id) ...
github
railslink/railslink
https://github.com/railslink/railslink
app/presenters/base_presenter.rb
Ruby
mit
93
master
348
# frozen_string_literal: true class BasePresenter < SimpleDelegator attr_reader :view def initialize(model, view = ActionView::Base.empty) @view = view super(model) end def self.from_collection(collection, view = ActionView::Base.empty) collection.map { |model| new(model, view) } end def mod...
github
railslink/railslink
https://github.com/railslink/railslink
app/presenters/slack_user_presenter.rb
Ruby
mit
93
master
321
# frozen_string_literal: true class SlackUserPresenter < BasePresenter def admin_checkmark is_admin? ? '✓' : '' end def name_with_email [name, email].select(&:present?).join(' - ') end def deleted_checkmark is_deleted? ? '✓' : '' end def bot_checkmark is_bot? ? '✓' : '' end end
github
railslink/railslink
https://github.com/railslink/railslink
app/jobs/application_job.rb
Ruby
mit
93
master
319
class ApplicationJob < ActiveJob::Base queue_as :default around_perform :with_connection_pool private # https://github.com/brandonhilkert/sucker_punch/#activerecord-connection-pool-connections def with_connection_pool ActiveRecord::Base.connection_pool.with_connection do yield end end end
github
railslink/railslink
https://github.com/railslink/railslink
app/jobs/slack_event/member_joined_channel_job.rb
Ruby
mit
93
master
2,890
# # See https://api.slack.com/events/member_joined_channel # # Example payload: # # {"token"=>"xxxx", # "team_id"=>"TCF0ZD3LL", # "api_app_id"=>"ACELG3B4H", # "event"=>{ # "type"=>"member_joined_channel", # "user"=>"UCFC0B6E9", # "channel"=>"CDPS07TPV", # "channel_type"=>"C", # "team"=>"TCF0ZD3LL", # "event...
github
railslink/railslink
https://github.com/railslink/railslink
app/jobs/slack_event/unhandled_job.rb
Ruby
mit
93
master
481
class SlackEvent::UnhandledJob < ApplicationJob MAX_LIST_SIZE = 100 attr_reader :options private :options def perform(options = {}) @options = options.with_indifferent_access store_in_redis_list prune_redis_list end private def store_in_redis_list REDIS.rpush(redis_key, options.to_jso...
github
railslink/railslink
https://github.com/railslink/railslink
app/jobs/slack_event/message_job.rb
Ruby
mit
93
master
3,424
# # See https://api.slack.com/events-api#receiving_events # class SlackEvent::MessageJob < ApplicationJob attr_reader :options private :options def perform(options = {}) @options = options.with_indifferent_access %i[ request_to_invite update_last_message_at ].each do |method| return i...
github
railslink/railslink
https://github.com/railslink/railslink
app/jobs/slack_event/team_join_job.rb
Ruby
mit
93
master
3,824
# # {token: "tokean123", # team_id: "team123", # api_app_id: "app123", # event: { # type: "team_join", # user: { # id: "user123", # team_id: "team123", # name: "name", # deleted: false, # color: "a63024", # real_name: " real name", # tz: "America/Chicago", # tz_label: "C...
github
railslink/railslink
https://github.com/railslink/railslink
app/jobs/slack_event/admins_job.rb
Ruby
mit
93
master
1,746
# # This comes through the slash commands API which has a # slightly different payload than the events API # # Example payload: # # { # "token": "xxxx", # "team_id": "TCF0ZD3LL", # "team_domain": "railslink-dev", # "channel_id": "xxxx", # "channel_name": "xxxx", # "user_id": "xxxx", # "user_name": "xxxx",...
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/home_controller.rb
Ruby
mit
93
master
323
class HomeController < ApplicationController def index @team_members_count = SlackUser.available.count @other_channels = SlackChannel.available.popular.to_a @channels_count = @other_channels.size @popular_channels = @other_channels.slice!(0, 6) @timezones = SlackUser.tz_offset_distribution end e...
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/sessions_controller.rb
Ruby
mit
93
master
772
class SessionsController < ApplicationController def setup if params[:require] == "admin" request.env["omniauth.strategy"].options["scope"] = "client" end head :not_found end def create user = SlackUser.find_or_create_from_auth_hash(request.env["omniauth.auth"]) self.current_user = use...
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/slack_controller.rb
Ruby
mit
93
master
1,415
class SlackController < ApplicationController skip_before_action :verify_authenticity_token before_action :publish_event before_action :verify_token! # see https://api.slack.com/events-api # see https://api.slack.com/events/url_verification def event if slack_params[:type] == "url_verification" r...
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/admin_controller.rb
Ruby
mit
93
master
288
class AdminController < ApplicationController before_action :require_admin! protected def require_admin! return if current_user && current_user.is_admin? redirect_to "/auth/slack?require=admin" and return unless current_user redirect_to root_path and return end end
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/pages_controller.rb
Ruby
mit
93
master
293
class PagesController < ApplicationController def admin_members @admin_members = SlackUser.admins.active.sort_by_recent_activity end def code_of_conduct text = File.read(File.join(Rails.root, "CODE_OF_CONDUCT.md")) @coc_html = Kramdown::Document.new(text).to_html end end
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/membership_submissions_controller.rb
Ruby
mit
93
master
838
class MembershipSubmissionsController < ApplicationController def new @submission = SlackMembershipSubmission.new end def create redirect_to root_path and return if submission_params.key?(:fax) @submission = SlackMembershipSubmission.new(submission_params) @submission.ip_address = request.remote...
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/admin/membership_submissions_controller.rb
Ruby
mit
93
master
1,274
class Admin::MembershipSubmissionsController < AdminController def index redirect_to admin_path end def pending @num_pending = SlackMembershipSubmission.pending.count if @num_pending.zero? flash[:info] = "There are no pending submissions right now." redirect_to admin_path return ...
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/admin/users_controller.rb
Ruby
mit
93
master
401
# frozen_string_literal: true class Admin::UsersController < AdminController def index @users = SlackUser.order( :is_deleted, { is_admin: :desc }, :last_name, :email ) @pagy, @users = pagy(@users) @users = SlackUserPresenter.from_collection(@users) end def show user ...
github
railslink/railslink
https://github.com/railslink/railslink
app/controllers/concerns/current_user.rb
Ruby
mit
93
master
736
module CurrentUser extend ActiveSupport::Concern included do before_action :reset_current_user helper_method :current_user end protected def current_user return unless session[:user_id] Thread.current[:current_user] ||= SlackUser.find_by(id: session[:user_id]).tap do |user| user.xoxp_...
github
railslink/railslink
https://github.com/railslink/railslink
config/routes.rb
Ruby
mit
93
master
976
Rails.application.routes.draw do root "home#index" namespace :slack do post "event" end get "/login" , to: "sessions#new" , as: :login get "/logout" , to: "sessions#destroy" , as: :logout get "/auth/failure" , to: "sessions#failure" get "/auth/:prov...
github
railslink/railslink
https://github.com/railslink/railslink
config/application.rb
Ruby
mit
93
master
1,811
require_relative "boot" require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" # Require the gems listed in Gemfile, including any gems...
github
railslink/railslink
https://github.com/railslink/railslink
config/puma.rb
Ruby
mit
93
master
1,805
# Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches...
github
railslink/railslink
https://github.com/railslink/railslink
config/initializers/rollbar.rb
Ruby
mit
93
master
3,076
Rollbar.configure do |config| # Without configuration, Rollbar is enabled in all environments. # To disable in specific environments, set config.enabled=false. config.access_token = ENV["ROLLBAR_ACCESS_TOKEN"] # Disable everywhere but production config.enabled = Rails.env.production? # By default, Rollba...
github
railslink/railslink
https://github.com/railslink/railslink
config/initializers/marginalia.rb
Ruby
mit
93
master
420
# see https://github.com/basecamp/marginalia#customization Marginalia::Comment.components = [:controller_with_namespace, :action, :line] # See https://github.com/basecamp/marginalia/blob/master/lib/marginalia/comment.rb#L109 # Our addition excludes: "/usr/local/lib/ruby/.../monitor.rb:...:in `mon_synchronize'" Margin...
github
railslink/railslink
https://github.com/railslink/railslink
config/initializers/omniauth.rb
Ruby
mit
93
master
472
OmniAuth.config.failure_raise_out_environments = [] Rails.application.config.middleware.use OmniAuth::Builder do provider :slack, ENV["SLACK_SIGNIN_API_KEY"], ENV["SLACK_SIGNIN_API_SECRET"], team: ENV["SLACK_TEAM"], scope: "channels:read, users:read", setup: true # if we ever add additional provid...
github
railslink/railslink
https://github.com/railslink/railslink
config/initializers/rack_attack.rb
Ruby
mit
93
master
206
Rack::Attack.blocklist("block invalid, bogus, requests") do |request| # Requests are blocked if the return value is truthy request.path.include?("/wp-login") || request.path.include?("/wp-admin") end
github
railslink/railslink
https://github.com/railslink/railslink
config/environments/test.rb
Ruby
mit
93
master
2,661
require "active_support/core_ext/integer/time" # 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 the...
github
railslink/railslink
https://github.com/railslink/railslink
config/environments/development.rb
Ruby
mit
93
master
3,440
require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for developme...
github
railslink/railslink
https://github.com/railslink/railslink
config/environments/production.rb
Ruby
mit
93
master
5,222
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. This eager loads most of Rails and # your app...
github
railslink/railslink
https://github.com/railslink/railslink
spec/spec_helper.rb
Ruby
mit
93
master
5,006
# This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be loaded, without a need to explicitly require ...
github
railslink/railslink
https://github.com/railslink/railslink
spec/rails_helper.rb
Ruby
mit
93
master
3,014
# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rail...
github
railslink/railslink
https://github.com/railslink/railslink
spec/presenters/slack_user_presenter_spec.rb
Ruby
mit
93
master
1,931
# frozen_string_literal: true require 'rails_helper' RSpec.describe SlackUserPresenter do subject { SlackUserPresenter.new(slack_user) } describe '#admin_checkmark' do context 'when is_admin? is true' do let(:slack_user) { double('is_admin?' => true) } it 'returns ✓' do expect(subject.ad...
github
railslink/railslink
https://github.com/railslink/railslink
spec/presenters/slack_channel_presenter_spec.rb
Ruby
mit
93
master
1,036
# frozen_string_literal: true require 'rails_helper' RSpec.describe SlackChannelPresenter do subject { SlackChannelPresenter.new(channel) } before { create(:slack_channel, name: "job-seekers", uid: "C123456") } describe '#cleaned_purpose' do context 'when purpose contains a Slack-style channel mention' do...
github
railslink/railslink
https://github.com/railslink/railslink
spec/models/ip_info_spec.rb
Ruby
mit
93
master
1,844
require 'rails_helper' RSpec.describe IpInfo, type: :model do context "exceptions" do let(:subject) { described_class.new("73.11.237.17") } it "is unsuccessful when the network times out" do allow(Net::HTTP).to receive(:get).and_raise(Net::OpenTimeout) expect(subject.successful?).to eq false ...
github
railslink/railslink
https://github.com/railslink/railslink
spec/models/slack_user_spec.rb
Ruby
mit
93
master
2,208
# == Schema Information # # Table name: slack_users # # id :bigint not null, primary key # uid :string # email :string # username :string # first_name :string # last_name :string # tz :string # tz_offset :integer # locale ...
github
railslink/railslink
https://github.com/railslink/railslink
spec/models/slack_channel_spec.rb
Ruby
mit
93
master
765
# == Schema Information # # Table name: slack_channels # # id :bigint not null, primary key # uid :string # name :string # is_archived :boolean # is_general :boolean default(FALSE) # is_private :boolean # purpose :text # members_count :integer ...
github
railslink/railslink
https://github.com/railslink/railslink
spec/models/slack_membership_submission_spec.rb
Ruby
mit
93
master
2,798
# == Schema Information # # Table name: slack_membership_submissions # # id :bigint not null, primary key # slack_user_id :bigint # status :integer default("pending") # first_name :string # last_name :string # email :string # location :string # introducti...
github
railslink/railslink
https://github.com/railslink/railslink
spec/models/concerns/emailable.rb
Ruby
mit
93
master
544
RSpec.shared_examples "a emailable concern" do it { should validate_uniqueness_of(:email).case_insensitive } describe "#sanitize_email" do it "lower cases the email" do subject.update!(email: "JOHN@DOE.COM") expect(subject.email).to eq "john@doe.com" end it "strips spaces" do subject...
github
railslink/railslink
https://github.com/railslink/railslink
spec/models/concerns/nameable.rb
Ruby
mit
93
master
719
RSpec.shared_examples "a nameable concern" do describe "#name" do it "joins first and last names together" do subject.first_name = "John" subject.last_name = "Doe" expect(subject.name).to eq "John Doe" end it "strips spaces" do subject.first_name = " John " subject.last_name...
github
railslink/railslink
https://github.com/railslink/railslink
spec/factories/slack_membership_submission.rb
Ruby
mit
93
master
331
FactoryBot.define do factory :slack_membership_submission do first_name { "John" } last_name { "Doe" } introduction { "Some intro here." } how_hear { "The Google" } sequence(:email) { |n| "john#{n}@doe.com" } factory :approved_slack_membership_submission do status { "approved" } end...
github
railslink/railslink
https://github.com/railslink/railslink
spec/requests/rack_attacks_spec.rb
Ruby
mit
93
master
502
require 'rails_helper' RSpec.describe "RackAttacks", type: :request do describe "sanity checks" do it "allows the homepage" do get root_path expect(response).to have_http_status(200) end end describe "blocklist" do it "blocks /wp-login requests" do get "/foo/wp-login/bar" exp...
github
railslink/railslink
https://github.com/railslink/railslink
spec/requests/slack_post_event_spec.rb
Ruby
mit
93
master
3,552
require "rails_helper" RSpec.describe "Slack post event", type: :request do describe "publishing events to Redis" do it "publishes events even if token is invalid" do expect(REDIS).to receive(:publish).with( :slack_events, { token: "invalid" }.to_json ) post "/slack/event", params: { s...
github
railslink/railslink
https://github.com/railslink/railslink
spec/requests/membership_submissions_spec.rb
Ruby
mit
93
master
1,553
require "rails_helper" RSpec.describe "Membership submissions", type: :request do describe "new membership submission page" do it "returns success for the new page" do get "/join-now" expect(response).to have_http_status(200) end end describe "membership creation" do describe "when honey...
github
railslink/railslink
https://github.com/railslink/railslink
spec/requests/admin/channels_spec.rb
Ruby
mit
93
master
477
require "rails_helper" RSpec.describe "Channels", type: :request do describe "index page" do context "guest user" do it "redirects to /auth/slack" do get "/admin/channels" expect(response).to redirect_to("/auth/slack?require=admin") end end context "admin user" do it "r...
github
railslink/railslink
https://github.com/railslink/railslink
spec/requests/admin/dashboard_spec.rb
Ruby
mit
93
master
264
require "rails_helper" RSpec.describe "Admin Dashboard page", type: :request do describe "without authorization" do it "redirects to the /auth/slack" do get "/admin" expect(response).to redirect_to("/auth/slack?require=admin") end end end
github
railslink/railslink
https://github.com/railslink/railslink
spec/requests/admin/users_spec.rb
Ruby
mit
93
master
688
require "rails_helper" RSpec.describe "Users", type: :request do describe "index page" do it_behaves_like "an authorized action" do let(:request) { get "/admin/users" } end it "returns http success" do authorize_admin! get "/admin/users" expect(response).to have_http_status(200)...
github
railslink/railslink
https://github.com/railslink/railslink
spec/requests/admin/membership_submissions_spec.rb
Ruby
mit
93
master
2,828
require "rails_helper" RSpec.describe "Membership submissions", type: :request do describe "index page" do it_behaves_like "an authorized action" do let(:request) { get "/admin/membership_submissions" } end it "redirects to admin dashboard" do authorize_admin! get "/admin/membership_su...
github
railslink/railslink
https://github.com/railslink/railslink
spec/jobs/application_job_spec.rb
Ruby
mit
93
master
351
require 'rails_helper' RSpec.describe ApplicationJob, type: :job do it "it wraps the job in AR's connection pool" do class SampleWorker < ApplicationJob def perform true end end expect(ActiveRecord::Base).to receive_message_chain(:connection_pool, :with_connection).and_yield Samp...
github
railslink/railslink
https://github.com/railslink/railslink
spec/jobs/slack_event/message_job_spec.rb
Ruby
mit
93
master
2,115
require 'rails_helper' RSpec.describe SlackEvent::MessageJob, type: :job do describe "#request_to_invite" do context "when not an invitation request" do it "won't invoke when message text is wrong" do expect(subject).to receive(:request_to_invite).and_return(false) payload = { event: { text...
github
railslink/railslink
https://github.com/railslink/railslink
spec/jobs/slack_event/team_join_job_spec.rb
Ruby
mit
93
master
712
require 'rails_helper' RSpec.describe SlackEvent::TeamJoinJob, type: :job do let(:options) {{ event: { user: { id: "user123", name: "johndoe", real_name: "John Doe", is_bot: false, }, } }} describe "#perform" do it "does not welcome bots to the team" do ...
github
railslink/railslink
https://github.com/railslink/railslink
spec/jobs/slack_event/unhandled_job_spec.rb
Ruby
mit
93
master
536
require 'rails_helper' RSpec.describe SlackEvent::UnhandledJob, type: :job do let(:options) { { event: { foo: "bar", one: 1 }} } describe "#perform" do it "stores the options in redis" do subject.perform(options) expect(REDIS.rpop("slack_event:unhandled_jobs")).to eq options.to_json end i...
github
railslink/railslink
https://github.com/railslink/railslink
spec/jobs/slack_event/member_joined_channel_job_spec.rb
Ruby
mit
93
master
2,627
require 'rails_helper' RSpec.describe SlackEvent::MemberJoinedChannelJob, type: :job do let(:channel_uid) { "channel123" } let(:user_uid) { "user13" } let(:options) {{token: "token123", team_id: "team123", api_app_id: "appid123", event: { type: "member_joined_channel", ...
github
railslink/railslink
https://github.com/railslink/railslink
spec/jobs/slack_event/admins_job_spec.rb
Ruby
mit
93
master
405
require 'rails_helper' RSpec.describe SlackEvent::AdminsJob, type: :job do let(:options) {{ token: "fake token", response_url: "https://www.fakeurl.com", event: { type: "admins" } }} describe "#perform" do it "responds with a list of admins" do expect(subject).to receive(:admin...
github
railslink/railslink
https://github.com/railslink/railslink
spec/support/vcr.rb
Ruby
mit
93
master
1,410
require "vcr" require "set" VCR.configure do |c| c.cassette_library_dir = "spec/fixtures/vcr" c.hook_into :webmock c.configure_rspec_metadata! c.default_cassette_options = { record: :once } end # # Track every cassette used so that we can optionally (only if doing a full spec suite) # print out no longer used...
github
railslink/railslink
https://github.com/railslink/railslink
spec/support/helpers.rb
Ruby
mit
93
master
289
module Helpers def authorize_admin! allow_any_instance_of(AdminController).to receive(:require_admin!).and_return(true) end def create_general_slack_channel SlackChannel.find_or_create_by!( is_general: true, name: 'general', uid: 'XXXXXXX' ) end end
github
felipeelias/resubject
https://github.com/felipeelias/resubject
Gemfile
Ruby
mit
93
main
285
# frozen_string_literal: true source 'https://rubygems.org' gemspec rails_version = ENV.fetch('RAILS_VERSION', '8.0') gem 'actionpack', "~> #{rails_version}.0" gem 'rake', '>= 13.0' gem 'redcarpet' gem 'rspec', '~> 3.0' gem 'rubocop', '~> 1.0', require: false gem 'yard', '~> 0.9'
github
felipeelias/resubject
https://github.com/felipeelias/resubject
Rakefile
Ruby
mit
93
main
275
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'yard' desc 'Default: run specs.' task default: :spec desc 'Run all specs' RSpec::Core::RakeTask.new(:spec) YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*.rb'] end
github
felipeelias/resubject
https://github.com/felipeelias/resubject
resubject.gemspec
Ruby
mit
93
main
953
# frozen_string_literal: true require_relative 'lib/resubject/version' Gem::Specification.new do |gem| gem.name = 'resubject' gem.version = Resubject::VERSION gem.authors = ['Felipe Philipp'] gem.email = ['felipephilipp@duck.com'] gem.description = "Simple presenters using Rub...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
spec/resubject/presenter_spec.rb
Ruby
mit
93
main
1,744
# frozen_string_literal: true require 'spec_helper' describe Resubject::Presenter do let(:object) { double :object } subject { Resubject::Presenter.new(object) } it 'delegate methods to object' do expect(object).to receive(:pretty) subject.pretty end describe :to_model do it 'returns the dele...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
spec/resubject/naming_spec.rb
Ruby
mit
93
main
2,751
# frozen_string_literal: true require 'spec_helper' describe Resubject::Naming do before do stub_const 'Box', Class.new stub_const 'BoxPresenter', Class.new end it 'gets the presenter class from an object' do presenter = Resubject::Naming.presenter_for Box.new expect(presenter).to eq BoxPresen...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
spec/resubject/builder_spec.rb
Ruby
mit
93
main
4,129
# frozen_string_literal: true require 'spec_helper' describe Resubject::Builder do let(:template) { double :template } before do stub_const 'Box', Class.new stub_const 'BoxPresenter', Class.new(Resubject::Presenter) stub_const 'OtherBoxPresenter', Class.new(Resubject::Presenter) end describe '.p...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
spec/resubject/extensions/template_methods_spec.rb
Ruby
mit
93
main
1,537
# frozen_string_literal: true require 'spec_helper' require 'uri' require 'action_view' describe Resubject::Presenter, 'template methods' do let(:model) { double :model } let(:presenter) do Class.new(Resubject::Presenter) do currency :price time_ago :posted_at percentage :rating, precision:...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject.rb
Ruby
mit
93
main
283
# frozen_string_literal: true require 'resubject/version' require 'resubject/naming' require 'resubject/extensions' require 'resubject/presenter' require 'resubject/builder' require 'resubject/rails' if defined? Rails ActiveSupport.run_load_hooks(:resubject, Resubject::Presenter)
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/rspec.rb
Ruby
mit
93
main
1,312
# frozen_string_literal: true require 'resubject' module Resubject # RSpec configuration and helpers # # This helper automatically creates `subject` and `template` # variables for RSpec when testing your presenter. # # To get this working, create a spec file in `spec/presenters` # and require `resubject...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/presenter.rb
Ruby
mit
93
main
2,724
# frozen_string_literal: true require 'delegate' module Resubject class Presenter < SimpleDelegator extend Resubject::Extensions::TemplateMethods # the HTML helpers context attr_reader :context alias template context # Create a new presenter # # @param model any object that can be pres...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/rails.rb
Ruby
mit
93
main
211
# frozen_string_literal: true require 'resubject/rails/engine' module Resubject class Presenter private def routes ::Rails.application.routes.url_helpers end alias r routes end end
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/naming.rb
Ruby
mit
93
main
1,083
# frozen_string_literal: true require 'active_support/core_ext/string/inflections' module Resubject module Naming # Discover the presenter class given the class name or string/symbol passed # # @example # # Naming.presenter_for :post # => PostPresenter # Naming.presenter_for "pos...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/builder.rb
Ruby
mit
93
main
3,361
# frozen_string_literal: true module Resubject module Builder # Raised when a invalid presenter is received class InvalidPresenterArgument < StandardError end # Presents a object or a collection of objects # # @param [Object, Array<Object>] objects objects to be instantiated with related pre...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/extensions/template_methods.rb
Ruby
mit
93
main
4,163
# frozen_string_literal: true require 'active_support/time' module Resubject module Extensions # All Rails extensions module TemplateMethods # Generates an attribute using `number_to_currency` helper from rails # # @example # # class ProductPresenter < Resubject::Presenter ...
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/rails/engine.rb
Ruby
mit
93
main
286
# frozen_string_literal: true module Resubject class Engine < ::Rails::Engine # :nodoc: initializer 'resubject.helpers' do ActiveSupport.on_load(:action_controller) do require 'resubject/rails/helpers' include Resubject::Helpers end end end end
github
felipeelias/resubject
https://github.com/felipeelias/resubject
lib/resubject/rails/helpers.rb
Ruby
mit
93
main
535
# frozen_string_literal: true module Resubject # ActionController helpers # # In case you have Rails, these helpers will be automatically included # module Helpers # adds present as a helper method in the controller def self.included(base) base.send(:helper_method, :present) end # @see...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
ragweed.gemspec
Ruby
bsd-3-clause
93
master
2,821
# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = "ragweed" s.version = "0.2.9" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
Rakefile
Ruby
bsd-3-clause
93
master
1,730
require 'rubygems' require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "ragweed" gem.summary = %Q{Scriptable debugger} gem.description = %Q{General debugging tool written in Ruby for OSX/Win32/Linux} gem.email = "td@matasano.com" gem.homepage = "http://www.matasano.com...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
spec/spec_helper.rb
Ruby
bsd-3-clause
93
master
381
require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib ragweed])) Spec::Runner.configure do |config| # == Mock Framework # # RSpec uses it's own mocking framework by default. If you prefer to # use mocha, flexmock or RR, uncomment the appropriate line: # # config.mock_with :mocha # con...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed.rb
Ruby
bsd-3-clause
93
master
3,419
require 'ffi' module Ragweed # :stopdoc: VERSION = File.read(File.join(File.dirname(__FILE__),"..","VERSION")).strip LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR # :startdoc: # Returns the version string for the library. #...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wrap32.rb
Ruby
bsd-3-clause
93
master
1,808
module Ragweed; end module Ragweed::Wrap32 # :stopdoc: VERSION = File.read(File.join(File.dirname(__FILE__),"..","..","VERSION")) LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR # :startdoc: # Returns the version string for the ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx.rb
Ruby
bsd-3-clause
93
master
1,932
# Dir[File.expand_path("#{File.dirname(__FILE__)}/wraposx/*.rb")].each do |file| # require file # end module Ragweed; end module Ragweed::Wraposx # :stopdoc: VERSION = File.read(File.join(File.dirname(__FILE__),"..","..","VERSION")).strip LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARAT...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/utils.rb
Ruby
bsd-3-clause
93
master
4,433
require 'iconv' # @deprecated - unused this will be removed at some point. class Range module RangeExtensions def each_backwards max.to_i.downto(min) {|i| yield i} end end include RangeExtensions end class Array module ArrayExtensions # Convert to hash ## def to_hash # too cl...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/debugger32.rb
Ruby
bsd-3-clause
93
master
12,783
require ::File.join(::File.dirname(__FILE__),'wrap32') # Debugger class for win32 # You can use this class in 2 ways: # # (1) You can create instances of Debugger and use them to set and handle # breakpoints. # # (2) If you want to do more advanced event handling, you can subclass from # debugger and define yo...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/sbuf.rb
Ruby
bsd-3-clause
93
master
4,078
# Stolen (mostly) from Net::SSH # a* string a10 string 10 bytes A* string trimmed # C uchar # L native u32, l signed # N BE u32, n 16 # Qq quad # Ss native u16 # Vv LE u32 # Encapsulate a buffer of data with structured data accessors class Ragweed::Sbuf attr_reader :content attr_accessor :position def self.fro...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/debuggerosx.rb
Ruby
bsd-3-clause
93
master
15,954
require ::File.join(::File.dirname(__FILE__),'wraposx') module Ragweed; end # Debugger class for Mac OS X # You can use this class in 2 ways: # # (1) You can create instances of Debuggerosx and use them to set and handle # breakpoints. # # (2) If you want to do more advanced event handling, you can subclass from ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/rasm.rb
Ruby
bsd-3-clause
93
master
1,748
module Ragweed; end module Ragweed::Rasm # :stopdoc: VERSION = File.read(File.join(File.dirname(__FILE__),"..","..","VERSION")).strip LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR # :startdoc: # Returns the version string for ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraptux.rb
Ruby
bsd-3-clause
93
master
1,755
module Ragweed; end module Ragweed::Wraptux # :stopdoc: VERSION = File.read(File.join(File.dirname(__FILE__),"..","..","VERSION")).strip LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR # :startdoc: # Returns the version string fo...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/detour.rb
Ruby
bsd-3-clause
93
master
6,779
class Ragweed::Detour # "Ghetto Detours", as Scott Stender might say. Patch subprograms # in to running programs as a hooking mechanism. class Detour attr_reader :snarfed attr_reader :dpoint attr_reader :stack # Easiest way to do this is just to ask WinProcess#detour. Wants # "p" to be a poin...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/ptr.rb
Ruby
bsd-3-clause
93
master
1,174
# TODO: make read/write work for other oses class Ragweed::Ptr # A dubious achievement. Wrap Integers in a pointer class, which, # when you call to_s, returns the marshalled type, and which exports # read/write methods. attr_accessor :p attr_reader :val # ptr-to-zero? def null? @val == 0 end # ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/blocks.rb
Ruby
bsd-3-clause
93
master
2,790
require ::File.join(::File.dirname(__FILE__),'rasm') pushv = $VERBOSE $VERBOSE = nil module Ragweed::Blocks include Ragweed::Rasm extend Ragweed::Rasm def remote_trampoline(argc, opts={}) i = Ragweed::Rasm::Subprogram.new # drop directly to debugger i << Int(3) if opts[:debug] # psuedo-frame-...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/debuggertux.rb
Ruby
bsd-3-clause
93
master
15,113
require ::File.join(::File.dirname(__FILE__),'wraptux') module Ragweed; end # Debugger class for Linux # You can use this class in 2 ways: # # (1) You can create instances of Debuggertux and use them to set and handle # breakpoints. # # (2) If you want to do more advanced event handling, you can subclass from # ...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/trampoline.rb
Ruby
bsd-3-clause
93
master
2,756
class Ragweed::Trampoline # Normally called through WinProcess#remote_call, but, for # what it's worth: needs a WinProcess instance and a location, # which can be a string module!function or a pointer. def initialize(p, loc, opts={}) @p = p @loc = @p.get_proc loc @argc = opts[:argc] @a = @p.are...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/arena.rb
Ruby
bsd-3-clause
93
master
1,191
class Ragweed::Arena # I want 3 lambdas: # * "get" should take no arguments and result in the address of a fresh # 4k page. # * "free" should free any 4k page returned by "get" # * "copy" should implement memcpy, copying a string into a 4k page. def initialize(get, free, copy) @get = get @free = f...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/rasm/bblock.rb
Ruby
bsd-3-clause
93
master
1,950
module Ragweed; end module Ragweed::Rasm # Ruby inline assembler. class Bblock # Don't call this directly; use Bblock#make def initialize @insns = Ragweed::Rasm::Subprogram.new end # Wrap the methods of Rasm::Subprogram we care about: # Assemble the instructions, which also calculates ap...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/rasm/isa.rb
Ruby
bsd-3-clause
93
master
27,881
module Ragweed; end ## ------------------------------------------------------------------------ # Rasm: a half-assed X86 assembler. # # Rasm implements a small subset of the X86 instruction set, and only in # simple encodings. # # However, Rasm implements enough X86 to do interesting things. I wrote it # to inject tra...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraptux/process.rb
Ruby
bsd-3-clause
93
master
1,232
class Ragweed::Process include Ragweed attr_reader :pid def initialize(pid); @pid = pid; end # Read/write ranges of data or fixnums to/from the process by address. def read(off, sz=4096) a = [] max = off+sz while off < max a.push(Ragweed::Wraptux::ptrace(Ragwee...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraptux/wraptux.rb
Ruby
bsd-3-clause
93
master
2,558
require 'ffi' module Ragweed::Wraptux module Libc extend FFI::Library ffi_lib FFI::Library::LIBC attach_function 'ptrace', [ :ulong, :pid_t, :ulong, :ulong ], :long attach_function 'wait', [ :pointer ], :int attach_function 'waitpid', [ :int, :pointer, :int ], :int attach_function 'kill', [ :...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraptux/constants.rb
Ruby
bsd-3-clause
93
master
1,666
NULL = nil module Ragweed; end module Ragweed::Wraptux;end module Ragweed::Wraptux::Ptrace TRACE_ME = 0 PEEK_TEXT = 1 PEEK_DATA = 2 PEEK_USER = 3 POKE_TEXT = 4 POKE_DATA = 5 POKE_USER = 6 CONTINUE = 7 KILL = 8 STEP = 9 GETREGS = 12 SETREGS = 13 ATTACH = 16 DETACH = 17 SYSCALL = 24 SETOP...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx/region_info.rb
Ruby
bsd-3-clause
93
master
14,378
module Ragweed; end module Ragweed::Wraposx; end module Ragweed::Wraposx::Vm # these are flavor arguments for vm_region # only basic info is supported by apple REGION_BASIC_INFO_64 = 9 REGION_BASIC_INFO = 10 REGION_EXTENDED_INFO = 11 REGION_TOP_INFO = 12 # behavior identifiers BEHAVIOR_DEFAULT = 0 #...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx/thread_info.rb
Ruby
bsd-3-clause
93
master
7,003
module Ragweed; end module Ragweed::Wraposx::ThreadInfo # info interfaces BASIC_INFO = 3 #basic information # following are obsolete interfaces # according to the source @ fxr they still work except FIFO SCHED_TIMESHARE_INFO = 10 SCHED_RR_INFO = 11 # SCHED_FIFO_INFO = 12 # Thread run states module...
github
tduehr/ragweed
https://github.com/tduehr/ragweed
lib/ragweed/wraposx/wraposx.rb
Ruby
bsd-3-clause
93
master
12,573
require 'ffi' module Ragweed; end module Ragweed::Wraposx module Libc extend FFI::Library ffi_lib FFI::Library::LIBC typedef :int, :kern_return_t typedef :ulong_long, :memory_object_offset_t typedef :uint, :vm_inherit_t typedef :uint, :natural_t typedef :natural_t, :mach_msg_type_number...