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 | hopsoft/stimulus_reflex_todomvc | https://github.com/hopsoft/stimulus_reflex_todomvc | config/environments/development.rb | Ruby | mit | 49 | master | 2,244 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | hopsoft/stimulus_reflex_todomvc | https://github.com/hopsoft/stimulus_reflex_todomvc | app/reflexes/todos_reflex.rb | Ruby | mit | 49 | master | 845 | class TodosReflex < StimulusReflex::Reflex
def create
Todo.create session_id: session.id, title: element[:value]
end
def edit
@edit_id = element.dataset[:id].to_i
end
def cancel_edit
@edit_id = nil
end
def update
Todo.find_by(session_id: session.id, id: element.dataset[:id])&.update tit... |
github | hopsoft/stimulus_reflex_todomvc | https://github.com/hopsoft/stimulus_reflex_todomvc | app/models/todo.rb | Ruby | mit | 49 | master | 570 | # == Schema Information
#
# Table name: todos
#
# id :bigint not null, primary key
# session_id :string not null
# title :string not null
# completed :boolean default(FALSE), not null
# created_at :datetime not null
# updated_at :datetime not nu... |
github | hopsoft/stimulus_reflex_todomvc | https://github.com/hopsoft/stimulus_reflex_todomvc | app/controllers/todos_controller.rb | Ruby | mit | 49 | master | 397 | class TodosController < ApplicationController
FILTERS = %w[all active completed].freeze
def index
session[:filter] = "all" unless filter_permitted?(session[:filter])
@all_todos = Todo.where(session_id: session.id)
@filtered_todos = @all_todos.public_send(session[:filter]).order(:created_at)
end
pr... |
github | hopsoft/stimulus_reflex_todomvc | https://github.com/hopsoft/stimulus_reflex_todomvc | app/controllers/application_controller.rb | Ruby | mit | 49 | master | 202 | class ApplicationController < ActionController::Base
before_action :set_action_cable_identifier
private
def set_action_cable_identifier
cookies.encrypted[:session_id] = session.id
end
end |
github | hopsoft/stimulus_reflex_todomvc | https://github.com/hopsoft/stimulus_reflex_todomvc | db/schema.rb | Ruby | mit | 49 | master | 1,290 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
#... |
github | hopsoft/stimulus_reflex_todomvc | https://github.com/hopsoft/stimulus_reflex_todomvc | db/migrate/20190811153814_create_todos.rb | Ruby | mit | 49 | master | 313 | class CreateTodos < ActiveRecord::Migration[6.0]
def change
create_table :todos do |t|
t.string :session_id, null: false
t.string :title, null: false
t.boolean :completed, null: false, default: false
t.timestamps
t.index :session_id
t.index :completed
end
end
end |
github | rails/actionpack-xml_parser | https://github.com/rails/actionpack-xml_parser | actionpack-xml_parser.gemspec | Ruby | mit | 49 | master | 821 | $:.push File.expand_path("../lib", __FILE__)
require "action_pack/xml_parser/version"
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'actionpack-xml_parser'
s.version = ActionPack::XmlParser::VERSION
s.summary = 'XML parameters parser for Action Pack (removed from cor... |
github | rails/actionpack-xml_parser | https://github.com/rails/actionpack-xml_parser | test/webservice_test.rb | Ruby | mit | 49 | master | 7,725 | require 'helper'
class WebServiceTest < ActionDispatch::IntegrationTest
class TestController < ActionController::Base
def assign_parameters
if params[:full]
render plain: dump_params_keys
else
render plain: (params.keys - ['controller', 'action']).sort.join(", ")
end
end
... |
github | rails/actionpack-xml_parser | https://github.com/rails/actionpack-xml_parser | test/helper.rb | Ruby | mit | 49 | master | 2,440 | require 'bundler/setup'
require 'active_support/testing/autorun'
require 'action_pack/xml_parser'
require 'action_controller'
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
module ActionDispatch
module SharedRoutes
def before_setup
... |
github | rails/actionpack-xml_parser | https://github.com/rails/actionpack-xml_parser | test/xml_params_parsing_test.rb | Ruby | mit | 49 | master | 5,351 | require 'helper'
class XmlParamsParsingTest < ActionDispatch::IntegrationTest
class TestController < ActionController::Base
class << self
attr_accessor :last_request_parameters
attr_accessor :last_request
end
def parse
self.class.last_request_parameters = request.request_parameters
... |
github | rails/actionpack-xml_parser | https://github.com/rails/actionpack-xml_parser | lib/action_pack/xml_parser.rb | Ruby | mit | 49 | master | 499 | require 'active_support'
require 'active_support/core_ext/hash/conversions'
require 'action_dispatch'
require 'action_dispatch/http/request'
require 'action_pack/xml_parser/version'
module ActionPack
class XmlParser
def self.register
original_parsers = ActionDispatch::Request.parameter_parsers
Action... |
github | rails/actionpack-xml_parser | https://github.com/rails/actionpack-xml_parser | lib/action_pack/xml_parser/railtie.rb | Ruby | mit | 49 | master | 229 | require 'action_pack/xml_parser'
module ActionPack
class XmlParser
class Railtie < ::Rails::Railtie
initializer "actionpack-xml_parser.configure" do
ActionPack::XmlParser.register
end
end
end
end |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | expedia.gemspec | Ruby | mit | 49 | master | 1,155 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'expedia/version'
Gem::Specification.new do |gem|
gem.name = "expedia"
gem.version = Expedia::VERSION
gem.platform = Gem::Platform::RUBY
gem.authors = [... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | spec/http_service_spec.rb | Ruby | mit | 49 | master | 2,439 | require 'spec_helper'
describe "Expedia::HTTPService" do
it "has an DEVELOPMENT_API_SERVER Constant" do
Expedia::HTTPService.constants.should include(:DEVELOPMENT_API_SERVER)
end
it "has an API_SERVER Constant" do
Expedia::HTTPService.constants.should include(:API_SERVER)
end
it "has an RESERVATIO... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | spec/spec_helper.rb | Ruby | mit | 49 | master | 752 | require 'expedia'
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Co... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | lib/expedia.rb | Ruby | mit | 49 | master | 856 | # useful tools
require 'digest/md5'
require 'multi_json'
# include expedia modules
require 'expedia/errors'
require 'expedia/api'
# HTTP module so we can communicate with Expedia
require 'expedia/http_service'
# miscellaneous
require 'expedia/utils'
require 'expedia/version'
if defined?(Rails)
require 'expedia/ra... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | lib/expedia/http_service.rb | Ruby | mit | 49 | master | 4,216 | require 'faraday'
require 'expedia/http_service/response'
module Expedia
module HTTPService
API_SERVER = 'api.eancdn.com'
# The development api server is not reliable. Often gives 400...
# DEVELOPMENT_API_SERVER = 'dev.api.ean.com'
DEVELOPMENT_API_SERVER = 'api.ean.com'
RESERVATION_SERVER = 'boo... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | lib/expedia/utils.rb | Ruby | mit | 49 | master | 962 | module Expedia
module Utils
# Utility methods used by Expedia.
require 'logger'
require 'forwardable'
extend Forwardable
extend self
def_delegators :logger, :debug, :info, :warn, :error, :fatal, :level, :level=
# The Expedia logger, an instance of the standard Ruby logger, pointing to ... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | lib/expedia/errors.rb | Ruby | mit | 49 | master | 1,724 | module Expedia
class ExpediaError < StandardError; end
# Expedia respondes with status of 200 even if there is an exception (most of the time)
class APIError < ::Expedia::ExpediaError
# @status The HTTP status code of the response
# @error_body The parsed response body
# @error_info One of the foll... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | lib/expedia/api.rb | Ruby | mit | 49 | master | 2,338 | module Expedia
# All method naming is done in correspondence with Expedia services and ruby conventions
class Api
# @param args [Hash] All the params required for 'get_list' call
# @return [Expedia::HTTPService::Response] on success. A response object representing the results from Expedia
# @return [E... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | lib/expedia/http_service/response.rb | Ruby | mit | 49 | master | 598 | module Expedia
module HTTPService
class Response
attr_reader :status, :body, :headers
# Creates a new Response object, which standardizes the response received From Expedia.
def initialize(status, body, headers)
@status = status
@body = MultiJson.load(body) rescue ''
... |
github | zaidakram/expedia | https://github.com/zaidakram/expedia | lib/generators/expedia/initialize_generator.rb | Ruby | mit | 49 | master | 273 | require 'rails/generators'
module Expedia
class InitializeGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates", __FILE__)
def copy_initializer_file
copy_file "expedia.txt", "config/initializers/expedia.rb"
end
end
end |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | Gemfile | Ruby | mit | 49 | main | 370 | # frozen_string_literal: true
source "https://rubygems.org"
eval_gemfile "Gemfile.devtools"
gemspec
group :tools do
gem "debug", platform: :mri
end
group :docs do
gem "redcarpet", platform: :mri
gem "yard"
gem "yard-junk"
end
group :integrations do
gem "hanami-view", github: "hanami/view", branch: "main... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | hanami-mailer.gemspec | Ruby | mit | 49 | main | 1,488 | # frozen_string_literal: true
# This file is synced from hanakai-rb/repo-sync. To update it, edit repo-sync.yml.
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "hanami/mailer/version"
Gem::Specification.new do |spec|
spec.name = "hanami-mailer"
spe... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | benchmark.rb | Ruby | mit | 49 | main | 1,268 | # frozen_string_literal: true
require "bundler/setup"
require "hanami/mailer"
require "benchmark/ips"
require "allocation_stats"
require_relative "examples/base"
configuration = Hanami::Mailer::Configuration.new do |config|
config.root = "examples/base"
config.delivery_method = :test
end
configuration... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | Rakefile | Ruby | mit | 49 | main | 1,080 | # frozen_string_literal: true
require "rake"
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new do |task|
file_list = FileList["spec/**/*_spec.rb"]
file_list = file_list.exclude("spec/isolation/**/*_spec.rb")
task.pattern = file_list
end
namespace :spec do
desc "Run isolati... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/spec_helper.rb | Ruby | mit | 49 | main | 838 | # frozen_string_literal: true
require "hanami-mailer"
require "fileutils"
SPEC_ROOT = Pathname(__dir__).realpath.freeze
Dir[File.join(__dir__, "support", "**", "*.rb")].each { |f| require f }
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_m... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/integration/mailer_spec.rb | Ruby | mit | 49 | main | 3,699 | # frozen_string_literal: true
RSpec.describe "Basic mail delivery" do
let(:mailer) { mailer_class.new }
describe "simple mailer with static values" do
let(:mailer_class) {
Class.new(Hanami::Mailer) {
from "noreply@example.com"
to "user@example.com"
subject "Welcome to our app"
... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/integration/delivery_result_spec.rb | Ruby | mit | 49 | main | 5,461 | # frozen_string_literal: true
RSpec.describe "Delivery results" do
let(:mailer) { mailer_class.new }
let(:mailer_class) do
Class.new(Hanami::Mailer) do
from "noreply@example.com"
to "user@example.com"
subject "Test email"
end
end
describe "Delivery::Result" do
it "returns a Resu... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/integration/format_spec.rb | Ruby | mit | 49 | main | 1,914 | # frozen_string_literal: true
RSpec.describe "Format restriction" do
let(:mailer) { mailer_class.new(view: view) }
let(:view) {
Class.new {
def call(format:, **)
case format
when :html then "<h1>Hello World!</h1>"
when :text then "Hello World!"
end
end
}.new
}... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/integration/attachments_spec.rb | Ruby | mit | 49 | main | 18,733 | # frozen_string_literal: true
RSpec.describe "Attachments" do
let(:mailer) { mailer_class.new }
describe "class-level attachments" do
describe "static filename attachment" do
let(:mailer_class) do
Class.new(Hanami::Mailer) do
from "noreply@example.com"
to "user@example.com"
... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/integration/delivery_options_spec.rb | Ruby | mit | 49 | main | 3,693 | # frozen_string_literal: true
RSpec.describe "Delivery options" do
let(:delivery_method) do
Class.new do
attr_reader :last_options
def call(message)
@last_options = message.delivery_options
# Simulate using the options for scheduling
status = message.delivery_options[:send_a... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/integration/view_integration_spec.rb | Ruby | mit | 49 | main | 10,045 | # frozen_string_literal: true
require "tmpdir"
RSpec.describe "View integration" do
let(:mailer) { mailer_class.new }
describe "with integration enabled (default)" do
around do |example|
Dir.mktmpdir do |dir|
@templates_dir = Pathname(dir)
example.run
end
end
let(:templat... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/integration/headers_spec.rb | Ruby | mit | 49 | main | 7,042 | # frozen_string_literal: true
RSpec.describe "Headers" do
let(:mailer) { mailer_class.new }
describe "static header values" do
let(:mailer_class) {
Class.new(Hanami::Mailer) do
from "noreply@example.com"
to "user@example.com"
subject "Test"
header :x_priority, "1"
... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/isolation/without_view_spec.rb | Ruby | mit | 49 | main | 770 | # frozen_string_literal: true
require_relative "isolation_helper"
require "hanami-mailer"
RSpec.describe Hanami::Mailer, "without hanami-view" do
it "does not include ViewIntegration" do
expect(Hanami::Mailer.ancestors).not_to include(Hanami::Mailer::ViewIntegration)
end
it "delivers successfully without ... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/isolation/isolation_helper.rb | Ruby | mit | 49 | main | 281 | # frozen_string_literal: true
require "rubygems"
require "bundler"
# Set up essential gems from the Gemfile, but NOT the :integrations group, which ensures hanami-view
# is not made available.
Bundler.setup :default, :development, :test
$LOAD_PATH.unshift "lib"
require "rspec" |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/unit/message_spec.rb | Ruby | mit | 49 | main | 5,854 | # frozen_string_literal: true
RSpec.describe Hanami::Mailer::Message do
describe "#initialize" do
describe "address normalization" do
it "wraps a string address in an array" do
message = described_class.new(
from: "sender@example.com",
to: "recipient@example.com",
subj... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/unit/dsl/exposure_spec.rb | Ruby | mit | 49 | main | 5,460 | # frozen_string_literal: true
RSpec.describe Hanami::Mailer::DSL::Exposure do
describe "#initialize" do
it "creates an exposure with a name" do
exposure = described_class.new(:user)
expect(exposure.name).to eq(:user)
end
it "creates an exposure with a proc" do
proc = -> { "value" }
... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/unit/dsl/exposures_spec.rb | Ruby | mit | 49 | main | 8,150 | # frozen_string_literal: true
RSpec.describe Hanami::Mailer::DSL::Exposures do
describe "#initialize" do
it "creates empty collection by default" do
exposures = described_class.new
expect(exposures).to be_empty
end
it "accepts initial exposures hash" do
exposure = Hanami::Mailer::DSL:... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/unit/dsl/plucky_proc_spec.rb | Ruby | mit | 49 | main | 8,917 | # frozen_string_literal: true
RSpec.describe Hanami::Mailer::DSL::PluckyProc do
describe ".from_name" do
it "returns PluckyProc when given a proc" do
proc = -> { "result" }
context = Object.new
plucky_proc = described_class.from_name(proc, :unused_name, context)
expect(plucky_proc).to b... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/unit/delivery/test_spec.rb | Ruby | mit | 49 | main | 1,663 | # frozen_string_literal: true
RSpec.describe Hanami::Mailer::Delivery::Test do
let(:message) { minimal_message }
let(:delivery) { described_class.new }
describe ".deliveries" do
it "is empty after clear" do
described_class.clear
expect(described_class.deliveries).to be_empty
end
it "ac... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/unit/delivery/smtp_spec.rb | Ruby | mit | 49 | main | 2,411 | # frozen_string_literal: true
require "mail"
require "net/smtp"
RSpec.describe Hanami::Mailer::Delivery::SMTP do
subject(:smtp_delivery) { described_class.new(address: "smtp.example.com", port: 587) }
let(:mailer_class) do
Class.new(Hanami::Mailer) do
from "noreply@example.com"
to "user@example.c... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | spec/support/mailer_helpers.rb | Ruby | mit | 49 | main | 543 | # frozen_string_literal: true
module MailerSpecHelpers
# Build a minimal valid Message for use in unit tests.
# Accepts keyword arguments to override any default field.
#
# @example
# let(:message) { minimal_message }
# let(:message) { minimal_message(subject: "Hello") }
def minimal_message(**attrs)
... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer.rb | Ruby | mit | 49 | main | 11,324 | # frozen_string_literal: true
require "dry/configurable"
require "zeitwerk"
require_relative "mailer/errors"
module Hanami
# Base mailer class
#
# @api public
class Mailer
# @api private
def self.gem_loader
@gem_loader ||= Zeitwerk::Loader.new.tap do |loader|
root = File.expand_path("..... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/message.rb | Ruby | mit | 49 | main | 3,264 | # frozen_string_literal: true
module Hanami
class Mailer
# Represents an email message
#
# @api private
class Message
# @api private
attr_reader :from, :to, :cc, :bcc, :reply_to, :return_path, :subject
# @api private
attr_reader :html_body, :text_body, :attachments, :headers,... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/attachment_set.rb | Ruby | mit | 49 | main | 1,044 | # frozen_string_literal: true
module Hanami
class Mailer
# A collection of attachments that enforces uniqueness.
#
# Aids the preparation of a single email delivery. It is returned from {DSL::Attachments#bind},
# containing class-level attachment definitions. Runtime attachments can be added via {#co... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/attachment.rb | Ruby | mit | 49 | main | 4,188 | # frozen_string_literal: true
module Hanami
class Mailer
# Represents an email attachment
#
# @api public
class Attachment
# Common MIME types for attachments
#
# @api private
MIME_TYPES = {
".pdf" => "application/pdf",
".zip" => "application/zip",
".jp... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/view_integration.rb | Ruby | mit | 49 | main | 5,384 | # frozen_string_literal: true
module Hanami
class Mailer
# Integration module for Hanami::View support.
# This module is included when Hanami::View is available,
# providing automatic view building and settings inheritance.
#
# @api private
module ViewIntegration
def self.included(base)... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/errors.rb | Ruby | mit | 49 | main | 1,827 | # frozen_string_literal: true
module Hanami
class Mailer
# Base error class for all Hanami::Mailer errors
#
# @api public
class Error < StandardError
end
# Raised when a mailer is missing required delivery configuration
#
# @api public
class MissingDeliveryError < Error
def... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/delivery/smtp.rb | Ruby | mit | 49 | main | 3,744 | # frozen_string_literal: true
require "net/smtp"
module Hanami
class Mailer
module Delivery
# SMTP delivery method
#
# @api public
class SMTP
# Initialize SMTP delivery with configuration
#
# @param options [Hash] SMTP configuration options
#
# @ap... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/delivery/test.rb | Ruby | mit | 49 | main | 1,374 | # frozen_string_literal: true
module Hanami
class Mailer
module Delivery
# Test delivery method that stores delivery results in memory
#
# @api public
class Test
class << self
# Returns all delivery results
#
# @return [Array<Delivery::Result>]
... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/delivery/result.rb | Ruby | mit | 49 | main | 2,694 | # frozen_string_literal: true
module Hanami
class Mailer
module Delivery
# Represents the outcome of a message delivery attempt.
#
# This is the base class for delivery results. Delivery methods return an instance of this
# class (or a subclass) from their #call method. Third-party delive... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/dsl/attachments.rb | Ruby | mit | 49 | main | 2,661 | # frozen_string_literal: true
module Hanami
class Mailer
module DSL
# Collection of class-level attachment definitions for a mailer.
#
# @api private
class Attachments
attr_reader :definitions
def initialize
@definitions = []
end
private def ini... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/dsl/exposures.rb | Ruby | mit | 49 | main | 2,318 | # frozen_string_literal: true
require "tsort"
require "dry/core/equalizer"
module Hanami
class Mailer
module DSL
# @api private
class Exposures
include Dry::Equalizer(:exposures)
include TSort
attr_reader :exposures
def initialize(exposures = {})
@exposure... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/dsl/plucky_proc.rb | Ruby | mit | 49 | main | 3,998 | # frozen_string_literal: true
module Hanami
class Mailer
module DSL
# A plucky proc that evaluates with automatic keyword argument extraction from input.
#
# This class encapsulates the logic for calling procs/methods in a mailer context,
# handling both positional and keyword arguments i... |
github | hanami/hanami-mailer | https://github.com/hanami/hanami-mailer | lib/hanami/mailer/dsl/exposure.rb | Ruby | mit | 49 | main | 1,492 | # frozen_string_literal: true
require "dry/core/equalizer"
module Hanami
class Mailer
module DSL
# An exposure defined on a mailer.
#
# @api private
class Exposure
include Dry::Equalizer(:name, :callable, :object, :options)
attr_reader :name
attr_reader :object
... |
github | alighters/MediumArticles | https://github.com/alighters/MediumArticles | Gemfile | Ruby | apache-2.0 | 49 | master | 1,502 | source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use Cof... |
github | alighters/MediumArticles | https://github.com/alighters/MediumArticles | config/application.rb | Ruby | apache-2.0 | 49 | master | 1,121 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module MediumArticles
class Application < Rails::Application
# Settings in config/environments/* tak... |
github | alighters/MediumArticles | https://github.com/alighters/MediumArticles | config/routes.rb | Ruby | apache-2.0 | 49 | master | 1,692 | Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'ca... |
github | alighters/MediumArticles | https://github.com/alighters/MediumArticles | app/controllers/article_controller.rb | Ruby | apache-2.0 | 49 | master | 767 | class ArticleController < ApplicationController
def create
title = params[:title]
link = params[:link]
data = []
file_name = Rails.root.to_s + '/README.md'
status = 'ok'
if title.nil? or link.nil?
status = 'error'
else
if(Date.today.mday == 1)
new_file_name = "#{Rails.... |
github | alighters/MediumArticles | https://github.com/alighters/MediumArticles | app/helpers/git_helper.rb | Ruby | apache-2.0 | 49 | master | 306 | module GitHelper
def self.commit(title)
t = fork do
Signal.trap("HUP") {
system 'git status'
system 'git add .'
system "git commit -am 'add #{title}'"
system 'git pull --rebase'
system 'git push'
}
end
Process.kill("HUP", t)
end
end |
github | alighters/MediumArticles | https://github.com/alighters/MediumArticles | app/helpers/data_helper.rb | Ruby | apache-2.0 | 49 | master | 1,673 | module DataHelper
# 根据文件获取添入标题和链接之后的最新文本内容
def self.append_to(file_name, title, link)
data = []
changed = false
inserted = false
File.open(file_name).each do |line|
if !inserted and line.start_with?('###')
# 当前行为具体的日期
date_str = line.slice(3, 3 + 10).squish
if(is_dat... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | Gemfile | Ruby | mit | 49 | master | 1,794 | source 'http://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.1.6'
# Database and model related
gem 'pg'
gem 'state_machine'
gem 'paperclip', '~> 4.1.1'
gem 'paperclip-meta'
gem 'schema_plus'
gem 'hstore_translate'
# Controller related
gem 'responders'
gem 'has_scope'
# Authentication and authorization
gem 'devise'
ge... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | Vagrantfile | Ruby | mit | 49 | master | 290 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty32'
config.vm.hostname = 'rails-dev-box'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :shell, path: 'Vagrant.sh', keep_color: true
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141102163238_set_gateways_states.rb | Ruby | mit | 49 | master | 388 | class SetGatewaysStates < ActiveRecord::Migration
def up
execute "UPDATE gateways SET state = 'draft'"
execute "UPDATE gateways SET state = 'sandbox' WHERE active AND settings -> 'sandbox' = 'true'"
execute "UPDATE gateways SET state = 'production' WHERE active AND settings -> 'sandbox' = 'false'"
end
... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141111193411_migrate_initiatives_currencies.rb | Ruby | mit | 49 | master | 206 | class MigrateInitiativesCurrencies < ActiveRecord::Migration
def up
execute "UPDATE initiatives SET currency = 'BRL'"
end
def down
execute "UPDATE initiatives SET currency = 'USD'"
end
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20140922232329_create_initiatives.rb | Ruby | mit | 49 | master | 293 | class CreateInitiatives < ActiveRecord::Migration
def change
create_table :initiatives do |t|
t.text :permalink
t.text :name
t.text :first_text
t.text :second_text
t.references :user
t.timestamps
end
add_index :initiatives, :user_id
end
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141117184652_migrate_translation_data_on_gateways.rb | Ruby | mit | 49 | master | 554 | class MigrateTranslationDataOnGateways < ActiveRecord::Migration
def up
execute("UPDATE gateways SET title_translations = ('pt => \"' || title || '\"')::hstore, ordering_translations = ('pt => \"' || ordering || '\"')::hstore")
remove_column :gateways, :title
remove_column :gateways, :ordering
end
de... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20140923044128_create_contributions.rb | Ruby | mit | 49 | master | 302 | class CreateContributions < ActiveRecord::Migration
def change
create_table :contributions do |t|
t.references :user
t.references :initiative
t.float :value
t.timestamps
end
add_index :contributions, :user_id
add_index :contributions, :initiative_id
end
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141102171933_set_contributions_gateways.rb | Ruby | mit | 49 | master | 319 | class SetContributionsGateways < ActiveRecord::Migration
def up
execute "UPDATE contributions SET gateway_id = (SELECT id FROM gateways WHERE gateways.initiative_id = contributions.initiative_id AND module_name = 'UnlockMoip')"
end
def down
execute "UPDATE contributions SET gateway_id = null"
end
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141029193123_migrate_moip_attributes_to_gateways.rb | Ruby | mit | 49 | master | 1,207 | class MigrateMoipAttributesToGateways < ActiveRecord::Migration
def up
execute("INSERT INTO gateways (initiative_id, module_name, ordering, settings, active) SELECT initiatives.id, 'UnlockMoip', 1, ('token => \"' || moip_token || '\", key => \"' || moip_key || '\", sandbox => \"' || sandbox || '\"')::hstore, (moi... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141102174051_change_contribution_state_to_string.rb | Ruby | mit | 49 | master | 760 | class ChangeContributionStateToString < ActiveRecord::Migration
def up
change_column :contributions, :state, :string
execute "UPDATE contributions SET state = 'pending' WHERE state = '0'"
execute "UPDATE contributions SET state = 'active' WHERE state = '1'"
execute "UPDATE contributions SET state = 's... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141117180939_migrate_translation_data_on_initiatives.rb | Ruby | mit | 49 | master | 866 | class MigrateTranslationDataOnInitiatives < ActiveRecord::Migration
def up
execute("UPDATE initiatives SET name_translations = ('pt => \"' || REPLACE(name, '\"', '\\\"') || '\"')::hstore, first_text_translations = ('pt => \"' || REPLACE(first_text, '\"', '\\\"') || '\"')::hstore, second_text_translations = ('pt =... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141105184452_store_gateway_data_on_contributions.rb | Ruby | mit | 49 | master | 659 | class StoreGatewayDataOnContributions < ActiveRecord::Migration
def up
execute "UPDATE contributions SET gateway_data = ('customer_code => ' || (substring((SELECT permalink FROM initiatives WHERE initiatives.id = contributions.initiative_id) from 1 for 30) || user_id || (CASE WHEN gateway_state = 'sandbox' THEN '... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141102164402_add_gateway_state_to_contributions.rb | Ruby | mit | 49 | master | 379 | class AddGatewayStateToContributions < ActiveRecord::Migration
def up
add_column :contributions, :gateway_state, :string
execute "UPDATE contributions SET gateway_state = 'sandbox'"
execute "UPDATE contributions SET gateway_state = 'production' WHERE gateway_data -> 'sandbox' = 'false'"
end
def down
... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141117184212_add_translation_columns_to_gateways.rb | Ruby | mit | 49 | master | 200 | class AddTranslationColumnsToGateways < ActiveRecord::Migration
def change
add_column :gateways, :title_translations, :hstore
add_column :gateways, :ordering_translations, :hstore
end
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141102165719_set_initiatives_states.rb | Ruby | mit | 49 | master | 381 | class SetInitiativesStates < ActiveRecord::Migration
def up
execute "UPDATE initiatives SET state = 'draft'"
execute "UPDATE initiatives SET state = 'published' WHERE permalink IS NOT NULL AND permalink <> '' AND id IN (SELECT DISTINCT initiative_id FROM gateways WHERE state = 'production')"
end
def down... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141118032303_migrate_translation_data_from_pt_to_pt_br.rb | Ruby | mit | 49 | master | 1,256 | class MigrateTranslationDataFromPtToPtBr < ActiveRecord::Migration
def up
execute "UPDATE gateways SET title_translations = title_translations || hstore('pt-BR', (title_translations -> 'pt'))"
execute "UPDATE gateways SET ordering_translations = ordering_translations || hstore('pt-BR', (ordering_translations ... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20140423141609_devise_create_users.rb | Ruby | mit | 49 | master | 1,405 | class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :name, null: false, default: ""
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
#... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141029160125_create_gateways.rb | Ruby | mit | 49 | master | 473 | class CreateGateways < ActiveRecord::Migration
def change
create_table :gateways do |t|
t.references :initiative, index: true
t.string :module_name, index: true
t.integer :ordering
t.text :title
t.text :description
t.hstore :settings
t.boolean :active, default: false
... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141029203103_migrate_contribution_sandbox_to_gateway.rb | Ruby | mit | 49 | master | 396 | class MigrateContributionSandboxToGateway < ActiveRecord::Migration
def up
execute("UPDATE contributions SET gateway_data = ('sandbox => ' || sandbox)::hstore")
remove_column :contributions, :sandbox
end
def down
add_column :contributions, :sandbox, :boolean
execute("UPDATE contributions SET sand... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141117180214_add_translation_columns_to_initiatives.rb | Ruby | mit | 49 | master | 274 | class AddTranslationColumnsToInitiatives < ActiveRecord::Migration
def change
add_column :initiatives, :name_translations, :hstore
add_column :initiatives, :first_text_translations, :hstore
add_column :initiatives, :second_text_translations, :hstore
end
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20141118042414_add_indexes_to_translations_columns.rb | Ruby | mit | 49 | master | 269 | class AddIndexesToTranslationsColumns < ActiveRecord::Migration
def change
add_index :gateways, :title_translations, using: :gist
add_index :gateways, :ordering_translations, using: :gist
add_index :initiatives, :name_translations, using: :gist
end
end |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | db/migrate/20140923193531_add_moip_columns_to_users.rb | Ruby | mit | 49 | master | 616 | class AddMoipColumnsToUsers < ActiveRecord::Migration
def change
add_column :users, :full_name, :text
add_column :users, :document, :text
add_column :users, :phone_area_code, :text
add_column :users, :phone_number, :text
add_column :users, :birthdate, :date
add_column :users, :address_street, ... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/application.rb | Ruby | mit | 49 | master | 1,486 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Unlock
class Application < Rails::Application
# Settings in config/environments/* take preced... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/unicorn.rb | Ruby | mit | 49 | master | 582 | worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 25
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.con... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/routes.rb | Ruby | mit | 49 | master | 1,034 | Rails.application.routes.draw do
devise_for :users
filter :locale
get '/sitemap' => "initiatives#sitemap", :as => :sitemap
resources :initiatives, except: [:create] do
resources :contributions, controller: 'initiatives/contributions', except: [:create, :edit, :destroy]
resources :gateways, contr... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/environments/test.rb | Ruby | mit | 49 | master | 1,867 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/environments/development.rb | Ruby | mit | 49 | master | 1,713 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/environments/production.rb | Ruby | mit | 49 | master | 4,037 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/initializers/svg_image_tag.rb | Ruby | mit | 49 | master | 668 | module ActionView
module Helpers
module AssetTagHelper
def image_tag(source, options={})
options = options.symbolize_keys
src = options[:src] = path_to_image(source)
unless src =~ /^(?:cid|data):/ || src.blank?
options[:alt] = options.fetch(:alt){ image_alt(src) }
... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/initializers/inflections.rb | Ruby | mit | 49 | master | 727 | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
ActiveSupport::Inflector.inflections(:en) do |inflect|... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/initializers/devise.rb | Ruby | mit | 49 | master | 12,602 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/initializers/filter_parameter_logging.rb | Ruby | mit | 49 | master | 245 | # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password, :password_confirmation, :settings, :gateway_data] |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | config/initializers/assets.rb | Ruby | mit | 49 | master | 754 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | app/views/initiatives/sitemap.xml.builder | Ruby | mit | 49 | master | 386 | xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
xml.url do
xml.loc root_url
xml.priority 1.0
xml.changefreq "daily"
end
@initiatives.each do |initiative|
xml.url do
xml.loc initiative_url(initiative)
xml.priority 0.8
xml.changefreq "daily"
... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | app/policies/contribution_policy.rb | Ruby | mit | 49 | master | 656 | class ContributionPolicy < ApplicationPolicy
def new?
user && record.gateway && !record.gateway.draft? && record.initiative && record.initiative.permalink.present?
end
def pay?
update?
end
def activate?
update?
end
def suspend?
update?
end
def permitted_attributes
if creat... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | app/policies/gateway_policy.rb | Ruby | mit | 49 | master | 492 | class GatewayPolicy < ApplicationPolicy
def index?
update?
end
def use_sandbox?
update?
end
def use_production?
update?
end
def revert_to_draft?
update?
end
def permitted_attributes
if create?
[:module_name, :title, :ordering, settings: [record.available_settings.map(&... |
github | danielweinmann/unlock | https://github.com/danielweinmann/unlock | app/policies/application_policy.rb | Ruby | mit | 49 | master | 845 | class ApplicationPolicy
class Scope
attr_reader :user, :scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
scope
end
end
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def index?
t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.