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
open-ews/open-ews
https://github.com/open-ews/open-ews
app/decorators/application_decorator.rb
Ruby
mit
47
develop
264
class ApplicationDecorator < SimpleDelegator class << self delegate :model_name, :human_attribute_name, to: :decorated_class def decorated_class name.delete_suffix("Decorator").safe_constantize end end def object __getobj__ end end
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/decorators/broadcast_decorator.rb
Ruby
mit
47
develop
1,522
class BroadcastDecorator < ApplicationDecorator ORDERED_STATUSES = %i[succeeded failed pending].freeze delegate :notifications, to: :object, private: true def notification_stats @notification_stats ||= begin stats = generate_stats ORDERED_STATUSES.each_with_object({}) { |s, result| result[s] = s...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/mailers/devise_mailer.rb
Ruby
mit
47
develop
326
class DeviseMailer < Devise::Mailer layout "account_mailer" helper ApplicationHelper private def devise_mail(record, action, opts = {}, &block) initialize_from_record(record) @account = record.account @host = record.account.subdomain_host bootstrap_mail(headers_for(action, opts), &block) en...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/mailers/forgot_subdomain_mailer.rb
Ruby
mit
47
develop
212
class ForgotSubdomainMailer < ApplicationMailer helper ApplicationHelper def forgot_subdomain(user) @user = user bootstrap_mail(to: user.email, subject: "#{user.account.name} Account URL") end end
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/update_delivery_attempt.rb
Ruby
mit
47
develop
952
class UpdateDeliveryAttempt < ApplicationWorkflow attr_reader :delivery_attempt, :somleng_resource SIP_RESPONSE_CODE_TO_ERROR_CODE_MAPPING = { "404" => "phone_number_unreachable" }.freeze def initialize(delivery_attempt, somleng_resource:) super() @delivery_attempt = delivery_attempt @somleng_...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/create_beneficiary_import_template.rb
Ruby
mit
47
develop
776
require "csv" class CreateBeneficiaryImportTemplate < ApplicationWorkflow attr_reader :template, :fields def initialize(**options) super() @template = options.fetch(:template, Pathname(Rails.root.join("app", "assets", "files", "beneficiary_import_template.csv"))) @fields = options.fetch(:fields) { Fie...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/download_broadcast_audio_file.rb
Ruby
mit
47
develop
668
class DownloadBroadcastAudioFile < ApplicationWorkflow class Error < Errors::ApplicationError; end attr_reader :broadcast def initialize(broadcast) super() @broadcast = broadcast end def call uri = URI.parse(broadcast.audio_url) broadcast.audio_file.attach( io: URI.open(uri), fi...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/start_broadcast.rb
Ruby
mit
47
develop
2,618
class StartBroadcast < ApplicationWorkflow attr_reader :broadcast, :broadcast_preview class Error < Errors::ApplicationError; end delegate :account, to: :broadcast, private: true delegate :filtered_beneficiaries, :group_beneficiaries, to: :broadcast_preview, private: true def initialize(broadcast, **option...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/copy_blob_with_extension.rb
Ruby
mit
47
develop
425
require "aws-sdk-s3" class CopyBlobWithExtension < ApplicationWorkflow attr_reader :blob, :bucket, :client def initialize(blob, bucket:, **options) super() @blob = blob @bucket = bucket @client = options.fetch(:client) { Aws::S3::Client.new } end def call client.copy_object( bucket:...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/import_csv.rb
Ruby
mit
47
develop
860
require "csv" class ImportCSV < ApplicationWorkflow attr_reader :import def initialize(import) super() @import = import end def call import_csv rescue Errors::ImportError => e import.error_code = e.code import.error_message = "Line #{import.error_line}: #{e.message}" import.transiti...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/handle_status_callback.rb
Ruby
mit
47
develop
713
class HandleStatusCallback < ApplicationWorkflow attr_reader :delivery_attempt, :resource def initialize(**options) super() @delivery_attempt = options.fetch(:delivery_attempt) { DeliveryAttempt.find(options.fetch(:delivery_attempt_id)) } @resource = options.fetch(:resource) do options.fetch(:par...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/create_beneficiary.rb
Ruby
mit
47
develop
698
class CreateBeneficiary < ApplicationWorkflow attr_reader :beneficiary_params, :address_params def initialize(address: {}, **params) super() @address_params = address @beneficiary_params = params end def call ApplicationRecord.transaction do beneficiary = Beneficiary.create!(beneficiary_...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/import_beneficiary.rb
Ruby
mit
47
develop
3,267
class ImportBeneficiary < ApplicationWorkflow attr_reader :import, :data def initialize(import:, data:) super() @import = import @data = data.with_indifferent_access end def call marked_for_deletion? ? delete_beneficiary! : create_beneficiary! end private def create_beneficiary! ra...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/handle_delivery_attempt_status_update.rb
Ruby
mit
47
develop
2,482
class HandleDeliveryAttemptStatusUpdate < ApplicationWorkflow class DeliveryAttemptRetryPolicy TERMINAL_ERRORS = [ "phone_number_unreachable" ].freeze attr_reader :delivery_attempt def initialize(delivery_attempt) @delivery_attempt = delivery_attempt end def terminal? return true if...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/update_broadcast.rb
Ruby
mit
47
develop
937
class UpdateBroadcast < ApplicationWorkflow class InvalidStateTransitionError < StandardError; end attr_reader :broadcast, :desired_status, :params def initialize(broadcast, desired_status: nil, **params) super() @broadcast = broadcast @desired_status = desired_status @params = params end d...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/delete_beneficiary.rb
Ruby
mit
47
develop
470
class DeleteBeneficiary < ApplicationWorkflow attr_reader :beneficiary def initialize(beneficiary) super() @beneficiary = beneficiary end def call Beneficiary.transaction do create_event beneficiary.destroy! end end private def create_event Event.create!( account:...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/create_broadcast.rb
Ruby
mit
47
develop
493
class CreateBroadcast < ApplicationWorkflow attr_reader :desired_status, :params def initialize(desired_status: nil, **params) super() @desired_status = desired_status @params = params end def call Broadcast.transaction do broadcast = Broadcast.create!(params) broadcast.transition_...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/workflows/export_csv.rb
Ruby
mit
47
develop
1,496
require "csv" class ExportCSV < ApplicationWorkflow attr_reader :export def initialize(export) super() @export = export end def call Tempfile.open do |tmpfile| write_csv(tmpfile) attach_file(tmpfile) end end private def write_csv(file) CSV.open(file, "w") do |csv| ...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/types/filter_data_type.rb
Ruby
mit
47
develop
773
class FilterDataType < ActiveRecord::Type::Value FilterData = Data.define(:fields) FilterData::Field = Data.define(:name, :operator, :value, :field_definition) attr_reader :field_definitions def initialize(field_definitions:, **) @field_definitions = field_definitions super(**) end def cast(value...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/types/phone_number_type.rb
Ruby
mit
47
develop
207
class PhoneNumberType < ActiveRecord::Type::String def cast(value) return if value.blank? result = value.gsub(/\D/, "") result.presence end def serialize(value) cast(value) end end
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/types/filter_form_type.rb
Ruby
mit
47
develop
1,199
class FilterFormType < FormType attr_reader :field_definitions, :filter_data def initialize(field_definitions:, filter_data: nil, **) @field_definitions = field_definitions @filter_data = filter_data super(**) end def cast(value) return value if value.is_a?(form) form.new(value.is_a?(filt...
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/types/form_data_type.rb
Ruby
mit
47
develop
201
class FormDataType < ActiveRecord::Type::String def cast(value) case value when Array value.reject(&:blank?) when String value.presence else value end end end
github
open-ews/open-ews
https://github.com/open-ews/open-ews
app/types/form_type.rb
Ruby
mit
47
develop
217
class FormType < ActiveRecord::Type::Value attr_reader :form def initialize(form:, **) @form = form super(**) end def cast(value) return value if value.is_a?(form) form.new(value) end end
github
jnewland/resource_this
https://github.com/jnewland/resource_this
Rakefile
Ruby
mit
47
master
266
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the resource_this plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end
github
jnewland/resource_this
https://github.com/jnewland/resource_this
lib/resource_this.rb
Ruby
mit
47
master
7,029
module ResourceThis # :nodoc: def self.included(base) base.extend(ClassMethods) end module ClassMethods def resource_this(options = {}) options.assert_valid_keys(:class_name, :will_paginate, :finder_options, :nested, :path_prefix) singular_name = controller_name.singularize sin...
github
jnewland/resource_this
https://github.com/jnewland/resource_this
test/resource_this_nesting_test.rb
Ruby
mit
47
master
4,214
require File.join(File.dirname(__FILE__), 'test_helper') class ResourceThisNestingTest < Test::Unit::TestCase def setup @controller = CommentsController.new @request = ActionController::TestRequest.new @request.accept = 'application/xml' @response = ActionController::TestResponse.new @firs...
github
jnewland/resource_this
https://github.com/jnewland/resource_this
test/test_helper.rb
Ruby
mit
47
master
1,820
$LOAD_PATH.unshift 'lib/' require 'rubygems' require 'multi_rails_init' require 'action_controller/test_process' require 'test/unit' require 'resource_this' begin require 'redgreen' rescue LoadError nil end RAILS_ROOT = '.' unless defined? RAILS_ROOT RAILS_ENV = 'test' unless defined? RAILS_ENV ActiveRecord...
github
jnewland/resource_this
https://github.com/jnewland/resource_this
test/resource_this_sorting_test.rb
Ruby
mit
47
master
1,443
require File.join(File.dirname(__FILE__), 'test_helper') class ResourceThisSortingTest < Test::Unit::TestCase def setup @controller = WidgetsController.new @request = ActionController::TestRequest.new @request.accept = 'application/xml' @response = ActionController::TestResponse.new @a = W...
github
jnewland/resource_this
https://github.com/jnewland/resource_this
test/resource_this_test.rb
Ruby
mit
47
master
2,552
require File.join(File.dirname(__FILE__), 'test_helper') class ResourceThisTest < Test::Unit::TestCase def setup @controller = PostsController.new @request = ActionController::TestRequest.new @request.accept = 'application/xml' @response = ActionController::TestResponse.new @first = Post.c...
github
jnewland/resource_this
https://github.com/jnewland/resource_this
test/resource_this_url_prefix_test.rb
Ruby
mit
47
master
1,230
require File.join(File.dirname(__FILE__), 'test_helper') class ResourceThisUrlPrefixTest < Test::Unit::TestCase def setup @controller = Admin::PostsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @first = Post.create(:title => "test", :b...
github
jnewland/resource_this
https://github.com/jnewland/resource_this
generators/resource_this/resource_this_generator.rb
Ruby
mit
47
master
2,832
class ResourceThisGenerator < Rails::Generator::NamedBase default_options :skip_migration => false attr_reader :controller_name, :controller_class_path, :controller_file_path, :controller_class_nesting, :controller_class_nesting_depth, ...
github
jnewland/resource_this
https://github.com/jnewland/resource_this
generators/resource_this/templates/functional_test.rb
Ruby
mit
47
master
1,659
require File.dirname(__FILE__) + '<%= '/..' * controller_class_nesting_depth %>/../test_helper' require '<%= controller_file_path %>_controller' # Re-raise errors caught by the controller. class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end class <%= controller_class_name %>ControllerT...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
proxifier.gemspec
Ruby
mit
47
master
653
$:.push File.expand_path("../lib", __FILE__) require "proxifier/version" Gem::Specification.new do |s| s.name = "proxifier" s.version = Proxifier::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Samuel Kadolph"] s.email = ["samuel@kadolph.com"] s.homepage = "https://github...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
lib/proxifier.rb
Ruby
mit
47
master
669
require "uri" require "uri/socks" module Proxifier require "proxifier/version" autoload :HTTPProxy, "proxifier/proxies/http" autoload :SOCKSProxy, "proxifier/proxies/socks" autoload :SOCKS5Proxy, "proxifier/proxies/socks" autoload :SOCKS4Proxy, "proxifier/proxies/socks4" autoload :SOCKS4AProxy, "proxifier...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
lib/uri/socks.rb
Ruby
mit
47
master
342
require "uri/generic" module URI class SOCKS < Generic DEFAULT_PORT = 1080 COMPONENT = [:scheme, :userinfo, :host, :port, :query].freeze end @@schemes["SOCKS"] = SOCKS @@schemes["SOCKS5"] = SOCKS class SOCKS4 < SOCKS end @@schemes["SOCKS4"] = SOCKS4 class SOCKS4A < SOCKS end @@schemes["SO...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
lib/proxifier/proxy.rb
Ruby
mit
47
master
1,462
require "socket" require "uri" require "uri/socks" module Proxifier class Proxy class << self def proxify?(host, no_proxy = nil) return true unless no_proxy dont_proxy = no_proxy.split(",") dont_proxy.none? { |h| host =~ /#{h}\Z/ } end end attr_reader :url, :options ...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
lib/proxifier/env.rb
Ruby
mit
47
master
3,096
require "socket" require "proxifier" module Proxifier class Proxy def open(host, port, local_host = nil, local_port = nil) return TCPSocket.new(host, port, local_host, local_port, :proxy => nil) unless proxify?(host) socket = TCPSocket.new(self.host, self.port, local_host, local_port, :proxy => nil)...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
lib/proxifier/proxies/socks.rb
Ruby
mit
47
master
3,156
require "ipaddr" require "proxifier/proxy" module Proxifier class SOCKSProxy < Proxy VERSION = 0x05 def do_proxify(socket, host, port) authenticaton_method = greet(socket) authenticate(socket, authenticaton_method) connect(socket, host, port) end protected def greet(socket) ...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
lib/proxifier/proxies/http.rb
Ruby
mit
47
master
573
require "net/http" require "proxifier/proxy" module Proxifier class HTTPProxy < Proxy def do_proxify(socket, host, port) return if query_options["tunnel"] == "false" socket << "CONNECT #{host}:#{port} HTTP/1.1\r\n" socket << "Host: #{host}:#{port}\r\n" socket << "Proxy-Authorization: Bas...
github
samuelkadolph/ruby-proxifier
https://github.com/samuelkadolph/ruby-proxifier
lib/proxifier/proxies/socks4.rb
Ruby
mit
47
master
1,320
require "proxifier/proxies/socks" module Proxifier class SOCKS4Proxy < SOCKSProxy VERSION = 0x04 protected def greet(socket) # noop end def authenticate(socket, method) # noop end def connect(socket, host, port) begin ip = IPAddr.new(host) ...
github
holman/rapinoe
https://github.com/holman/rapinoe
rapinoe.gemspec
Ruby
mit
47
master
1,165
Gem::Specification.new do |s| s.name = 'rapinoe' s.version = '0.0.4' s.licenses = ['MIT'] s.summary = "Parse Keynote files in Ruby." s.description = "Rapinoe is designed to parse the native files for Apple's Keynote presentation software. Its main focus is to help extract previews and genera...
github
holman/rapinoe
https://github.com/holman/rapinoe
Rakefile
Ruby
mit
47
master
3,397
require 'rubygems' require 'rake' require 'date' ############################################################################# # # Helper functions # ############################################################################# def name @name ||= Dir['*.gemspec'].first.split('.').first end def version line = Fil...
github
holman/rapinoe
https://github.com/holman/rapinoe
lib/rapinoe.rb
Ruby
mit
47
master
208
require 'fastimage' require 'miro' require 'zip' require_relative 'rapinoe/keynote' require_relative 'rapinoe/slide' module Rapinoe VERSION = '0.0.4' def self.new(path) Keynote.new(path) end end
github
holman/rapinoe
https://github.com/holman/rapinoe
lib/rapinoe/slide.rb
Ruby
mit
47
master
1,663
module Rapinoe # `Slide` is a really vague approximation. Keynote stores its data in a # zip-compressed file that has a bunch of .iwa files in it, which is where it # stores its data. Each of those .iwa files is a file that's been compressed # with a non-standard version of Google's Snappy compression format, a...
github
holman/rapinoe
https://github.com/holman/rapinoe
lib/rapinoe/keynote.rb
Ruby
mit
47
master
3,021
module Rapinoe class Keynote # The path where we can find the .key file. attr_accessor :path # The name of the file. attr_accessor :name # The (first stage) of uncompressed Keynote data in memory. attr_accessor :data # Create a new Keynote instance. # # path - The path to the ...
github
holman/rapinoe
https://github.com/holman/rapinoe
test/test_rapinoe.rb
Ruby
mit
47
master
246
require 'test/unit' require 'lib/rapinoe' class TestRapinoe < Test::Unit::TestCase def setup @keynote = Rapinoe.new('test/fixtures/ice-cream.key') end def test_quick_initializes assert_kind_of Rapinoe::Keynote, @keynote end end
github
holman/rapinoe
https://github.com/holman/rapinoe
test/test_slide.rb
Ruby
mit
47
master
890
require 'test/unit' require 'lib/rapinoe' include Rapinoe class TestSlide < Test::Unit::TestCase def setup @keynote = Keynote.new('test/fixtures/ice-cream.key') @slide = @keynote.slides.first end def test_preview_data assert_equal 1484, @slide.preview_data.size end def test_write_preview_to_f...
github
holman/rapinoe
https://github.com/holman/rapinoe
test/test_keynote.rb
Ruby
mit
47
master
1,537
require 'test/unit' require 'lib/rapinoe' include Rapinoe class TestKeynote < Test::Unit::TestCase def setup @keynote = Keynote.new('test/fixtures/ice-cream.key') end def test_path assert_equal 'test/fixtures/ice-cream.key', @keynote.path end def test_name assert_equal "ice-cream", @keynote.nam...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
Gemfile
Ruby
mit
47
main
490
# frozen_string_literal: true source 'https://rubygems.org/' gemspec group :development do gem 'pry-byebug', '~> 3.9' gem 'gem_toys', '~> 1.0' gem 'toys', '~> 0.19.1' end group :audit do gem 'bundler-audit', '~> 0.9.0' end group :test do gem 'rack-test', '~> 2.0' gem 'rspec', '~> 3.9' gem 'simplecov', '~> ...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
.toys.rb
Ruby
mit
47
main
280
# frozen_string_literal: true include :bundler, static: true subtool_apply do include :exec, exit_on_nonzero_status: true, log_level: Logger::UNKNOWN unless include? :exec end require 'gem_toys' expand GemToys::Template, unreleased_title: '## Unreleased' alias_tool :g, :gem
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
flame.gemspec
Ruby
mit
47
main
1,346
# frozen_string_literal: true require_relative 'lib/flame/version' Gem::Specification.new do |spec| spec.name = 'flame' spec.version = Flame::VERSION spec.summary = 'Web-framework, based on MVC-pattern' spec.description = <<~DESC Use controller's classes with instance methods as routing actions,...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame.rb
Ruby
mit
47
main
299
# frozen_string_literal: true require 'gorilla_patch/inflections' ## Base module module Flame using GorillaPatch::Inflections %i[Config Application Controller VERSION] .each do |constant_name| autoload( constant_name, "#{__dir__}/flame/#{constant_name.to_s.underscore}" ) end end
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/render.rb
Ruby
mit
47
main
5,109
# frozen_string_literal: true require 'pathname' require 'tilt' require 'tilt/plain' require 'tilt/erb' require 'gorilla_patch/inflections' require_relative 'errors/template_not_found_error' module Flame ## Helper for render functionality class Render ## Create a new instance from controller, by path and with ...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/application.rb
Ruby
mit
47
main
4,093
# frozen_string_literal: true require 'addressable' require_relative 'router' require_relative 'dispatcher' module Flame ## Core class, like Framework::Application class Application class << self include Memery ## Remember root directory when inherited def inherited(app) super app.root_dir = Fi...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/controller.rb
Ruby
mit
47
main
6,045
# frozen_string_literal: true require 'forwardable' require 'gorilla_patch/namespace' require_relative 'router' require_relative 'controller/actions' require_relative 'controller/cookies' require_relative 'controller/path_to' ## Just because of `autoload` module Flame autoload :Render, "#{__dir__}/render" ## Cla...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/dispatcher.rb
Ruby
mit
47
main
4,241
# frozen_string_literal: true require 'gorilla_patch/symbolize' require 'rack' require_relative 'dispatcher/request' require_relative 'dispatcher/response' require_relative 'dispatcher/static' require_relative 'dispatcher/routes' require_relative 'errors/route_not_found_error' module Flame ## Helpers for dispatch...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/config.rb
Ruby
mit
47
main
2,430
# frozen_string_literal: true require_relative 'errors/config_file_not_found_error' module Flame ## Class for application configuration class Config < Hash DEFAULT_DIRS = %i[config log public tmp views].each_with_object({}) do |key, result| result[:"#{key}_dir"] = proc { File.join(self[:root_dir], key.to_s...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/router.rb
Ruby
mit
47
main
1,901
# frozen_string_literal: true require 'gorilla_patch/deep_merge' require 'gorilla_patch/inflections' require 'gorilla_patch/namespace' require_relative 'router/controller_finder' require_relative 'errors/controller_not_found_error' module Flame ## Router class for routing class Router extend Forwardable HTTP_...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/path.rb
Ruby
mit
47
main
6,373
# frozen_string_literal: true require 'forwardable' require 'memery' require_relative 'errors/argument_not_assigned_error' module Flame ## Class for working with paths class Path include Memery extend Forwardable def_delegators :to_s, :include? ## Merge parts of path to one path ## @param parts [Array...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/validators.rb
Ruby
mit
47
main
2,835
# frozen_string_literal: true require_relative 'errors/route_extra_arguments_error' require_relative 'errors/route_arguments_order_error' module Flame module Validators ## Compare arguments from path and from controller's action class RouteArgumentsValidator include Memery ## Create a new instance of vali...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/errors/route_extra_arguments_error.rb
Ruby
mit
47
main
1,068
# frozen_string_literal: true module Flame module Errors ## Error for Route initialization class RouteExtraArgumentsError < StandardError ## Create a new instance of error ## @param ctrl [Flame::Controller] controller ## @param action [Symbol] action ## @param path [Flame::Path, String] path ## @pa...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/errors/route_arguments_order_error.rb
Ruby
mit
47
main
570
# frozen_string_literal: true module Flame module Errors ## Error for Route initialization class RouteArgumentsOrderError < StandardError ## Create a new instance of error ## @param path [Flame::Path, String] path with wrong arguments order ## @param wrong_ordered_arguments [Array<Symbol>] ## two wr...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/errors/route_not_found_error.rb
Ruby
mit
47
main
521
# frozen_string_literal: true module Flame module Errors ## Error for Flame::Dispatcher.path_to class RouteNotFoundError < StandardError ## Create a new instance of error ## @param controller [Flame::Controller] ## controller with which route not found ## @param action [Symbol] action with which rou...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/errors/config_file_not_found_error.rb
Ruby
mit
47
main
535
# frozen_string_literal: true module Flame module Errors ## Error for not found config file in Config class ConfigFileNotFoundError < StandardError ## Create a new instance of error ## @param file_name [String] ## file name mask by which file was not found ## @param directory [String] directory in w...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/errors/template_not_found_error.rb
Ruby
mit
47
main
533
# frozen_string_literal: true module Flame module Errors ## Error for not found template file in Render class TemplateNotFoundError < StandardError ## Create a new instance of error ## @param controller [Flame::Controller] ## controller from which template not found ## @param path [String, Symbol] p...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/errors/argument_not_assigned_error.rb
Ruby
mit
47
main
474
# frozen_string_literal: true module Flame module Errors ## Error for Flame::Dispatcher.path_to class ArgumentNotAssignedError < StandardError ## Create a new instance of error ## @param path [Flame::Path, String] path without argument ## @param argument [Flame::Path::Part, String, Symbol] ## not as...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/errors/controller_not_found_error.rb
Ruby
mit
47
main
524
# frozen_string_literal: true module Flame module Errors ## Error for not found controller by name in namespace class ControllerNotFoundError < StandardError ## Create a new instance of error ## @param controller_name [Symbol, String] ## name of controller which not found ## @param namespace [Module...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/controller/actions.rb
Ruby
mit
47
main
3,727
# frozen_string_literal: true require 'gorilla_patch/slice' module Flame class Controller ## Module for work with actions module Actions include Memery using GorillaPatch::Slice ## Shortcut for not-inherited public methods: actions ## @return [Array<Symbol>] array of actions (public instance method...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/controller/cookies.rb
Ruby
mit
47
main
1,354
# frozen_string_literal: true module Flame class Controller ## Helper class for cookies class Cookies ## Create an instance of Cookies ## @param request_cookies [Hash{String=>Object}] cookies from request ## @param response [Flame::Dispatcher::Response, Rack::Response] ## response object for cookies...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/controller/path_to.rb
Ruby
mit
47
main
1,600
# frozen_string_literal: true module Flame class Controller ## Module with methods for path or URL building module PathTo include Memery ## Look documentation at {Flame::Dispatcher#path_to} def path_to(*args) add_controller_class(args) add_controller_arguments(args) @dispatcher.path_to(*args...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/dispatcher/response.rb
Ruby
mit
47
main
575
# frozen_string_literal: true module Flame class Dispatcher ## Class for responses class Response < Rack::Response ## Set Content-Type header directly or by extension ## @param value [String] value for header or extension of file ## @return [String] setted value ## @example Set value directly ## ...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/dispatcher/routes.rb
Ruby
mit
47
main
1,884
# frozen_string_literal: true module Flame class Dispatcher ## Module for working with routes module Routes private ## Find route and try execute it def try_route http_method = request.http_method http_method = :GET if http_method == :HEAD return unless available_endpoint route = availa...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/dispatcher/static.rb
Ruby
mit
47
main
1,877
# frozen_string_literal: true require 'cgi/escape' module Flame class Dispatcher ## Module for working with static files module Static ## Find static file by path ## @param filename [String] relative path to the static file ## @param dir [String] ## absolute local path of the directory with static ...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/dispatcher/request.rb
Ruby
mit
47
main
1,047
# frozen_string_literal: true module Flame class Dispatcher ## Class for requests class Request < Rack::Request include Memery ## Initialize Flame::Path memoize def path Flame::Path.new path_info end ## Override HTTP-method of the request if the param '_method' found memoize def http_metho...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/router/routes.rb
Ruby
mit
47
main
3,879
# frozen_string_literal: true module Flame class Router ## Custom Hash for routes class Routes < Hash ## @param path_parts [Array<String, Flame::Path, Flame::Path::Part>] ## path parts for nested keys ## @example Initialize without keys ## Flame::Router::Routes.new # => {} ## @example Initializ...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/router/route.rb
Ruby
mit
47
main
894
# frozen_string_literal: true require_relative '../path' require_relative '../validators' module Flame class Router ## Class for Route in Router.routes class Route extend Forwardable attr_reader :controller, :action def_delegators :to_s, :inspect ## Create a new instance ## @param controller [F...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/router/controller_finder.rb
Ruby
mit
47
main
1,515
# frozen_string_literal: true module Flame ## Comment due to `private_constant` class Router ## Class for controller constant finding in namespace by names class ControllerFinder attr_reader :controller def initialize(namespace_name, controller_or_name) @namespace = namespace_name.empty? ? Object...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/router/routes_refine.rb
Ruby
mit
47
main
4,326
# frozen_string_literal: true require_relative 'routes_refine/mounting' module Flame class Router ## Helper class for controller routing refine class RoutesRefine attr_reader :routes, :reverse_routes class << self include Memery ## Defaults REST routes (methods, pathes, controllers actions) d...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
lib/flame/router/routes_refine/mounting.rb
Ruby
mit
47
main
1,550
# frozen_string_literal: true module Flame class Router class RoutesRefine ## Module for mounting in RoutesRefine module Mounting private using GorillaPatch::DeepMerge ## Mount controller inside other (parent) controller ## @param controller [Flame::Controller] class of mounting controller ...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/spec_helper.rb
Ruby
mit
47
main
781
# frozen_string_literal: true require 'pry-byebug' require 'simplecov' if ENV['CI'] require 'simplecov-cobertura' SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter end SimpleCov.start RSpec.configure do |config| config.example_status_persistence_file_path = "#{__dir__}/examples.txt" end require_re...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/validators_spec.rb
Ruby
mit
47
main
2,072
# frozen_string_literal: true ## Test controller for Validators class ValidatorsController < Flame::Controller def foo(first, second, third = nil, fourth = nil); end end describe Flame::Validators do describe Flame::Validators::RouteArgumentsValidator do subject(:validator) do described_class.new(ValidatorsCon...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/path_spec.rb
Ruby
mit
47
main
7,922
# frozen_string_literal: true class PathController def foo; end def bar(first); end def baz(first, second, third = nil); end end describe Flame::Path do def path_initialize(*args) Flame::Path.new(*args) end subject(:path) { path_initialize(*path_args) } let(:other) { path_initialize(*other_args) } l...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/controller_spec.rb
Ruby
mit
47
main
18,865
# frozen_string_literal: true module ControllerTest ## Controller for Controller tests class OneController < Flame::Controller def foo(first, second = nil); end def bar view end def baz reroute AnotherOneController, :baz end def object_hash hash end def respond_for_reroute 'Hello from...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/render_spec.rb
Ruby
mit
47
main
6,973
# frozen_string_literal: true module RenderTest class OneController < Flame::Controller end class AnotherOneController < Flame::Controller end class Application < Flame::Application mount OneController mount AnotherOneController end end describe Flame::Render do def render_init(*args) Flame::Render.new...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/dispatcher_spec.rb
Ruby
mit
47
main
10,194
# frozen_string_literal: true module DispatcherTest ## Test controller for Dispatcher class IndexController < Flame::Controller def index; end def foo; end def create; end def hello(name) "Hello, #{name}!" end def baz(var = nil); end def test; end def action_with_after_hook 'Body of actio...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/router_spec.rb
Ruby
mit
47
main
3,556
# frozen_string_literal: true module RouterTest ## Test controller for Router class OneController < Flame::Controller def index; end def foo(first, second, third = nil, fourth = nil); end get '/:?key/bar', def bar(key = nil); end end ## Another test controller for Router class AnotherOneController < F...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/config_spec.rb
Ruby
mit
47
main
2,416
# frozen_string_literal: true describe Flame::Config do let(:config) { described_class.new(__dir__) } describe '#[]' do describe 'regular values' do subject { config[:foo] } before do config[:foo] = 1 end it { is_expected.to eq 1 } end describe 'proc values' do context 'without parameter...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/application_spec.rb
Ruby
mit
47
main
23,957
# frozen_string_literal: true class ApplicationController < Flame::Controller def index; end def foo 'Hello from foo!' end def bar; end def hello(name); end def baz(first, second, third = nil, fourth = nil); end def view render :view end end module TestRefinedActions extend Flame::Controller::Action...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/controller/cookies_spec.rb
Ruby
mit
47
main
1,438
# frozen_string_literal: true describe Flame::Controller::Cookies do subject(:cookies) { described_class.new(request.cookies, response) } let(:env) do { 'HTTP_COOKIE' => 'foo=bar; baz=bat' } end let(:request) { Flame::Dispatcher::Request.new(env) } let(:response) { Flame::Dispatcher::Response.new } des...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/router/routes_spec.rb
Ruby
mit
47
main
5,639
# frozen_string_literal: true describe Flame::Router::Routes do def initialize_routes(path = nil, endpoints = nil) result = described_class.new(path) result.dig(*Flame::Path.new(path).parts).merge! endpoints if endpoints result end subject(:routes) { initialize_routes path, endpoints } let(:path) { '/foo/b...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/router/route_spec.rb
Ruby
mit
47
main
1,394
# frozen_string_literal: true ## Test controller for Route class RouteController < Flame::Controller def foo(first, second, third = nil, fourth = nil); end def bar(first, second, third = nil, fourth = nil); end def baz(first, second); end def show(id); end def export_cards; end end class AnotherRouteControll...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/require_dirs/services/another_service.rb
Ruby
mit
47
main
254
# frozen_string_literal: true require_relative 'regular/all' module RequireDirs module Services class AnotherService < Services::Base @mailer = RequireDirs::Mailer::SomeMailer @regular_all = RequireDirs::Services::Regular::All end end end
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/dispatcher/request_spec.rb
Ruby
mit
47
main
1,430
# frozen_string_literal: true describe Flame::Dispatcher::Request do subject(:request) { described_class.new(env) } let(:method) { :PATCH } let(:query) { '' } let(:env) do { Rack::REQUEST_METHOD => 'POST', Rack::PATH_INFO => '/hello/great/world', Rack::QUERY_STRING => query, Rack::RACK_INPUT => Str...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/dispatcher/static_spec.rb
Ruby
mit
47
main
2,626
# frozen_string_literal: true module StaticTest class Application < Flame::Application end end describe Flame::Dispatcher::Static do subject(:try_static) { dispatcher.send(:try_static) } let(:app) { StaticTest::Application } let(:file) { 'test.txt' } let(:file_mtime) { File.mtime File.join(__dir__, 'public',...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/dispatcher/response_spec.rb
Ruby
mit
47
main
525
# frozen_string_literal: true describe Flame::Dispatcher::Response do subject(:response) { described_class.new } it { is_expected.to be_a Rack::Response } describe '#content_type=' do subject { response.content_type } before do response.content_type = content_type end context 'with MIME-type' do l...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/errors/route_extra_arguments_error_spec.rb
Ruby
mit
47
main
1,414
# frozen_string_literal: true describe Flame::Errors::RouteExtraArgumentsError do subject(:error) { described_class.new(ErrorsController, :foo, path, extra) } context 'when extra action required arguments' do let(:path) { '/foo/:first/:?third/:?fourth' } let(:extra) { { place: :ctrl, type: :req, args: [:second]...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/errors/template_not_found_error_spec.rb
Ruby
mit
47
main
656
# frozen_string_literal: true require_relative '../../../lib/flame/errors/template_not_found_error' describe Flame::Errors::TemplateNotFoundError do subject(:error) { described_class.new(controller, :foo) } context 'with controller class' do let(:controller) { ErrorsController } let(:correct_message) do "T...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/errors/controller_not_found_error_spec.rb
Ruby
mit
47
main
352
# frozen_string_literal: true describe Flame::Errors::ControllerNotFoundError do subject(:error) { described_class.new(controller_name, namespace) } let(:controller_name) { :foo } let(:namespace) { Flame::Errors } let(:correct_message) do "Controller 'foo' not found for 'Flame::Errors'" end it_behaves_like ...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/errors/config_file_not_found_error_spec.rb
Ruby
mit
47
main
958
# frozen_string_literal: true require_relative '../../../lib/flame/errors/config_file_not_found_error' describe Flame::Errors::ConfigFileNotFoundError do subject(:error) { described_class.new(file_name, directory) } let(:file_name) { 'foo.y{a,}ml' } let(:correct_message) do "Config file 'foo.y{a,}ml' not found...
github
AlexWayfer/flame
https://github.com/AlexWayfer/flame
spec/flame/errors/route_not_found_error_spec.rb
Ruby
mit
47
main
326
# frozen_string_literal: true describe Flame::Errors::RouteNotFoundError do subject(:error) { described_class.new(ErrorsController, :bar) } let(:correct_message) do "Route with controller 'ErrorsController' and action 'bar' " \ 'not found in application routes' end it_behaves_like 'error with correct output...