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 | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250219154112_create_versions.rb | Ruby | apache-2.0 | 46 | main | 1,719 | # This migration creates the `versions` table, the only schema PT requires.
# All other migrations PT provides are optional.
class CreateVersions < ActiveRecord::Migration[8.0]
# The largest text column available in all supported RDBMS is
# 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
# so that MySQ... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250709205352_add_devise_to_users.rb | Ruby | apache-2.0 | 46 | main | 1,986 | # frozen_string_literal: true
class AddDeviseToUsers < ActiveRecord::Migration[8.0]
def self.up
change_table :users do |t|
## NB: Some devise standard code has been commented out, due to migrating existing fields and indexes.
## Database authenticatable
# t.string :email, null: fal... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250414172602_move_site_to_user.rb | Ruby | apache-2.0 | 46 | main | 377 | class MoveSiteToUser < ActiveRecord::Migration[8.0]
def up
# Remove user reference on site.
remove_reference :sites, :user
# Add site reference to user instead.
add_reference :users, :site, null: true, foreign_key: true
end
def down
# Reverse the above.
remove_reference :users, :site
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250411193643_add_cascade_to_document_inference_fk.rb | Ruby | apache-2.0 | 46 | main | 345 | class AddCascadeToDocumentInferenceFk < ActiveRecord::Migration[8.0]
def up
remove_foreign_key :document_inferences, :documents
add_foreign_key :document_inferences, :documents, on_delete: :cascade
end
def down
remove_foreign_key :document_inferences, :documents
add_foreign_key :document_inferenc... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250311145959_create_document_inferences.rb | Ruby | apache-2.0 | 46 | main | 357 | class CreateDocumentInferences < ActiveRecord::Migration[8.0]
def change
create_table :document_inferences do |t|
t.datetime :creation_date
t.references :document, null: false, foreign_key: true
t.text :inference_type
t.text :inference_value
t.float :inference_confidence
t.text... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250716155512_add_devise_trackable.rb | Ruby | apache-2.0 | 46 | main | 313 | class AddDeviseTrackable < ActiveRecord::Migration[8.0]
def self.up
change_table :users do |t|
t.integer :sign_in_count, default: 0, null: false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
end
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250912151347_add_last_crawl_date.rb | Ruby | apache-2.0 | 46 | main | 401 | class AddLastCrawlDate < ActiveRecord::Migration[8.0]
def up
add_column :documents, :last_crawl_date, :datetime
change_column_default :documents, :document_status, from: nil, to: Document::DOCUMENT_STATUS_ACTIVE
end
def down
remove_column :documents, :last_crawl_date
change_column_default :docume... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250203181754_create_sites.rb | Ruby | apache-2.0 | 46 | main | 262 | class CreateSites < ActiveRecord::Migration[8.0]
def change
create_table :sites do |t|
t.string :name
t.string :location
t.string :primary_url
t.references :user, null: false, foreign_key: true
t.timestamps
end
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250203181826_create_documents.rb | Ruby | apache-2.0 | 46 | main | 861 | class CreateDocuments < ActiveRecord::Migration[8.0]
def change
create_table :documents do |t|
t.text :file_name
t.text :url
t.integer :file_size
t.text :source
t.string :status
t.string :document_status, default: "discovered"
t.string :document_category, default: "Unknow... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250807171517_create_feedback_items.rb | Ruby | apache-2.0 | 46 | main | 370 | class CreateFeedbackItems < ActiveRecord::Migration[8.0]
def change
create_table :feedback_items do |t|
t.text :sentiment
t.text :comment
t.references :document_inference, null: true, foreign_key: {on_delete: :cascade}
t.references :user, null: true
t.timestamps
end
end
def ... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250411210519_remove_category_default_value.rb | Ruby | apache-2.0 | 46 | main | 308 | class RemoveCategoryDefaultValue < ActiveRecord::Migration[8.0]
def change
change_column_default(:documents, :document_category, nil)
change_column_null :documents, :document_category, false
change_column_default(:documents, :accessibility_recommendation, Document::DEFAULT_DECISION)
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250219154113_add_object_changes_to_versions.rb | Ruby | apache-2.0 | 46 | main | 454 | # This migration adds the optional `object_changes` column, in which PaperTrail
# will store the `changes` diff for each update event. See the readme for
# details.
class AddObjectChangesToVersions < ActiveRecord::Migration[8.0]
# The largest text column available in all supported RDBMS.
# See `create_versions.rb` ... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250822152152_add_llm_details_document_inference.rb | Ruby | apache-2.0 | 46 | main | 218 | class AddLlmDetailsDocumentInference < ActiveRecord::Migration[8.0]
def change
add_column :document_inferences, :inference_model_name, :string
add_column :document_inferences, :token_details, :json
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250403192757_add_unique_key_to_document_inferences.rb | Ruby | apache-2.0 | 46 | main | 291 | class AddUniqueKeyToDocumentInferences < ActiveRecord::Migration[8.0]
def up
remove_column :documents, :summary
end
def change
add_index :document_inferences, [:document_id, :inference_type], unique: true
end
def down
add_column :documents, :summary, :text
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | db/migrate/20250710152639_add_sessions_table.rb | Ruby | apache-2.0 | 46 | main | 286 | class AddSessionsTable < ActiveRecord::Migration[8.0]
def change
create_table :sessions do |t|
t.string :session_id, null: false
t.text :data
t.timestamps
end
add_index :sessions, :session_id, unique: true
add_index :sessions, :updated_at
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/channels/application_cable/connection.rb | Ruby | apache-2.0 | 46 | main | 367 | module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
set_current_user || reject_unauthorized_connection
end
private
def set_current_user
if (session = Session.find_by(id: cookies.signed[:session_id]))
self.current_u... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/services/aws_lambda_manager.rb | Ruby | apache-2.0 | 46 | main | 1,907 | class AwsLambdaManager
def initialize(region: "us-east-1", function_name: nil, function_url: nil)
@region = region
if function_name.nil? && function_url.nil?
raise StandardError, "Lambda manager must be instantiated with either a function_name or function_url."
end
@function_name = function_name... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/services/aws_s3_manager.rb | Ruby | apache-2.0 | 46 | main | 1,353 | class AwsS3Manager
def initialize
@s3_client = if Rails.env.development? || Rails.env.test?
Aws::S3::Client.new(
endpoint: "http://localhost:4566",
account_id: "none",
access_key_id: "none",
secret_access_key: "none",
region: "us-east-1",
force_path_style: tru... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/services/aws_local_secret_manager.rb | Ruby | apache-2.0 | 46 | main | 983 | class AwsLocalSecretManager
def initialize
@secret_manager = Aws::SecretsManager::Client.new(
endpoint: "http://localhost:4566",
account_id: "none",
access_key_id: "none",
secret_access_key: "none",
region: "us-east-1"
)
end
def get_secret!(secret_name)
@secret_manager.g... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/helpers/application_helper.rb | Ruby | apache-2.0 | 46 | main | 1,345 | module ApplicationHelper
include ActionView::Helpers::AssetUrlHelper
include ActionView::Helpers::AssetTagHelper
def document_source(source)
return {text: "", url: nil} unless source
# Store original URL
url = source.strip
# Format the display text
begin
uri = URI.parse(url)
# G... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/models/document_inference.rb | Ruby | apache-2.0 | 46 | main | 1,251 | class DocumentInference < ApplicationRecord
INFERENCE_TYPES = {
summary: {
label: "Summary"
},
"exception:is_archival": {
label: "Archived web content",
url: "https://www.ada.gov/resources/2024-03-08-web-rule/#1-archived-web-content"
},
"exception:is_application": {
label: ... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/models/site.rb | Ruby | apache-2.0 | 46 | main | 15,087 | class Site < ApplicationRecord
DEPARTMENT_MAPPING = {
"Information management Services" => [
"slc.gov/ims/",
"slcdocs.com/ims"
],
"Finance" => [
"slc.gov/Finance",
"slcdocs.com/finance"
],
"City Attorney's Office" => [
"slc.gov/attorney",
"slcdocs.com/attorney"
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/models/feedback_item.rb | Ruby | apache-2.0 | 46 | main | 212 | class FeedbackItem < ApplicationRecord
SENTIMENT_TYPES = %w[positive negative]
belongs_to :document_inference
belongs_to :user
validates :sentiment, inclusion: {in: SENTIMENT_TYPES}, presence: true
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/models/document.rb | Ruby | apache-2.0 | 46 | main | 10,437 | class Document < ApplicationRecord
DEFAULT_DECISION = "Needs Decision".freeze
IN_REVIEW_DECISION = "In Review".freeze
DONE_DECISION = "Done".freeze
ARCHIVE_DECISION = "Archive".freeze
REMOVE_DECISION = "Remove".freeze
CONVERT_DECISION = "Convert".freeze
REMEDIATE_DECISION = "Remediate".freeze
LEAVE_DECI... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/models/user.rb | Ruby | apache-2.0 | 46 | main | 598 | class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable, :trackable
belongs_to :site, optional: true
has_many :feedback_item
delegate :documents, to: :site, allow_nil: true
attr_accessor :resend_invitation
scope :by_email, ->(email) {
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/configurations_controller.rb | Ruby | apache-2.0 | 46 | main | 2,721 | class ConfigurationsController < AuthenticatedController
include Access
before_action :ensure_user_site_admin
def initialize
super
@config = {
google_ai_api_key: nil,
anthropic_api_key: nil,
openai_api: nil,
google_evaluation_service_account_credentials: nil,
google_evaluat... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/documents_controller.rb | Ruby | apache-2.0 | 46 | main | 8,899 | class DocumentsController < AuthenticatedController
include Access
include ParamsHelper
protect_from_forgery with: :exception
skip_before_action :verify_authenticity_token, only: [:update_document_category, :update_accessibility_recommendation, :update_notes, :update_summary_inference, :update_recommendation_i... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/sites_controller.rb | Ruby | apache-2.0 | 46 | main | 2,330 | class SitesController < AuthenticatedController
include Access
include ParamsHelper
before_action :find_site, only: [:show, :edit, :update, :destroy, :create_workflow_audit_report, :workflow_audit_report]
before_action :ensure_user_site_access, only: [:show, :edit, :update, :destroy, :workflow_audit_report]
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/feedback_items_controller.rb | Ruby | apache-2.0 | 46 | main | 921 | class FeedbackItemsController < ApplicationController
wrap_parameters false
def update_feedback_items
begin
batch_params["feedback_items"].each do |patched_item|
item = FeedbackItem.where(document_inference_id: patched_item["document_inference_id"], user_id: patched_item["user_id"]).first_or_creat... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/concerns/access.rb | Ruby | apache-2.0 | 46 | main | 950 | module Access
def ensure_user_site_admin
unless current_user.present? && current_user.is_site_admin?
redirect_to sites_path, alert: "You don't have permission to access that page."
end
end
def ensure_user_is_user_admin
unless current_user.present? && current_user.is_user_admin?
redirect_t... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/users/sessions_controller.rb | Ruby | apache-2.0 | 46 | main | 773 | # frozen_string_literal: true
class Users::SessionsController < Devise::SessionsController
layout "centered"
def new
flash.clear
super
end
def create
self.resource = warden.authenticate(auth_options)
if resource
set_flash_message!(:notice, :signed_in)
sign_in(resource_name, resour... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/users/passwords_controller.rb | Ruby | apache-2.0 | 46 | main | 585 | # frozen_string_literal: true
class Users::PasswordsController < Devise::PasswordsController
layout "centered"
def create
self.resource = resource_class.send_reset_password_instructions(resource_params)
set_flash_message! :notice, :send_paranoid_instructions
resource.email = nil
redirect_back(fall... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/controllers/admin/users_controller.rb | Ruby | apache-2.0 | 46 | main | 2,725 | class Admin::UsersController < ApplicationController
include Access
before_action :ensure_user_is_user_admin
before_action :set_user, only: [:edit, :update]
before_action :site_list, only: [:new, :create, :edit, :update]
before_action :set_minimum_password_length, only: [:new, :edit, :update]
def index
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/jobs/example_job.rb | Ruby | apache-2.0 | 46 | main | 282 | class ExampleJob < ApplicationJob
queue_as :default
def perform(*args)
# Add your job logic here
Rails.logger.info "ExampleJob performed with arguments: #{args.inspect}"
sleep 2 # Simulate some work being done
Rails.logger.info "ExampleJob completed"
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/mailers/application_mailer.rb | Ruby | apache-2.0 | 46 | main | 328 | class ApplicationMailer < Devise::Mailer
layout "mailer"
helper :application
def new_account_instructions(record, token)
@token = token
@resource = record
mail(to: @resource.email, subject: "Welcome to the Code for America PDF Accessibility App! Set up your account", template_path: "users/mailer")
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | app/api/asap_pdf/api.rb | Ruby | apache-2.0 | 46 | main | 5,687 | require "grape"
require "grape-swagger"
module AsapPdf
class API < Grape::API::Instance
format :json
http_basic do |email, password|
@user = User.find_by(email: email)
@user&.valid_password?(password)
end
rescue_from ActiveRecord::RecordNotFound do |e|
error!({error: e.message}, 4... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | lib/tasks/users.rake | Ruby | apache-2.0 | 46 | main | 432 | namespace :users do
desc "Create admin user with specified password (usage: rake users:create_admin[email, password])"
task :create_admin, [:email, :password] => :environment do |t, args|
User.find_or_create_by!(email: args.email) do |user|
user.password = args.password
user.is_site_admin = true
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | lib/tasks/documents.rake | Ruby | apache-2.0 | 46 | main | 5,023 | require "zip"
namespace :documents do
desc "Bootstrap"
task bootstrap: :environment do |t, args|
User.first
# Create Salt Lake City site
slc = Site.find_or_create_by!(
name: "SLC.gov",
location: "Salt Lake City, UT",
primary_url: "https://www.slc.gov/"
)
puts "Created site: #{... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/spec_helper.rb | Ruby | apache-2.0 | 46 | main | 470 | require "shoulda/matchers"
require "factory_bot_rails"
require "capybara/rspec"
require "capybara/email/rspec"
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.ver... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/rails_helper.rb | Ruby | apache-2.0 | 46 | main | 2,412 | require "spec_helper"
ENV["RAILS_ENV"] ||= "test"
ENV["RAILS_ENV"] = "test" if ENV["RAILS_ENV"] == "development"
require_relative "../config/environment"
abort("The Rails environment is running in production mode!") if Rails.env.production?
require "rspec/rails"
require "rails-controller-testing"
require "shoulda/match... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/factories/documents.rb | Ruby | apache-2.0 | 46 | main | 264 | FactoryBot.define do
factory :document do
file_name { "example.pdf" }
url { "http://example.com/example.pdf" }
document_status { "Active" }
document_category { "Brochure" }
number_of_images { 0 }
number_of_tables { 0 }
site
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/factories/sites.rb | Ruby | apache-2.0 | 46 | main | 237 | FactoryBot.define do
factory :site do
name { "Example Site #{(0...8).map { rand(65..90).chr }.join}" }
location { "Example Location" }
primary_url { "http://#{(0...8).map { rand(65..90).chr }.join}.example.com" }
end
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/factories/document_inferences.rb | Ruby | apache-2.0 | 46 | main | 327 | FactoryBot.define do
factory :document_inference do
creation_date { Time.current }
inference_type { "exception:is_application" }
inference_value { "True" }
inference_confidence { 0.85 }
inference_reason { "This is an event flyer for a for a croquet party." }
is_active { true }
document
e... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/tasks/document_tasks.rb | Ruby | apache-2.0 | 46 | main | 3,911 | require "rails_helper"
describe "rake documents:import_documents", type: :rake do
let(:site) { create(:site, primary_url: "https://www.city.org") }
it "imports the documents" do
expect { Rake::Task["documents:import_documents"].invoke(site.id, "spec/fixtures/documents/slc_fixtures/salt_lake_city.csv", true) }... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/helpers/user.rb | Ruby | apache-2.0 | 46 | main | 317 | module AuthHelpers
def login_user(user)
visit "/users/sign_in"
within("#new_user") do
fill_in "Email", with: user.email
fill_in "Password", with: user.password
end
click_button "Log in"
sleep(1)
end
end
RSpec.configure do |config|
config.include AuthHelpers, type: :feature
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/helpers/mail.rb | Ruby | apache-2.0 | 46 | main | 265 | module MailHelpers
def wait_for_mail_delivery
Timeout.timeout(5) do
loop do
break if ActionMailer::Base.deliveries.any?
sleep(0.1)
end
end
end
end
RSpec.configure do |config|
config.include MailHelpers, type: :feature
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/helpers/application_helper_spec.rb | Ruby | apache-2.0 | 46 | main | 1,956 | require "rails_helper"
RSpec.describe ApplicationHelper, type: :helper do
describe "#document_source" do
it "returns empty text and nil url for nil source" do
expect(helper.document_source(nil)).to eq({text: "", url: nil})
end
it "formats a single source URL for display" do
url = "https://ww... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/requests/sites_controller_spec.rb | Ruby | apache-2.0 | 46 | main | 2,232 | require "rails_helper"
RSpec.describe SitesController, type: :request do
include Warden::Test::Helpers
describe "GET workflow_audit_report" do
let(:site) { create(:site) }
let(:bucket_name) { "test-bucket" }
let(:file_key) { "reports/audit.csv" }
let(:file_content) { "id,name,status\n1,doc1,comple... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/requests/api/sites_spec.rb | Ruby | apache-2.0 | 46 | main | 5,775 | require "rails_helper"
RSpec.describe AsapPdf::API do
include Rack::Test::Methods
def app
AsapPdf::API
end
def auth_headers user
encoded_credentials = ActionController::HttpAuthentication::Basic.encode_credentials(user.email, "password")
{"HTTP_AUTHORIZATION" => encoded_credentials}
end
let!... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/models/document_spec.rb | Ruby | apache-2.0 | 46 | main | 4,650 | require "rails_helper"
RSpec.describe Document, type: :model do
it { should belong_to(:site) }
describe "#file_name" do
let(:document) { Document.new(document_category: "Brochure") }
it { should validate_presence_of(:file_name) }
it "handles file names with special characters" do
document.file_n... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/models/site_spec.rb | Ruby | apache-2.0 | 46 | main | 614 | require "rails_helper"
RSpec.describe Site, type: :model do
subject { build(:site) }
it { is_expected.to have_many(:users) }
it { is_expected.to have_many(:documents) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:location) }
it { is_expected.to validate_pre... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/models/user_spec.rb | Ruby | apache-2.0 | 46 | main | 520 | require "rails_helper"
RSpec.describe User, type: :model do
before do
create(:user, email: "test@example.com")
end
it { is_expected.to belong_to(:site).optional(true) }
it { is_expected.to delegate_method(:documents).to(:site).allow_nil }
it { is_expected.to validate_presence_of(:email) }
it { is_exp... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/features/admin_spec.rb | Ruby | apache-2.0 | 46 | main | 6,363 | require "rails_helper"
describe "admins can see admin pages", js: true, type: :feature do
before :each do
Site.create(location: "Colorado", name: "City and County of Denver", primary_url: "https://www.denver.gov")
@current_user = User.create(email: "user@example.com", password: "password")
login_user(@cu... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/features/site_spec.rb | Ruby | apache-2.0 | 46 | main | 3,459 | require "rails_helper"
describe "sites function as expected", type: :feature do
before :each do
@current_user = User.create(email: "user@example.com", password: "password")
login_user(@current_user)
end
it "admins can create and see sites" do
visit "/"
expect(page).to have_no_content("Add New Si... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/features/document_spec.rb | Ruby | apache-2.0 | 46 | main | 34,482 | require "rails_helper"
describe "documents function as expected", js: true, type: :feature do
before :each do
@current_user = User.create(email: "user@example.com", password: "password1231231232wordpass")
login_user(@current_user)
end
it "documents belong to a site and may be manipulated" do
page.dr... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | spec/features/login_spec.rb | Ruby | apache-2.0 | 46 | main | 1,989 | require "rails_helper"
describe "users may log into the site", js: true, type: :feature do
before :each do
@current_user = User.create(email: "user@example.com", password: "password12345")
end
it "email and password are authenticated" do
visit "/users/sign_in"
expect(page).to have_selector "#new_use... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/application.rb | Ruby | apache-2.0 | 46 | main | 984 | require_relative "boot"
require "rails"
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railt... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/routes.rb | Ruby | apache-2.0 | 46 | main | 1,494 | Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: "users/sessions",
passwords: "users/passwords",
registrations: "users/registrations"
}
# Administrative user paths.
namespace :admin do
resources :users, only: [:index, :new, :create, :edit, :update, :show]
end
get... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/environments/development.rb | Ruby | apache-2.0 | 46 | main | 1,839 | require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = true
config.eager_load = false
config.consider_all_requests_local = true
config.server_timing = true
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true
... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/environments/staging.rb | Ruby | apache-2.0 | 46 | main | 1,668 | require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = false
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.public_file_server.headers = {"cache-control" => "public, max-age=#{1.year... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/environments/production.rb | Ruby | apache-2.0 | 46 | main | 1,642 | require "active_support/core_ext/integer/time"
Rails.application.configure do
config.enable_reloading = false
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.public_file_server.headers = {"cache-control" => "public, max-age=#{1.year... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/environments/test.rb | Ruby | apache-2.0 | 46 | main | 1,325 | Rails.application.configure do
config.enable_reloading = false
config.eager_load = ENV["CI"].present?
config.public_file_server.headers = {"cache-control" => "public, max-age=3600"}
config.consider_all_requests_local = true
config.cache_store = :null_store
config.action_dispatch.show_exceptions = :rescua... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/initializers/filter_parameter_logging.rb | Ruby | apache-2.0 | 46 | main | 474 | # Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behavio... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/initializers/time_formats.rb | Ruby | apache-2.0 | 46 | main | 468 | Time::DATE_FORMATS[:display_time] = "%b %-d %l:%M%P"
Time::DATE_FORMATS[:display_date] = "%b %-d, %Y"
Time::DATE_FORMATS[:display_full] = "%b %-d, %Y %l:%M%P"
Time::DATE_FORMATS[:display_time_only] = "%l:%M%P"
Time::DATE_FORMATS[:display_date_only] = "%b %-d"
Time::DATE_FORMATS[:display_day_date_time] = "%A: %b %-d, %Y... |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/initializers/kaminari.rb | Ruby | apache-2.0 | 46 | main | 312 | Kaminari.configure do |config|
config.default_per_page = 25
config.window = 2 # Shows 2 pages on each side of current page
config.outer_window = 1 # Shows 1 page at the beginning and end
config.left = 1 # Shows 1 page to the left
config.right = 1 # Shows 1 page to the right
end |
github | codeforamerica/asap_pdf | https://github.com/codeforamerica/asap_pdf | config/initializers/devise.rb | Ruby | apache-2.0 | 46 | main | 15,444 | # frozen_string_literal: true
# Assuming you have not yet modified this file, each configuration option below
# is set to its default value. Note that some are commented out while others
# are not: uncommented lines are intended to protect your configuration from
# breaking changes in upgrades (i.e., in the event that... |
github | m-ender/alice | https://github.com/m-ender/alice | state.rb | Ruby | mit | 47 | master | 7,470 | # coding: utf-8
require_relative 'mode'
require_relative 'point2d'
require_relative 'direction'
class State
# I'm sorry.
attr_accessor :in_str, :out_str, :args, :max_ticks,
:grid, :height, :width,
:ip, :dir, :storage_offset,
:stack, :tape, :rp, :mp... |
github | m-ender/alice | https://github.com/m-ender/alice | alice.rb | Ruby | mit | 47 | master | 2,369 | # coding: utf-8
Encoding.default_internal = Encoding::UTF_8
Encoding.default_external = Encoding::UTF_8
require_relative 'state'
# Add stable sorting methods to Enumerable
module Enumerable
def stable_sort
sort_by.with_index { |x, idx| [x, idx] }
end
def stable_sort_by
sort_by.with_index { |x, idx| [y... |
github | m-ender/alice | https://github.com/m-ender/alice | interpreter.rb | Ruby | mit | 47 | master | 381 | #!ruby --encoding utf-8:utf-8
# coding: utf-8
require_relative 'alice'
if ARGV.size == 0
puts "Usage: ruby interpreter.rb source.alice [args ...]"
else
source = File.read(ARGV.shift)
alice = Alice.new(source)
begin
alice.run
rescue => e
alice.state.print_debug_info
$stder... |
github | m-ender/alice | https://github.com/m-ender/alice | direction.rb | Ruby | mit | 47 | master | 3,491 | require_relative 'point2d'
class North
def right() East.new end
def left() West.new end
def reverse() South.new end
def vec() Point2D.new(0,-1) end
def reflect(mirror)
case mirror
when '/'; SouthWest.new
when '\\'; SouthEast.new
when '_'; South.new
when... |
github | m-ender/alice | https://github.com/m-ender/alice | mode.rb | Ruby | mit | 47 | master | 33,465 | # coding: utf-8
require_relative 'point2d'
require_relative 'direction'
require 'prime'
require 'date'
class Mode
# List of operators which should not be ignored while in string mode.
STRING_CMDS = "\"'\\/_|"
def initialize(state)
@state = state
end
def is_char? val
val && (val ... |
github | m-ender/alice | https://github.com/m-ender/alice | point2d.rb | Ruby | mit | 47 | master | 879 | class Point2D
attr_accessor :x, :y
def initialize(x, y)
@x = x
@y = y
end
def self.from_string(string)
coords = string.split.map(&:to_i)
Point2D.new(coords[0], coords[1])
end
def +(other)
if other.is_a?(Point2D)
return Point2D.new(@x+other.x... |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | metadata.rb | Ruby | apache-2.0 | 46 | main | 514 | # frozen_string_literal: true
name 'ufw'
maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
license 'Apache-2.0'
description 'Provides the ufw_firewall resource for managing Uncomplicated Firewall rules'
version '4.0.10'
source_url 'https://github.com/s... |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | libraries/helpers.rb | Ruby | apache-2.0 | 46 | main | 3,196 | # frozen_string_literal: true
module UfwCookbook
module Helpers
SECURITY_LEVEL_ROLE_PATTERN = /SecurityLevel-(Red|Green|Yellow)/.freeze unless const_defined?(:SECURITY_LEVEL_ROLE_PATTERN)
def merged_rules(*rule_sets)
rule_sets.compact.reduce({}) do |combined, raw_rules|
combined.merge(normaliz... |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | test/cookbooks/test/recipes/default.rb | Ruby | apache-2.0 | 46 | main | 231 | # frozen_string_literal: true
ufw_firewall 'default' do
rules(
[
{ 'web' => { 'port' => '8080' } },
{ 'deny-udp' => { 'port' => '8081', 'protocol' => 'udp', 'action' => 'deny' } },
]
)
action :create
end |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | test/integration/default/controls/default_spec.rb | Ruby | apache-2.0 | 46 | main | 763 | # frozen_string_literal: true
require_relative '../../spec_helper'
control 'ufw-package-01' do
impact 1.0
title 'The ufw package is installed'
describe package('ufw') do
it { should be_installed }
end
end
control 'ufw-service-01' do
impact 1.0
title 'The ufw service is enabled'
describe service('... |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | examples/roles/fw_example.rb | Ruby | apache-2.0 | 46 | main | 620 | name 'fw_example'
description 'Firewall rules for Examples'
override_attributes(
'firewall' => {
'rules' => [
{ 'tftp' => {} },
{ 'http' => {
'port' => '80',
},
},
{ 'block tomcat from 192.168.1.0/24' => {
'port' => '8080',
'source' => '192.168.1.0/24',
... |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | resources/ufw_firewall.rb | Ruby | apache-2.0 | 46 | main | 3,279 | # frozen_string_literal: true
provides :ufw_firewall
unified_mode true
property :firewall_name, String, name_property: true
property :rules, [Array, Hash], default: {}
property :allow_ssh, [true, false], default: true
property :data_bag_name, [String, nil], desired_state: false
property :collect_recipe_rules, [true, ... |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | spec/unit/resources/ufw_firewall_spec.rb | Ruby | apache-2.0 | 46 | main | 1,269 | # frozen_string_literal: true
require 'spec_helper'
describe 'ufw_firewall' do
step_into :ufw_firewall
platform 'ubuntu', '24.04'
default_attributes['firewall'] = { 'solution' => 'ufw' }
context 'with explicit rules' do
recipe do
ufw_firewall 'default' do
rules(
[
{ 'h... |
github | sous-chefs/ufw | https://github.com/sous-chefs/ufw | spec/unit/libraries/helpers_spec.rb | Ruby | apache-2.0 | 46 | main | 1,642 | # frozen_string_literal: true
require 'spec_helper'
require_relative '../../../libraries/helpers' unless defined?(UfwCookbook::Helpers)
describe UfwCookbook::Helpers do
subject(:helper_host) do
Class.new do
include UfwCookbook::Helpers
end.new
end
describe '#normalized_rules' do
it 'normalize... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | rspec-hanami.gemspec | Ruby | mit | 46 | master | 1,080 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rspec/hanami/version'
Gem::Specification.new do |spec|
spec.name = "rspec-hanami"
spec.version = RSpec::Hanami::VERSION
spec.authors = ["Anton Davydov"]
spec.email ... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | Rakefile | Ruby | mit | 46 | master | 254 | require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList['test/**/*_test.rb']
end
task default: :spec
desc 'run Rspec specs'
task :spec do
sh 'rspec spec'
end |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/spec_helper.rb | Ruby | mit | 46 | master | 221 | require 'coveralls'
Coveralls.wear!
# $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'rspec/hanami'
require 'rspec/support/spec'
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami_spec.rb | Ruby | mit | 46 | master | 843 | require 'rspec/support/spec/library_wide_checks'
require 'spec_helper'
RSpec.describe "RSpec::Hanami" do
include RSpec::Support::WhitespaceChecks
# Pasted from rspec-support lib/rspec/support/spec/library_wide_checks.rb:134
# Easier to do that here than to extract it out
RSpec::Matchers.define :be_well_formed... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/request_spec.rb | Ruby | mit | 46 | master | 1,213 | require 'spec_helper'
require 'rspec/hanami/request_helpers'
RSpec.describe RSpec::Hanami::RequestHelpers::Request do
describe '#env' do
[['GET', '/', {}],
['POST', '/users', {}],
['PATCH', '/posts', {}],
['PUT', '/comments', {}],
['DELETE', '/tags', {}]].each do |m... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/match_status_spec.rb | Ruby | mit | 46 | master | 2,442 | require 'spec_helper'
require 'rspec/hanami/match_status'
RSpec.describe RSpec::Hanami::MatchStatus do
SUCCESS_STATUSES = [200, 201, 202, 203, 204]
ERROR_STATUSES = [400, 401, 402, 403, 404]
SERVER_ERROR_STATUSES = [500, 501, 502, 503, 502, 503]
REDIRECTION_STATUSES = [301, 302, 303, 304]
let(:... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/form_presenter_spec.rb | Ruby | mit | 46 | master | 2,224 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe RSpec::Hanami::FormPresenter do
let(:form_html_string) {
<<~FORM
<form action="/users" method="POST" accept-charset="utf-8" id="user-form">
<label for="password-reset-email">Email</label>
<input type="text" id="user-first-... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/form_parser_spec.rb | Ruby | mit | 46 | master | 1,600 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe RSpec::Hanami::FormParser do
let(:parser) { RSpec::Hanami::FormParser.new }
let(:form_html_string) do
<<~FORM
<form action="/users" method="POST" accept-charset="utf-8" id="user-form">
<label for="password-reset-email">Email</la... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/matchers/include_json_spec.rb | Ruby | mit | 46 | master | 485 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe "include_json" do
include RSpec::Hanami::Matchers
let(:params) { {} }
context 'for JsonAction' do
let(:action) { JsonAction.new }
it "return true" do
response = action.call(params)
expect(response).to include_json(user: {... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/matchers/be_status_spec.rb | Ruby | mit | 46 | master | 798 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe "be matchers" do
include RSpec::Hanami::Matchers
let(:params) { {} }
describe '#be_success' do
context 'for SuccessfulAction' do
let(:action) { SuccessfulAction.new }
it "return true" do
response = action.call(params)... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/matchers/form_matchers_spec.rb | Ruby | mit | 46 | master | 1,996 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe 'form matchers' do
include RSpec::Hanami::Matchers
let(:view) { MainView.new }
describe '#have_form_action' do
context 'for form with right action' do
it 'return true' do
expect(view.form).to have_form_action('/users')
... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/matchers/redirect_to_spec.rb | Ruby | mit | 46 | master | 864 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe "be matchers" do
include RSpec::Hanami::Matchers
let(:params) { {} }
let(:site) { 'http://example.com/' }
describe '#be_success' do
context 'for SuccessfulAction' do
let(:action) { SuccessfulAction.new }
it "return true" ... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/matchers/have_http_status_spec.rb | Ruby | mit | 46 | master | 4,597 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe "have_http_status" do
include RSpec::Hanami::Matchers
let(:params) { {} }
describe 'with a successful number status' do
context 'for SuccessfulAction' do
let(:action) { SuccessfulAction.new }
it "return true" do
respo... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/matchers/match_in_body_spec.rb | Ruby | mit | 46 | master | 572 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe 'match_in_body' do
include RSpec::Hanami::Matchers
let(:params) { {} }
context 'for SuccessfulAction' do
let(:action) { SuccessfulAction.new }
it { expect(action.call(params)).to match_in_body('Hi') }
it { expect(action.call(param... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/rspec/hanami/matchers/match_entity_schema_spec.rb | Ruby | mit | 46 | master | 874 | require 'spec_helper'
require 'rspec/hanami/matchers'
RSpec.describe 'match_entity_schema' do
include RSpec::Hanami::Matchers
let(:entity) { UserEntity.new(id: 1, name: 'whatever', gender: true) }
describe 'pass with success' do
context 'for UserEntity single parameter' do
it { expect(entity).to have... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/support/views.rb | Ruby | mit | 46 | master | 690 | require 'hanami/controller'
require 'hanami/helpers'
require 'hanami/view'
class MainView
include Hanami::Helpers::FormHelper
def params
{}
end
def form
form_for :user, '/users' do
input type: 'text', id: 'user-first-name', name: 'user[first_name]', value: 'L'
check_box :free_shipping
... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | spec/support/actions.rb | Ruby | mit | 46 | master | 593 | require 'json'
require 'hanami-controller'
class SuccessfulAction
include Hanami::Action
def call(params)
self.status = 200
self.body = "Hi! It's successful"
end
end
class FailedAction
include Hanami::Action
def call(params)
self.status = 404
self.body = "Hi! It's failed"
end
end... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | lib/rspec/hanami/form_presenter.rb | Ruby | mit | 46 | master | 410 | require 'hanami/utils/hash'
module RSpec
module Hanami
class FormPresenter
def call(form_data)
stringify = form_data.map(&:to_h).map(&:to_s)
indentify = stringify.map.with_index do |value, index|
value = " " + value if index > 0
value = " " + value if value.match(/opti... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | lib/rspec/hanami/matchers.rb | Ruby | mit | 46 | master | 630 | require 'rspec/core/warnings'
require 'rspec/expectations'
require 'rspec/hanami/form_parser'
require 'rspec/hanami/form_presenter'
require 'rspec/hanami/match_status'
require 'rspec/hanami/match_type'
require 'rspec/hanami/matchers/have_http_status'
require 'rspec/hanami/matchers/match_in_body'
require 'rspec/hanami/m... |
github | davydovanton/rspec-hanami | https://github.com/davydovanton/rspec-hanami | lib/rspec/hanami/request_helpers.rb | Ruby | mit | 46 | master | 2,359 | module RSpec
module Hanami
module RequestHelpers
class Request
def initialize(method, path, options)
@path, @query_string = path.split('?', 2)
@method = method
@params = options[:params]
@headers = options[:headers] || {}
end
def env
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.