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 | tech-bureau/catapult-service-bootstrap | https://github.com/tech-bureau/catapult-service-bootstrap | common/ruby/lib/catapult/bootstrap/tools/nemesis/nemgen/process_node.rb | Ruby | apache-2.0 | 48 | master | 1,533 | module Catapult::Bootstrap
class Tools::Nemesis::Nemgen
class ProcessNode < self
def initialize(node_ref, parent)
@node_ref = node_ref
@parent = parent
end
private :initialize
def self.process?(node_ref, parent)
new(node_ref, parent).process?
end
def ... |
github | tech-bureau/catapult-service-bootstrap | https://github.com/tech-bureau/catapult-service-bootstrap | common/ruby/lib/catapult/bootstrap/tools/nemesis/nemgen/mosaics.rb | Ruby | apache-2.0 | 48 | master | 633 | module Catapult::Bootstrap
class Tools::Nemesis::Nemgen
class Mosaics
require_relative('mosaics/config_network')
require_relative('mosaics/element')
def initialize(nemgen_log)
@currency_mosaic_id = Element.id(:currency, nemgen_log)
@harvesting_mosaic_id = Element.id(:harvestin... |
github | tech-bureau/catapult-service-bootstrap | https://github.com/tech-bureau/catapult-service-bootstrap | common/ruby/lib/catapult/bootstrap/tools/nemesis/nemgen/mosaics/config_network.rb | Ruby | apache-2.0 | 48 | master | 1,863 | module Catapult::Bootstrap
class Tools::Nemesis::Nemgen::Mosaics
class ConfigNetwork
def initialize(component_userconfig_dir, mosaics)
@component_userconfig_dir = component_userconfig_dir
@mosaics = mosaics
end
def self.update_file(component_userconfig_dir... |
github | tech-bureau/catapult-service-bootstrap | https://github.com/tech-bureau/catapult-service-bootstrap | common/ruby/lib/catapult/bootstrap/tools/nemesis/nemgen/mosaics/element.rb | Ruby | apache-2.0 | 48 | master | 1,485 | module Catapult::Bootstrap
class Tools::Nemesis::Nemgen::Mosaics
class Element
def initialize(mosaic_type, nemgen_log)
@mosaic_type = mosaic_type
@nemgen_log = nemgen_log
end
def self.id(mosaic_type, nemgen_log)
new(mosaic_type, nemgen_log).id
end
def id
... |
github | tech-bureau/catapult-service-bootstrap | https://github.com/tech-bureau/catapult-service-bootstrap | common/ruby/spec/config_generation/test_case_1_spec.rb | Ruby | apache-2.0 | 48 | master | 1,211 | require 'fileutils'
require 'yaml'
require_relative('../../lib/catapult')
require 'byebug'
KEYS_FILE_PATH = ::File.expand_path('../resources/build/generated-addresses/addresses.yaml', ::File.dirname(__FILE__))
BASE_CONFIG_TARGET_DIR = ::File.expand_path('./output/build/catapult-config', ::File.dirname(__FILE_... |
github | tech-bureau/catapult-service-bootstrap | https://github.com/tech-bureau/catapult-service-bootstrap | common/ruby/bin/setup-network.rb | Ruby | apache-2.0 | 48 | master | 1,779 | #!/usr/bin/env ruby
# Copyright 2018 Tech Bureau, Corp
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requi... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | Gemfile | Ruby | mit | 48 | master | 236 | source 'http://rubygems.org'
gem 'rake'
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
gem 'growl'
gem 'guard-rspec'
gem 'guard-cucumber'
gem 'fuubar'
# Specify your gem's dependencies in data_magic.gemspec
gemspec |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | data_magic.gemspec | Ruby | mit | 48 | master | 1,053 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/data_magic/version', __FILE__)
Gem::Specification.new do |gem|
gem.name = "data_magic"
gem.version = DataMagic::VERSION
gem.platform = Gem::Platform::RUBY
gem.authors = ["Jeff Morgan"]
gem.email = ["jeff.morgan@leand... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | Guardfile | Ruby | mit | 48 | master | 658 | # A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', cmd: 'rspec --color --format Fuubar' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { "spec" }
watch('spec/spec_helper.rb') { "spec" }
end
guard 'cucumber', :notification => true, :cli => '--profile focus' ... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | Rakefile | Ruby | mit | 48 | master | 524 | #!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
require 'cucumber'
require 'cucumber/rake/task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.ruby_opts = "-I lib:spec"
spec.pattern = 'spec/**/*_spec.rb'
end
task :spec
Cucumber::Rake::Task.new(:features, "Run features") do |t|
t... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | spec/spec_helper.rb | Ruby | mit | 48 | master | 724 | # encoding: utf-8
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
if ENV['coverage']
raise "simplecov only works on Ruby 1.9" unless RUBY_VERSION =~ /^1\.9/
require 'simplecov'
SimpleCov.start { add_filter "spec/" }
end
require 'rspec'
require 'dat... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | spec/lib/data_magic_spec.rb | Ruby | mit | 48 | master | 3,486 | require 'spec_helper'
class UserPage
include DataMagic
end
class MockScenario
attr_accessor :tags
def initialize(tags)
@tags = tags
end
end
class MockTag
attr_reader :name, :line
def initialize(name, line)
@name = name
@line = line
end
end
describe DataMagic do
context "when configuring ... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | spec/lib/translation_spec.rb | Ruby | mit | 48 | master | 12,074 | require 'spec_helper'
describe "DataMagic translations" do
context "when delivering data" do
let(:example) { (Class.new { include DataMagic }).new }
def set_field_value(value)
expect(DataMagic).to receive(:yml).twice.and_return({'key' => {'field' => value}})
end
it "should deliver the hash fro... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | features/step_definitions/data_magic_steps.rb | Ruby | mit | 48 | master | 5,016 | class TestClass
include DataMagic
end
Given /^I have read the yaml file from features\/yaml$/ do
DataMagic.yml_directory = 'features/yaml'
DataMagic.load "example.yml"
end
Given /^I have read the default yaml file from the default location$/ do
end
When /^I ask for the data for "(.+)"$/ do |key|
TestClass.... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | lib/data_magic.rb | Ruby | mit | 48 | master | 2,997 | require 'data_magic/core_ext/string'
require 'data_magic/core_ext/integer'
require 'data_magic/core_ext/hash'
require 'data_magic/version'
require 'data_magic/translation'
require 'data_magic/date_translation'
require 'data_magic/standard_translation'
require 'yml_reader'
require 'faker'
module DataMagic
extend YmlR... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | lib/data_magic/translation.rb | Ruby | mit | 48 | master | 248 | require 'data_magic/date_translation'
require 'data_magic/standard_translation'
module DataMagic
class Translation
include StandardTranslation
include DateTranslation
def initialize(parent)
@parent = parent
end
end
end |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | lib/data_magic/standard_translation.rb | Ruby | mit | 48 | master | 6,704 | module DataMagic
module StandardTranslation
attr_reader :parent
#
# return a random name (first and last)
#
def full_name
Faker::Name.name
end
alias_method :dm_full_name, :full_name
#
# return a random first name
#
def first_name
Faker::Name.first_name
en... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | lib/data_magic/date_translation.rb | Ruby | mit | 48 | master | 1,752 | module DataMagic
module DateTranslation
#
# return today's date
#
# @param String the format to use for the date. Default is %D
#
# See http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html#method-i-strftime
# for details of the formats
#
def today(format = '%D')
Date.... |
github | cheezy/data_magic | https://github.com/cheezy/data_magic | lib/data_magic/core_ext/integer.rb | Ruby | mit | 48 | master | 220 | class Integer
def days_from_today(format = '%D')
the_day = Date.today + self
the_day.strftime(format)
end
def days_ago(format = '%D')
the_day = Date.today - self
the_day.strftime(format)
end
end |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | courrier.gemspec | Ruby | mit | 49 | main | 903 | # frozen_string_literal: true
require_relative "lib/courrier/version"
Gem::Specification.new do |spec|
spec.name = "courrier"
spec.version = Courrier::VERSION
spec.authors = ["Rails Designer"]
spec.email = ["devs@railsdesigner.com"]
spec.summary = "API-powered email delivery for Ruby apps"
spec.descripti... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | Gemfile | Ruby | mit | 49 | main | 273 | # frozen_string_literal: true
source "https://rubygems.org"
gemspec
group :development do
gem "standard", "~> 1.49"
end
group :development, :test do
gem "rake", "~> 13.2", ">= 13.2.1"
gem "minitest", "~> 5.25", ">= 5.25.5"
gem "debug", "~> 1.9", ">= 1.9.2"
end |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | config/routes.rb | Ruby | mit | 49 | main | 219 | # frozen_string_literal: true
Courrier::Engine.routes.draw do
resources :previews, only: %w[show], constraints: {id: /.*\.html/}
resource :cleanup, only: %w[create], module: "previews"
root "previews#index"
end |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/test_helper.rb | Ruby | mit | 49 | main | 274 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "courrier"
require "minitest/autorun"
Dir[File.expand_path("support/**/*.rb", __dir__)].each { require _1 }
Dir[File.expand_path("fixtures/**/*.rb", __dir__)].each { require _1 } |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/support/test_email_helpers.rb | Ruby | mit | 49 | main | 458 | module TestEmailHelpers
def reset_test_email_class
TestEmail.provider = nil
TestEmail.api_key = nil
TestEmail.from = nil
TestEmail.reply_to = nil
TestEmail.cc = nil
TestEmail.bcc = nil
end
def reset_configuration
Courrier.configuration = Courrier::Configuration.new
end
def create... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email_delivery_test.rb | Ruby | mit | 49 | main | 3,347 | require "test_helper"
class Courrier::EmailDeliveryTest < Minitest::Test
include TestEmailHelpers
def setup
reset_test_email_class
reset_configuration
end
def test_deliver_now_calls_provider_deliver
provider_mock = Minitest::Mock.new
provider_mock.expect(:deliver, "delivery_result")
Cour... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email_configuration_test.rb | Ruby | mit | 49 | main | 4,113 | require "test_helper"
class Courrier::EmailConfigurationTest < Minitest::Test
include TestEmailHelpers
def setup
reset_test_email_class
reset_configuration
end
def test_initialization_with_class_defaults
TestEmail.configure(
provider: "class_provider",
api_key: "class_key",
from... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/subscriber_test.rb | Ruby | mit | 49 | main | 1,827 | require "test_helper"
require "courrier/subscriber"
require "courrier/subscriber/result"
class Courrier::SubscriberTest < Minitest::Test
def setup
reset_configuration
end
def test_create_with_configured_provider
Courrier.configure do |config|
config.subscriber = {
provider: :buttondown,
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email_test.rb | Ruby | mit | 49 | main | 5,606 | require "test_helper"
class Courrier::EmailTest < Minitest::Test
include TestEmailHelpers
def setup
reset_test_email_class
reset_configuration
end
def test_initialization_with_options
email = TestEmail.new(
provider: "test_provider",
api_key: "test_key",
to: "recipient@railsdesi... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/providers/base_test.rb | Ruby | mit | 49 | main | 1,275 | require "test_helper"
class Courrier::Email::Providers::BaseTest < Minitest::Test
def setup
@provider = Courrier::Email::Providers::TestProvider.new
end
def test_initialize_sets_options
provider = Courrier::Email::Providers::Base.new(
api_key: "test_key",
options: { from: "devs@railsdesigner... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email/result_test.rb | Ruby | mit | 49 | main | 1,314 | require "test_helper"
class Courrier::Email::ResultTest < Minitest::Test
def test_initialize_with_success_response
response = Data.define(:code, :body).new(
code: "200",
body: '{"success": true, "message_id": "test-123"}'
)
result = Courrier::Email::Result.new(response: response)
assert ... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email/provider_test.rb | Ruby | mit | 49 | main | 3,274 | require "test_helper"
require "courrier/email/provider"
class TestCourrierEmailProvider < Minitest::Test
def setup
Object.send(:remove_const, :Rails) if defined?(Rails)
end
def test_raises_error_for_empty_provider
provider = Courrier::Email::Provider.new(
provider: "",
api_key: "test-key"
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email/transformer_test.rb | Ruby | mit | 49 | main | 1,611 | require "test_helper"
class TransformerTest < Minitest::Test
def test_removes_unwanted_elements
html = <<~HTML
<script>alert('hi')</script>
<style>body { color: red; }</style>
<p>Actual content</p>
HTML
assert_equal "Actual content", transform(html)
end
def test_processes_links
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email/address_test.rb | Ruby | mit | 49 | main | 1,712 | require "test_helper"
require "courrier/email/address"
class Courrier::Email::AddressTest < Minitest::Test
def test_with_name_basic_formatting
assert_equal "Rails Designer <devs@railsdesigner.com>",
Courrier::Email::Address.with_name("devs@railsdesigner.com", "Rails Designer")
end
def test_with_name_r... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email/layouts_test.rb | Ruby | mit | 49 | main | 878 | require "test_helper"
class Courrier::Email::LayoutsTest < Minitest::Test
def test_without_layouts
email = TestEmail.new(
from: "devs@railsdesigner.com",
to: "recipient@railsdesigner.com"
)
assert_equal [], Courrier::Email::Layouts.new(email).build
end
def test_string_layouts
email ... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email/providers/logger_test.rb | Ruby | mit | 49 | main | 1,629 | require "test_helper"
module Courrier::Email::Providers
class LoggerTest < Minitest::Test
include TestEmailHelpers
def test_formats_email_for_logging
email = TestEmail.new(
from: "devs@railsdesigner.com",
to: "recipient@railsdesigner.com",
reply_to: "support@railsdesigner.com"
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/email/providers/inbox_test.rb | Ruby | mit | 49 | main | 1,330 | require "test_helper"
require "courrier/email/providers/inbox"
class Courrier::Email::Providers::InboxTest < Minitest::Test
include TestEmailHelpers
def setup
reset_configuration
end
def test_extract_name_and_email_from_full_address
email = TestEmail.new(
from: "devs@railsdesigner.com",
t... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | test/courrier/subscriber/result_test.rb | Ruby | mit | 49 | main | 1,354 | require "test_helper"
require "courrier/subscriber/result"
class Courrier::Subscriber::ResultTest < Minitest::Test
def test_initialize_with_success_response
response = Data.define(:code, :body).new(
code: "200",
body: '{"id": "sub-123", "email": "test@example.com"}'
)
result = Courrier::Subs... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | app/controllers/courrier/previews_controller.rb | Ruby | mit | 49 | main | 584 | # frozen_string_literal: true
module Courrier
class PreviewsController < ActionController::Base
def index
@emails = emails.map { Courrier::Email::Providers::Inbox::Email.from_file(_1) }
end
def show
file_path = File.join(Courrier.configuration.inbox.destination, params[:id])
content = ... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | app/controllers/courrier/previews/cleanups_controller.rb | Ruby | mit | 49 | main | 238 | # frozen_string_literal: true
module Courrier
module Previews
class CleanupsController < ActionController::Base
def create
system("bin/rails courrier:clear")
redirect_to root_path
end
end
end
end |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier.rb | Ruby | mit | 49 | main | 284 | # frozen_string_literal: true
require "courrier/version"
require "courrier/errors"
require "courrier/configuration"
require "courrier/email"
require "courrier/subscriber"
require "courrier/engine" if defined?(Rails)
require "courrier/railtie" if defined?(Rails)
module Courrier
end |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/railtie.rb | Ruby | mit | 49 | main | 554 | module Courrier
class Railtie < Rails::Railtie
config.after_initialize do
Courrier::Email.default_url_options = Courrier.configuration.default_url_options
end
ActiveSupport.on_load(:action_view) do
include Courrier::Email::Address
end
ActiveSupport.on_load(:action_controller) do
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber.rb | Ruby | mit | 49 | main | 764 | # frozen_string_literal: true
module Courrier
class Subscriber
class << self
def create(email)
provider.create(email)
end
alias_method :add, :create
def destroy(email)
provider.destroy(email)
end
alias_method :delete, :destroy
private
def provide... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/errors.rb | Ruby | mit | 49 | main | 285 | # frozen_string_literal: true
module Courrier
class Error < StandardError; end
class ConfigurationError < Error; end
class ArgumentError < ::ArgumentError; end
class NotImplementedError < ::NotImplementedError; end
class BackgroundDeliveryError < StandardError; end
end |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/markdown.rb | Ruby | mit | 49 | main | 1,092 | # frozen_string_literal: true
module Courrier
class Markdown
class << self
def available?
defined?(::Redcarpet) || defined?(::Kramdown) || defined?(::Commonmarker)
end
def render(text)
return unless available?
parser.parse(text.to_s)
end
private
def... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/configuration.rb | Ruby | mit | 49 | main | 1,895 | # frozen_string_literal: true
require "courrier/configuration/inbox"
require "courrier/configuration/providers"
module Courrier
class << self
attr_writer :configuration
def configure
self.configuration ||= Configuration.new
yield(configuration) if block_given?
end
def configuration
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email.rb | Ruby | mit | 49 | main | 5,782 | # frozen_string_literal: true
require "erb"
require "courrier/email/address"
require "courrier/jobs/email_delivery_job" if defined?(Rails)
require "courrier/email/layouts"
require "courrier/markdown"
require "courrier/email/options"
require "courrier/email/provider"
module Courrier
class Email
attr_accessor :p... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/configuration/providers.rb | Ruby | mit | 49 | main | 889 | # frozen_string_literal: true
module Courrier
class Configuration
class Providers
def initialize
@providers = {}
end
def method_missing(name, *, **)
@providers[name.to_sym] ||= ProviderConfig.new
end
def respond_to_missing?(name, include_private = false) = true
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/configuration/inbox.rb | Ruby | mit | 49 | main | 556 | # frozen_string_literal: true
module Courrier
class Configuration
class Inbox
attr_accessor :destination, :auto_open, :template_path
def initialize
@destination = default_destination
@auto_open = false
@template_path = File.expand_path("../../../courrier/email/providers/inbox... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/kit.rb | Ruby | mit | 49 | main | 836 | # frozen_string_literal: true
require "courrier/subscriber/base"
module Courrier
class Subscriber
class Kit < Base
ENDPOINT_URL = "https://api.convertkit.com/v3/forms"
def create(email)
form_id = Courrier.configuration.subscriber[:form_id]
raise Courrier::ConfigurationError, "Kit re... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/beehiiv.rb | Ruby | mit | 49 | main | 1,481 | # frozen_string_literal: true
require "courrier/subscriber/base"
module Courrier
class Subscriber
class Beehiiv < Base
ENDPOINT_URL = "https://api.beehiiv.com/v2/publications"
def create(email)
publication_id = Courrier.configuration.subscriber[:publication_id]
raise Courrier::Confi... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/mailchimp.rb | Ruby | mit | 49 | main | 1,146 | # frozen_string_literal: true
require "courrier/subscriber/base"
module Courrier
class Subscriber
class Mailchimp < Base
def create(email)
dc = Courrier.configuration.subscriber[:dc]
list_id = Courrier.configuration.subscriber[:list_id]
raise Courrier::ConfigurationError, "Mailchi... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/result.rb | Ruby | mit | 49 | main | 823 | # frozen_string_literal: true
module Courrier
class Subscriber
class Result
attr_reader :success, :response, :data, :error
def initialize(response: nil, error: nil)
@response = response
@error = error
@data = parsed(@response&.body)
@success = successful?
end
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/buttondown.rb | Ruby | mit | 49 | main | 557 | # frozen_string_literal: true
require "courrier/subscriber/base"
module Courrier
class Subscriber
class Buttondown < Base
ENDPOINT_URL = "https://api.buttondown.email/v1/subscribers"
def create(email)
request(:post, ENDPOINT_URL, {"email" => email})
end
def destroy(email)
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/loops.rb | Ruby | mit | 49 | main | 614 | # frozen_string_literal: true
require "courrier/subscriber/base"
module Courrier
class Subscriber
class Loops < Base
ENDPOINT_URL = "https://app.loops.so/api/v1/contacts"
def create(email)
request(:post, "#{ENDPOINT_URL}/create", {
"email" => email
})
end
def ... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/mailerlite.rb | Ruby | mit | 49 | main | 561 | # frozen_string_literal: true
require "courrier/subscriber/base"
module Courrier
class Subscriber
class Mailerlite < Base
ENDPOINT_URL = "https://connect.mailerlite.com/api/subscribers"
def create(email)
request(:post, ENDPOINT_URL, {"email" => email})
end
def destroy(email)
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/subscriber/base.rb | Ruby | mit | 49 | main | 1,163 | # frozen_string_literal: true
require "courrier/subscriber/result"
module Courrier
class Subscriber
class Base
def initialize(api_key:)
@api_key = api_key
end
def create(email)
raise NotImplementedError
end
def destroy(email)
raise NotImplementedError
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/tasks/courrier.rake | Ruby | mit | 49 | main | 292 | namespace :tmp do
task :courrier do
rm_rf Dir["#{Courrier.configuration.inbox.destination}/[^.]*"], verbose: false
end
task clear: :courrier
end
namespace :courrier do
desc "Clear email files from `#{Courrier.configuration.inbox.destination}`"
task clear: "tmp:courrier"
end |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/provider.rb | Ruby | mit | 49 | main | 2,785 | # frozen_string_literal: true
require "courrier/email/providers/base"
require "courrier/email/providers/inbox"
require "courrier/email/providers/logger"
require "courrier/email/providers/loops"
require "courrier/email/providers/mailgun"
require "courrier/email/providers/mailjet"
require "courrier/email/providers/mailp... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/layouts.rb | Ruby | mit | 49 | main | 716 | # frozen_string_literal: true
module Courrier
class Email
class Layouts
def initialize(email)
@email = email
end
def build
return [] if no_layouts?
[layouts]
end
private
FORMATS = %w[html text]
def no_layouts? = @email.class.layouts.nil?
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/result.rb | Ruby | mit | 49 | main | 842 | # frozen_string_literal: true
require "json"
module Courrier
class Email
class Result
attr_reader :success, :response, :data, :error
def initialize(response: nil, error: nil)
@response = response
@error = error
@data = parse_body(@response&.body)
@success = successfu... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/request.rb | Ruby | mit | 49 | main | 1,630 | # frozen_string_literal: true
require "json"
require "net/http"
require "courrier/email/result"
module Courrier
class Email
class Request
def initialize(endpoint_url:, body:, provider:, headers: {}, content_type: "application/json")
@endpoint_url = endpoint_url
@body = body
@provid... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/transformer.rb | Ruby | mit | 49 | main | 1,199 | # frozen_string_literal: true
require "nokogiri"
module Courrier
class Email
class Transformer
def initialize(content)
@content = content
end
def to_text
Nokogiri::HTML(@content)
.then { remove_unwanted_elements(_1) }
.then { process_links(_1) }
.... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/address.rb | Ruby | mit | 49 | main | 1,058 | # frozen_string_literal: true
module Courrier
class Email
module Address
class << self
def with_name(address, name)
raise Courrier::ArgumentError, "Both `address` and `name` are required" if address.nil? || name.nil?
raise Courrier::ArgumentError, "Both `address` and `name` must... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/options.rb | Ruby | mit | 49 | main | 1,743 | # frozen_string_literal: true
require "courrier/email/transformer"
module Courrier
class Email
class Options
attr_reader :from, :to, :reply_to, :cc, :bcc, :subject
def initialize(options = {})
@from = options.fetch(:from, nil)
@to = options.fetch(:to, nil)
@reply_to = optio... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/sendgrid.rb | Ruby | mit | 49 | main | 1,189 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Sendgrid < Base
ENDPOINT_URL = "https://api.sendgrid.com/v3/mail/send"
def body
{
"from" => {
"email" => @options.from
},
"personalizations" => [
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/mailgun.rb | Ruby | mit | 49 | main | 903 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Mailgun < Base
ENDPOINT_URL = "https://api.mailgun.net/v3/%{domain}/messages"
def body
{
"from" => @options.from,
"to" => @options.to,
"h:Reply-To" => @options.re... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/mailjet.rb | Ruby | mit | 49 | main | 1,070 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Mailjet < Base
ENDPOINT_URL = "https://api.mailjet.com/v3.1/send"
def body
{
"Messages" => [
{
"From" => {
"Email" => @options.from
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/inbox.rb | Ruby | mit | 49 | main | 2,191 | # frozen_string_literal: true
require "tmpdir"
require "fileutils"
require "launchy"
module Courrier
class Email
module Providers
class Inbox < Base
def deliver
FileUtils.mkdir_p(config.destination)
file_path = File.join(config.destination, "#{Time.now.to_i}.html")
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/mailpace.rb | Ruby | mit | 49 | main | 624 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Mailpace < Base
ENDPOINT_URL = "https://app.mailpace.com/api/v1/send"
def body
{
"from" => @options.from,
"to" => @options.to,
"replyto" => @options.reply_to,
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/userlist.rb | Ruby | mit | 49 | main | 1,356 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Userlist < Base
ENDPOINT_URL = "https://push.userlist.com/messages"
def body
{
"from" => @options.from,
"to" => @options.to,
"subject" => @options.subject,
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/base.rb | Ruby | mit | 49 | main | 950 | # frozen_string_literal: true
require "courrier/email/request"
module Courrier
class Email
module Providers
class Base
def initialize(api_key: nil, options: {}, provider_options: {}, context_options: {})
@api_key = api_key
@options = options
@provider_options = provid... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/logger.rb | Ruby | mit | 49 | main | 1,352 | # frozen_string_literal: true
require "logger"
module Courrier
class Email
module Providers
class Logger < Base
def deliver
logger = Courrier.configuration.logger
logger.formatter = proc do |_severity, _datetime, _progname, message|
"#{format_email_using(message)}\n... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/loops.rb | Ruby | mit | 49 | main | 668 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Loops < Base
ENDPOINT_URL = "https://app.loops.so/api/v1/transactional"
def body
{
"email" => @options.to,
"transactionalId" => @provider_options.transactional_id || raise(Cou... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/resend.rb | Ruby | mit | 49 | main | 678 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Resend < Base
ENDPOINT_URL = "https://api.resend.com/emails"
def body
{
"from" => @options.from,
"to" => @options.to,
"reply_to" => @options.reply_to,
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/sparkpost.rb | Ruby | mit | 49 | main | 803 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Sparkpost < Base
ENDPOINT_URL = "https://api.sparkpost.com/api/v1/transmissions"
def body
{
"content" => {
"reply_to" => @options.reply_to,
"from" => @options.... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/email/providers/postmark.rb | Ruby | mit | 49 | main | 703 | # frozen_string_literal: true
module Courrier
class Email
module Providers
class Postmark < Base
ENDPOINT_URL = "https://api.postmarkapp.com/email"
def body
{
"From" => @options.from,
"To" => @options.to,
"ReplyTo" => @options.reply_to,
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/courrier/jobs/email_delivery_job.rb | Ruby | mit | 49 | main | 627 | # frozen_string_literal: true
module Courrier
module Jobs
class EmailDeliveryJob < ActiveJob::Base
def perform(data)
email_class = data[:email_class].constantize
email_class.new(
provider: data[:provider],
api_key: data[:api_key],
from: data[:options][:from],
... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/generators/courrier/email_generator.rb | Ruby | mit | 49 | main | 1,128 | module Courrier
class EmailGenerator < Rails::Generators::NamedBase
AVAILABLE_TEMPLATES = %w[welcome password_reset]
desc "Create a new Courrier Email class"
source_root File.expand_path("templates", __dir__)
check_class_collision suffix: "Email"
class_option :skip_suffix, type: :boolean, defa... |
github | Rails-Designer/courrier | https://github.com/Rails-Designer/courrier | lib/generators/courrier/install_generator.rb | Ruby | mit | 49 | main | 287 | module Courrier
class InstallGenerator < Rails::Generators::Base
desc "Creates the initializer for Courrier"
source_root File.expand_path("templates", __dir__)
def copy_initializer_file
template "initializer.rb", "config/initializers/courrier.rb"
end
end
end |
github | apotonick/erbse | https://github.com/apotonick/erbse | Rakefile | Ruby | mit | 48 | master | 251 | require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
desc 'Default: run unit tests.'
task :default => :test
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.pattern = 'test/*_test.rb'
test.verbose = true
end |
github | apotonick/erbse | https://github.com/apotonick/erbse | erbse.gemspec | Ruby | mit | 48 | master | 907 | lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'erbse/version'
Gem::Specification.new do |spec|
spec.name = "erbse"
spec.version = Erbse::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ["Nick Sutterer"]
spec.email = ["apotonick@... |
github | apotonick/erbse | https://github.com/apotonick/erbse | lib/erbse.rb | Ruby | mit | 48 | master | 1,191 | require "temple"
require "erbse/parser"
module Erbse
class BlockFilter < Temple::Filter
# Highly inspired by https://github.com/slim-template/slim/blob/master/lib/slim/controls.rb#on_slim_output
def on_erb_block(code, content_ast)
# this is for <%= do %>
outter_i = unique_name
inner_i = un... |
github | apotonick/erbse | https://github.com/apotonick/erbse | lib/erbse/parser.rb | Ruby | mit | 48 | master | 2,188 | module Erbse
class Parser
# ERB_EXPR = /(\n)|<%(=|\#)?(.*?)%>(\n)*/m # this is the desired pattern.
ERB_EXPR = /(\n)|<=|<%(=+|-|\#|@\s|%)?(.*?)[-=]?%>/m # this is for backward-compatibility.
# BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/
BLOCK_EXPR = /\sdo\s*\z|\sdo\s+\|[^|]*\|\s*\z/
... |
github | apotonick/erbse | https://github.com/apotonick/erbse | test/erbse_test.rb | Ruby | mit | 48 | master | 8,877 | require "test_helper"
#ob_0 = '';;ob_0<< ( true ).to_s;ob_0 << ' '.freeze;;ob_1 = form_for do ; ob_2='';;ob_2<< ( 1 ).to_s;;ob_2<< ( 2 ).to_s;;ob_3 = nested do ; ob_4='';;ob_4<< ( 3 ).to_s;;ob_4<< ( 4 ).to_s;ob_4; end ;ob_2 << ob_3;ob_3; end ;ob_1 << ob_2;ob_0.to_s
class ErbseTest < Minitest::Spec
let (:str) { %{... |
github | apotonick/erbse | https://github.com/apotonick/erbse | benchmark/bench.rb | Ruby | mit | 48 | master | 8,244 | #!/usr/bin/env ruby
###
### $Release: 2.7.0 $
### copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
###
require 'erb'
require 'erubis'
require 'erubis/tiny'
require 'erubis/engine/enhanced'
require 'yaml'
require 'cgi'
include ERB::Util
begin
require 'eruby'
rescue LoadError
ERuby = nil
end
def File.wr... |
github | sorah/revision_plate | https://github.com/sorah/revision_plate | revision_plate.gemspec | Ruby | mit | 48 | master | 1,317 | # coding: utf-8
require_relative 'lib/revision_plate/version'
Gem::Specification.new do |spec|
spec.name = "revision_plate"
spec.version = RevisionPlate::VERSION
spec.authors = ["Sorah Fukumori"]
spec.email = ["her@sorah.jp"]
spec.summary = %q{Rack middleware and applicatio... |
github | sorah/revision_plate | https://github.com/sorah/revision_plate | test/middleware_test.rb | Ruby | mit | 48 | master | 2,014 | require_relative './test_helper'
require 'tempfile'
require 'revision_plate/middleware'
module RevisionPlate
AppOriginal = App
end
class AppTest < Minitest::Spec
include Rack::Test::Methods
alias_method :response, :last_response
describe 'middleware' do
let(:tempfile) { Tempfile.new('revision_plate-midd... |
github | sorah/revision_plate | https://github.com/sorah/revision_plate | test/app_test.rb | Ruby | mit | 48 | master | 4,032 | require_relative './test_helper'
require 'tmpdir'
require 'revision_plate/app'
class AppTest < Minitest::Spec
include Rack::Test::Methods
alias_method :response, :last_response
describe 'app' do
let(:app) { RevisionPlate::App.new(file) }
let(:tmpdir) { Dir.mktmpdir('revision_plate_app_test') }
let(... |
github | sorah/revision_plate | https://github.com/sorah/revision_plate | lib/revision_plate/app.rb | Ruby | mit | 48 | master | 1,244 | require 'pathname'
module RevisionPlate
class App
def initialize(file = nil, path: nil)
@file = file
@path = path
if @file
unless @file.kind_of?(Pathname)
@file = Pathname.new(@file)
end
else
if defined? Rails
@file = Rails.root.join('REVISION')... |
github | sorah/revision_plate | https://github.com/sorah/revision_plate | lib/revision_plate/rails.rb | Ruby | mit | 48 | master | 263 | require 'revision_plate'
if defined?(Rails)
module RevisionPlate
class Railtie < Rails::Railtie
initializer "revision_plate.rails_middleware" do |app|
app.middleware.use RevisionPlate::Middleware, '/site/sha'
end
end
end
end |
github | sorah/revision_plate | https://github.com/sorah/revision_plate | lib/revision_plate/middleware.rb | Ruby | mit | 48 | master | 455 | require 'revision_plate/app'
module RevisionPlate
class Middleware
def initialize(app, path, file = nil, options={})
@path = path
@app = app
@revision_app = App.new(file, **options)
end
ACCEPT_METHODS = %w[GET HEAD].freeze
def call(env)
if env['PATH_INFO'] == @path && ACCEPT... |
github | FooBarWidget/encrypted_cookie_store | https://github.com/FooBarWidget/encrypted_cookie_store | Rakefile | Ruby | bsd-3-clause | 48 | master | 1,135 | desc "Run unit tests"
task :test do
sh "spec -f s -c test/*_test.rb"
end
desc "Run benchmark"
task :benchmark do
$LOAD_PATH.unshift(File.expand_path("lib"))
require 'rubygems'
require 'benchmark'
require 'action_controller'
require 'encrypted_cookie_store'
secret = "b6a30e998806a238c4bad45cc720ed55e56e50d9f00... |
github | FooBarWidget/encrypted_cookie_store | https://github.com/FooBarWidget/encrypted_cookie_store | test/encrypted_cookie_store_test.rb | Ruby | bsd-3-clause | 48 | master | 3,451 | $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'rubygems'
gem 'rails', '~> 2.3.0'
require 'action_controller'
require 'encrypted_cookie_store'
describe EncryptedCookieStore do
SECRET = "b6a30e998806a238c4bad45cc720ed55e56e50d9f00fff58552e78a20fe8262df61" <<
"42fcfdb0676018bb9767ed5... |
github | FooBarWidget/encrypted_cookie_store | https://github.com/FooBarWidget/encrypted_cookie_store | lib/encrypted_cookie_store.rb | Ruby | bsd-3-clause | 48 | master | 4,238 | require 'openssl'
require 'encrypted_cookie_store/constants'
class EncryptedCookieStore < ActionController::Session::CookieStore
OpenSSLCipherError = OpenSSL::Cipher.const_defined?(:CipherError) ? OpenSSL::Cipher::CipherError : OpenSSL::CipherError
include EncryptedCookieStoreConstants
class << self
attr_access... |
github | FooBarWidget/encrypted_cookie_store | https://github.com/FooBarWidget/encrypted_cookie_store | lib/tasks/encrypted_cookie_store.rake | Ruby | bsd-3-clause | 48 | master | 366 | dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$LOAD_PATH << dir
namespace :secret do
desc "Generate an encryption key for EncryptedCookieStore that's cryptographically secure."
task :encryption_key do
require 'encrypted_cookie_store/constants'
puts ActiveSupport::SecureRandom.hex(EncryptedCooki... |
github | cats-oss/fastlane-plugin-firebase_test_lab_android | https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android | fastlane-plugin-firebase_test_lab_android.gemspec | Ruby | mit | 48 | master | 1,255 | # coding: utf-8
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fastlane/plugin/firebase_test_lab_android/version'
Gem::Specification.new do |spec|
spec.name = 'fastlane-plugin-firebase_test_lab_android'
spec.version = Fastlane::FirebaseTe... |
github | cats-oss/fastlane-plugin-firebase_test_lab_android | https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android | lib/fastlane/plugin/firebase_test_lab_android.rb | Ruby | mit | 48 | master | 431 | require 'fastlane/plugin/firebase_test_lab_android/version'
module Fastlane
module FirebaseTestLabAndroid
def self.all_classes
Dir[File.expand_path('**/{actions,helper}/**/*.rb', File.dirname(__FILE__))]
end
end
end
# By default we want to import all available actions
# A plugin can contain any numb... |
github | cats-oss/fastlane-plugin-firebase_test_lab_android | https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android | lib/fastlane/plugin/firebase_test_lab_android/actions/firebase_test_lab_android_action.rb | Ruby | mit | 48 | master | 15,358 | require 'fastlane/action'
require 'json'
require 'fileutils'
module Fastlane
module Actions
class FirebaseTestLabAndroidAction < Action
def self.run(params)
UI.message("Starting...")
results_bucket = params[:firebase_test_lab_results_bucket] || "#{params[:project_id]}_test_results"
... |
github | cats-oss/fastlane-plugin-firebase_test_lab_android | https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android | lib/fastlane/plugin/firebase_test_lab_android/helper/Helper.rb | Ruby | mit | 48 | master | 4,544 | require 'fastlane_core/ui/ui'
module Fastlane
# Outcome
PASSED = 'Passed'
FAILED = 'Failed'
SKIPPED = 'Skipped'
INCONCLUSIVE = 'Inconclusive'
module Helper
def self.gcs_result_bucket_url(bucket, dir)
"https://console.developers.google.com/storage/browser/#{bucket}/#{CGI.escape(dir)}"
end
... |
github | cats-oss/fastlane-plugin-firebase_test_lab_android | https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android | lib/fastlane/plugin/firebase_test_lab_android/helper/slack_notifier.rb | Ruby | mit | 48 | master | 545 | require 'fastlane/action'
require 'fastlane_core/ui/ui'
require 'json'
module Fastlane
module SlackNotifier
def self.notify(slack_url, message, success)
slackArgs = Fastlane::ConfigurationHelper.parse(Fastlane::Actions::SlackAction, {
slack_url: slack_url,
message: message,
su... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.