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
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/taxon.rb
Ruby
mit
19
main
363
class Etl::Edition::Content::Parsers::Taxon def parse(json) html = [] html << json["description"] children = json.dig("links", "child_taxons") unless children.nil? children.each do |child| html << child["title"] html << child["description"] end end html.join(" ") ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/body_content.rb
Ruby
mit
19
main
1,030
module Etl::Edition::Content::Parsers class BodyContent def parse(json) ContentArray.new.parse(json.dig("details", "body")) end def schemas %w[ answer calendar call_for_evidence case_study consultation corporate_information_page detailed...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/travel_advice.rb
Ruby
mit
19
main
482
class Etl::Edition::Content::Parsers::TravelAdvice def parse_subpage(json, subpage_path) if summary_page?(json, subpage_path) json.dig("details", "summary").find { |x| x["content_type"] == "text/html" }.try(:dig, "content") else Etl::Edition::Content::Parsers::Parts.new.parse_subpage(json, subpage...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/no_content.rb
Ruby
mit
19
main
1,209
class Etl::Edition::Content::Parsers::NoContent def parse(_json) nil end def schemas %w[ coming_soon completed_transaction content_block content_block_contact content_block_pension content_block_tax content_block_time_period coronavirus_landing_page e...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/mainstream.rb
Ruby
mit
19
main
613
class Etl::Edition::Content::Parsers::Mainstream def parse(json) html = [] html << json["title"] unless json["title"].nil? html << json["description"] unless json["description"].nil? children = json.dig("links", "children") if children.present? children.each do |child| html << child...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/contact.rb
Ruby
mit
19
main
1,380
class Etl::Edition::Content::Parsers::Contact def parse(json) html = [] html << json.dig("details", "description") html << get_email(json) unless get_email(json).nil? html << get_postal(json) unless get_postal(json).nil? html << get_phone(json) unless get_phone(json).nil? html.join(" ") end ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/generic_with_links.rb
Ruby
mit
19
main
338
class Etl::Edition::Content::Parsers::GenericWithLinks def parse(json) html = [] links = json.dig("details", "external_related_links") unless links.nil? links.each do |link| html << link["title"] end html.join(" ") end end def schemas %w[generic_with_external_related...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/finder.rb
Ruby
mit
19
main
400
class Etl::Edition::Content::Parsers::Finder def parse(json) html = [] html << json["title"] unless json["title"].nil? children = json.dig("links", "children") unless children.nil? children.each do |child| html << child["title"] html << child["description"] end end ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/parts.rb
Ruby
mit
19
main
382
module Etl::Edition::Content::Parsers class Parts def parse_subpage(json, subpage_path) parts = json.dig("details", "parts") return if parts.nil? current_part = parts.find { |part| part["slug"] == subpage_path } return if current_part.nil? ContentArray.new.parse(current_part["body"...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/step_by_step.rb
Ruby
mit
19
main
1,029
class Etl::Edition::Content::Parsers::StepByStep def parse(json) html = [] steps = json.dig("details", "step_by_step_nav") if steps.present? html << steps["title"] html << steps["introduction"] chapters = steps["steps"] if chapters.present? html << get_chapters(chapters)...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/travel_advice_index.rb
Ruby
mit
19
main
364
class Etl::Edition::Content::Parsers::TravelAdviceIndex def parse(json) html = [] children = json.dig("links", "children") return if children.nil? children.each do |child| country = child.dig("country", "name") html << country unless country.nil? end html.join(" ") end def sc...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/finder_email_signup.rb
Ruby
mit
19
main
372
class Etl::Edition::Content::Parsers::FinderEmailSignup def parse(json) html = [] choices = json.dig("details", "email_signup_choice") unless choices.nil? choices.each do |choice| html << choice["radio_button_name"] end end html << json["description"] html.join(" ") end ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/service_manual_service_toolkit.rb
Ruby
mit
19
main
538
class Etl::Edition::Content::Parsers::ServiceManualServiceToolkit def parse(json) html = [] items = json.dig("details", "collections") unless items.nil? items.each do |item| html << item["title"] html << item["description"] links = item["links"] next if links.nil? ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/content_array.rb
Ruby
mit
19
main
317
class Etl::Edition::Content::Parsers::ContentArray def parse(content) return if content.blank? return content unless content.is_a?(Array) html_content = content.find { |content_hash| content_hash["content_type"] == "text/html" } return if html_content.blank? html_content["content"] end end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/email_alert_signup.rb
Ruby
mit
19
main
371
class Etl::Edition::Content::Parsers::EmailAlertSignup def parse(json) html = [] breadcrumbs = json.dig("details", "breadcrumbs") unless breadcrumbs.nil? breadcrumbs.each do |crumb| html << crumb["title"] end end html << json.dig("details", "summary") html.join(" ") end ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/need.rb
Ruby
mit
19
main
261
class Etl::Edition::Content::Parsers::Need def parse(json) html = [] html << json.dig("details", "role") html << json.dig("details", "goal") html << json.dig("details", "benefit") html.join(" ") end def schemas %w[need] end end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/hmrc_manual.rb
Ruby
mit
19
main
667
class Etl::Edition::Content::Parsers::HMRCManual def parse(json) html = [] html << json["title"] unless json["title"].nil? html << json["description"] unless json["description"].nil? groups = json.dig("details", "child_section_groups") unless groups.nil? groups.each do |group| html <...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/transaction.rb
Ruby
mit
19
main
367
class Etl::Edition::Content::Parsers::Transaction def parse(json) html = [] html << json.dig("details", "introductory_paragraph") html << json.dig("details", "start_button_text") html << json.dig("details", "will_continue_on") html << json.dig("details", "more_information") html.join(" ") en...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/service_manual_topic.rb
Ruby
mit
19
main
380
class Etl::Edition::Content::Parsers::ServiceManualTopic def parse(json) html = [] html << json["description"] groups = json.dig("details", "groups") unless groups.nil? groups.each do |group| html << group["name"] html << group["description"] end end html.join(" ") ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/service_manual_standard.rb
Ruby
mit
19
main
435
class Etl::Edition::Content::Parsers::ServiceManualStandard def parse(json) html = [] html << json["title"] html << json.dig("details", "body") children = json.dig("links", "children") unless children.nil? children.each do |child| html << child["title"] html << child["descrip...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/statistics_announcement.rb
Ruby
mit
19
main
296
class Etl::Edition::Content::Parsers::StatisticsAnnouncement def parse(json) html = [] html << json["description"] html << json.dig("details", "display_date") html << json.dig("details", "state") html.join(" ") end def schemas %w[statistics_announcement] end end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/licence.rb
Ruby
mit
19
main
205
module Etl::Edition::Content::Parsers class Licence def parse(json) ContentArray.new.parse(json.dig("details", "licence_overview")) end def schemas %w[licence] end end end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/etl/edition/content/parsers/service_manual_homepage.rb
Ruby
mit
19
main
429
class Etl::Edition::Content::Parsers::ServiceManualHomepage def parse(json) html = [] html << json["title"] html << json["description"] children = json.dig("links", "children") if children.present? children.each do |child| html << child["title"] html << child["description"] ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/message_processor_job.rb
Ruby
mit
19
main
572
require_dependency("streams/messages/factory") module Streams class MessageProcessorJob < ActiveJob::Base # rubocop:disable Rails/ApplicationJob retry_on ActiveRecord::RecordNotUnique, wait: 5.seconds, attempts: 3 def perform(payload, routing_key) message = Streams::Messages::Factory.build(payload, ro...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/grow_dimension.rb
Ruby
mit
19
main
1,050
class Streams::GrowDimension def self.should_grow?(old_edition:, attrs:) new(old_edition, attrs).should_grow? end def initialize(old_edition, attrs) @old_edition = old_edition @attrs = attrs end def should_grow? is_new_item? || item_needs_update? end private attr_reader :attrs, :old_ed...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/consumer.rb
Ruby
mit
19
main
638
module Streams class Consumer def process(message) if valid_routing_key?(message) Streams::MessageProcessorJob.perform_later(message.payload, message.delivery_info.routing_key) else Monitor::Messages.increment_discarded end message.ack rescue StandardError => e G...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/messages/multipart_message.rb
Ruby
mit
19
main
2,404
module Streams class Messages::MultipartMessage < Messages::BaseMessage def self.is_multipart?(payload) payload.dig("details", "parts").present? end def handler Streams::Handlers::MultipartHandler.new( edition_attributes, content_id, locale, @payload, @...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/messages/base_message.rb
Ruby
mit
19
main
2,921
class Streams::Messages::BaseMessage attr_reader :payload def initialize(payload, routing_key) @payload = payload @routing_key = routing_key end def build_attributes(base_path:, title:, document_text:, warehouse_item_id:, sibling_order: nil) parser = Streams::ParentChild::Parser.new parent_chi...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/messages/factory.rb
Ruby
mit
19
main
273
module Streams::Messages class Factory def self.build(payload, routing_key) if MultipartMessage.is_multipart?(payload) MultipartMessage.new(payload, routing_key) else SingleItemMessage.new(payload, routing_key) end end end end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/messages/single_item_message.rb
Ruby
mit
19
main
761
module Streams class Messages::SingleItemMessage < Messages::BaseMessage def edition_attributes build_attributes( base_path:, title:, document_text:, warehouse_item_id: "#{content_id}:#{locale}", ).merge( acronym:, ) end def handler Streams:...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/parent_child/links_processor.rb
Ruby
mit
19
main
1,148
class Streams::ParentChild::LinksProcessor def self.update_parent_and_sort_siblings(edition, parent_warehouse_id) new(edition, parent_warehouse_id).update_parent_and_sort_siblings end def initialize(edition, parent_warehouse_id) @edition = edition @parent_warehouse_id = parent_warehouse_id end d...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/parent_child/parser.rb
Ruby
mit
19
main
844
class Streams::ParentChild::Parser PARSERS = [ ::Streams::ParentChild::ParentChildLinksParser, ::Streams::ParentChild::ManualSectionManualParser, ::Streams::ParentChild::ManualSectionsParser, ].freeze def get_parent_id(payload) parser = parsers[payload["document_type"]] return nil if parser.n...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/parent_child/manual_section_manual_parser.rb
Ruby
mit
19
main
386
class Streams::ParentChild::ManualSectionManualParser < Streams::ParentChild::BaseParser DOCUMENT_TYPES = %w[manual_section].freeze def self.get_parent_id(payload) manuals = payload.dig("expanded_links", "manual") return nil if manuals.blank? to_warehouse_id(manuals.first["content_id"], manuals.first[...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/parent_child/parent_child_links_parser.rb
Ruby
mit
19
main
889
class Streams::ParentChild::ParentChildLinksParser < Streams::ParentChild::BaseParser DOCUMENT_TYPES = %w[ guidance form foi_release promotional html_publication notice correspondence research official_statistics transparency statutory_guidance independent_report na...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/parent_child/manual_sections_parser.rb
Ruby
mit
19
main
346
class Streams::ParentChild::ManualSectionsParser < Streams::ParentChild::BaseParser DOCUMENT_TYPES = %w[manual].freeze def self.get_children_ids(payload) sections = payload.dig("expanded_links", "sections") || [] sections.map { |h| to_warehouse_id(h["content_id"], h["locale"]) } end def self.get_paren...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/handlers/base_handler.rb
Ruby
mit
19
main
1,372
class Streams::Handlers::BaseHandler def update_editions(items_with_old_editions) publishing_api_event = Events::PublishingApi.new(payload: @payload, routing_key: @routing_key) items_to_grow = items_with_old_editions.select do |item| Streams::GrowDimension.should_grow? old_edition: item[:old_edition], a...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/handlers/single_item_handler.rb
Ruby
mit
19
main
821
class Streams::Handlers::SingleItemHandler < Streams::Handlers::BaseHandler class MissingLocaleError < StandardError end def self.process(*args) new(*args).process end def initialize(attrs, payload, routing_key) super() @attrs = attrs @payload = payload @routing_key = routing_key end ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/domain/streams/handlers/multipart_handler.rb
Ruby
mit
19
main
1,006
class Streams::Handlers::MultipartHandler < Streams::Handlers::BaseHandler def initialize(attr_list, content_id, locale, payload, routing_key) super() @attr_list = attr_list @content_id = content_id @locale = locale @payload = payload @routing_key = routing_key end attr_reader :attr_list,...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/controllers/application_controller.rb
Ruby
mit
19
main
393
class ApplicationController < ActionController::Base include GDS::SSO::ControllerMethods protect_from_forgery with: :exception before_action :authenticate_user! # Raise ActionController::UnpermittedParameters if there are unpermitted # parameters, so we can return better errors for invalid API requests Ac...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/controllers/single_item_controller.rb
Ruby
mit
19
main
1,155
class SingleItemController < Api::BaseController before_action :validate_params! def show @from = from @to = to @base_path = format_base_path_param @live_edition = find_live_edition @time_series_metrics = find_time_series @edition_metrics = find_editions @aggregations = find_aggregatio...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/controllers/content_controller.rb
Ruby
mit
19
main
818
class ContentController < Api::BaseController before_action :validate_params! def show filter = api_request.to_filter content = Finders::Content.call(filter:) @content_items = content[:results] @page = content[:page] @total_pages = content[:total_pages] @total_results = content[:total_resu...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/controllers/api/base_controller.rb
Ruby
mit
19
main
2,385
class Api::NotFoundError < StandardError end class Api::ParentNotFoundError < StandardError end class Api::BaseController < ApplicationController before_action :set_cache_headers rescue_from(ActionController::UnpermittedParameters) do |pme| error_response( "unknown-parameter", title: "One or more...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/controllers/api/documents_controller.rb
Ruby
mit
19
main
914
class Api::DocumentsController < Api::BaseController before_action :validate_params! def children @document_id = params[:document_id] @parent = find_parent_edition! @documents = Finders::DocumentChildren.call(@parent, api_request.to_filter) end private def api_request @api_request ||= Api::...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/metric.rb
Ruby
mit
19
main
873
class Metric include ActiveModel::Model include Comparable attr_accessor :description, :name, :source def self.find_all @find_all ||= (daily_metrics + edition_metrics).sort end def self.find_all_names find_all.map(&:name) end def self.is_edition_metric?(metric_name) edition_metrics.map(&:...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/user.rb
Ruby
mit
19
main
210
class User < ApplicationRecord include GDS::SSO::User serialize :permissions, coder: YAML, type: Array def organisation @organisation ||= item.find_by(content_id: organisation_content_id) end end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/document_type.rb
Ruby
mit
19
main
225
class DocumentType include ActiveModel::Model include ActiveModel::Serialization IGNORED_TYPES = %w[ gone need redirect substitute unpublishing vanish ].freeze attr_accessor :id, :name end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/dimensions/edition.rb
Ruby
mit
19
main
2,822
require "json" class Dimensions::Edition < ApplicationRecord has_one :facts_edition, class_name: "Facts::Edition", foreign_key: :dimensions_edition_id, inverse_of: "dimensions_edition" belongs_to :publishing_api_event, class_name: "Events::PublishingApi", inverse_of: "dimensions_editions" belongs_to :parent, cla...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/dimensions/date.rb
Ruby
mit
19
main
2,959
class Dimensions::Date < ApplicationRecord self.primary_key = "date" scope :between, ->(from, to) { where("date BETWEEN ? AND ?", from, to) } def self.build(date) new({ date:, date_name: date.to_fs(:govuk_date), date_name_abbreviated: date.to_fs(:govuk_date_short), year: date.year, ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/dimensions/month.rb
Ruby
mit
19
main
1,185
class Dimensions::Month < ApplicationRecord self.primary_key = :id validates :year, presence: true, numericality: { only_integer: true } validates :quarter, presence: true, numericality: { only_integer: true }, inclusion: { in: (1..4) } validates :month_number, presence: true, numericality: { only_integer: tru...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/facts/edition.rb
Ruby
mit
19
main
663
class Facts::Edition < ApplicationRecord belongs_to :dimensions_date, class_name: "Dimensions::Date" belongs_to :dimensions_edition, class_name: "Dimensions::Edition" validates :dimensions_date, presence: true validates :dimensions_edition, presence: true scope :between, lambda { |from, to| ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/facts/metric.rb
Ruby
mit
19
main
733
class Facts::Metric < ApplicationRecord belongs_to :dimensions_date, class_name: "Dimensions::Date" belongs_to :dimensions_edition, class_name: "Dimensions::Edition" has_one :facts_edition, through: :dimensions_edition delegate :pdf_count, :doc_count, :readability, :chars, ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/aggregations/materialized_view.rb
Ruby
mit
19
main
859
class Aggregations::MaterializedView < ApplicationRecord self.abstract_class = true self.primary_key = "warehouse_item_id" def self.prepare increase_work_mem_for_current_transaction end # `work_mem` speeds up the query because it is a big aggregations with sorting # that needs to perform the operatio...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/aggregations/monthly_metric.rb
Ruby
mit
19
main
285
class Aggregations::MonthlyMetric < ApplicationRecord belongs_to :dimensions_month, class_name: "Dimensions::Month" belongs_to :dimensions_edition, class_name: "Dimensions::Edition" validates :dimensions_month, presence: true validates :dimensions_edition, presence: true end
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/concerns/trace_and_recoverable.rb
Ruby
mit
19
main
678
require "active_support/concern" module TraceAndRecoverable extend ActiveSupport::Concern include Traceable included do def time_and_trap(process:, &block) raise ArgumentError "No block was given to TraceAndRecoverable#time_and_trap" unless block_given? begin time(process:, &block) ...
github
alphagov/content-data-api
https://github.com/alphagov/content-data-api
app/models/concerns/traceable.rb
Ruby
mit
19
main
910
require "active_support/concern" module Traceable extend ActiveSupport::Concern include ActionView::Helpers::DateHelper included do def time(process:) raise ArgumentError "No block was given to Traceable#time" unless block_given? started = Time.zone.now logger.info "Process: '#{process}' ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
solidus_print_invoice.gemspec
Ruby
bsd-3-clause
19
master
1,450
# frozen_string_literal: true $:.push File.expand_path('lib', __dir__) require 'solidus_print_invoice/version' Gem::Specification.new do |s| s.name = 'solidus_print_invoice' s.version = SolidusPrintInvoice::VERSION s.summary = 'Print invoices from a spree order' s.description = \ 'This extension provides ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
Gemfile
Ruby
bsd-3-clause
19
master
1,221
# frozen_string_literal: true source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } branch = ENV.fetch('SOLIDUS_BRANCH', 'master') solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2') %w[solidusio/solidus solidu...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
lib/solidus_print_invoice.rb
Ruby
bsd-3-clause
19
master
395
# frozen_string_literal: true require 'solidus_core' require 'solidus_support' require 'solidus_print_invoice/version' require 'solidus_print_invoice/engine' require 'prawn_handler' module Spree module PrintInvoice # Support the legacy location for the constant VERSION = SolidusPrintInvoice::VERSION ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
lib/prawn_handler.rb
Ruby
bsd-3-clause
19
master
701
# frozen_string_literal: true require 'prawn' module ActionView module Template::Handlers class Prawn def self.register! Template.register_template_handler :prawn, self end def self.call(template, source = template.source) %(extend #{DocumentProxy}; #{source}; pdf.render) ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
lib/solidus_print_invoice/engine.rb
Ruby
bsd-3-clause
19
master
758
# frozen_string_literal: true require 'spree/core' require 'deface' require_relative '../../app/models/spree/print_invoice_configuration' module SolidusPrintInvoice class Engine < Rails::Engine include SolidusSupport::EngineExtensions isolate_namespace ::Spree engine_name 'solidus_print_invoice' ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
lib/generators/solidus_print_invoice/install/install_generator.rb
Ruby
bsd-3-clause
19
master
711
# frozen_string_literal: true module SolidusPrintInvoice module Generators class InstallGenerator < Rails::Generators::Base class_option :auto_run_migrations, type: :boolean, default: false def add_migrations run 'bundle exec rake railties:install:migrations FROM=solidus_print_invoice' ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
app/decorators/controllers/solidus_print_invoice/spree/admin/orders_controller_decorator.rb
Ruby
bsd-3-clause
19
master
1,023
# frozen_string_literal: true module SolidusPrintInvoice module Spree module Admin module OrdersControllerDecorator def self.prepended(base) base.class_eval do respond_to :pdf helper ::Spree::Admin::PrintInvoiceHelper end end def show ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
app/models/spree/print_invoice_configuration.rb
Ruby
bsd-3-clause
19
master
1,304
# frozen_string_literal: true module Spree class PrintInvoiceConfiguration < Preferences::Configuration preference :print_invoice_next_number, :integer, default: nil # To avoid breaking stores with custom logos on their invoices and to # provide a fully functioning OOTB experience, this preference uses ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
app/helpers/spree/admin/print_invoice_helper.rb
Ruby
bsd-3-clause
19
master
464
# frozen_string_literal: true module Spree module Admin module PrintInvoiceHelper def font_faces fonts = Prawn::Font::AFM::BUILT_INS.reject { |f| f =~ /zapf|symbol|bold|italic|oblique/i }.map { |f| [f.tr('-', ' '), f] } options_for_select(fonts, Spree::PrintInvoice::Config[:print_invoice_fo...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
app/overrides/layouts_admin_print_buttons_decorator.rb
Ruby
bsd-3-clause
19
master
797
# frozen_string_literal: true # TODO Axe in favor of content_for # Versions of solidus >= 1.2 Deface::Override.new(virtual_path: "spree/admin/shared/_header", name: "print_buttons", insert_top: ".page-actions", partial: "spree/admin/orders/print_buttons", ...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
spec/spec_helper.rb
Ruby
bsd-3-clause
19
master
774
# frozen_string_literal: true # Configure Rails Environment ENV['RAILS_ENV'] = 'test' # Run Coverage report require 'solidus_dev_support/rspec/coverage' require File.expand_path('dummy/config/environment.rb', __dir__) # Requires factories and other useful helpers defined in spree_core. require 'solidus_dev_support/...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
spec/features/admin_order_spec.rb
Ruby
bsd-3-clause
19
master
585
# frozen_string_literal: true require 'spec_helper' RSpec.describe "Print Invoice button", js: true do let!(:order) { FactoryBot.create(:completed_order_with_totals) } let(:user) { FactoryBot.create(:admin_user, password: "boxen1011") } it "displays a print invoice button on order pages" do visit spree.adm...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
spec/requests/admin_orders_controller_spec.rb
Ruby
bsd-3-clause
19
master
1,016
# frozen_string_literal: true require 'spec_helper' RSpec.describe "Order Invoice Generation" do before do ActionController::Base.allow_forgery_protection = false end after do ActionController::Base.allow_forgery_protection = true end describe "GET show" do let(:order) { FactoryBot.create(:com...
github
solidusio-contrib/solidus_print_invoice
https://github.com/solidusio-contrib/solidus_print_invoice
db/migrate/20140123094547_add_invoice_details_to_spree_orders.rb
Ruby
bsd-3-clause
19
master
231
# frozen_string_literal: true class AddInvoiceDetailsToSpreeOrders < SolidusSupport::Migration[4.2] def change add_column :spree_orders, :invoice_number, :integer add_column :spree_orders, :invoice_date, :date end end
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
alexa_verifier.gemspec
Ruby
mit
19
master
1,369
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'alexa_verifier/version' Gem::Specification.new do |spec| spec.name = 'alexa_verifier' spec.version = AlexaVerifier::VERSION spec.authors = ['Christopher Mullins', 'Matt Rayner'] spec...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/spec_helper.rb
Ruby
mit
19
master
1,009
require 'simplecov' require 'coveralls' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ] SimpleCov.start require 'bundler/setup' require 'vcr' require 'webmock/rspec' require 'timecop' require 'alexa_verifier' RSpec.configure d...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/alexa_verifier_spec.rb
Ruby
mit
19
master
932
require 'spec_helper' RSpec.describe AlexaVerifier, vcr: true do it 'has a version number' do expect(AlexaVerifier::VERSION).not_to be nil end it_behaves_like 'a verifier object', AlexaVerifier describe '#configuration' do it 'returns a configuration object' do expect(subject.configuration).to ...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/alexa_verifier/certificate_store_spec.rb
Ruby
mit
19
master
4,929
require_relative '../spec_helper' RSpec.describe AlexaVerifier::CertificateStore, vcr: true do after :each do subject.instance_variable_set(:@store, nil) end describe '#fetch' do let(:uri) { 'https://s3.amazonaws.com/echo.api/echo-api-cert-5.pem' } before :each do Timecop.freeze(Time.local(20...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/alexa_verifier/invalid_certificate_u_r_i_error_spec.rb
Ruby
mit
19
master
628
require_relative '../spec_helper' RSpec.describe AlexaVerifier::InvalidCertificateURIError do describe '#initializer' do context 'without a value attribute' do it 'creates the expected message' do expect(AlexaVerifier::InvalidCertificateURIError.new('Test Message').message).to eq('Invalid certifica...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/alexa_verifier/configuration_spec.rb
Ruby
mit
19
master
1,083
require_relative '../spec_helper' RSpec.describe AlexaVerifier::Configuration do attribute_array = [ :enabled, :verify_uri, :verify_timeliness, :verify_certificate, :verify_signature ] let(:attributes) { attribute_array } # Convert our attributes into their respective helper functions. ...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/alexa_verifier/verifier/certificate_u_r_i_verifier_spec.rb
Ruby
mit
19
master
3,354
require_relative '../../spec_helper' RSpec.describe AlexaVerifier::Verifier::CertificateURIVerifier do describe '#valid!' do context 'with a valid URI' do it 'returns true' do expect(subject.valid!('https://s3.amazonaws.com/echo.api/echo-api-cert-5.pem')).to eq(true) end context 'corre...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/alexa_verifier/verifier/certificate_verifier_spec.rb
Ruby
mit
19
master
3,821
require_relative '../../spec_helper' RSpec.describe AlexaVerifier::Verifier::CertificateVerifier, vcr: true do let(:valid_certificate) do certificate, _ = AlexaVerifier::CertificateStore.fetch('https://s3.amazonaws.com/echo.api/echo-api-cert-5.pem') certificate end let(:valid_chain) do _, chain = A...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
spec/support/shared_examples.rb
Ruby
mit
19
master
8,510
RSpec.shared_examples 'a StandardError' do it 'behaves like a StandardError' do error = described_class.new('foo') expect(error.message).to eq('foo') end end RSpec.shared_examples 'it has configuration options' do |attributes| attributes.each do |attribute| describe "##{attribute.to_s}?" do con...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier.rb
Ruby
mit
19
master
1,674
require 'alexa_verifier/certificate_store' require 'alexa_verifier/configuration' require 'alexa_verifier/verifier' require 'alexa_verifier/version' # Errors require 'alexa_verifier/base_error' require 'alexa_verifier/invalid_certificate_error' require 'alexa_verifier/invalid_certificate_u_r_i_error' require 'alexa_ve...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier/invalid_certificate_error.rb
Ruby
mit
19
master
200
module AlexaVerifier # An error that is raised when the certificate referenced from a request is # invalid. # # @since 0.1 class InvalidCertificateError < AlexaVerifier::BaseError end end
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier/certificate_store.rb
Ruby
mit
19
master
3,560
module AlexaVerifier # A module used to download, cache and serve certificates from our requests. # @since 0.1 module CertificateStore CERTIFICATE_CACHE_TIME = 1800 # 30 minutes CERTIFICATE_SEPARATOR = '-----BEGIN CERTIFICATE-----'.freeze class << self # Given a certificate uri, either download...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier/configuration.rb
Ruby
mit
19
master
1,314
module AlexaVerifier # Stores our configuration information # @since 0.2.0 class Configuration attr_accessor :enabled, :verify_uri, :verify_timeliness, :verify_certificate, :verify_signature # Create a new instance of our configuration object that has all of our settings enabled def initialize ...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier/verifier.rb
Ruby
mit
19
master
4,796
require_relative 'verifier/certificate_verifier' require_relative 'verifier/certificate_u_r_i_verifier' module AlexaVerifier # A namespace for all of our verifiers to live under # @since 0.1 class Verifier attr_accessor :configuration # Create a new AlexaVerifier::Verifier object # # @yield the ...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier/invalid_certificate_u_r_i_error.rb
Ruby
mit
19
master
1,210
module AlexaVerifier # An error that is raised when the certificate URI from a request is invalid. # @since 0.1 class InvalidCertificateURIError < AlexaVerifier::BaseError # Create a new instance of our InvalidCertificateURIError # # @param [String] message the main message we want to include # @p...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier/verifier/certificate_verifier.rb
Ruby
mit
19
master
4,088
require 'json' require 'time' require 'net/http' require 'openssl' require 'base64' module AlexaVerifier class Verifier # Given an OpenSSL certificate, validate it according to: # https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-a-web-service.html#h2_verify_sig_cert # # @since 0...
github
sidoh/alexa_verifier
https://github.com/sidoh/alexa_verifier
lib/alexa_verifier/verifier/certificate_u_r_i_verifier.rb
Ruby
mit
19
master
2,728
module AlexaVerifier class Verifier # Given an Alexa certificate URI, validate it according to: # https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-a-web-service.html#h2_verify_sig_cert # # @since 0.1 module CertificateURIVerifier VALIDATIONS = { scheme: 'https',...
github
willrax/motion-distance
https://github.com/willrax/motion-distance
motion-distance.gemspec
Ruby
mit
19
master
814
#-*- encoding: utf-8 -*- VERSION = "0.2.3" Gem::Specification.new do |spec| spec.name = "motion-distance" spec.version = VERSION spec.authors = ["Will Raxworthy"] spec.email = ["git@willrax.com"] spec.description = %q{Easy distance tracking for iOS RubyMotion projects.} spec....
github
willrax/motion-distance
https://github.com/willrax/motion-distance
Rakefile
Ruby
mit
19
master
376
# -*- coding: utf-8 -*- $:.unshift("/Library/RubyMotion/lib") require 'motion/project/template/ios' require './lib/motion-distance' begin require 'bundler' require 'motion/project/template/gem/gem_tasks' Bundler.require rescue LoadError end Motion::Project::App.setup do |app| # Use `rake config' to see comple...
github
willrax/motion-distance
https://github.com/willrax/motion-distance
spec/motion/distance_spec.rb
Ruby
mit
19
master
327
describe Motion::Distance do before do @distance = Motion::Distance.new end describe "#get" do it "starts requesting location updates" do end end describe "#location_manager" do it "returns a CLLocationManager" do @distance.location_manager.class.should == CLLocationManager end e...
github
willrax/motion-distance
https://github.com/willrax/motion-distance
example/Rakefile
Ruby
mit
19
master
283
# -*- coding: utf-8 -*- $:.unshift("/Library/RubyMotion/lib") require 'motion/project/template/ios' begin require 'bundler' Bundler.require rescue LoadError end Motion::Project::App.setup do |app| # Use `rake config' to see complete project settings. app.name = 'test' end
github
willrax/motion-distance
https://github.com/willrax/motion-distance
example/app/distance_controller.rb
Ruby
mit
19
master
850
class DistanceController < UIViewController def viewDidLoad super self.view.backgroundColor = UIColor.whiteColor create_view fetch_location end def fetch_location @distance = Motion::Distance.new @distance.activity_type = CLActivityTypeFitness @distance.get do |distance| unless...
github
willrax/motion-distance
https://github.com/willrax/motion-distance
example/app/app_delegate.rb
Ruby
mit
19
master
277
class AppDelegate def application(application, didFinishLaunchingWithOptions:launchOptions) @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) @window.rootViewController = DistanceController.alloc.init @window.makeKeyAndVisible true end end
github
willrax/motion-distance
https://github.com/willrax/motion-distance
lib/motion-distance.rb
Ruby
mit
19
master
327
unless defined?(Motion::Project::Config) raise "This file must be required within a RubyMotion project Rakefile." end lib_dir_path = File.dirname(File.expand_path(__FILE__)) Motion::Project::App.setup do |app| app.files.unshift(Dir.glob(File.join(lib_dir_path, "motion/**/*.rb"))) app.frameworks += ["CoreLocation...
github
willrax/motion-distance
https://github.com/willrax/motion-distance
lib/motion/distance.rb
Ruby
mit
19
master
1,510
module Motion class Distance attr_accessor :activity_type, :accuracy, :distance_filter def initialize(args = {}) self.accuracy = args[:accuracy] || KCLLocationAccuracyBest self.activity_type = args[:activity_type] || CLActivityTypeOther self.distance_filter = args[:distance_filter] || KCLDi...
github
tonytonyjan/allpay
https://github.com/tonytonyjan/allpay
Rakefile
Ruby
mit
19
master
206
# frozen_string_literal: true require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new task default: [:rubocop, :spec]
github
tonytonyjan/allpay
https://github.com/tonytonyjan/allpay
allpay.gemspec
Ruby
mit
19
master
1,046
# coding: utf-8 # frozen_string_literal: true lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'allpay/version' Gem::Specification.new do |spec| spec.name = 'allpay_client' spec.version = Allpay::VERSION spec.authors = ['Jian Weihang'...
github
tonytonyjan/allpay
https://github.com/tonytonyjan/allpay
examples/server.rb
Ruby
mit
19
master
1,104
# frozen_string_literal: true $LOAD_PATH << File.expand_path('../../lib', __FILE__) require 'bundler/setup' require 'sinatra' require 'allpay' get '/' do client = Allpay::Client.new(mode: :test) @params = client.generate_checkout_params(MerchantTradeNo: SecureRandom.hex(4), ...
github
tonytonyjan/allpay
https://github.com/tonytonyjan/allpay
spec/allpay_spec.rb
Ruby
mit
19
master
5,688
# encoding: utf-8 # frozen_string_literal: true require 'spec_helper' require 'securerandom' describe Allpay::Client do before :all do @client = Allpay::Client.new(mode: :test) end it '#api /Cashier/AioCheckOut' do res = @client.request '/Cashier/AioCheckOut', MerchantTradeNo: ...
github
tonytonyjan/allpay
https://github.com/tonytonyjan/allpay
lib/allpay/client.rb
Ruby
mit
19
master
2,982
# frozen_string_literal: true require 'net/http' require 'json' require 'cgi' require 'digest' require 'allpay/errors' require 'allpay/core_ext/hash' module Allpay class Client # :nodoc: PRODUCTION_API_HOST = 'https://payment.allpay.com.tw' TEST_API_HOST = 'http://payment-stage.allpay.com.tw' TEST_OPTION...
github
tonytonyjan/allpay
https://github.com/tonytonyjan/allpay
lib/allpay/errors.rb
Ruby
mit
19
master
205
# frozen_string_literal: true module Allpay # Generic Allpay exception class. class AllpayError < StandardError; end class MissingOption < AllpayError; end class InvalidMode < AllpayError; end end