This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jobs: | |
rubocop: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: .ruby-version | |
bundler-cache: true | |
- name: RuboCop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fetch_using_http(uri) | |
HTTP::Client.get(uri.to_s) do |response| | |
if response.status == HTTP::Status::OK | |
parse_type(response.body_io) # return FastImage::Meta or raises an error | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process(uri) | |
if uri.scheme == "http" || uri.scheme == "https" | |
fetch_using_http(uri) # returns FastImage::Meta | |
elsif (uri.scheme.nil? || uri.scheme == "file") && !uri.path.nil? | |
fetch_using_file(uri) # returns FastImage::Meta | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PluginA | |
DEFAULT_OPTIONS = { | |
c: 3, | |
d: 4, | |
} | |
module InstanceMethods | |
def plugin_a_method_a | |
"plugin_a_method_a" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Spectator::Matchers | |
struct HavePermissionsMatcher(ExpectedType) < Spectator::Matchers::ValueMatcher(ExpectedType) | |
def description : String | |
"have permissions of #{expected.label}" | |
end | |
# Checks whether the matcher is satisfied with the expression given to it. | |
private def match?(actual : Spectator::TestExpression(T)) : Bool forall T | |
File.info(actual.value).permissions.value == expected.value | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fund::CreateCallForm < BaseForm | |
property :type | |
property :fund | |
validation do | |
required(:type) { filled? & included_in?(TRANSACTION_TYPES['Fund::Call']) } | |
end | |
validation if: -> (results) { rebalance? } do | |
required(:fund).filled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fund::CreateCallForm < BaseForm | |
# your properties are here | |
# ... | |
validation do | |
configure do | |
config.messages_file = 'config/locales/dry-validation/errors.yml' | |
# don't forget about this option to be able to access your form object from your predicates | |
option :form | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@purchased_at = Date.civil(params[:purchased_at]["(1i)"].to_i, | |
params[:purchased_at]["(2i)"].to_i, | |
params[:purchased_at]["(3i)"].to_i) | |
@code = Partner::Code.lookup("Vendor", params[:code]) || build_vendor_code | |
@not_redeem = nil | |
@error_text = nil | |
@to_late = nil | |
if @code.nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tour < Sequel::Model | |
many_to_one :vendor_pansion, | |
:dataset => proc{ Vendor::Pansion.where(:id => self.vendor_pansion_id) }, | |
:reciprocal => nil, :class => 'Vendor::Pansion', | |
:eager_loader => (proc do |opts| | |
opts[:rows].each{ |object| object.associations[:vendor_pansion] = nil } | |
Vendor::Pansion.where(:id => opts[:id_map].keys).each do |vendor_pansion| | |
if tours = opts[:id_map][vendor_pansion.id] | |
tours.each do |tour| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionController::Base | |
def force_utf8_params | |
traverse = lambda do |object, block| | |
if object.kind_of?(Hash) | |
object.each_value { |o| traverse.call(o, block) } | |
elsif object.kind_of?(Array) | |
object.each { |o| traverse.call(o, block) } | |
else | |
block.call(object) |
NewerOlder