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
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
example_yard.rb
Ruby
mit
18
main
2,953
# A mixin for aquatic creatures. # module Aquatic # Swim in the water. # # @return [void] def swim puts "swimming in the water" end end # The base class for all fish. class Fish # Make a sound. # # @yield [sound] The sound produced by the fish # @yieldparam sound [String] The actual sound # @re...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
yard-markdown.gemspec
Ruby
mit
18
main
1,604
# frozen_string_literal: true Gem::Specification.new do |spec| spec.name = "yard-markdown" spec.version = "0.7.1" spec.authors = ["Stanislav (Stas) Katkov"] spec.email = ["yard-markdown@skatkov.com"] spec.summary = "yard plugin to generate markdown documentation" spec.description = "yard plugin to generat...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard-markdown.rb
Ruby
mit
18
main
788
# frozen_string_literal: true require "yard" require_relative "yard/markdown/anchor_component_helper" require_relative "yard/markdown/aref_helper" require_relative "yard/markdown/collection_rendering_helper" require_relative "yard/markdown/documentation_helper" require_relative "yard/markdown/heading_helper" require_r...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/link_normalization_helper.rb
Ruby
mit
18
main
5,477
# frozen_string_literal: true module YARD module Markdown # Rewrites generated Markdown links so they point at Markdown output. module LinkNormalizationHelper # Normalizes generated Markdown before it is written to disk. # # @param content [String, Array<String>] Markdown content to finaliz...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/relationship_section_helper.rb
Ruby
mit
18
main
1,258
# frozen_string_literal: true module YARD module Markdown # Renders inheritance and mixin relationship summaries. module RelationshipSectionHelper # Returns section content with the expected trailing spacing. # # @param content [Object] Section content to render. # @return [String] Se...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/collection_rendering_helper.rb
Ruby
mit
18
main
3,795
# frozen_string_literal: true module YARD module Markdown # Renders grouped Markdown sections for constants, attributes, and methods. module CollectionRenderingHelper # Renders the constants section for an object page. # # @param constants [Array<YARD::CodeObjects::Base>] Constant objects c...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/object_listing_helper.rb
Ruby
mit
18
main
3,423
# frozen_string_literal: true module YARD module Markdown # Collects and sorts the objects shown on a rendered object page. module ObjectListingHelper # Returns the constants and class variables defined on an object. # # @param object [YARD::CodeObjects::NamespaceObject] Object being render...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/method_presentation_helper.rb
Ruby
mit
18
main
1,653
# frozen_string_literal: true module YARD module Markdown # Formats method and attribute names for Markdown headings. module MethodPresentationHelper # Builds the display heading for a method. # # @param method_object [YARD::CodeObjects::MethodObject] Method being rendered. # @return ...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/section_assembly_helper.rb
Ruby
mit
18
main
1,579
# frozen_string_literal: true module YARD module Markdown # Assembles grouped content into ordered Markdown sections. module SectionAssemblyHelper # Groups items by their YARD group and orders them for rendering. # # @param items [Array<#group>] Renderable objects that expose a YARD group n...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/aref_helper.rb
Ruby
mit
18
main
991
# frozen_string_literal: true module YARD module Markdown # Computes anchor ids that match the generated Markdown headings. module ArefHelper include AnchorComponentHelper # Returns the primary anchor id for a documented object. # # @param object [YARD::CodeObjects::Base] Object bein...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/heading_helper.rb
Ruby
mit
18
main
1,744
# frozen_string_literal: true module YARD module Markdown # Builds headings and legacy anchors for rendered object sections. module HeadingHelper include ArefHelper # Returns the legacy YARD anchor for an object when one exists. # # @param object [YARD::CodeObjects::Base] Object bein...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/tag_formatting_helper.rb
Ruby
mit
18
main
2,570
# frozen_string_literal: true module YARD module Markdown # Formats YARD tags into Markdown list items and fenced examples. module TagFormattingHelper # Renders all tags for an object as Markdown. # # @param object [YARD::CodeObjects::Base] Object whose tags are being rendered. # @ret...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/anchor_component_helper.rb
Ruby
mit
18
main
668
# frozen_string_literal: true # Namespace for YARD extensions used by this gem. module YARD # Shared helpers for rendering YARD objects as Markdown. module Markdown # Builds anchor-safe identifier fragments from arbitrary values. module AnchorComponentHelper # Encodes a value so it can be embedded sa...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
lib/yard/markdown/documentation_helper.rb
Ruby
mit
18
main
1,360
# frozen_string_literal: true require "rdoc" module YARD module Markdown # Converts YARD docstrings into Markdown-friendly text. module DocumentationHelper # Returns the rendered documentation text for an object. # # @param object [YARD::CodeObjects::Base] Object whose docstring is being r...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/test_helper.rb
Ruby
mit
18
main
240
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "yard-markdown" require "minitest/autorun" require "minitest/strict" require "mutant/minitest/coverage" require_relative "support/mutant_setup"
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/example/example.rb
Ruby
mit
18
main
2,612
## # === RDoc::Generator::Markdown example. # # This example employs various RDoc features to demonstrate # generator output. # # --- # # Links: # # 1. {Project Home Page}[https://github.com/skatkov/rdoc-markdown) # 2. {RDoc Documentation}[http://ruby-doc.org/stdlib-2.0.0/libdoc/rdoc/rdoc/RDoc/Markup.html] # ## # A ...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_method_presentation_helper.rb
Ruby
mit
18
main
3,214
# frozen_string_literal: true require "test_helper" class YARD::TestMethodPresentationHelper < Minitest::Test cover YARD::Markdown::MethodPresentationHelper FakeAttribute = Struct.new(:attr_info, :reader_value, :writer_value, keyword_init: true) do def reader? reader_value end def writer? ...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_documentation_helper.rb
Ruby
mit
18
main
1,740
# frozen_string_literal: true require "test_helper" class YARD::TestDocumentationHelper < Minitest::Test cover YARD::Markdown::DocumentationHelper def test_documented_text_handles_documented_and_undocumented_objects YARD::Registry.clear assert_equal "**hello**", helper.documented_text(build_object(docst...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_link_normalization_helper.rb
Ruby
mit
18
main
7,294
# frozen_string_literal: true require "test_helper" class YARD::TestLinkNormalizationHelper < Minitest::Test cover YARD::Markdown::LinkNormalizationHelper class Serializer def initialize(mapping:) @mapping = mapping end def serialized_path(object) mapping.fetch(object.path) end ...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_tag_formatting.rb
Ruby
mit
18
main
3,492
# frozen_string_literal: true require "test_helper" class YARD::TestTagFormatting < Minitest::Test cover YARD::Markdown::TagFormattingHelper def test_format_tag_normalizes_hash_and_scalar_type_values assert_equal "**@validates** [presence]", formatter.format_tag(tag(tag_name: "validates", types: {" presence...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_collection_rendering_helper.rb
Ruby
mit
18
main
8,425
# frozen_string_literal: true require "test_helper" class YARD::TestCollectionRenderingHelper < Minitest::Test cover YARD::Markdown::CollectionRenderingHelper def test_render_constants_handle_grouping_sorting_and_spacing parse_example_yard output = helper.render_constants([YARD::Registry.at("Salmon::MAX_...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_section_assembly_helper.rb
Ruby
mit
18
main
2,619
# frozen_string_literal: true require "test_helper" class YARD::TestSectionAssemblyHelper < Minitest::Test cover YARD::Markdown::SectionAssemblyHelper def test_grouped_items_orders_declared_missing_and_default_groups parse_source(<<~RUBY) class Fish # @!group beta def b1 end ...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_relationship_section_helper.rb
Ruby
mit
18
main
3,766
# frozen_string_literal: true require "test_helper" class YARD::TestRelationshipSectionHelper < Minitest::Test cover YARD::Markdown::RelationshipSectionHelper def test_render_section_content_normalizes_blank_string_and_non_string_input content = Class.new do def to_s "hello" end end.n...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_template_sections.rb
Ruby
mit
18
main
2,662
# frozen_string_literal: true require "test_helper" class YARD::TestTemplateSections < Minitest::Test cover YARD::Markdown::AnchorComponentHelper cover YARD::Markdown::ArefHelper cover YARD::Markdown::HeadingHelper def test_anchor_component_escapes_non_identifier_characters template = Class.new do ...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/yard/test_listing_helper.rb
Ruby
mit
18
main
4,809
# frozen_string_literal: true require "test_helper" class YARD::TestListingHelper < Minitest::Test cover YARD::Markdown::ObjectListingHelper def test_basic_listing_helpers_include_direct_members_and_sort_values YARD::Registry.clear YARD.parse_string(<<~RUBY) module Swimmer SPEED = 10 ...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
test/support/markdown_validator.rb
Ruby
mit
18
main
3,897
# frozen_string_literal: true require "cgi" require "commonmarker" class MarkdownValidator ValidationError = Class.new(StandardError) LOCAL_LINK_REGEX = %r{\]\((?!https?://|mailto:|#)([^)]+)\)} LOCAL_HTML_LINK_REGEX = %r{\]\((?!https?://|mailto:|#)[^)]+\.html(?:[?#][^)]+)?\)} GFM_EXTENSIONS = %i[table strike...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
templates/default/module/markdown/setup.rb
Ruby
mit
18
main
4,361
# frozen_string_literal: true require "rdoc" class_eval do include YARD::Templates::Helpers::ModuleHelper include YARD::Markdown::AnchorComponentHelper include YARD::Markdown::ArefHelper include YARD::Markdown::CollectionRenderingHelper include YARD::Markdown::DocumentationHelper include YARD::Markdown::H...
github
skatkov/yard-markdown
https://github.com/skatkov/yard-markdown
templates/default/fulldoc/markdown/setup.rb
Ruby
mit
18
main
2,909
# frozen_string_literal: true require "csv" class_eval do include YARD::Templates::Helpers::ModuleHelper include YARD::Markdown::ArefHelper include YARD::Markdown::ObjectListingHelper end # Prepares the markdown serializer and renders each object page. # # @return [void] def init options.objects = objects = ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
Gemfile
Ruby
mit
18
master
569
source 'https://rubygems.org' # Declare your gem's dependencies in shopr.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare any dependencies that are still in development here instead of in # y...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
shopr.gemspec
Ruby
mit
18
master
2,422
$LOAD_PATH.push File.expand_path('lib', __dir__) require 'shopr/version' Gem::Specification.new do |s| s.name = 'shopr' s.version = Shopr::VERSION s.authors = ['Dean Perry'] s.email = ['dean@voupe.com'] s.homepage = 'https://shoprgem.com' s.summary = 'A fully featured ecommerce...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
Rakefile
Ruby
mit
18
master
764
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__) load 'rails/tasks/engine.rake' Bundler::GemHelper.install_tasks # namespace :shopr do # desc 'Publish the release notes...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/validators/permalink_validator.rb
Ruby
mit
18
master
207
class PermalinkValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless value =~ /\A[A-z0-9\-_]+\Z/ record.errors.add(attribute, :wrong_format) end end end
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/helpers/shopr/product_category_helper.rb
Ruby
mit
18
master
1,714
module Shopr module ProductCategoryHelper def nested_product_category_spacing_adjusted_for_depth(category, relative_depth) depth = category.depth - relative_depth spacing = depth < 2 ? 0.8 : 1.5 ("<span style='display:inline-block;width:#{spacing}em;'></span>" * category.depth).html_safe end...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/helpers/shopr/application_helper.rb
Ruby
mit
18
master
2,805
module Shopr module ApplicationHelper def navigation_manager_link(item) link_to item.description, item.url(self), item.link_options.merge(class: item.active?(self) ? 'active' : 'inactive') end def status_tag(status) content_tag :span, t("shopr.orders.statuses.#{status}"), class: "status-tag #...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/product_categories_controller.rb
Ruby
mit
18
master
1,375
module Shopr class ProductCategoriesController < Shopr::ApplicationController before_action { @active_nav = :product_categories } before_action { params[:id] && @product_category = Shopr::ProductCategory.find(params[:id]) } def index @product_categories_without_parent = Shopr::ProductCategory.witho...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/orders_controller.rb
Ruby
mit
18
master
4,210
module Shopr class OrdersController < Shopr::ApplicationController before_action { @active_nav = :orders } before_action { params[:id] && @order = Shopr::Order.find(params[:id]) } def index @query = Shopr::Order.ordered.received.includes(order_items: :ordered_item).page(params[:page]).search(params...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/delivery_services_controller.rb
Ruby
mit
18
master
1,215
module Shopr class DeliveryServicesController < Shopr::ApplicationController before_action { @active_nav = :delivery_services } before_action { params[:id] && @delivery_service = Shopr::DeliveryService.find(params[:id]) } def index @delivery_services = Shopr::DeliveryService.all end def ne...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/payments_controller.rb
Ruby
mit
18
master
998
module Shopr class PaymentsController < ApplicationController before_action { @order = Shopr::Order.find(params[:order_id]) } before_action { params[:id] && @payment = @order.payments.find(params[:id]) } def create payment = @order.payments.build(params[:payment].permit(:amount, :method, :reference...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/customers_controller.rb
Ruby
mit
18
master
1,314
module Shopr class CustomersController < Shopr::ApplicationController before_action { @active_nav = :customers } before_action { params[:id] && @customer = Shopr::Customer.find(params[:id]) } def index @query = Shopr::Customer.ordered.page(params[:page]).search(params[:q]) @customers = @query...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/application_controller.rb
Ruby
mit
18
master
421
module Shopr class ApplicationController < ActionController::Base protect_from_forgery prepend: true before_action :authenticate_user! rescue_from ActiveRecord::DeleteRestrictionError do |e| redirect_to request.referer || root_path, alert: e.message end rescue_from Shopr::Error do |e| ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/addresses_controller.rb
Ruby
mit
18
master
1,202
module Shopr class AddressesController < Shopr::ApplicationController before_action { @active_nav = :customers } before_action { params[:customer_id] && @customer = Shopr::Customer.find(params[:customer_id]) } before_action { params[:id] && @address = @customer.addresses.find(params[:id]) } def new ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/users_controller.rb
Ruby
mit
18
master
1,253
module Shopr class UsersController < Shopr::ApplicationController before_action { @active_nav = :users } before_action { params[:id] && @user = Shopr::User.find(params[:id]) } before_action(only: %i[create update destroy]) do if Shopr.settings.demo_mode? raise Shopr::Error, t('shopr.users.de...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/stock_level_adjustments_controller.rb
Ruby
mit
18
master
1,511
module Shopr class StockLevelAdjustmentsController < ApplicationController SUITABLE_OBJECTS = ['Shopr::Product'].freeze before_action do raise Shopr::Error, t('shopr.stock_level_adjustments.invalid_item_type', suitable_objects: SUITABLE_OBJECTS.to_sentence) unless SUITABLE_OBJECTS.include?(params[:item_...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/countries_controller.rb
Ruby
mit
18
master
1,058
module Shopr class CountriesController < Shopr::ApplicationController before_action { @active_nav = :countries } before_action { params[:id] && @country = Shopr::Country.find(params[:id]) } def index @countries = Shopr::Country.ordered end def new @country = Shopr::Country.new en...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/attachments_controller.rb
Ruby
mit
18
master
385
module Shopr class AttachmentsController < Shopr::ApplicationController def destroy @attachment = Shopr::Attachment.find_by!(token: params[:id]) @attachment.destroy respond_to do |wants| wants.html { redirect_to request.referer, notice: t('shopr.attachments.remove_notice') } want...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/tax_rates_controller.rb
Ruby
mit
18
master
1,111
module Shopr class TaxRatesController < Shopr::ApplicationController before_action { @active_nav = :tax_rates } before_action { params[:id] && @tax_rate = Shopr::TaxRate.find(params[:id]) } def index @tax_rates = Shopr::TaxRate.ordered.all end def new @tax_rate = Shopr::TaxRate.new ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/settings_controller.rb
Ruby
mit
18
master
390
module Shopr class SettingsController < ApplicationController before_action { @active_nav = :settings } def update if Shopr.settings.demo_mode? raise Shopr::Error, t('shopr.settings.demo_mode_error') end Shopr::Setting.update_from_hash(params[:settings].permit!) redirect_to :...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/delivery_service_prices_controller.rb
Ruby
mit
18
master
1,518
module Shopr class DeliveryServicePricesController < Shopr::ApplicationController before_action { @active_nav = :delivery_services } before_action { @delivery_service = Shopr::DeliveryService.find(params[:delivery_service_id]) } before_action { params[:id] && @delivery_service_price = @delivery_service.de...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/variants_controller.rb
Ruby
mit
18
master
1,273
module Shopr class VariantsController < ApplicationController before_action { @active_nav = :products } before_action { @product = Shopr::Product.find(params[:product_id]) } before_action { params[:id] && @variant = @product.variants.find(params[:id]) } def index @variants = @product.variants.o...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/controllers/shopr/products_controller.rb
Ruby
mit
18
master
2,985
module Shopr class ProductsController < Shopr::ApplicationController before_action { @active_nav = :products } before_action { params[:id] && @product = Shopr::Product.root.find(params[:id]) } def index @products_paged = Shopr::Product.root .includes(:stock_lev...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/uploaders/shopr/attachment_uploader.rb
Ruby
mit
18
master
550
class Shopr::AttachmentUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick # Where should files be stored? def store_dir "attachment/#{model.id}" end # Returns true if the file is an image def image?(_new_file) file.content_type.include? 'image' end # Returns true if the fi...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/mailers/shopr/user_mailer.rb
Ruby
mit
18
master
232
module Shopr class UserMailer < ActionMailer::Base def new_password(user) @user = user mail from: Shopr.settings.outbound_email_address, to: user.email_address, subject: 'Your new Shopr password' end end end
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/mailers/shopr/order_mailer.rb
Ruby
mit
18
master
935
module Shopr class OrderMailer < ActionMailer::Base def received(order) @order = order mail from: Shopr.settings.outbound_email_address, to: order.email_address, subject: I18n.t('shopr.order_mailer.received.subject', default: 'Order Confirmation') end def accepted(order) @order = order ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/tax_rate.rb
Ruby
mit
18
master
1,519
module Shopr class TaxRate < ApplicationRecord include Shopr::AssociatedCountries # The order address types which may be used when choosing how to apply the tax rate ADDRESS_TYPES = %w[billing delivery].freeze # Validations validates :name, presence: true validates :address_type, inclusion: ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/customer.rb
Ruby
mit
18
master
1,288
module Shopr class Customer < ApplicationRecord EMAIL_REGEX = /\A\b[A-Z0-9\.\_\%\-\+]+@(?:[A-Z0-9\-]+\.)+[A-Z]{2,6}\b\z/i.freeze PHONE_REGEX = /\A[+?\d\ \-x\(\)]{7,}\z/.freeze has_many :addresses, dependent: :restrict_with_exception, class_name: 'Shopr::Address' has_many :orders, dependent: :restric...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/setting.rb
Ruby
mit
18
master
1,890
require 'ostruct' module Shopr class Setting < ApplicationRecord # Validations validates :key, presence: true, uniqueness: true validates :value, presence: true validates :value_type, presence: true before_validation do self.value_type = I18n.t('shopr.settings.types')[key.to_sym].try(:capi...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/stock_level_adjustment.rb
Ruby
mit
18
master
678
module Shopr class StockLevelAdjustment < ApplicationRecord # The orderable item which the stock level adjustment belongs to belongs_to :item, polymorphic: true # The parent (OrderItem) which the stock level adjustment belongs to belongs_to :parent, polymorphic: true # Validations validates ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/product_category.rb
Ruby
mit
18
master
2,455
require 'awesome_nested_set' module Shopr class ProductCategory < ApplicationRecord # Allow the nesting of product categories # :restrict_with_exception relies on a fix to the awesome_nested_set gem # which has been referenced in the Gemfile as we can't add a dependency # to a branch in the .gemspec ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/product.rb
Ruby
mit
18
master
6,764
require 'roo' module Shopr class Product < ApplicationRecord # Add dependencies for products require_dependency 'shopr/product/product_attributes' require_dependency 'shopr/product/variants' # Attachments for this product has_many :attachments, as: :parent, dependent: :destroy, autosave: true, c...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/delivery_service.rb
Ruby
mit
18
master
1,128
module Shopr class DeliveryService < ApplicationRecord # Validations validates :name, presence: true validates :courier, presence: true # Orders which are assigned to this delivery service has_many :orders, dependent: :restrict_with_exception, class_name: 'Shopr::Order' # Prices for the diff...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/country.rb
Ruby
mit
18
master
901
# The Shopr::Country model stores countries which can be used for delivery & billing # addresses for orders. # # You can use the Shopr::CountryImporter to import a pre-defined list of countries # into your database. This automatically happens when you run the 'shopr:setup' # rake task. module Shopr class Country < A...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/product_attribute.rb
Ruby
mit
18
master
1,737
module Shopr class ProductAttribute < ApplicationRecord # Validations validates :key, presence: true # The associated product # # @return [Shopr::Product] belongs_to :product, class_name: 'Shopr::Product' # All attributes which are searchable scope :searchable, -> { where(searchable:...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/product_categorization.rb
Ruby
mit
18
master
292
module Shopr class ProductCategorization < ApplicationRecord # Links back belongs_to :product, class_name: 'Shopr::Product' belongs_to :product_category, class_name: 'Shopr::ProductCategory' # Validations validates :product, :product_category, presence: true end end
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/order_item.rb
Ruby
mit
18
master
6,714
module Shopr class OrderItem < ApplicationRecord # The associated order # # @return [Shopr::Order] belongs_to :order, class_name: 'Shopr::Order', touch: true, inverse_of: :order_items # The item which has been ordered belongs_to :ordered_item, polymorphic: true # Any stock level adjustme...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/order.rb
Ruby
mit
18
master
3,249
module Shopr class Order < ApplicationRecord EMAIL_REGEX = /\A\b[A-Z0-9\.\_\%\-\+]+@(?:[A-Z0-9\-]+\.)+[A-Z]{2,6}\b\z/i.freeze PHONE_REGEX = /\A[+?\d\ \-x\(\)]{7,}\z/.freeze # Orders can have properties key_value_store :properties # Require dependencies require_dependency 'shopr/order/states'...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/address.rb
Ruby
mit
18
master
1,265
module Shopr class Address < ApplicationRecord # An array of all the available types for an address TYPES = %w[billing delivery].freeze # The customer which this address should be linked to # # @return [Shopr::Customer] belongs_to :customer, class_name: 'Shopr::Customer' # The order whic...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/attachment.rb
Ruby
mit
18
master
1,137
module Shopr class Attachment < ApplicationRecord # Mount the Carrierwave uploader mount_uploader :file, AttachmentUploader # Relationships belongs_to :parent, polymorphic: true # Validations validates :file_name, presence: true validates :file_type, presence: true validates :file_si...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/delivery_service_price.rb
Ruby
mit
18
master
909
module Shopr class DeliveryServicePrice < ApplicationRecord include Shopr::AssociatedCountries # The delivery service which this price belongs to belongs_to :delivery_service, class_name: 'Shopr::DeliveryService' # The tax rate which should be applied belongs_to :tax_rate, class_name: 'Shopr::Ta...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/payment.rb
Ruby
mit
18
master
2,266
module Shopr class Payment < ApplicationRecord # Additional callbacks extend ActiveModel::Callbacks define_model_callbacks :refund # The associated order # # @return [Shopr::Order] belongs_to :order, class_name: 'Shopr::Order' # An associated payment (only applies to refunds) # ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/user.rb
Ruby
mit
18
master
693
module Shopr class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Validations validates :first_name,...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/order/billing.rb
Ruby
mit
18
master
2,575
module Shopr class Order < ApplicationRecord # The country which this order should be billed to # # @return [Shopr::Country] belongs_to :billing_country, class_name: 'Shopr::Country', foreign_key: 'billing_country_id' # Payments which have been stored for the order has_many :payments, depende...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/order/delivery.rb
Ruby
mit
18
master
7,527
module Shopr class Order < ApplicationRecord # The associated delivery service # # @return [Shopr::DeliveryService] belongs_to :delivery_service, class_name: 'Shopr::DeliveryService' # The country where this order is being delivered to (if one has been provided) # # @return [Shopr::Countr...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/order/actions.rb
Ruby
mit
18
master
2,730
module Shopr class Order < ApplicationRecord extend ActiveModel::Callbacks # These additional callbacks allow for applications to hook into other # parts of the order lifecycle. define_model_callbacks :confirmation, :acceptance, :rejection # This method should be called by the base application w...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/order/states.rb
Ruby
mit
18
master
1,647
module Shopr class Order < ApplicationRecord # An array of all the available statuses for an order STATUSES = %w[building confirming received accepted rejected shipped].freeze # The Shopr::User who accepted the order # # @return [Shopr::User] belongs_to :accepter, class_name: 'Shopr::User', f...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/product/variants.rb
Ruby
mit
18
master
1,339
module Shopr class Product < ApplicationRecord # Validations validate { errors.add :base, :can_belong_to_root if parent && parent.parent } # Variants of the product has_many :variants, class_name: 'Shopr::Product', foreign_key: 'parent_id', dependent: :destroy # The parent product (only applies ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
app/models/shopr/product/product_attributes.rb
Ruby
mit
18
master
659
module Shopr class Product < ApplicationRecord # Product attributes for this product has_many :product_attributes, -> { order(:position) }, class_name: 'Shopr::ProductAttribute' # Used for setting an array of product attributes which will be updated. Usually # received from a web browser. attr_ac...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
test_old/models/shoppe/product_categories_test.rb
Ruby
mit
18
master
447
require 'test_helper' module Shopr class ProductCategoriesTest < ActiveSupport::TestCase test 'hierarchy_array' do parent = create(:parent_category_with_child) child = parent.reload.children.first assert_equal Array, child.hierarchy_array.class assert_equal 2, child.hierarchy_array.count...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
test_old/models/shoppe/settings_test.rb
Ruby
mit
18
master
1,002
require 'test_helper' module Shopr class SettingsTest < ActiveSupport::TestCase setup do Shopr.reset_settings end test 'settings are automatically loaded' do assert_equal true, Shopr.settings.is_a?(Settings) end test 'defaults are loaded' do assert_equal 'Widgets Inc.', Shopr....
github
tryshopr/shopr
https://github.com/tryshopr/shopr
test_old/models/shoppe/orders_test.rb
Ruby
mit
18
master
21,800
require 'test_helper' module Shopr class OrdersTest < ActiveSupport::TestCase test 'a completely clean new order' do order = create(:order) assert_equal true, order.building? assert_equal false, order.received? assert_equal true, order.empty? assert_equal 0, order.total_items ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
test_old/models/shoppe/users_test.rb
Ruby
mit
18
master
659
require 'test_helper' module Shopr class UsersTest < ActiveSupport::TestCase # test 'authentication' do # user = create(:user) # authed_user = User.authenticate('someone@something.com', 'password') # assert_equal User, authed_user.class # assert_equal user, authed_user # authed_user...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
test_old/models/shoppe/delivery_services_test.rb
Ruby
mit
18
master
1,837
require 'test_helper' module Shopr class DeliveryServicesTest < ActiveSupport::TestCase test 'tracking urls can be generated' do # create an order and an environment create_environment order = create_order_with_products(confirmed: true) user = create(:user) order.accept!(user) ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
test_old/models/shoppe/tax_rates_text.rb
Ruby
mit
18
master
1,503
require 'test_helper' module Shopr class TaxRatesTest < ActiveSupport::TestCase test 'description' do rate = create(:standard_tax) assert_equal 'Standard Tax (20.0)', rate.description end test 'rate can be provided' do # create an environment with some countries so we can test that tax...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
test_old/models/shoppe/order_items_test.rb
Ruby
mit
18
master
4,418
require 'test_helper' module Shopr class OrderItemsTest < ActiveSupport::TestCase setup do create_environment @order = create(:order) @product = create(:yealink_t22p, weight: 0.5, initial_stock: 10) @item = @order.order_items.create!(quantity: 2, ordered_item: @product) end test ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr.rb
Ruby
mit
18
master
1,500
require 'coffee-rails' require 'sass-rails' require 'jquery-rails' require 'haml' require 'devise' require 'dynamic_form' require 'kaminari' require 'ransack' require 'nifty/utils' require 'nifty/key_value_store' require 'nifty/dialog' require 'carrierwave' require 'shopr/settings_loader' module Shopr class << sel...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/settings_loader.rb
Ruby
mit
18
master
208
module Shopr class SettingsLoader def initialize(app) @app = app end def call(env) Shopr.reset_settings @app.call(env) ensure Shopr.reset_settings end end end
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/error.rb
Ruby
mit
18
master
311
module Shopr class Error < StandardError def initialize(options = {}) @options = if options.is_a?(String) { message: options } else options end end def message @options[:message] end attr_reader :options end end
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/settings.rb
Ruby
mit
18
master
493
module Shopr class Settings def initialize(hash) @hash = hash end def outbound_email_address "#{store_name} <#{email_address}>" end def method_missing(key, _ = nil) key = key.to_s.gsub(/\?\z/, '') if value = @hash[key.to_s] value elsif I18n.translate('shopr....
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/view_helpers.rb
Ruby
mit
18
master
427
module Shopr module ViewHelpers # Returns currency values with the currency unit as specified by the Shopr settings def number_to_currency(number, options = {}) options[:unit] ||= Shopr.settings.currency_unit super end # Returns a number of kilograms with the appropriate suffix def nu...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/orderable_item.rb
Ruby
mit
18
master
471
module Shopr # All items which can be ordered should include this module and ensure that all methods # have been overridden. It's a lazy-mans protocol. module OrderableItem # stock_level_adjustments must be an association def full_name; end def orderable?; end def sku; end def price; end ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/engine.rb
Ruby
mit
18
master
1,851
module Shopr class Engine < ::Rails::Engine isolate_namespace Shopr if Shopr.respond_to?(:root) config.autoload_paths << File.join(Shopr.root, 'lib') config.assets.precompile += ['shopr/sub.css', 'shopr/printable.css'] end # We don't want any automatic generators in the engine. confi...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/model_extension.rb
Ruby
mit
18
master
1,333
module Shopr module ModelExtension def self.included(base) base.extend ClassMethods base.after_save do if @pending_attachments @pending_attachments.each do |pa| old_attachments = attachments.where(role: pa[:role]).pluck(:id) attachments.create(file: pa[:file],...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/default_navigation.rb
Ruby
mit
18
master
639
require 'shopr/navigation_manager' # This file defines all the default navigation managers used in Shopr. Of course, # modules can make changes to these by removing them or adding their own. This # file is loaded on application initialization so if you make changes, you'll need # to restart the webserver. # # This is...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/associated_countries.rb
Ruby
mit
18
master
536
module Shopr module AssociatedCountries def self.included(base) base.serialize :country_ids, Array base.before_validation { self.country_ids = country_ids.map(&:to_i).select { |i| i > 0 } if country_ids.is_a?(Array) } end def country?(id) id = id.id if id.is_a?(Shopr::Country) cou...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/navigation_manager.rb
Ruby
mit
18
master
2,026
module Shopr class NavigationManager def self.managers @managers ||= [] end def self.create(identifier) managers << new(identifier.to_s) end def self.build(identifier, &block) manager = new(identifier.to_s) manager.instance_eval(&block) if block_given? managers << m...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/country_importer.rb
Ruby
mit
18
master
865
module Shopr module CountryImporter def self.import eu_members = ['Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia', 'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Ireland', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands', 'Poland', 'Po...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/errors/not_enough_stock.rb
Ruby
mit
18
master
226
module Shopr module Errors class NotEnoughStock < Error def available_stock @options[:ordered_item].stock end def requested_stock @options[:requested_stock] end end end end
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/shopr/errors/insufficient_stock_to_fulfil.rb
Ruby
mit
18
master
220
module Shopr module Errors class InsufficientStockToFulfil < Error def order @options[:order] end def out_of_stock_items @options[:out_of_stock_items] end end end end
github
tryshopr/shopr
https://github.com/tryshopr/shopr
lib/tasks/shopr.rake
Ruby
mit
18
master
1,986
namespace :shopr do desc 'Load seed data for the Shopr' task seed: :environment do require File.join(Shopr.root, 'db', 'seeds') end desc 'Create a default admin user' task create_default_user: :environment do Shopr::User.create(email: 'admin@example.com', password: 'password', password_confirmation: ...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
spec/spec_helper.rb
Ruby
mit
18
master
948
ENV['RAILS_ENV'] ||= 'test' require File.expand_path("../dummy/config/environment.rb", __FILE__) require 'rspec/rails' require 'factory_bot_rails' require 'shoulda-matchers' # Load support files Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } # Set Factory Girl factories locations # first init wi...
github
tryshopr/shopr
https://github.com/tryshopr/shopr
spec/dummy/Rakefile
Ruby
mit
18
master
321
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # require_relative 'config/application' # Rails.application.load_tasks require File.expand_path('../config/application', __FILE__) Dummy::Application.load_tasks