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
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/demo.rb
Ruby
mit
89
main
10,393
require 'excon' require 'pathname' require 'fileutils' require 'date' require 'json' require 'timecop' require 'wait_for_it' require 'enumerable/statistics' require_relative 'chart.rb' Thread.abort_on_exception = true # A class for simulating or "demoing" a rate throttle client # # Example: # # duration = 3600 # s...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/info.rb
Ruby
mit
89
main
222
module RateThrottleClient # Class used for reporting class Info attr_reader :sleep_for, :request def initialize(sleep_for: , request: ) @sleep_for = sleep_for @request = request end end end
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/clients/exponential_increase_proportional_remaining_decrease.rb
Ruby
mit
89
main
1,117
module RateThrottleClient class ExponentialIncreaseProportionalRemainingDecrease < Base attr_accessor :decrease_divisor, :remaining_block def initialize(*args, decrease_divisor: nil, remaining_block: nil, **kargs) super(*args, **kargs) @decrease_divisor = (decrease_divisor || RateThrottleClient.m...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/clients/exponential_increase_gradual_decrease.rb
Ruby
mit
89
main
726
module RateThrottleClient class ExponentialIncreaseGradualDecrease < Base attr_accessor :decrease def initialize(*args, decrease: nil, **kargs) super(*args, **kargs) @decrease = decrease || @min_sleep end def call(&block) sleep_for = @sleep_for sleep(sleep_for + jitter(sleep_...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/clients/base.rb
Ruby
mit
89
main
540
module RateThrottleClient # Standard interface for Client classes # Don't abuse this power class Base attr_accessor :log, :min_sleep, :multiplier, :sleep_for def initialize(log: nil, min_sleep: nil, starting_sleep_for: 0, multiplier: nil) @log = log || RateThrottleClient.log_block @min_sleep ...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/clients/exponential_backoff.rb
Ruby
mit
89
main
772
module RateThrottleClient # Actual exponential backoff class with some extra jazz so it reports # when sleep goes back to zero # # Essentially it doesn't throttle at all until it hits a 429 then it exponentially # throttles every repeatedly limited request. When it hits a successful request it stops # rate ...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/clients/exponential_increase_proportional_decrease.rb
Ruby
mit
89
main
852
module RateThrottleClient class ExponentialIncreaseProportionalDecrease < Base attr_accessor :decrease_divisor def initialize(*args, decrease_divisor: nil, **kargs) super(*args, **kargs) @decrease_divisor = (decrease_divisor || RateThrottleClient.max_limit).to_f end def call(&block) ...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/servers/decrease_only/config.ru
Ruby
mit
89
main
1,170
require 'timecop' require 'rate_throttle_client' if ENV["TIME_SCALE"] require 'timecop' Timecop.scale(ENV["TIME_SCALE"].to_f) end module RateThrottleClient # This server does not gain new requests over time # it's main purpose is to benchmark how long it takes to # clear a fixed sized workload class NullF...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/servers/gcra/config.ru
Ruby
mit
89
main
273
require_relative "gcra_fake_server.rb" require 'timecop' if ENV["TIME_SCALE"] require 'timecop' Timecop.scale(ENV["TIME_SCALE"].to_f) end starting_limit = ENV.fetch("STARTING_LIMIT", 0).to_i run RateThrottleClient::GcraFakeServer.new(starting_limit: starting_limit)
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
lib/rate_throttle_client/servers/gcra/gcra_fake_server.rb
Ruby
mit
89
main
1,311
require 'thread' require 'rate_throttle_client' if ENV["TIME_SCALE"] require 'timecop' Timecop.scale(ENV["TIME_SCALE"].to_f) end module RateThrottleClient class GcraFakeServer def initialize(starting_limit: 0) @limit_left = starting_limit.to_f @mutex = Mutex.new @rate_of_gain = RateThrottl...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/test_helper.rb
Ruby
mit
89
main
975
$LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "rate_throttle_client" RateThrottleClient.config do |config| config.log_block = ->(info){ } end if defined?(M) # https://github.com/qrush/m/issues/80 require "minitest" else require "minitest/autorun" end require 'rate_throttle_client/demo' requi...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/demo_test.rb
Ruby
mit
89
main
6,000
require "test_helper" module RateThrottleClient class DemoTest < Minitest::Test def setup @tmp_dir = Dir.mktmpdir end def teardown FileUtils.remove_entry @tmp_dir end def test_print_results dir = fixture_path("logs/90_sec_json_logs") demo = Demo.new(client: Null.new, log...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/chart_test.rb
Ruby
mit
89
main
652
require "test_helper" module RateThrottleClient class ChartTest < Minitest::Test def test_making_a_chart_works dir = fixture_path("logs/prop_dec") chart = RateThrottleClient::Chart.new(log_dir: dir, name: "ProportionalDecrease", time_scale: 1) chart.log_files.each do |file| assert file...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/clients/exponential_increase_proportional_remaining_decrease_test.rb
Ruby
mit
89
main
1,563
require "test_helper" module RateThrottleClient class ExponentialIncreaseProportionalRemainingDecreaseTest < Minitest::Test include ClientSharedTests def setup @klass = ExponentialIncreaseProportionalRemainingDecrease end def test_kwargs assert 42, @klass.new(decrease_divisor: 42).decrea...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/clients/exponential_increase_gradual_decrease_test.rb
Ruby
mit
89
main
305
require "test_helper" module RateThrottleClient class ExponentialIncreaseGradualDecreaseTest < Minitest::Test include ClientSharedTests def setup @klass = ExponentialIncreaseGradualDecrease end def test_kwargs assert 42, @klass.new(decrease: 42).decrease end end end
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/clients/shared_tests.rb
Ruby
mit
89
main
1,533
module RateThrottleClient module ClientSharedTests def test_gets_called client = @klass.new def client.sleep(val); end @called_count = 0 response = client.call do @called_count += 1 FakeResponse.new end assert_equal 1, @called_count assert_equal 200, res...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/clients/exponential_increase_proportional_decrease_test.rb
Ruby
mit
89
main
1,019
require "test_helper" module RateThrottleClient class ExponentialIncreaseProportionalDecreaseTest < Minitest::Test include ClientSharedTests def setup @klass = ExponentialIncreaseProportionalDecrease end def test_kwargs assert 42, @klass.new(decrease_divisor: 42).decrease_divisor end...
github
zombocom/rate_throttle_client
https://github.com/zombocom/rate_throttle_client
test/clients/null_test.rb
Ruby
mit
89
main
343
require "test_helper" module RateThrottleClient class NullTest < Minitest::Test include ClientSharedTests def setup @klass = Null end def test_gets_called client = Null.new @called_count = 0 client.call do @called_count += 1 end assert_equal 1, @called_c...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
init.rb
Ruby
mit
89
main
759
require 'redmine' Rails.configuration.to_prepare do unless Project.included_modules.include? RedminePeriodictask::ProjectPatch Project.include RedminePeriodictask::ProjectPatch end end Redmine::Plugin.register :periodictask do name 'Redmine Periodictask plugin' author 'Julian Perelli' description 'Plugi...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20190214232727_add_custom_field_values_to_periodictasks.rb
Ruby
mit
89
main
379
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddCustomFieldValuesToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :custom_field_values, :text end def self.down re...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20180909013403_add_estimated_hours_to_periodictasks.rb
Ruby
mit
89
main
395
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddEstimatedHoursToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :estimated_hours, :float, null: true, default: nil end ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20260406000000_add_priority_id_to_periodictasks.rb
Ruby
mit
89
main
391
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddPriorityIdToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :priority_id, :integer, :null => true, :default => nil end ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20110922180841_create_periodictasks.rb
Ruby
mit
89
main
679
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class CreatePeriodictasks < active_record_migration_class def self.up create_table :periodictasks do |t| t.column :project_id, :integer t.column :tracker_id, ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20260406000001_add_watcher_user_ids_to_periodictasks.rb
Ruby
mit
89
main
370
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddWatcherUserIdsToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :watcher_user_ids, :json end def self.down remove_c...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20231224000000_add_parent_id_to_periodictasks.rb
Ruby
mit
89
main
385
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddParentIdToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :parent_id, :integer, :null => true, :default => nil end def ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20180910202703_add_checklists_template_id_to_periodictasks.rb
Ruby
mit
89
main
417
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddChecklistsTemplateIdToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :checklists_template_id, :integer, null: true, default...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20190214161616_add_last_error_to_periodictasks.rb
Ruby
mit
89
main
355
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddLastErrorToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :last_error, :string end def self.down remove_column :pe...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20140722185522_add_date_and_description_to_periodictasks.rb
Ruby
mit
89
main
765
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddDateAndDescriptionToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :set_start_date, :boolean, null: false, default: false ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
db/migrate/20151002140303_add_category_to_periodictasks.rb
Ruby
mit
89
main
395
active_record_migration_class = ActiveRecord::Migration.respond_to?(:current_version) ? ActiveRecord::Migration[4.2] : ActiveRecord::Migration class AddCategoryToPeriodictasks < active_record_migration_class def self.up add_column :periodictasks, :issue_category_id, :integer, null: true, default: nil end de...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
config/routes.rb
Ruby
mit
89
main
1,173
Rails.application.routes.draw do # this is like "resources :periodictask" but it has been # replaced put with match for action 'update', allowing both http-verb options 'put' # and the new verb 'patch' for compatibility with Redmine 3 and below match 'projects/:project_id/periodictask/customfields', to: ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
app/models/periodictask.rb
Ruby
mit
89
main
4,300
class Periodictask < ActiveRecord::Base include Redmine::I18n belongs_to :project belongs_to :assigned_to, class_name: 'Principal', foreign_key: 'assigned_to_id' belongs_to :issue_category, class_name: 'IssueCategory', foreign_key: 'issue_category_id' serialize :custom_field_values attribute :watcher_user_...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
app/controllers/periodictask_controller.rb
Ruby
mit
89
main
3,879
class PeriodictaskController < ApplicationController unless respond_to?(:before_action) class << self alias before_action before_filter end end before_action :find_project # before_filter :find_periodictask, :except => [:new, :create, :index] before_action :load_users, except: [:destroy] befo...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
app/helpers/periodictask_helper.rb
Ruby
mit
89
main
980
module PeriodictaskHelper def checklistPluginInstalled? Redmine::Plugin.all.any? { |p| p.id == :redmine_checklists } && Object.const_defined?('ChecklistTemplate') end def template_options_for_select(project = nil, selected_id = nil) scoped = ChecklistTemplate.visible scoped = scoped.in_project_and_gl...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
lib/scheduled_tasks_checker.rb
Ruby
mit
89
main
817
class ScheduledTasksChecker def self.checktasks! now = Time.current Periodictask.where('next_run_date <= ? ', now).each do |task| # replace variables (set locale from shell) I18n.locale = ENV['LOCALE'] || I18n.default_locale issue = task.generate_issue(now) if issue begin ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
lib/tasks/periodictask.rake
Ruby
mit
89
main
355
desc <<~END_DESC Check for and assign periodic tasks Example: rake redmine:check_periodictasks RAILS_ENV="production" END_DESC Rails.configuration.active_job.queue_adapter = :inline if Rails.configuration.respond_to?(:active_job) namespace :redmine do task check_periodictasks: :environment do Scheduled...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
test/test_helper.rb
Ruby
mit
89
main
821
# Load the normal Rails helper require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper') module Redmine module PluginFixturesLoader def self.included(base) base.class_eval do def self.plugin_fixtures(*symbols) fixture_klass = ActiveRecord.const_defined?('FixtureSet')...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
test/functional/periodictask_controller_test.rb
Ruby
mit
89
main
3,966
require File.dirname(__FILE__) + '/../test_helper' class PeriodictaskControllerTest < ActionController::TestCase fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :enumerations, :issue_categories d...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
test/unit/periodictasks_test.rb
Ruby
mit
89
main
16,434
require File.dirname(__FILE__) + '/../test_helper' class PeriodictasksTest < ActiveSupport::TestCase fixtures :projects, :users, :trackers, :projects_trackers, :issue_statuses, :enumerations, :enabled_modules, :roles, :members, :member_roles def setup @project = Project.find(1) EnabledModule.cr...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
test/unit/timezone_test.rb
Ruby
mit
89
main
8,437
require 'minitest/autorun' require 'active_support' require 'active_support/core_ext/integer/time' require 'active_support/core_ext/numeric/time' require 'active_support/core_ext/time' require 'business_time' # Tests for https://github.com/jperelli/Redmine-Periodic-Task/issues/25 # and validation that our approach is ...
github
jperelli/Redmine-Periodic-Task
https://github.com/jperelli/Redmine-Periodic-Task
test/unit/get_next_run_date_test.rb
Ruby
mit
89
main
6,283
require 'minitest/autorun' require 'active_support' require 'active_support/core_ext/integer/time' require 'active_support/core_ext/numeric/time' require 'business_time' # Standalone test for get_next_run_date logic (no Redmine dependency needed). # Tests the fix for https://github.com/jperelli/Redmine-Periodic-Task/i...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
Gemfile
Ruby
mit
89
main
762
# Specify the ruby version so Heroku can host the app # But not in CI, since we test the gem against multiple ruby versions ruby File.read(".ruby-version").strip unless ENV["CI"] source "https://rubygems.org" # Declare your gem's dependencies in govuk_publishing_components.gemspec. # Bundler will treat runtime depend...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
Rakefile
Ruby
mit
89
main
1,333
require "rubocop/rake_task" require "rspec/core/rake_task" APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__) ENV["RAILS_TRANSLATION_MANAGER_LOCALE_ROOT"] ||= File.expand_path("config/locales", __dir__) load "rails/tasks/engine.rake" load "rails/tasks/statistics.rake" rails_translation_manager = Gem::Sp...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
govuk_publishing_components.gemspec
Ruby
mit
89
main
2,084
$LOAD_PATH.push File.expand_path("lib", __dir__) # Maintain your gem's version: require "govuk_publishing_components/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "govuk_publishing_components" s.version = GovukPublishingComponents::VERSION s.authors ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/component_wrapper_helper_options.rb
Ruby
mit
89
main
1,597
module GovukPublishingComponents module ComponentWrapperHelperOptions def self.intro "This component uses the component wrapper helper. It accepts the following options and applies them to the parent element of the component. See the [component wrapper helper documentation](https://github.com/alphagov/govuk...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/applications_page.rb
Ruby
mit
89
main
2,373
module GovukPublishingComponents class ApplicationsPage attr_reader :source, :ruby_version def initialize(application) @application = application @dir = get_directory @gemfilelock = get_file("Gemfile.lock") rubyfile = get_file(".ruby-version") @ruby_version = rubyfile.strip if r...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/audit_components.rb
Ruby
mit
89
main
10,501
module GovukPublishingComponents class AuditComponents attr_reader :data def initialize(path, options = {}) # paths to key file locations @templates_path = options[:templates_path] || "app/views/govuk_publishing_components/components" @stylesheets_path = options[:stylesheets_path] || "app/a...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/component_doc.rb
Ruby
mit
89
main
3,223
module GovukPublishingComponents class ComponentDoc attr_reader :id, :name, :description, :body, :component, :accessibility_excluded_rules, :source, :embed def initialize(component) @componen...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/audit_comparer.rb
Ruby
mit
89
main
8,692
module GovukPublishingComponents class AuditComparer attr_reader :applications_data, :gem_data def initialize(gem_data, results) if gem_data[:gem_found] @gem_data = gem_data @applications_data = sort_results(results) @gem_data[:components_by_application] = get_components_by_appl...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/component_docs.rb
Ruby
mit
89
main
1,862
module GovukPublishingComponents # @private class ComponentDocs def initialize(gem_components: false, limit_to: false) @limit_to = limit_to @documentation_directory = gem_components ? gem_documentation_directory : app_documentation_directory end def get(id) component = fetch_component...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/component_example.rb
Ruby
mit
89
main
2,438
require "rouge" module GovukPublishingComponents class ComponentExample attr_reader :id, :data, :context, :description, :block, :embed def initialize(id, example) @id = id @data = example["data"] || {} @context...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/shared_accessibility_criteria.rb
Ruby
mit
89
main
933
module GovukPublishingComponents module SharedAccessibilityCriteria def self.link " Links in the component must: - accept focus - be focusable with a keyboard - be usable with a keyboard - indicate when they have focus - change in appearance when touched (in the touch-down state) - change in appearance whe...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/models/govuk_publishing_components/audit_applications.rb
Ruby
mit
89
main
6,167
module GovukPublishingComponents class AuditApplications attr_reader :data def initialize(path, name, dir) @path = path application_found = application_exists(path) components_found = [] @component_locations = {} @gem_style_references = [] @jquery_references = [] @he...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/controllers/govuk_publishing_components/applications_page_controller.rb
Ruby
mit
89
main
2,102
module GovukPublishingComponents class ApplicationsPageController < GovukPublishingComponents::ApplicationController def show applications = [ { type: "public-facing", apps: %w[collections email-alert-frontend feedback finder-frontend frontend govuk_publishing_components smart-an...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/controllers/govuk_publishing_components/audit_controller.rb
Ruby
mit
89
main
2,290
module GovukPublishingComponents class AuditController < GovukPublishingComponents::ApplicationController def show application_dirs = %w[ account-api collections collections-publisher content-block-manager content-data-admin content-tagger datagovuk_fi...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/controllers/govuk_publishing_components/component_guide_controller.rb
Ruby
mit
89
main
5,841
module GovukPublishingComponents class ComponentGuideController < GovukPublishingComponents::ApplicationController append_view_path Rails.root.join("app", "views", GovukPublishingComponents::Config.component_directory_name).to_s MATCH_COMPONENTS = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
app/controllers/govuk_publishing_components/application_controller.rb
Ruby
mit
89
main
335
module GovukPublishingComponents class ApplicationController < ActionController::Base helper ::Rails.application.helpers protect_from_forgery with: :exception before_action :set_x_frame_options_header private def set_x_frame_options_header response.headers["X-Frame-Options"] = "ALLOWALL" ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components.rb
Ruby
mit
89
main
3,569
require "active_support" require "action_controller" require "action_view" require "govuk_personalisation" require "ostruct" require "govuk_publishing_components/config" require "govuk_publishing_components/engine" require "govuk_publishing_components/version" require "govuk_publishing_components/presenters/shared_help...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/generators/govuk_publishing_components/component_generator.rb
Ruby
mit
89
main
1,206
require "rails/generators" require "fileutils" module GovukPublishingComponents class ComponentGenerator < ::Rails::Generators::NamedBase source_root File.expand_path("templates", __dir__) def copy_component_files @public_name = file_name.dasherize @component_prefix = "app-c-" component_di...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/config.rb
Ruby
mit
89
main
1,341
module GovukPublishingComponents def self.configure yield(Config) end module Config APP_COMPONENT_DIRECTORY = "components".freeze mattr_accessor :component_guide_title self.component_guide_title = "Component Guide" mattr_accessor :application_dir self.application_dir = "" mattr_acc...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/minitest/component_guide_test.rb
Ruby
mit
89
main
993
module GovukPublishingComponents module Minitest module ComponentGuideTest extend ActiveSupport::Concern included do test "renders all component guide preview pages without erroring" do visit "/component-guide" # Confirm accessibility JS test is available assert...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/middleware/ga4_optimise.rb
Ruby
mit
89
main
883
module GovukPublishingComponents module Middleware class Ga4Optimise DATA_GA4_REGEX = /data-ga4-(?:link|event|form|focus-loss)=("[^"]*")/ def initialize(app) @app = app end def call(env) status, headers, response = @app.call(env) return [status, headers, safe_body...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/intervention_helper.rb
Ruby
mit
89
main
1,614
module GovukPublishingComponents module Presenters class InterventionHelper def initialize(options = {}) @name = options[:name] @dismiss_text = options[:dismiss_text] @accessible_text_suffix = I18n.t("components.intervention.accessible_link_text_suffix") @params = options[:pa...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/image_card_helper.rb
Ruby
mit
89
main
2,917
module GovukPublishingComponents module Presenters class ImageCardHelper include ActionView::Helpers include ActionView::Context attr_reader :href, :large, :extra_details, :extra_details_no_indent, :heading_text, :metadata, :lang, :image_loading, :image_src, :two_thirds, :large_font_size_mobile...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/contents_list_helper.rb
Ruby
mit
89
main
2,265
require "action_view" module GovukPublishingComponents module Presenters class ContentsListHelper include ActionView::Helpers::SanitizeHelper attr_reader :classes, :contents def initialize(options) @contents = options[:contents] || [] @nested = @contents.any? { |c| c[:items] &...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/pagination_helper.rb
Ruby
mit
89
main
4,829
module GovukPublishingComponents module Presenters class PaginationHelper include ActionView::Helpers include ActionView::Context attr_reader :prev_link, :next_link, :page_links, :ga4_type def initialize(local_assigns) @arrow_links = { next: local_assigns[:next_page] ||...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/public_layout_helper.rb
Ruby
mit
89
main
1,901
module GovukPublishingComponents module Presenters class PublicLayoutHelper FOOTER_NAVIGATION_COLUMNS = [2, 1].freeze FOOTER_META = { items: [ { href: "/help", text: "Help", }, { href: "/help/privacy-notice", text: "...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/devolved_nations_helper.rb
Ruby
mit
89
main
2,209
module GovukPublishingComponents module Presenters class DevolvedNationsHelper attr_reader :national_applicability, :content_type def initialize(local_assigns) @national_applicability = local_assigns[:national_applicability] @content_type = local_assigns[:content_type] || "publication...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/contextual_navigation.rb
Ruby
mit
89
main
4,338
module GovukPublishingComponents module Presenters # @private class ContextualNavigation attr_reader :content_item, :request_path, :query_parameters # @param content_item A content item hash with strings as keys # @param request_path `request.path` def initialize(content_item, request...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb
Ruby
mit
89
main
2,377
module GovukPublishingComponents module Presenters class SinglePageNotificationButtonHelper attr_reader :already_subscribed, :data_attributes, :base_path, :button_type, :button_location, :skip_account, :button_text_subscribe, :button_text_unsubscribe def initialize(local_assigns) @local_assig...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/meta_tags.rb
Ruby
mit
89
main
9,296
module GovukPublishingComponents module Presenters class MetaTags FORMATS_THAT_MIGHT_INCLUDE_POSTCODES = %w[smart_answer finder local_transaction place special_route transaction].freeze attr_reader :content_item, :details, :links, :local_assigns, :request def initialize(content_item, local_ass...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/select_with_search_helper.rb
Ruby
mit
89
main
2,836
## # Helper methods for use with the "select-with-search" component. # This wraps and extends the Select component's helper methods to add support for option groups. ## module GovukPublishingComponents module Presenters class SelectWithSearchHelper include ActionView::Helpers::FormOptionsHelper attr_...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb
Ruby
mit
89
main
6,288
module GovukPublishingComponents module Presenters # @private # Only used by the step by step component class PageWithStepByStepNavigation MAX_SECTION_LENGTH = RelatedNavigationHelper::MAX_SECTION_LENGTH def initialize(content_store_response, current_path, query_parameters = {}) @cont...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/checkboxes_helper.rb
Ruby
mit
89
main
4,119
module GovukPublishingComponents module Presenters class CheckboxesHelper include ActionView::Helpers include ActionView::Context attr_reader :items, :name, :css_classes, :error, :has_conditional, :has_nes...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/curated_taxonomy_sidebar_links.rb
Ruby
mit
89
main
2,684
module GovukPublishingComponents module Presenters # @private class CuratedTaxonomySidebarLinks def initialize(content_item) @content_item = content_item end def related_items @related_items ||= taxon_links + elsewhere_on_gov_uk_links + elsewher...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb
Ruby
mit
89
main
1,055
module GovukPublishingComponents module Presenters # @private class ContentBreadcrumbsBasedOnTaxons def self.call(content_item) new(content_item).breadcrumbs end def initialize(content_item) @content_item = ContentItem.new(content_item) end def breadcrumbs ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/select_helper.rb
Ruby
mit
89
main
2,493
module GovukPublishingComponents module Presenters class SelectHelper include ActionView::Helpers::FormOptionsHelper attr_reader :options, :options_markup, :error_items, :error_id, :hint, :hint_id, :describedby def initialize(local_assigns) @options = local_assigns[:options] || [] ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/content_item.rb
Ruby
mit
89
main
4,202
module GovukPublishingComponents module Presenters # Simple wrapper around a content store representation of a content item. # Works for both the main content item and the expanded links in the links # hash. # # @private class ContentItem attr_reader :content_store_response def in...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/heading_helper.rb
Ruby
mit
89
main
945
module GovukPublishingComponents module Presenters class HeadingHelper attr_reader :heading_tag, :id, :classes, :heading_classes def initialize(options) @id = options[:id] @classes = "" @classes += " gem-c-heading--padding" if options[:padding] @classes += " gem-c-hea...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb
Ruby
mit
89
main
3,348
module GovukPublishingComponents module Presenters # @private # Only used by the step by step component class StepByStepNavHelper include ActionView::Helpers include ActionView::Context def render_step_nav_element(element, options) @options = options @link_index = option...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/layout_footer_helper.rb
Ruby
mit
89
main
1,373
module GovukPublishingComponents module Presenters class LayoutFooterHelper attr_reader :ga4_index_section_count, :ga4_ogl_link_index_section, :ga4_copyright_link_index_section def initialize(footer_navigation_section, footer_meta_section) @ga4_index_section_count = footer_navigation_section....
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/breadcrumb_selector.rb
Ruby
mit
89
main
3,457
module GovukPublishingComponents module Presenters class BreadcrumbSelector attr_reader :content_item, :request, :prioritise_taxon_breadcrumbs def initialize(content_item, request, prioritise_taxon_breadcrumbs, disable_ga4) @content_item = content_item @request = request @prio...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/button_helper.rb
Ruby
mit
89
main
5,222
require "action_view" module GovukPublishingComponents module Presenters class ButtonHelper attr_reader :href, :text, :title, :info_text, :info_text_classes, :rel, :data_attributes, ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/shared_helper.rb
Ruby
mit
89
main
2,344
module GovukPublishingComponents module Presenters class SharedHelper attr_reader :options, :margin_bottom, :heading_level, :classes def initialize(local_assigns) @options = local_assigns @margin_bottom = @options[:margin_bottom] || 3 @heading_level = @options[:heading_level] ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/subscription_links_helper.rb
Ruby
mit
89
main
1,635
module GovukPublishingComponents module Presenters class SubscriptionLinksHelper attr_reader :feed_box_id, :email_signup_link, :email_signup_link_data_attributes, :feed_link_box_value def initialize(local_assigns) @local_assigns = local_assigns @feed_box_id = "feed-reader-#{SecureRand...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/component_wrapper_helper.rb
Ruby
mit
89
main
12,122
module GovukPublishingComponents module Presenters class ComponentWrapperHelper def initialize(options) @options = options check_id_is_valid(@options[:id]) if @options.include?(:id) check_data_attributes_are_valid(@options[:data_attributes]) if @options.include?(:data_attributes) ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/attachment_helper.rb
Ruby
mit
89
main
7,400
module GovukPublishingComponents module Presenters class AttachmentHelper delegate :opendocument?, :document?, :spreadsheet?, :pdf?, to: :content_type attr_reader :attachment_data # Expects a hash of attachment data # * title and url are required # * type, content_type, filename, f...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb
Ruby
mit
89
main
1,541
module GovukPublishingComponents module Presenters class Breadcrumbs def initialize(breadcrumbs) @breadcrumbs = breadcrumbs end def structured_data { "@context" => "http://schema.org", "@type" => "BreadcrumbList", "itemListElement" => item_list_elem...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/big_number_helper.rb
Ruby
mit
89
main
998
module GovukPublishingComponents module Presenters class BigNumberHelper def initialize(local_assigns) @label = local_assigns[:label] @href = local_assigns[:href] @number = local_assigns[:number] || nil end def value_classes class_list = ["gem-c-big-number__value...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/accordion_helper.rb
Ruby
mit
89
main
1,083
module GovukPublishingComponents module Presenters class AccordionHelper def initialise; end def translations { show_text: "common.show", hide_text: "common.hide", show_all_text: "components.accordion.show_all", hide_all_text: "components.accordion.hide...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
Ruby
mit
89
main
1,486
module GovukPublishingComponents module Presenters class OrganisationLogoHelper include ActionView::Helpers include ActionView::Context def initialize(local_assigns) @name = local_assigns[:organisation][:name] @url = local_assigns[:organisation][:url] @crest = local_assi...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/translation_nav_helper.rb
Ruby
mit
89
main
710
module GovukPublishingComponents module Presenters class TranslationNavHelper attr_reader :translations def initialize(local_assigns) @translations = [] @translations = local_assigns[:translations] if local_assigns[:translations] @inverse = local_assigns[:inverse] end ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/schema_org.rb
Ruby
mit
89
main
2,078
require "govuk_publishing_components/presenters/machine_readable/page" require "govuk_publishing_components/presenters/machine_readable/article_schema" require "govuk_publishing_components/presenters/machine_readable/creative_work_schema" require "govuk_publishing_components/presenters/machine_readable/faq_page_schema"...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/emergency_banner_helper.rb
Ruby
mit
89
main
368
module GovukPublishingComponents module Presenters class EmergencyBannerHelper EMERGENCY_TYPES = %w[notable-death national-emergency local-emergency].freeze def initialize; end def emergency_types EMERGENCY_TYPES end def is_a_valid_emergency_type?(type) EMERGENCY_T...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb
Ruby
mit
89
main
856
module GovukPublishingComponents module Presenters # @private class ContentBreadcrumbsBasedOnAncestors def self.call(content_item) new(content_item).breadcrumbs end def initialize(content_item) @content_item = ContentItem.new(content_item) end def breadcrumbs ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/related_navigation_helper.rb
Ruby
mit
89
main
7,004
module GovukPublishingComponents module Presenters # @private # Only used by the related_navigation component class RelatedNavigationHelper MAX_SECTION_LENGTH = 5 DEFINED_SECTIONS = %w[ related_guides topics collections topical_events world_locations ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_organisations.rb
Ruby
mit
89
main
899
module GovukPublishingComponents module Presenters # @private class ContentBreadcrumbsBasedOnOrganisations def self.call(content_item) new(content_item).breadcrumbs end def initialize(content_item) @content_item = ContentItem.new(content_item) end def breadcrumb...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb
Ruby
mit
89
main
2,892
module GovukPublishingComponents module Presenters class FaqPageSchema attr_reader :page def initialize(page) @page = page end def structured_data # http://schema.org/FAQPage data = CreativeWorkSchema.new(@page).structured_data .merge(main_entity) ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
Ruby
mit
89
main
812
require "plek" module GovukPublishingComponents module Presenters class PotentialSearchActionSchema attr_reader :facet_params, :description BASE_SEARCH_URL = "#{Plek.new.website_root}/search/all?keywords={query}&order=relevance".freeze def initialize(facet_params, description) @facet_...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/machine_readable/has_part_schema.rb
Ruby
mit
89
main
431
module GovukPublishingComponents module Presenters class HasPartSchema attr_reader :has_part_url def initialize(has_part_url) @has_part_url = has_part_url end def structured_data # http://schema.org/hasPart - minimal { "@context" => "http://schema.org", ...
github
alphagov/govuk_publishing_components
https://github.com/alphagov/govuk_publishing_components
lib/govuk_publishing_components/presenters/machine_readable/person_schema.rb
Ruby
mit
89
main
760
module GovukPublishingComponents module Presenters class PersonSchema attr_reader :page def initialize(page) @page = page end def structured_data # http://schema.org/Person { "@context" => "http://schema.org", "@type" => "Person", "ma...