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
influitive/multiple_man
https://github.com/influitive/multiple_man
spec/subscribers/base_spec.rb
Ruby
mit
19
master
398
require 'spec_helper' describe MultipleMan::Subscribers::Base do class MockClass end specify "routing_key should be the model name and a wildcard" do described_class.new(MockClass).routing_key.should =~ /\.MockClass\.\#$/ end specify "it should be alright to use a string for a class name" do descri...
github
influitive/multiple_man
https://github.com/influitive/multiple_man
spec/channel_maintenance/reaper_spec.rb
Ruby
mit
19
master
907
require 'spec_helper' describe MultipleMan::ChannelMaintenance::Reaper do let(:mock_channel) { double(Bunny::Channel, close: nil, closed?: false, number: 1) } let(:mock_queue) { double(Queue, pop: mock_channel) } let(:mock_config_hash) { { time_between_retries: 1 } } let(:mock_mm_config) { double(MultipleMan, ...
github
chamaeleonidae/omniauth-hubspot
https://github.com/chamaeleonidae/omniauth-hubspot
Rakefile
Ruby
mit
19
master
251
require 'bundler/gem_tasks' desc "Build the gem" task :build do system "gem build omniauth-hubspot.gemspec" end desc "Build and release the gem" task :release => :build do system "gem push omniauth-hubspot-#{OmniAuth::HubSpot::VERSION}.gem" end
github
chamaeleonidae/omniauth-hubspot
https://github.com/chamaeleonidae/omniauth-hubspot
omniauth-hubspot.gemspec
Ruby
mit
19
master
923
# -*- encoding: utf-8 -*- require File.expand_path('../lib/omniauth/hubspot/version', __FILE__) Gem::Specification.new do |gem| gem.add_dependency 'omniauth' gem.add_dependency 'oauth2' gem.add_dependency 'omniauth-oauth2' gem.authors = ['Brian Norton'] gem.email = ['brian@trychameleon.com'] ...
github
chamaeleonidae/omniauth-hubspot
https://github.com/chamaeleonidae/omniauth-hubspot
lib/omniauth/strategies/hubspot.rb
Ruby
mit
19
master
1,149
require 'omniauth-oauth2' module OmniAuth module Strategies class HubSpot < OmniAuth::Strategies::OAuth2 option :name, 'hubspot' args [:client_id, :client_secret] option :client_options, { site: 'https://api.hubapi.com', authorize_url: 'https://app.hubspot.com/oauth/authorize'...
github
jorgemanrubia/rack-ratelimit
https://github.com/jorgemanrubia/rack-ratelimit
rack-ratelimit.gemspec
Ruby
mit
19
master
392
Gem::Specification.new do |s| s.name = 'rack-ratelimit' s.version = '1.2.0' s.author = 'Jeremy Daer' s.email = 'jeremydaer@gmail.com' s.homepage = 'https://github.com/jeremy/rack-ratelimit' s.summary = 'Flexible rate limits for your Rack apps' s.license = 'MIT' s.required_ruby_versio...
github
jorgemanrubia/rack-ratelimit
https://github.com/jorgemanrubia/rack-ratelimit
test/ratelimit_test.rb
Ruby
mit
19
master
6,311
require 'rubygems' require 'bundler/setup' require 'minitest/autorun' require 'rack/ratelimit' require 'stringio' require 'json' require 'dalli' require 'redis' module RatelimitTests def setup @app = ->(env) { [200, {}, []] } @logger = Logger.new(@out = StringIO.new) @limited = build_ratelimiter(@app,...
github
jorgemanrubia/rack-ratelimit
https://github.com/jorgemanrubia/rack-ratelimit
lib/rack/ratelimit.rb
Ruby
mit
19
master
8,825
require 'logger' require 'time' module Rack # = Ratelimit # # * Run multiple rate limiters in a single app # * Scope each rate limit to certain requests: API, files, GET vs POST, etc. # * Apply each rate limit by request characteristics: IP, subdomain, OAuth2 token, etc. # * Flexible time window to limit b...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
sinatra-minimal/app.rb
Ruby
mit
19
master
985
require 'sinatra' require 'mongoid' # Configure Mongoid by creating config/mongoid.yml. The format of this file # is documented at # https://docs.mongodb.com/mongoid/master/tutorials/mongoid-configuration/#anatomy-of-a-mongoid-config Mongoid.load!(File.join(File.dirname(__FILE__), 'config', 'mongoid.yml')) # Define m...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails-api/Gemfile
Ruby
mit
19
master
1,242
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem 'mongoid', '~> 7.0.5' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Build JSON APIs with ease. Read more: https://github.com/...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails-api/app/controllers/comments_controller.rb
Ruby
mit
19
master
1,099
class CommentsController < ApplicationController before_action :set_comment, only: [:show, :update, :destroy] # GET /comments def index @comments = Comment.all render json: @comments end # GET /comments/1 def show render json: @comment end # POST /comments def create @comment = Com...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails-api/app/controllers/posts_controller.rb
Ruby
mit
19
master
1,003
class PostsController < ApplicationController before_action :set_post, only: [:show, :update, :destroy] # GET /posts def index @posts = Post.all render json: @posts end # GET /posts/1 def show render json: @post end # POST /posts def create @post = Post.new(post_params) if @po...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails-api/config/application.rb
Ruby
mit
19
master
1,316
require_relative 'boot' require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" # require "active_record/railtie" # require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" # require "action_mailbox/engine" # require "action...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails-api/config/environments/development.rb
Ruby
mit
19
master
1,487
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
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails-api/config/environments/test.rb
Ruby
mit
19
master
1,791
# 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 suite and is wiped # and recreated between test runs. Don't rely on the data there! Rails.application.configure do # Settings...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails-api/config/environments/production.rb
Ruby
mit
19
master
4,542
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
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails/Gemfile
Ruby
mit
19
master
1,630
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem 'mongoid', '~> 7.0.5' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5' # Trans...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails/app/controllers/posts_controller.rb
Ruby
mit
19
master
1,780
class PostsController < ApplicationController before_action :set_post, only: [:show, :edit, :update, :destroy] # GET /posts # GET /posts.json def index @posts = Post.all end # GET /posts/1 # GET /posts/1.json def show end # GET /posts/new def new @post = Post.new end # GET /posts/1...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails/app/controllers/comments_controller.rb
Ruby
mit
19
master
1,912
class CommentsController < ApplicationController before_action :set_comment, only: [:show, :edit, :update, :destroy] # GET /comments # GET /comments.json def index @comments = Comment.all end # GET /comments/1 # GET /comments/1.json def show end # GET /comments/new def new @comment = Co...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails/config/application.rb
Ruby
mit
19
master
1,066
require_relative 'boot' require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" # require "active_record/railtie" # require "active_storage/engine" require "action_controller/railtie" require "action_mailer/railtie" # require "action_mailbox/engine" # require "action...
github
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails/config/environments/production.rb
Ruby
mit
19
master
4,774
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
mongoid/mongoid-demo
https://github.com/mongoid/mongoid-demo
rails/config/environments/development.rb
Ruby
mit
19
master
1,885
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
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
Gemfile
Ruby
mit
19
master
2,943
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.3' ## 3rd party integrations and integration enablers gem 'httparty' gem 'recaptcha' gem 'rpush' gem 'sendgrid-ruby' gem 'slack-ruby-client' ## Active admin gem 'active_admin-humanized_enum' gem 'activeadmin' gem...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
lib/tasks/db_rebuild.rake
Ruby
mit
19
master
263
# frozen_string_literal: true namespace :db do desc 'Rebuild database' task :rebuild, [] => :environment do Rake::Task['db:drop'].execute Rake::Task['db:create'].execute Rake::Task['db:migrate'].execute Rake::Task['db:seed'].execute end end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
lib/tasks/zeitwerk.rake
Ruby
mit
19
master
1,846
# frozen_string_literal: true ensure_zeitwerk_mode = ->() do unless Rails.autoloaders.zeitwerk_enabled? abort "Please, enable :zeitwerk mode in config/application.rb and try again." end end eager_load = ->() do puts "Hold on, I am eager loading the application." Zeitwerk::Loader.eager_load_all end report...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
lib/tasks/admin.rake
Ruby
mit
19
master
631
namespace :admin do task :create_super_admin, [:first_name, :last_name, :email, :password] => [ :environment ] do |t, args| user = User.new first_name: args[:first_name], last_name: args[:last_name], email: args[:email], password: args[:password], ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/serializers/volunteer_serializer.rb
Ruby
mit
19
master
400
class VolunteerSerializer < ActiveModel::Serializer attributes :id, :first_name, :last_name, :email, :phone, :address, :addresses def address ActiveModelSerializers::SerializableResource.new object.addresses[0] end def addresses...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/serializers/address_serializer.rb
Ruby
mit
19
master
478
class AddressSerializer < ActiveModel::Serializer attributes :id, :street, :street_number, :city, :city_part, :geo_entry_id, :latitude, :longitude, :postal_code, :country_code, :default ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/serializers/organisation_serializer.rb
Ruby
mit
19
master
259
class OrganisationSerializer < ActiveModel::Serializer attributes :id, :name, :abbreviation, :business_id_number, :contact_person, :contact_person_phone, :contact_person_email end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/serializers/volunteer_preferences_serializer.rb
Ruby
mit
19
master
269
class VolunteerPreferencesSerializer < ActiveModel::Serializer attributes :notifications_to_app, :sound def notifications_to_app object.preferences&.dig('notifications_to_app') || false end def sound object.preferences&.dig('sound') || false end end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/serializers/requested_volunteer_serializer.rb
Ruby
mit
19
master
2,515
class RequestedVolunteerSerializer < ActiveModel::Serializer attributes :id, :state, :requested_volunteer_state, :title, :short_description, :organisation_id, :fullfillment_date, :required_volunteer_count, :accepte...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/meta_helper.rb
Ruby
mit
19
master
675
module MetaHelper def page_meta path = SessionsHelper.normalize_path(request.path).join('') return MetaHelper.default_meta unless I18n.t('meta').keys.any? { |key| key.to_s == path.to_s } MetaHelper.meta_for(path) end def self.extract_values(path, key) I18n.t format("meta.%{path}.%{key}", path: ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/seed_helper.rb
Ruby
mit
19
master
3,492
# frozen_string_literal: true module SeedHelper def self.create_user(**args) User.find_or_initialize_by(email: args[:email]).tap do |user| next if user.persisted? user.assign_attributes password: args[:password], password_confirmation: args[:password_confirmation], ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/link_helper.rb
Ruby
mit
19
master
200
# typed: false # frozen_string_literal: true module LinkHelper def modal_link(title = '', path, **options) link_to title, path, options.merge(remote: true, 'data-modal-trigger': true) end end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/application_helper.rb
Ruby
mit
19
master
218
module ApplicationHelper def class_names(*classnames) classnames.join(' ') end def if_path_active(path, if_result, else_result = nil) request.env['PATH_INFO'] == path ? if_result : else_result end end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/view_helper.rb
Ruby
mit
19
master
352
# typed: false # frozen_string_literal: true module ViewHelper include ViewHelpers def tooltip(text) h.content_tag :img, nil, src: asset_pack_path('media/images/tooltip.svg'), class: "tooltipped", 'data-position' => 'top', ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/translations_helper.rb
Ruby
mit
19
master
1,094
module TranslationsHelper # Returns an array of the possible key/i18n values for the enum # Example usage: # enum_options_for_select(User, :approval_state) def enum_options_for_select(class_name, enum) class_name.send(enum.to_s.pluralize).map do |key, _| [enum_i18n(class_name, enum, key), key] end...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/sessions_helper.rb
Ruby
mit
19
master
620
module SessionsHelper def login_screen_text(path) return :login if path.blank? path = SessionsHelper.normalize_path path case path when SessionsHelper.normalize_path(confirm_destruction_of_volunteer_profile_path) :delete_profile when SessionsHelper.normalize_path(accept_request_path) ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/active_admin/locations_helper.rb
Ruby
mit
19
master
298
module ActiveAdmin module LocationsHelper def location_autocomplete(callback: 'InitAddressAutocomplete') [].tap do |content| content << "https://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_MAPS_API_KEY']}&libraries=places&callback=#{callback}" end end end end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/helpers/active_admin/volunteers_helper.rb
Ruby
mit
19
master
377
module ActiveAdmin module VolunteersHelper def scoped_request return @scoped_request if defined? @scoped_request @scoped_request = Request.find_by id: params[:request_id] end def referer_request referer_params = Rack::Utils.parse_nested_query(URI.parse(request.referer).query) Req...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/jobs/messages/receiver_job.rb
Ruby
mit
19
master
1,455
module Messages class ReceiverJob < ApplicationJob queue_as :receiver_queue REPEAT_COUNT = 30 TIMEOUT = 30 # seconds around_perform do |job, block| PgLock.new(name: lock_key, attempts: 1, ttl: false).lock! do block.call rescue StandardError => e Raven.capture_excepti...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/jobs/messages/sender_job.rb
Ruby
mit
19
master
215
module Messages class SenderJob < ApplicationJob def perform(message_id) MessagingService.send_message Message.eager_load(:volunteer, :creator, request: :organisation).find(message_id) end end end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/jobs/messages/received_processor_job.rb
Ruby
mit
19
master
2,576
module Messages class ReceivedProcessorJob < ApplicationJob attr_reader :message, :requested_volunteer, :request def perform(message) @message = message # Process response message in context of requested volunteer associations waiting for response RequestedVolunteer.eager_load(:request, :v...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/push_service.rb
Ruby
mit
19
master
851
# frozen_string_literal: true module PushService def self.send_message(message_object) response = connector.send_message resolve_payload_data(message_object), resolve_notification_data(message_object), message_object.fcm_token bloc...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/options_wrapper.rb
Ruby
mit
19
master
1,372
# frozen_string_literal: true class OptionsWrapper include ActionView::Helpers::FormOptionsHelper attr_reader :collection, :params, :query, :model, :method def initialize(collection, params, query, model = nil, method = nil) @collection = collection @params = params @query = query @mode...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/sms_service.rb
Ruby
mit
19
master
566
# frozen_string_literal: true module SmsService attr_reader :connector def self.send_message(message_object) response = Connector::O2.send_message(message_object.phone, message_object.text, delivery_report: ENV['DISABLE_SMS_RE...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/slack_bot.rb
Ruby
mit
19
master
529
class SlackBot def self.send_new_request_notification(request, path) channel = ENV.fetch 'SLACK_NEW_REQUEST_CHANNEL', 'test-notifikaci' text = format ":new: *<https://pomuzeme.si%{path}|Nová poptávka>* od %{subscriber}.", path: path, subscriber: request.subscriber SlackBot.send_message text, channel e...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/messaging_service.rb
Ruby
mit
19
master
739
# frozen_string_literal: true module MessagingService def self.create_and_send_message(new_message_args) message = Message.create! new_message_args Messages::SenderJob.perform_later message.id end def self.send_message(active_record_message) message_object = OutgoingMessage.new(active_record_message...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/recaptchable.rb
Ruby
mit
19
master
821
module Recaptchable def resolve_recaptcha(action, model, threshold = nil) # Cannot get recaptcha to work so let bots pass for now return true score_threshold = threshold&.to_f if score_threshold.present? verify_recaptcha(action: action, minimum_score: score_threshold) recaptcha_response ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/data_import_service.rb
Ruby
mit
19
master
577
module DataImportService def self.call(filename, group) Importer.new(filename, group).call end def self.cleanup(group) group_organisations = Organisation.joins(:organisation_groups).where(organisation_groups: { group_id: group.id }) Request.where(organisation_id: group_organisations.pluck(:id)).dest...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/api/json_web_token.rb
Ruby
mit
19
master
365
require 'jwt' module Api class JsonWebToken SECRET_KEY = ENV.fetch('SECRET_KEY_BASE') def self.encode(payload, exp = 30.days.from_now) payload[:exp] = exp.to_i ::JWT.encode(payload, SECRET_KEY) end def self.decode(token) decoded = ::JWT.decode(token, SECRET_KEY)[0] HashWithIn...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/api/volunteer/update_profile.rb
Ruby
mit
19
master
506
module Api module Volunteer class UpdateProfile attr_reader :volunteer, :params def initialize(volunteer, params) @volunteer = volunteer @params = params end def perform @volunteer.assign_attributes @params return validation_error unless @volunteer.valid? ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/api/volunteer/register.rb
Ruby
mit
19
master
879
module Api module Volunteer class Register attr_reader :volunteer, :params def initialize(volunteer, params) @volunteer = volunteer @params = params end def perform volunteer.assign_attributes params.except(:addresses).merge(confirmed_at: DateTime.now) bui...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/api/volunteer/update_preferences.rb
Ruby
mit
19
master
742
module Api module Volunteer class UpdatePreferences REQUIRED_PARAMS = %i(notifications_to_app sound) def initialize(volunteer, params) @volunteer = volunteer @params = params end def perform validate_params! @volunteer.preferences ||= {} @volunteer...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/sms_service/manager.rb
Ruby
mit
19
master
978
module SmsService module Manager class << self def send_verification_code(phone, code) msg = I18n.t('sms.verification', code: code) sms_gateway(phone, msg) end def send_authorization_code(code, phone) msg = I18n.t('sms.mobile_authorization', code: code) sms_gatew...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/sms_service/connector/o2.rb
Ruby
mit
19
master
2,093
module SmsService module Connector module O2 BA_ID = ENV['O2_BA_ID'] PHONE_NUMBER = ENV['O2_PHONE_NUMBER'] def self.send_message(phone, text, delivery_report:) Message.send(phone, text, delivery_report: delivery_report) end def self.re...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/sms_service/connector/net_host.rb
Ruby
mit
19
master
746
module SmsService module Connector class NetHost include HTTParty base_uri ENV['NETHOST_BASE_URL'] default_params apit: ENV['NETHOST_API_KEY'] def send_msg(phone, text, msg_id = nil, attempt = 0) if ENV['SMS_MOCK'] == 'true' puts "SMS for #{phone}, TEXT -> #{text}" ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/sms_service/connector/o2/message.rb
Ruby
mit
19
master
4,738
module SmsService class MessagingError < StandardError; end module Connector module O2 class Message attr_reader :phone, :text, :request_delivery_report def initialize(phone, text, delivery_report: nil) @phone = phone @text = sanitize_text(text) @request_de...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/sms_service/connector/o2/response.rb
Ruby
mit
19
master
1,986
module SmsService module Connector module O2 class Response MESSAGE_DELIVERED_TO_NETWORK = 'ISUC_010'.freeze MESSAGE_DELIVERED_TO_PHONE = 'ISUC_005'.freeze # Required methods # :channel_msg_id, :from_number, :text, :delivery_receipt_timestamp attr_reader :response...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/volunteer_feedback/sender.rb
Ruby
mit
19
master
1,092
module VolunteerFeedback::Sender extend VolunteerFeedback::Helper def self.batch_send RequestedVolunteer.feedback_required .includes(:volunteer, request: :organisation) .each do |requested_volunteer| call requested_volunteer end end def self.call(reque...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/volunteer_feedback/helper.rb
Ruby
mit
19
master
835
module VolunteerFeedback::Helper def decorated_permitted_interpolations permitted_interpolations.map { |i| "%{#{i}}" }.join(', ') end def interpolate_message(message, requested_volunteer) format message, fill_interpolations(requested_volunteer) end def extract_interpolations(text) text.scan(/%\{...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/push_service/connector/fcm_push.rb
Ruby
mit
19
master
490
module PushService module Connector module FcmPush def self.send_message(payload, notification, fcm_token) Message.send payload, notification, fcm_token end def self.handle_response(notification_object) response = Message.handle_response notification_object MessagingSer...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/push_service/connector/fcm_push/helper.rb
Ruby
mit
19
master
698
module PushService module Connector module FcmPush class Helper def self.event_type(message_object) return :REQUEST_CREATED if message_object.message.message_type_request_offer? return :REQUEST_UPDATED if message_object.message.message_type_request_update? :OTHER ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/push_service/connector/fcm_push/response.rb
Ruby
mit
19
master
1,234
module PushService module Connector module FcmPush class Response ERROR_MESSAGE_TYPE = :error_message # Required methods # :channel_msg_id, :from_number, :text, :delivery_receipt_timestamp attr_reader :response delegate :error_description, to: :response def ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/push_service/connector/fcm_push/message.rb
Ruby
mit
19
master
1,265
module PushService class MessagingError < StandardError; end module Connector module FcmPush class Message attr_reader :payload, :notification, :fcm_token def initialize(payload, notification, fcm_token) @payload = payload @notification = notification @fcm_t...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/push_service/connector/fcm_push/client.rb
Ruby
mit
19
master
664
module PushService module Connector module FcmPush class Client def self.send(payload_data, notification_data, receivers) Rpush::Gcm::Notification.new.tap do |n| n.app = Rpush::Gcm::App.find_by_name ENV['PUSH_APP_NAME'] n.registration_ids = receivers n.d...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/messaging_service/callbacks.rb
Ruby
mit
19
master
1,892
# frozen_string_literal: true module MessagingService module Callbacks # adapter_response required methods # :channel_msg_id, :from_number, :text, :delivery_receipt_timestamp class << self def message_sent(message_object, response) message = message_object.message requested_volunte...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/messaging_service/outgoing_message.rb
Ruby
mit
19
master
829
module MessagingService class OutgoingMessage attr_reader :phone, :message, :fcm_token, :request def initialize(active_record_message) @phone = active_record_message&.phone @fcm_token = active_record_message&.volunteer&.fcm_token @text = active_record_message.text @creator = active_re...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/common/request/response_processor.rb
Ruby
mit
19
master
3,252
module Common module Request class ResponseProcessor attr_reader :request, :volunteer, :is_accepted def initialize(request, volunteer, is_accepted) @request = request @volunteer = volunteer @is_accepted = is_accepted end def perform validate_access! ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/data_import_service/array_to_csv.rb
Ruby
mit
19
master
410
module DataImportService module ArrayToCsv OUTPUT = 'tmp/import_result.csv'.freeze refine Array do require 'csv' def to_csv(csv_filename = OUTPUT) CSV.open(csv_filename, 'wb') do |csv| keys = first.keys # header_row csv << keys each do |hash| ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/data_import_service/model_helpers.rb
Ruby
mit
19
master
1,607
module DataImportService module ModelHelpers def find_or_create_by(klass, attribute, value) return if value.blank? || attribute.blank? creator = (klass.to_s.underscore + '_creator').to_sym @cache[klass.to_s][attribute][value].presence || (@cache[klass.to_s][attribute][value] = send(creator, at...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/data_import_service/creators.rb
Ruby
mit
19
master
3,206
require 'ffaker' module DataImportService module Creators def volunteer_creator(attribute, value) check_supported_attributes(__method__, attribute, :phone) phone = value.gsub(' ', '') Volunteer.find_by(phone: phone).presence || save_model(volunteer_builder) end def request_creator(att...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/data_import_service/importer.rb
Ruby
mit
19
master
1,585
module DataImportService class Importer include Creators include Builders include Utils include ModelHelpers using DataImportService::ArrayToCsv attr_accessor :raw_lines def initialize(filename, organisation_group, output_file = DataImportService::ArrayToCsv::OUTPUT) @filename ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/data_import_service/builders.rb
Ruby
mit
19
master
1,944
require 'ffaker' module DataImportService module Builders def address_builder(_string) raise NotImplementedError, 'Address is cached on Geocoder level' end def request_builder request = build_instance(Request, @row.except('request_address', 'request_organisation', 'request_creator')) r...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/data_import_service/utils.rb
Ruby
mit
19
master
857
module DataImportService module Utils def transaction_wrapper ActiveRecord::Base.connection.transaction do yield rescue StandardError => e puts e puts e.backtrace[0..20] Raven.extra_context(data_row: @row_output) Raven.capture_exception e raise ActiveRec...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/geography/point.rb
Ruby
mit
19
master
763
module Geography class Point S_JTSK_TO_WGS_84_SQL = "SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT(%{x} %{y})',2065),4326)) As wkt_point;".freeze # Creates geographic point using Rgeo factory from coordinates in S-JTSK geography system def self.from_coordinates(longitude:, latitude:) RGeo::G...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/admin/requests/volunteer_assigner.rb
Ruby
mit
19
master
1,081
module Admin module Requests class VolunteerAssigner DEFAULT_STATE = 'to_be_notified'.freeze def initialize(user, request, volunteers, requested_state: nil) @user = user @request = request @volunteers = volunteers @requested_state = requested_state || DEFAULT_STATE ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/services/admin/requests/volunteer_notifier.rb
Ruby
mit
19
master
3,367
module Admin module Requests class VolunteerNotifier attr_reader :user, :request, :requested_volunteer def initialize(user, request, requested_volunteer = nil) @user = user @request = request @requested_volunteer = requested_volunteer end def notify_assigned ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/location_subscriptions_controller.rb
Ruby
mit
19
master
3,078
class LocationSubscriptionsController < PublicController skip_before_action :authorize_current_volunteer before_action :build_location_subscription, only: %w[request_code create] def request_code if @location_subscription.valid? send_and_persist_verification_code render :verify_code else ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/volunteer_profiles_controller.rb
Ruby
mit
19
master
2,605
class VolunteerProfilesController < PublicController skip_before_action :authorize_current_volunteer, only: [:destroyed] def show @volunteer = Volunteer.includes(volunteer_interests: :interest, volunteer_skills: :skill) .where(id: @current_volunteer.id) .firs...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/volunteers_controller.rb
Ruby
mit
19
master
4,617
class VolunteersController < ApplicationController RECAPTCHA_THRESHOLD = ENV['RECAPTCHA_THRESHOLD_VOLUNTEER']&.to_f include Recaptchable before_action :partner_signup_group attr_accessor :volunteer def register @volunteer = Volunteer.new(volunteer_params).with_existing_record @volunteer.prepare_par...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/public_controller.rb
Ruby
mit
19
master
598
class PublicController < ApplicationController before_action :load_current_volunteer before_action :authorize_current_volunteer attr_accessor :current_volunteer private def load_current_volunteer @current_volunteer = Volunteer.find(session[:volunteer_id]) if session[:volunteer_id] rescue ActiveRecord...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/api_controller.rb
Ruby
mit
19
master
1,278
class ApiController < ApplicationController include Api::JsonResponse include Api::Authorization skip_before_action :verify_authenticity_token before_action :authorize_request, :must_be_registered rescue_from StandardError, with: :unexpected_error rescue_from AuthorisationError, with: :authorization_error...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/sessions_controller.rb
Ruby
mit
19
master
2,157
class SessionsController < ApplicationController layout 'volunteer_profiles' before_action :load_session before_action :set_login_description_based_on_redirect, only: %i[new request_code] def new save_redirect_to_session redirect_to volunteer_profile_path if session[:volunteer_id] end def request...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/application_controller.rb
Ruby
mit
19
master
1,036
class ApplicationController < ActionController::Base before_action :set_raven_context def not_found raise ActionController::RoutingError, 'Not Found' end rescue_from PG::ForeignKeyViolation do |error| Raven.capture_exception error redirect_to request.referrer, alert: 'Tato položka se používá. Poku...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/requests_controller.rb
Ruby
mit
19
master
4,927
class RequestsController < PublicController RECAPTCHA_THRESHOLD = ENV['RECAPTCHA_THRESHOLD_REQUEST']&.to_f include Recaptchable skip_before_action :authorize_current_volunteer, only: %i[index new need_volunteers create new_request_accepted confirm_interest] before_action :load_and_authorize_request, only: %i[...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/home_controller.rb
Ruby
mit
19
master
916
class HomeController < PublicController skip_before_action :authorize_current_volunteer before_action :load_counts def index session[:volunteer_id] = nil session[:group_id] = nil @requests = Request.for_web_preloaded.limit(3).decorate @all_requests_count = Request.for_web_preload...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/concerns/api/authorization.rb
Ruby
mit
19
master
584
module Api module Authorization extend ActiveSupport::Concern included do attr_reader :current_volunteer end def authorize_request @current_volunteer = ::Volunteer.find Api::JsonWebToken.decode(request.headers['HTTP_AUTHORIZATION'].split(' ').last)[:volunteer_id] rescue StandardError...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/concerns/api/json_response.rb
Ruby
mit
19
master
329
module Api module JsonResponse extend ActiveSupport::Concern def json_response(data, status: :ok, **args) render json: data, status: status, **args end def error_response(error_key, message: nil, status:) json_response({ error_key: error_key, message: message }, status: status) end ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/api/v1/volunteer_controller.rb
Ruby
mit
19
master
1,131
class Api::V1::VolunteerController < ApiController skip_before_action :must_be_registered, only: :register def profile json_response current_volunteer end def update_profile Api::Volunteer::UpdateProfile.new(current_volunteer, profile_params).perform head :ok end def register Api::Volun...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/api/v1/session_controller.rb
Ruby
mit
19
master
2,083
class Api::V1::SessionController < ApiController skip_before_action :authorize_request, :must_be_registered, except: :refresh def new return error_response(ApiErrors[:INVALID_CAPTCHA], status: :forbidden) unless valid_recaptcha? volunteer = volunteer_from_params return error_response(ApiErrors[:VOLUNTE...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/api/v1/volunteer/requests_controller.rb
Ruby
mit
19
master
637
class Api::V1::Volunteer::RequestsController < ApiController rescue_from Common::Request::CapacityExceededError, with: :capacity_exceeded_response def index json_response current_volunteer.requested_volunteers.eager_load(request: :address) end def respond request = Request.find permitted_params[:id] ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/controllers/api/v1/volunteer/addresses_controller.rb
Ruby
mit
19
master
1,469
class Api::V1::Volunteer::AddressesController < ApiController rescue_from ActiveRecord::RecordNotFound, with: :foreign_address_response def index json_response current_volunteer.addresses end def show json_response current_volunteer.addresses.find(permitted_params[:id]) end def create address...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/components/active_admin/inputs/address_search_input.rb
Ruby
mit
19
master
476
module ActiveAdmin module Inputs class AddressSearchInput < ::Formtastic::Inputs::StringInput # Add filter module wrapper include ActiveAdmin::Inputs::Filters::Base def to_html input_wrapping do [label_html, builder.text_field('id', input_html_options)].join("\n").html_sa...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/components/active_admin/views/modal_window_component.rb
Ruby
mit
19
master
403
# typed: true # frozen_string_literal: true module ActiveAdmin module Views class ModalWindowComponent < ActiveAdmin::Component builder_method :modal_window def build(*) div class: 'modal', 'data-modal': true do div class: 'content-wrapper' do button class: 'close' ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/components/active_admin/views/load_javascript.rb
Ruby
mit
19
master
273
# frozen_string_literal: true module ActiveAdmin module Views class LoadJavascript < ActiveAdmin::Component builder_method :javascript_for def build(*scripts) scripts.each do |js| script src: js end end end end end
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/components/active_admin/views/custom_input.rb
Ruby
mit
19
master
1,599
module ActiveAdmin module Views class CustomInput < ActiveAdmin::Component builder_method :custom_input def build(name, options = {}) if options[:type] == :hidden input(extract_options(name, options)) elsif options[:type] == :input input(extract_options(name, optio...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/admin/volunteers.rb
Ruby
mit
19
master
6,922
ActiveAdmin.register Volunteer do decorate_with VolunteerDecorator permit_params :description, :first_name, :last_name, :phone, :email, addresses_attributes: %i[street_number street city city_part postal_code country_code latitude longitude geo_entry_id] ...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/admin/labels.rb
Ruby
mit
19
master
634
# frozen_string_literal: true ActiveAdmin.register Label do belongs_to :group permit_params :group_id, :name, :description controller do def create super do |success, failure| success.html { redirect_to admin_group_path(resource.group_id) } failure.html { render :new } end en...
github
Applifting/pomuzeme.si
https://github.com/Applifting/pomuzeme.si
app/admin/group_volunteers.rb
Ruby
mit
19
master
2,425
# frozen_string_literal: true ActiveAdmin.register GroupVolunteer do decorate_with GroupVolunteerDecorator belongs_to :volunteer permit_params :comments, :contract_expires, :coordinator_id, :group_id, :recruitment_status, :source controller do def create # Is current user part of the submitted org...