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 | antiwork/gumroad | https://github.com/antiwork/gumroad | db/migrate/20230821194317_create_seller_profile_sections.rb | Ruby | mit | 8,966 | main | 406 | # frozen_string_literal: true
class CreateSellerProfileSections < ActiveRecord::Migration[7.0]
def change
create_table :seller_profile_sections do |t|
t.references :seller, index: true, null: false
t.string :header
t.text :shown_products, null: false
t.boolean :show_filters, null: false
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/migrate/20120426001944_add_index_to_stripe_finger_print.rb | Ruby | mit | 8,966 | main | 229 | # frozen_string_literal: true
class AddIndexToStripeFingerPrint < ActiveRecord::Migration
def up
add_index :credit_cards, :stripe_fingerprint
end
def down
remove_index :credit_cards, :stripe_fingerprint
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/migrate/20140605195555_create_purchase_codes.rb | Ruby | mit | 8,966 | main | 434 | # frozen_string_literal: true
class CreatePurchaseCodes < ActiveRecord::Migration
def change
create_table :purchase_codes, options: "DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci" do |t|
t.string :token
t.datetime :used_at
t.datetime :expires_at
t.integer :url_redirect_id
t.ti... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_paypal_merchant_account_seeds.rb | Ruby | mit | 8,966 | main | 386 | # frozen_string_literal: true
# Create the shared PayPal merchant accounts
if MerchantAccount.gumroad(PaypalChargeProcessor.charge_processor_id).nil?
paypal_merchant_account = MerchantAccount.new
paypal_merchant_account.charge_processor_id = PaypalChargeProcessor.charge_processor_id
paypal_merchant_account.charg... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/010_stripe_merchant_account_seeds.rb | Ruby | mit | 8,966 | main | 324 | # frozen_string_literal: true
# Create the shared Stripe merchant account
if MerchantAccount.gumroad(StripeChargeProcessor.charge_processor_id).nil?
merchant_account_stripe = MerchantAccount.new
merchant_account_stripe.charge_processor_id = StripeChargeProcessor.charge_processor_id
merchant_account_stripe.save!
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_braintree_merchant_account_seeds.rb | Ruby | mit | 8,966 | main | 447 | # frozen_string_literal: true
# Create the shared Braintree merchant accounts
if MerchantAccount.gumroad(BraintreeChargeProcessor.charge_processor_id).nil?
merchant_account_braintree = MerchantAccount.new
merchant_account_braintree.charge_processor_id = BraintreeChargeProcessor.charge_processor_id
merchant_accou... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/eu_tax_rates.rb | Ruby | mit | 8,966 | main | 4,800 | # frozen_string_literal: true
ZipTaxRate.find_or_create_by(country: "AT").update(combined_rate: 0.20)
ZipTaxRate.find_or_create_by(country: "BE").update(combined_rate: 0.21)
ZipTaxRate.find_or_create_by(country: "BG").update(combined_rate: 0.20)
ZipTaxRate.find_or_create_by(country: "CZ").update(combined_rate: 0.21)
Z... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/taxonomy_products.rb | Ruby | mit | 8,966 | main | 3,777 | # frozen_string_literal: true
def find_or_create_recommendable_user(category_name)
user = User.find_by(email: "gumbo_#{category_name}@gumroad.com")
return user if user
user = User.create!(
name: "Gumbo #{category_name}",
username: "gumbo#{category_name}",
email: "gumbo_#{category_name}@gumroad.com",... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/02_products.rb | Ruby | mit | 8,966 | main | 380 | # frozen_string_literal: true
product = Link.fetch("demo")
if product.blank?
# Demo product used on /widgets page for non-logged in users
seller = User.find_by(email: "seller@gumroad.com")
seller.products.create!(
name: "Beautiful widget",
unique_permalink: "demo",
description: "Description for demo ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/tax_rates_for_countries_that_collect_on_digital_products.rb | Ruby | mit | 8,966 | main | 2,264 | # frozen_string_literal: true
ZipTaxRate.find_or_create_by(country: "BH").update(combined_rate: 0.10) # Bahrain
ZipTaxRate.find_or_create_by(country: "BY").update(combined_rate: 0.20) # Belarus
ZipTaxRate.find_or_create_by(country: "CL").update(combined_rate: 0.19) # Chile
ZipTaxRate.find_or_create_by(country: "CO").u... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/tax_rates_for_countries_that_collect_on_all_products.rb | Ruby | mit | 8,966 | main | 817 | # frozen_string_literal: true
ZipTaxRate.find_or_create_by(country: "IS").update(combined_rate: 0.24) # Iceland
ZipTaxRate.find_or_create_by(country: "IS", flags: 2).update(combined_rate: 0.11) # Iceland
ZipTaxRate.find_or_create_by(country: "JP").update(combined_rate: 0.10) # Japan
ZipTaxRate.find_or_create_by(countr... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/gumroad_posts.rb | Ruby | mit | 8,966 | main | 2,383 | # frozen_string_literal: true
email = "hi@gumroad.com"
gumroad_user = User.find_by(email:)
if gumroad_user.nil?
gumroad_user = User.new
gumroad_user.email = email
gumroad_user.username = "gumroad"
gumroad_user.confirmed_at = Time.current
gumroad_user.password = SecureRandom.hex(24)
gumroad_user.save!
# ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/01_users.rb | Ruby | mit | 8,966 | main | 1,348 | # frozen_string_literal: true
seller = User.find_by(email: "seller@gumroad.com")
if seller.blank?
seller = User.new
seller.email = "seller@gumroad.com"
seller.name = "Seller"
seller.username = "seller"
seller.confirmed_at = Time.current
seller.is_team_member = true
seller.user_risk_state = "compliant"
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/020_development_staging/sg_tax_rates.rb | Ruby | mit | 8,966 | main | 227 | # frozen_string_literal: true
ZipTaxRate.find_or_create_by(country: "SG", combined_rate: 0.08).update(applicable_years: [2023])
ZipTaxRate.find_or_create_by(country: "SG", combined_rate: 0.09).update(applicable_years: [2024]) |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_staging/mobile_oauth_application.rb | Ruby | mit | 8,966 | main | 770 | # frozen_string_literal: true
mobile_oauth_app = OauthApplication.where(uid: "7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b",
secret: "1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b").first
mobile_oauth_app = OauthApplication.new if mobile... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/010_development_staging_test/taxonomy_create.rb | Ruby | mit | 8,966 | main | 23,401 | # frozen_string_literal: true
return if ENV["SKIP_TAXONOMY_CREATION"] == "1"
return if Taxonomy.where(slug: "3d").exists?
three_d = Taxonomy.find_or_create_by!(slug: "3d")
Taxonomy.find_or_create_by!(slug: "3d-modeling", parent: three_d)
Taxonomy.find_or_create_by!(slug: "character-design", parent: three_d)
Taxonomy.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_development/mobile_app_test_data.rb | Ruby | mit | 8,966 | main | 2,641 | # frozen_string_literal: true
# Used by the mobile app e2e test framework. Logging in as these users may break the test expectations.
def create_mobile_user(email:, name:, username:)
user = User.find_by(email:)
return user if user.present?
user = User.create!(
email:,
name:,
username:,
password... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_development/notion_oauth_application.rb | Ruby | mit | 8,966 | main | 544 | # frozen_string_literal: true
notion_oauth_app = OauthApplication.find_or_initialize_by(name: "Notion (dev)")
if notion_oauth_app.new_record?
notion_oauth_app.owner = User.find_by(email: "seller@gumroad.com") || User.first
notion_oauth_app.scopes = "unfurl"
notion_oauth_app.redirect_uri = "https://www.notion.so... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_development/mobile_oauth_application.rb | Ruby | mit | 8,966 | main | 772 | # frozen_string_literal: true
mobile_oauth_app = OauthApplication.where(uid: "7f3a9b2c1d8e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9",
secret: "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2").first
mobile_oauth_app = OauthApplication.new if mobile_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_development/products.rb | Ruby | mit | 8,966 | main | 2,063 | # frozen_string_literal: true
def load_products
if Rails.env.production?
puts "Shouldn't run product seeds on production"
raise
end
10.times.each do |i|
# create seller
user = User.create!(
name: "Gumbo #{i}",
username: "gumbo#{i}",
email: "gumbo#{i}@gumroad.com",
password... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_development/helper_oauth_application.rb | Ruby | mit | 8,966 | main | 386 | # frozen_string_literal: true
helper_oauth_app = OauthApplication.find_or_initialize_by(name: "Helper (dev)")
if helper_oauth_app.new_record?
helper_oauth_app.owner = User.find_by(email: "seller@gumroad.com") || User.is_team_member.first
helper_oauth_app.scopes = "helper_api"
helper_oauth_app.redirect_uri = "ht... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_development/expo_oauth_application.rb | Ruby | mit | 8,966 | main | 689 | # frozen_string_literal: true
mobile_oauth_app = OauthApplication.where(uid: "MOBILE_DEVELOPMENT_CLIENT_kx3sRpN217qPwqk9s",
secret: "G4ML9OBAzfzQMXt1U5vLve0fflF6Onl_A_SuWdDkrlY").first
mobile_oauth_app = OauthApplication.new if mobile_oauth_app.nil?
mobile_oauth_app.owner = ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | db/seeds/030_development/cli_oauth_application.rb | Ruby | mit | 8,966 | main | 456 | # frozen_string_literal: true
cli_oauth_app = OauthApplication.find_or_initialize_by(uid: "CLI_DEVELOPMENT_CLIENT_pkce_auth")
cli_oauth_app.owner = User.find_by(email: "seller@gumroad.com")
cli_oauth_app.scopes = "edit_products view_sales mark_sales_as_shipped edit_sales view_payouts view_profile account"
cli_oauth_a... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/users_helper.rb | Ruby | mit | 8,966 | main | 554 | # frozen_string_literal: true
module UsersHelper
def allowed_avatar_extensions
User::ALLOWED_AVATAR_EXTENSIONS.map { |extension| ".#{extension}" }.join(",")
end
def signed_in_user_home(user, next_url: nil, include_host: false)
return next_url if next_url.present?
host = UrlService.domain_with_protoc... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/currency_helper.rb | Ruby | mit | 8,966 | main | 5,518 | # frozen_string_literal: true
module CurrencyHelper
include BasePrice::Recurrence
# Note: To reference a currency in code, use Currency::[3-char-ref].
# e.g. Currency::USD, Currency::CAD
def currency_namespace
Redis::Namespace.new(:currencies, redis: $redis)
end
def symbol_for(type = :usd)
curren... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/preorder_helper.rb | Ruby | mit | 8,966 | main | 1,649 | # frozen_string_literal: true
module PreorderHelper
def displayable_release_at_date(release_at, seller_timezone)
release_at_seller_time = release_at_seller_time(release_at, seller_timezone)
release_at_seller_time.to_fs(:formatted_date_full_month)
end
def displayable_release_at_time(release_at, seller_ti... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/mailer_helper.rb | Ruby | mit | 8,966 | main | 1,553 | # frozen_string_literal: true
module MailerHelper
# This regex matches all non-ASCII characters from the Latin script
EXTENDED_LATIN_REGEX = /[\p{InLatin-1_Supplement}|\p{InLatin_Extended-A}|\p{InLatin_Extended-B}]/
# This regex matches if there is a non-ASCII character from the Latin script AND a symbol
EXTEN... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/installment_rule_helper.rb | Ruby | mit | 8,966 | main | 580 | # frozen_string_literal: true
module InstallmentRuleHelper
# Converts duration and period into seconds
#
# Examples
# convert_to_seconds(1, "HOUR")
# #=> 3600
# convert_to_seconds(7, "DAY")
# # => 604800
#
# Returns an integer
def convert_to_seconds(duration, period)
duration = duration... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/button_helper.rb | Ruby | mit | 8,966 | main | 467 | # frozen_string_literal: true
module ButtonHelper
# color options: "success" | "warning" | "info" | "danger" | "primary" | "accent" | "filled"
def navigation_button(body, url, options = {})
disabled = options.delete(:disabled)
color = options.delete(:color) || "accent"
class_names = options.delete(:cla... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/affiliates_helper.rb | Ruby | mit | 8,966 | main | 421 | # frozen_string_literal: true
module AffiliatesHelper
def affiliate_products_select_data(affiliate, products)
tag_ids = products.each_with_object([]) do |product, selected|
selected << product.external_id if affiliate.products.exists? && affiliate.products.include?(product)
end
tag_list = products.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/infos_helper.rb | Ruby | mit | 8,966 | main | 1,106 | # frozen_string_literal: true
module InfosHelper
include ActionView::Helpers::TextHelper
def duration_displayable(duration)
return nil if !duration || duration == 0
time = ""
if duration < 60
return time = (Time.mktime(0) + duration).strftime("0:%S")
elsif duration < 60 * 10
time = (Tim... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/installments_helper.rb | Ruby | mit | 8,966 | main | 257 | # frozen_string_literal: true
module InstallmentsHelper
def post_title_displayable(post:, url: nil)
return content_tag(:span, post.subject, class: "title") unless url.present?
link_to post.subject, url, target: "_blank", class: "title"
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/card_params_helper.rb | Ruby | mit | 8,966 | main | 1,155 | # frozen_string_literal: true
module CardParamsHelper
module_function
# Public: Gets the card data handling mode that's indicated in the card parameters.
# params - the params received containing posted data and the card_data_handling_mode parameter
# Returns: a string indicating the card data handling mode or... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/cdn_url_helper.rb | Ruby | mit | 8,966 | main | 320 | # frozen_string_literal: true
module CdnUrlHelper
def replace_s3_urls_with_cdn_urls(content)
return content if content.blank?
CDN_URL_MAP.each do |origin_regex, cdn_prefix|
content = content.gsub(origin_regex, cdn_prefix)
end
content
end
alias cdn_url_for replace_s3_urls_with_cdn_urls
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/social_share_url_helper.rb | Ruby | mit | 8,966 | main | 362 | # frozen_string_literal: true
module SocialShareUrlHelper
def twitter_url(url, text)
"https://twitter.com/intent/tweet?text=#{CGI.escape(text)}:%20#{url}"
end
def facebook_url(url, text = nil)
share_url = "https://www.facebook.com/sharer/sharer.php?u=#{url}"
share_url += ""e=#{CGI.escape(text)}"... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/payouts_helper.rb | Ruby | mit | 8,966 | main | 8,776 | # frozen_string_literal: true
module PayoutsHelper
include CurrencyHelper
# Payments before this date don't have balances associated with them (pre rolling payouts)
OLDEST_DISPLAYABLE_PAYOUT_PERIOD_END_DATE = Date.parse("2013-01-04")
def formatted_payout_date(payout_date)
return "" if payout_date.nil?
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/application_helper.rb | Ruby | mit | 8,966 | main | 1,025 | # frozen_string_literal: true
module ApplicationHelper
def load_pack(page)
render("shared/pack_setup", page:)
end
def s3_bucket_url
"#{AWS_S3_ENDPOINT}/#{S3_BUCKET}"
end
def default_footer_content
safe_join(
[
"Powered by",
tag.span("Gumroad", class: "inline-block aspect-1... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/signed_url_helper.rb | Ruby | mit | 8,966 | main | 6,092 | # frozen_string_literal: true
module SignedUrlHelper
SIGNED_S3_URL_VALID_FOR_MINIMUM = 10.minutes
SIGNED_S3_URL_VALID_FOR_MAXIMUM = 3.hours
SIGNED_VIDEO_URL_VALID_FOR = 12.hours
# Warning: Changing the value of this will invalidate a lot of cached files in CloudFlare
CF_WORKER_CACHE_KEY = "caIWHGT4Qhqo6KoxD... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/helpers/products_helper.rb | Ruby | mit | 8,966 | main | 4,183 | # frozen_string_literal: true
module ProductsHelper
include CdnUrlHelper
include Pagy::Backend
include CustomDomainConfig
def files_data(product)
product.product_files.alive.in_order.includes(:alive_subtitle_files).map(&:as_json)
end
def file_specific_attributes(product)
{
permalink: produc... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/money_formatter.rb | Ruby | mit | 8,966 | main | 356 | # frozen_string_literal: true
module MoneyFormatter
module_function
def format(amount, currency_type, opts = {})
amount ||= 0
# use the default symbol unless explicitly stated not to use one
opts[:symbol] = CURRENCY_CHOICES[currency_type][:symbol] unless opts[:symbol] == false
Money.new(amount, cu... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase_error_code.rb | Ruby | mit | 8,966 | main | 13,336 | # frozen_string_literal: true
module PurchaseErrorCode
INVALID_NUMBER = "invalid_number"
HIGH_RISK_COUNTRY = "high_risk_country"
PRICE_TOO_HIGH = "price_too_high"
BLOCKED_BROWSER_GUID = "blocked_browser_guid"
BLOCKED_EMAIL_DOMAIN = "blocked_email_domain"
BLOCKED_IP_ADDRESS = "blocked_ip_address"
BLOCKED... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/recommendation_type.rb | Ruby | mit | 8,966 | main | 1,452 | # frozen_string_literal: true
module RecommendationType
GUMROAD_DISCOVER_RECOMMENDATION = "discover"
GUMROAD_SEARCH_RECOMMENDATION = "search"
GUMROAD_RECEIPT_RECOMMENDATION = "receipt"
GUMROAD_LIBRARY_RECOMMENDATION = "library"
GUMROAD_MORE_LIKE_THIS_RECOMMENDATION = "more_like_this"
GUMROAD_PRODUCTS_FOR_Y... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/immutable.rb | Ruby | mit | 8,966 | main | 1,753 | # frozen_string_literal: true
# An immutable ActiveRecord.
# Any model this module is included into will be immutable, except for
# any fields specified using `attr_mutable`.
#
# If you need to change an Immutable you should call `dup_and_save` or `dup_and_save!`.
module Immutable
extend ActiveSupport::Concern
in... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/with_file_properties.rb | Ruby | mit | 8,966 | main | 5,620 | # frozen_string_literal: true
module WithFileProperties
include InfosHelper
MAX_DOWNLOAD_SIZE = 40.gigabytes
def file_info(require_shipping = false)
# One-off for not showing image properties for a physical product.
return {} if filegroup == "image" && require_shipping
attributes = {
Size: s... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/discount_code.rb | Ruby | mit | 8,966 | main | 763 | # frozen_string_literal: true
# DiscountCode is where all discounts for ServiceCharges are kept. They are broken into 2 types:
# cents & percentage just like OfferCodes. There is either an amount directly correlated to the type
# (e.g. type: :percentage, amount: 50 --> 50% off) or a function name which is used to calc... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/with_cdn_url.rb | Ruby | mit | 8,966 | main | 343 | # frozen_string_literal: true
module WithCdnUrl
include CdnUrlHelper
extend ActiveSupport::Concern
class_methods do
def has_cdn_url(*attributes)
attributes.each do |attribute|
define_method attribute do
replace_s3_urls_with_cdn_urls(self.attributes[attribute.to_s])
end
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/with_product_files.rb | Ruby | mit | 8,966 | main | 11,839 | # frozen_string_literal: true
module WithProductFiles
def self.included(base)
base.class_eval do
has_many :product_files
has_many :ordered_alive_product_files, -> { alive.in_order }, class_name: "ProductFile"
has_many :product_files_archives
has_many :product_folders, -> { alive }, foreig... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/lograge_helper.rb | Ruby | mit | 8,966 | main | 377 | # frozen_string_literal: true
module LogrageHelper
def append_info_to_payload(payload)
super
payload[:remote_ip] = request.remote_ip
payload[:uuid] = request.uuid
payload[:headers] = {
"CF-RAY" => request.headers["HTTP_CF_RAY"],
"X-Amzn-Trace-Id" => request.headers["HTTP_X_AMZN_TR... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/cdn_deletable.rb | Ruby | mit | 8,966 | main | 382 | # frozen_string_literal: true
module CdnDeletable
extend ActiveSupport::Concern
included do
scope :alive_in_cdn, -> { where(deleted_from_cdn_at: nil) }
scope :cdn_deletable, -> { s3.deleted.alive_in_cdn }
end
def deleted_from_cdn?
deleted_from_cdn_at.present?
end
def mark_deleted_from_cdn
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/s3_retrievable.rb | Ruby | mit | 8,966 | main | 4,472 | # frozen_string_literal: true
module S3Retrievable
extend ActiveSupport::Concern
GUID_LENGTH = 32
# Use the guid if it can be found, otherwise use self.url
# Assumes guid is a 32-character alphanumeric sequence preceding "/original/" in the url
def unique_url_identifier
identifier = s3_url.split("/orig... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/multipart_transfer.rb | Ruby | mit | 8,966 | main | 2,411 | # frozen_string_literal: true
module MultipartTransfer
# Public: Transfer an item from some arbitrary url source to our s3 bucket using multipart transfer
#
# source_file_url - The url of the file you wish to copy
# destination_filename - Optional, the destination filename of the file you want to copy over, u... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/vertical.rb | Ruby | mit | 8,966 | main | 227 | # frozen_string_literal: true
module Vertical
FILM = "film"
MUSIC = "music"
PUBLISHING = "publishing"
EDUCATION = "education"
SOFTWARE = "software"
PHYSICAL = "physical"
OTHER = "other"
NOTHING = "nothing"
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/obfuscate_ids.rb | Ruby | mit | 8,966 | main | 2,512 | # frozen_string_literal: true
require "openssl"
require "base64"
module ObfuscateIds
CIPHER_KEY = GlobalConfig.get("OBFUSCATE_IDS_CIPHER_KEY")
NUMERIC_CIPHER_KEY = GlobalConfig.get("OBFUSCATE_IDS_NUMERIC_CIPHER_KEY").to_i
MAX_BYTES_FOR_NUMERIC_ENCRYPTION = 30
def self.encrypt(id, padding: true)
c = ciphe... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/paypal_api_response.rb | Ruby | mit | 8,966 | main | 517 | # frozen_string_literal: true
module PaypalApiResponse
def open_struct_to_hash(object, hash = {})
case object
when OpenStruct
object.each_pair do |key, value|
hash[key] = case value
when OpenStruct then open_struct_to_hash(value)
when Array then value.map... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/timestamp_scopes.rb | Ruby | mit | 8,966 | main | 1,122 | # frozen_string_literal: true
module TimestampScopes
extend ActiveSupport::Concern
included do
scope :created_between, ->(range) { where(created_at: range) if range }
scope :column_between_with_offset, lambda { |column_name, range, offset|
where("date(convert_tz(#{table_name}.#{column_name}, '+00:00... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/sendable_to_kindle.rb | Ruby | mit | 8,966 | main | 362 | # frozen_string_literal: true
module SendableToKindle
extend ActiveSupport::Concern
included do
def send_to_kindle(kindle_email)
raise ArgumentError, "Please enter a valid Kindle email address" unless kindle_email.match(KINDLE_EMAIL_REGEX)
CustomerMailer.send_to_kindle(kindle_email, id).deliver_l... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/platform.rb | Ruby | mit | 8,966 | main | 211 | # frozen_string_literal: true
module Platform
WEB = "web"
IPHONE = "iphone"
ANDROID = "android"
OTHER = "other"
def self.all
[
WEB,
IPHONE,
ANDROID,
OTHER
]
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/external_id.rb | Ruby | mit | 8,966 | main | 1,093 | # frozen_string_literal: true
module ExternalId
extend ActiveSupport::Concern
def external_id
ObfuscateIds.encrypt(id)
end
def external_id_numeric
ObfuscateIds.encrypt_numeric(id)
end
class_methods do
def to_external_id(id)
ObfuscateIds.encrypt(id)
end
def from_external_id(ext... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/utilities.rb | Ruby | mit | 8,966 | main | 256 | # frozen_string_literal: true
module Utilities
module_function
def sign_with_aws_secret_key(to_sign)
Base64.encode64(
OpenSSL::HMAC.digest(
OpenSSL::Digest.new("sha1"), AWS_SECRET_KEY, to_sign
)
).delete("\n")
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/subdomain.rb | Ruby | mit | 8,966 | main | 1,342 | # frozen_string_literal: true
module Subdomain
USERNAME_REGEXP = /[a-z0-9-]+/
class << self
def find_seller_by_request(request)
find_seller_by_hostname(request.host)
end
def find_seller_by_hostname(hostname)
if subdomain_request?(hostname)
subdomain = ActionDispatch::Http::URL.ext... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/deletable.rb | Ruby | mit | 8,966 | main | 757 | # frozen_string_literal: true
# Module for anything that uses soft deletion functionality.
module Deletable
extend ActiveSupport::Concern
included do
scope :alive, -> { where(deleted_at: nil) }
scope :deleted, -> { where.not(deleted_at: nil) }
end
def mark_deleted!
self.deleted_at = Time.curren... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/with_product_files_many_to_many.rb | Ruby | mit | 8,966 | main | 318 | # frozen_string_literal: true
# A module to include the WithProductFiles module
# and allow for has_and_belongs_to_many relationships
# for product files
module WithProductFilesManyToMany
extend ActiveSupport::Concern
included do
include WithProductFiles
has_and_belongs_to_many :product_files
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/elasticsearch_model_async_callbacks.rb | Ruby | mit | 8,966 | main | 1,040 | # frozen_string_literal: true
module ElasticsearchModelAsyncCallbacks
extend ActiveSupport::Concern
include TransactionalAttributeChangeTracker
included do
after_commit lambda { send_to_elasticsearch("index") }, on: :create
after_commit lambda { send_to_elasticsearch("update") }, on: :update
after_c... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/media_location/unit.rb | Ruby | mit | 8,966 | main | 227 | # frozen_string_literal: true
module MediaLocation::Unit
PAGE_NUMBER = "page_number"
SECONDS = "seconds"
PERCENTAGE = "percentage"
def self.all
[
PAGE_NUMBER,
SECONDS,
PERCENTAGE
]
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/payment/stats.rb | Ruby | mit | 8,966 | main | 2,683 | # frozen_string_literal: true
module Payment::Stats
def revenue_by_link
# First calculate the revenue per product (i.e. purchase price - affiliate commission - fee)
# based on all the sales in this payout period
# including refunded and charged-back sales.
revenue_by_link = successful_sale_amounts
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/payment_stats.rb | Ruby | mit | 8,966 | main | 1,889 | # frozen_string_literal: true
# Mixin contains stats helpers for use on Users, relevant to the internal payments team at Gumroad.
# The numbers in this stats module should unlikely be displayed to the Creator. For example, most
# stats within relate to transaction total values and not the values received or earned by ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/devise_internal.rb | Ruby | mit | 8,966 | main | 289 | # frozen_string_literal: true
##
# A collection of methods used internally in devise gem.
##
class User
module DeviseInternal
def active_for_authentication?
true
end
def confirmation_required?
email_required? && !confirmed? && email.present?
end
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/recommendations.rb | Ruby | mit | 8,966 | main | 701 | # frozen_string_literal: true
module User::Recommendations
def recommendable?
recommendable_reasons.values.all?
end
# All of the factors(values/records/etc.) which influence the return value of this method should be watched.
# Whenever any of those factors change, a `SendToElasticsearchWorker` job must be... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/ping_notification.rb | Ruby | mit | 8,966 | main | 1,822 | # frozen_string_literal: true
module User::PingNotification
def send_test_ping(url)
latest_sale = sales.last
return nil if latest_sale.blank?
URI.parse(url) # TestPingsController.create catches URI::InvalidURIError
ping_params = latest_sale.payload_for_ping_notification.merge(test: true)
ping_p... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/tier.rb | Ruby | mit | 8,966 | main | 714 | # frozen_string_literal: true
module User::Tier
# Earning tiers
TIER_0 = 0
TIER_1 = 1_000
TIER_2 = 10_000
TIER_3 = 100_000
TIER_4 = 1_000_000
TIER_RANGES = {
0...1_000_00 => TIER_0,
1_000_00...10_000_00 => TIER_1,
10_000_00...100_000_00 => TIER_2,
100_000_00...1_000_000_00 => TIER_3,
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/payout_info.rb | Ruby | mit | 8,966 | main | 2,555 | # frozen_string_literal: true
module User::PayoutInfo
include CurrencyHelper
def payout_info
@payout_info ||= {
active_bank_account: active_bank_account&.as_json(only: %i[type account_holder_full_name], methods: %i[formatted_account]),
payment_address:,
payouts_paused_by_source:,
payou... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/feature_status.rb | Ruby | mit | 8,966 | main | 4,080 | # frozen_string_literal: true
##
# A collections of methods that determines user's status with certain features.
##
class User
module FeatureStatus
def merchant_migration_enabled?
check_merchant_account_is_linked || (Feature.active?(:merchant_migration, self) &&
StripeMerchantAccountManager::COU... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/money_balance.rb | Ruby | mit | 8,966 | main | 4,471 | # frozen_string_literal: true
class User
module MoneyBalance
def unpaid_balance_cents(via: :sql)
if via == :elasticsearch
begin
Balance.amount_cents_sum_for(self)
rescue => e
ErrorNotifier.notify(e)
unpaid_balance_cents(via: :sql)
end
else
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/payout_schedule.rb | Ruby | mit | 8,966 | main | 5,471 | # frozen_string_literal: true
module User::PayoutSchedule
PAYOUT_STARTING_DATE = Date.new(2012, 12, 21)
PAYOUT_RECURRENCE_DAYS = 7
PAYOUT_DELAY_DAYS = 7
WEEKLY = "weekly"
MONTHLY = "monthly"
QUARTERLY = "quarterly"
DAILY = "daily"
include CurrencyHelper
def next_payout_date
return nil if unpai... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/validations.rb | Ruby | mit | 8,966 | main | 3,191 | # frozen_string_literal: true
module User::Validations
ALLOWED_AVATAR_EXTENSIONS = ["png", "jpg", "jpeg"]
MINIMUM_AVATAR_DIMENSION = 200
MAXIMUM_AVATAR_FILE_SIZE = 10.megabytes
GA_REGEX = %r{G-[a-zA-Z0-9]+} # Regex for Google Analytics 4 Measurement ID.
TIKTOK_PIXEL_REGEX = /\A[A-Z0-9]+\z/ # TikTok Pixel IDs... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/async_devise_notification.rb | Ruby | mit | 8,966 | main | 1,508 | # frozen_string_literal: true
# This module is responsible for sending Devise email notifications via ActiveJob.
# See https://github.com/heartcombo/devise/blob/098345aace53d4ddf88e04f1eb2680e2676e8c28/lib/devise/models/authenticatable.rb#L133-L194.
module User::AsyncDeviseNotification
extend ActiveSupport::Concern... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/compliance.rb | Ruby | mit | 8,966 | main | 8,350 | # frozen_string_literal: true
module User::Compliance
# https://stripe.com/global lists all countries supported by Stripe.
# https://stripe.com/connect/pricing lists default currencies for the supported countries.
# This list contains supported countries which have euros listed as default currency.
EUROPEAN_CO... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/risk.rb | Ruby | mit | 8,966 | main | 8,422 | # frozen_string_literal: true
module User::Risk
extend ActiveSupport::Concern
PAYMENT_REMINDER_RISK_STATES = %w[flagged_for_tos_violation not_reviewed compliant].freeze
SUSPENDED_STATES = %w[suspended_for_tos_violation suspended_for_fraud].freeze
INCREMENTAL_ENQUEUE_BALANCE = 100_00
PROBATION_WITH_REMINDER_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/australian_backtaxes.rb | Ruby | mit | 8,966 | main | 838 | # frozen_string_literal: true
##
# A collection of methods to help with backtax calculations
##
class User
module AustralianBacktaxes
def opted_in_to_australia_backtaxes?
australia_backtax_agreement.present?
end
def au_backtax_agreement_date
australia_backtax_agreement&.created_at
end
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/stats.rb | Ruby | mit | 8,966 | main | 40,078 | # frozen_string_literal: true
# Mixin contains stats helpers for use on Users.
#
# See the User::PaymentStats module for internal stats that are not displayed to the Seller.
module User::Stats
include CurrencyHelper
extend ActiveSupport::Concern
included do
attr_accessor :sales_total
scope :by_sales_re... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/user/posts.rb | Ruby | mit | 8,966 | main | 4,628 | # frozen_string_literal: true
module User::Posts
def visible_posts_for(pundit_user:, shown_on_profile: true)
# The condition below doesn't take into consideration logged-in user's role for logged-in seller
# This is a non-issue at this moment as all roles have "read" access to posts.
# To have a more gra... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase/risk.rb | Ruby | mit | 8,966 | main | 3,594 | # frozen_string_literal: true
module Purchase::Risk
IP_PROXY_THRESHOLD = 2
CHECK_FOR_FRAUD_TIMEOUT_SECONDS = 4
def check_for_fraud
Timeout.timeout(CHECK_FOR_FRAUD_TIMEOUT_SECONDS) do
check_for_past_blocked_email_domains
return if errors.present?
check_for_past_blocked_guids
return i... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase/reviews.rb | Ruby | mit | 8,966 | main | 2,502 | # frozen_string_literal: true
module Purchase::Reviews
extend ActiveSupport::Concern
included do
COUNTS_REVIEWS_STATES = %w[successful gift_receiver_purchase_successful not_charged]
has_one :product_review
after_save :update_product_review_stat
# Important: The logic needs to be the same as the ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase/refundable.rb | Ruby | mit | 8,966 | main | 21,233 | # frozen_string_literal: true
class Purchase
module Refundable
ACTIVE_DISPUTE_REFUND_ERROR_MESSAGE = "This purchase has an active dispute. " \
"The funds have already been returned to the buyer. " \
"No additional refund is neede... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase/completion_handler.rb | Ruby | mit | 8,966 | main | 470 | # frozen_string_literal: true
module Purchase::CompletionHandler
# Makes sure that a block of code that creates an in_progress purchase eventually transitions
# that purchase to a completing state, otherwise this method marks the purchase as failed.
def ensure_completion
yield
ensure
mark_failed! if pe... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase/accounting.rb | Ruby | mit | 8,966 | main | 2,066 | # frozen_string_literal: true
##
# A collection of methods to help with accounting calculations
##
class Purchase
module Accounting
# returns price in USD. 0.15 means 15 cents
def price_dollars
convert_cents_to_dollars(price_cents)
end
def variant_extra_cost_dollars
convert_cents_to_dol... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase/targeting.rb | Ruby | mit | 8,966 | main | 1,577 | # frozen_string_literal: true
module Purchase::Targeting
extend ActiveSupport::Concern
included do
scope :by_variant, lambda { |variant_id|
if variant_id.present?
joins("INNER JOIN base_variants_purchases ON base_variants_purchases.purchase_id = purchases.id")
.where("base_variants_pur... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/purchase/ping_notification.rb | Ruby | mit | 8,966 | main | 3,731 | # frozen_string_literal: true
module Purchase::PingNotification
def payload_for_ping_notification(url_parameters: nil, resource_name: nil)
# general_permalink was being sent as "permalink' which is wrong because it's not a full url unlike the name suggests.
# Consider it deprecated; it's removed from the pin... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/base_price/recurrence.rb | Ruby | mit | 8,966 | main | 2,346 | # frozen_string_literal: true
module BasePrice::Recurrence
MONTHLY = "monthly"
QUARTERLY = "quarterly"
BIANNUALLY = "biannually"
YEARLY = "yearly"
EVERY_TWO_YEARS = "every_two_years"
DEFAULT_TIERED_MEMBERSHIP_RECURRENCE = MONTHLY
ALLOWED_RECURRENCES = [
MONTHLY,
QUARTERLY,
BIANNUALLY,
Y... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/base_price/shared.rb | Ruby | mit | 8,966 | main | 4,277 | # frozen_string_literal: true
module BasePrice::Shared
def clean_price(price_string)
clean = price_string.to_s
unless single_unit_currency?
clean = clean.gsub(/[^-0-9.,]/, "") # allow commas for now
if clean.rindex(/,/) == clean.length - 3 # euro style!
clean = clean.delete(".") # re... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/review_stat.rb | Ruby | mit | 8,966 | main | 3,129 | # frozen_string_literal: true
module Product::ReviewStat
delegate :average_rating, :rating_counts, :reviews_count, :rating_percentages, to: :review_stat_proxy
def rating_stats
{
count: reviews_count,
average: average_rating,
percentages: rating_percentages.values,
}
end
def update_r... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/recommendations.rb | Ruby | mit | 8,966 | main | 934 | # frozen_string_literal: true
module Product::Recommendations
def recommendable?
recommendable_reasons.values.all?
end
alias_method :recommendable, :recommendable?
# All of the factors(values/records/etc.) which influence the return value of this method should be watched.
# Whenever any of those factors... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/utils.rb | Ruby | mit | 8,966 | main | 993 | # frozen_string_literal: true
module Product::Utils
extend ActiveSupport::Concern
class_methods do
# Helper for when debugging in console.
#
# Fetches a product uniquely identified by `id_or_permalink` (ID, unique or custom permalink)
# and optionally scoped by `user_id` if more than one product c... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/prices.rb | Ruby | mit | 8,966 | main | 12,533 | # frozen_string_literal: true
module Product::Prices
include BasePrice::Shared
# Public: Alias for default_price_cents in order to hide the price_cents column, which isn't used anymore in favor of the Price model.
def price_cents
default_price_cents
end
# Public: Returns a single price for the product ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/preview.rb | Ruby | mit | 8,966 | main | 2,144 | # frozen_string_literal: true
module Product::Preview
extend ActiveSupport::Concern
MAX_PREVIEW_COUNT = 8
# If the preview height is not defined or too small we will default to this value, this makes sure we display a large enough preview
# image in the users library
DEFAULT_MOBILE_PREVIEW_HEIGHT = 204
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/searchable.rb | Ruby | mit | 8,966 | main | 17,746 | # frozen_string_literal: true
module Product::Searchable
extend ActiveSupport::Concern
# we want to show 9 tags, but this is used as an array indexing which starts at 0
MAX_NUMBER_OF_TAGS = 8
RECOMMENDED_PRODUCTS_PER_PAGE = 9
MAX_NUMBER_OF_FILETYPES = 8
MAX_OFFER_CODES_IN_INDEX = 300
MAX_PRICE_FILTER_CE... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/caching.rb | Ruby | mit | 8,966 | main | 3,182 | # frozen_string_literal: true
module Product::Caching
def scoped_cache_key(locale, fragmented = false, displayed_switch_ids = [], prefetched_cache_key_prefix = nil, request_host = nil)
displayed_switch_ids = displayed_switch_ids.sort
displayed_switch_ids = displayed_switch_ids.join("_")
prefix = prefetch... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/stats.rb | Ruby | mit | 8,966 | main | 5,187 | # frozen_string_literal: true
module Product::Stats
extend ActiveSupport::Concern
class_methods do
# Essentially returns a sum of "active customers" (for each product)
# because we're considering each subscription as one sale,
# and excluding deactivated subscription.
def successful_sales_count(pr... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/validations.rb | Ruby | mit | 8,966 | main | 3,544 | # frozen_string_literal: true
module Product::Validations
include ActionView::Helpers::TextHelper
MAX_VIEW_CONTENT_BUTTON_TEXT_LENGTH = 26
MAX_CUSTOM_RECEIPT_TEXT_LENGTH = 500
private
def max_purchase_count_is_greater_than_or_equal_to_inventory_sold
return unless max_purchase_count_changed?
r... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/modules/product/creation_limit.rb | Ruby | mit | 8,966 | main | 1,579 | # frozen_string_literal: true
module Product::CreationLimit
extend ActiveSupport::Concern
included do
validate :validate_daily_product_creation_limit, on: :create
end
class_methods do
def bypass_product_creation_limit
previous = product_creation_limit_bypassed?
self.product_creation_limit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.