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
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/workers/sitemap_refresh_worker.rb
Ruby
apache-2.0
214
main
528
require "sitemap_generator" # # Worker that refreshes Supermarket's sitemap once a day at midnight. Uses # Sidetiq to schedule the job. # class SitemapRefreshWorker include Sidekiq::Worker # # Refresh the sitemap and ping search engines using the SitemapGenerator # library. # # Essentially runs the tasks ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/workers/spdx_license_update_worker.rb
Ruby
apache-2.0
214
main
590
class SpdxLicenseUpdateWorker include Sidekiq::Worker def perform(json_data, cookbook_version_id) cookbook_version = CookbookVersion.find(cookbook_version_id.to_i) spdx_record = json_data.select { |record| record["licenseId"] == cookbook_version.license } if spdx_record.present? cookbook_version....
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/workers/cookbook_deprecated_notifier.rb
Ruby
apache-2.0
214
main
1,039
# # Lets those who follow and/or collaborate on a cookbook know when the cookbook # has been deprecated. # class CookbookDeprecatedNotifier include Sidekiq::Worker # # Queues an email to each follower and/or collaborator of the cookbook # # @param cookbook_id [Fixnum] Identifies a +Cookbook+ # def perfor...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/adoption_helper.rb
Ruby
apache-2.0
214
main
1,169
module AdoptionHelper # # Return a link to either a Cookbook or a Tool to enable/disable adoption. # # @param obj [Cookbook,Tool] # # @return [String] the link, wrapped in an <li> # def link_to_adoption(obj) if policy(obj).manage_adoption? txt, up = if obj.up_for_adoption? ["...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/feature_flag_helper.rb
Ruby
apache-2.0
214
main
213
module FeatureFlagHelper def air_gapped? ENV["AIR_GAPPED"] == "true" end def gtag_enabled? ENV["ENABLE_GTAG"] == "true" end def onetrust_enabled? ENV["ENABLE_ONETRUST"] == "true" end end
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/cookbooks_helper.rb
Ruby
apache-2.0
214
main
4,140
module CookbooksHelper # # Returns a URL for the latest version of the given cookbook # # @param cookbook [Cookbook] # # @return [String] the URL # def latest_cookbook_version_url(cookbook) api_v1_cookbook_version_url( cookbook, cookbook.latest_cookbook_version ) end # # Show the co...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/markdown_helper.rb
Ruby
apache-2.0
214
main
2,331
module MarkdownHelper # # Make auto-links target=_blank # class SupermarketRenderer < Redcarpet::Render::Safe include ActionView::Helpers::TagHelper def initialize(extensions = {}) super extensions.merge( link_attributes: { target: "_blank", rel: "noopener" }, with_toc_data: true...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/cookbook_versions_helper.rb
Ruby
apache-2.0
214
main
2,633
module CookbookVersionsHelper include MarkdownHelper # # Encapsulates the logic required to return an updated_at timestamp for an # Atom feed, while handling possibly empty collections # # @param collection [Array<Object>] some collection to be checked # # @return [ActiveSupport::TimeWithZone] the most...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/supported_platforms_helper.rb
Ruby
apache-2.0
214
main
1,008
module SupportedPlatformsHelper # # Determines the correct icon to use for a given platform # # @example # platform = SupportedPlatform.new(name: 'mac_os_x_server') # supported_platform_icon(platform) == 'macosx' # # # @return [String] the icon # def supported_platform_icon(platform) { ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/profile_helper.rb
Ruby
apache-2.0
214
main
1,104
module ProfileHelper # # Prepare a +User+ for display on the profile edit screen. This will add # empty +EmailPreference+ objects to the +User+ depending on how many # +SystemEmail+s exist in the system, and how many they're already subscribed # to. This makes the checkboxes on the form behave properly. # ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/custom_url_helper.rb
Ruby
apache-2.0
214
main
2,112
module CustomUrlHelper # # This module defines URL helpers that are used throughout the application. # Each method here has a corresponding ENV variable in the .env template to # set appropriate default values. # def chef_domain ENV["CHEF_DOMAIN"] || "chef.io" end def progress_domain ENV["PROG...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/tools_helper.rb
Ruby
apache-2.0
214
main
421
module ToolsHelper # # Takes a tool type and returns a pretty version of it for display. This is # needed because DSC Resources are a special case that Rails' built-in # titleize doesn't handle. # # @param type [String] The tool type # # @return [String] The titleized tool type # def pretty_type(typ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/users_helper.rb
Ruby
apache-2.0
214
main
1,672
module UsersHelper # # Return the image_tag of the specified user's gravatar based on their # email. If the user does not have a Gravatar, the default Gravatar image is # displayed. The default size is 48 pixels. # # @param user [User] the User for get the Gravatar for # @param options [Hash] options for ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/collaborators_helper.rb
Ruby
apache-2.0
214
main
1,478
module CollaboratorsHelper def non_group_collaborators(collaborators) collaborators.where(group: nil) end def group_collaborators(collaborators, group) collaborators.where(group: group) end # # Returns a string that will be unique within the DOM, suitable for use as an # id attribute for a DOM e...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/application_helper.rb
Ruby
apache-2.0
214
main
1,770
module ApplicationHelper # # The OmniAuth path for the given +provider+. # # @param [String, Symbol] provider # def auth_path(provider) "/auth/#{provider}" end # # Returns a possessive version of the string # # @param name [String] # # @return [String] # def posessivize(name) retu...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/helpers/groups_helper.rb
Ruby
apache-2.0
214
main
438
module GroupsHelper def admin_member?(user, group) group.group_members.where(user_id: user.id, admin: true).present? end def admin_members(group) group.group_members.where(admin: true) end def group_resourceables(group) resourceables = [] group.group_resources.each do |resource| resour...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/services/update_spdx_license_url.rb
Ruby
apache-2.0
214
main
1,730
class UpdateSpdxLicenseUrl def self.all_latest_cookbook_versions cookbook_version_ids = CookbookVersion.where(' cookbook_versions.created_at = ( SELECT MAX(latest.created_at) FROM cookbook_versions AS latest WHERE latest.cookbook_id = cookbook_versions.cookbook_id ) ').plu...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/services/run_quality_metrics.rb
Ruby
apache-2.0
214
main
1,722
class RunQualityMetrics def self.all_the_latest return [:error, I18n.t("fieri.not_enabled")] unless Feature.active? :fieri cookbook_version_ids = CookbookVersion.where(' cookbook_versions.created_at = ( SELECT MAX(latest.created_at) FROM cookbook_versions AS latest WHERE latest....
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/services/fetch_spdx_license_json.rb
Ruby
apache-2.0
214
main
224
class FetchSpdxLicenseJson def self.spdx_license_json response = JSON.parse(File.read(Rails.root.join("app/assets/data/licenses.json"))) response["licenses"] rescue StandardError => e [:error, e] end end
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/services/make_user_admin.rb
Ruby
apache-2.0
214
main
912
class MakeUserAdmin def initialize(user_name) @user_name = user_name end def call user = User.with_username(@user_name).first user.present? ? add_admin_role(user) : user_not_found_message(@user_name) end private def user_not_found_message(user_name) I18n.t("user.not_found", name: user_nam...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/services/grant_badge_to_cookbook.rb
Ruby
apache-2.0
214
main
1,197
class GrantBadgeToCookbook attr_reader :badge_name, :cookbook_name def initialize(badge:, cookbook:) @badge_name = badge @cookbook_name = cookbook end def call cookbook = Cookbook.find_by(name: cookbook_name) cookbook.present? ? add_badge_to_cookbook(cookbook) : cookbook_not_found_message en...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/group_member.rb
Ruby
apache-2.0
214
main
365
class GroupMember < ApplicationRecord belongs_to :group belongs_to :user validates :group, presence: true validates :user, presence: true validates :user_id, uniqueness: { scope: [:group_id], message: "cannot be added to a group multiple times" } # Accessors # ------...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_follower.rb
Ruby
apache-2.0
214
main
324
class CookbookFollower < ApplicationRecord # Associations # -------------------- belongs_to :cookbook, counter_cache: true belongs_to :user # Validations # -------------------- validates :cookbook, presence: true validates :user, presence: true validates :cookbook_id, uniqueness: { scope: :user_id } ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook.rb
Ruby
apache-2.0
214
main
13,976
require "chef/version_class" class Cookbook < ApplicationRecord include PgSearch::Model include Badgeable extend Badgeable::ClassMethods # # Query cookbooks by case-insensitive name. # # @param name [String, Array<String>] a single name, or a collection of names # # @example # Cookbook.with_name...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/system_email.rb
Ruby
apache-2.0
214
main
302
class SystemEmail < ApplicationRecord # Associations # -------------------- has_many :email_preferences, dependent: :destroy has_many :subscribed_users, through: :email_preferences, source: :user # Validations # -------------------- validates :name, presence: true, uniqueness: true end
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_version.rb
Ruby
apache-2.0
214
main
3,220
require "active_model/validations/chef_version_validator" class CookbookVersion < ApplicationRecord include SeriousErrors # Associations # -------------------- has_many :cookbook_version_platforms, dependent: :destroy has_many :supported_platforms, through: :cookbook_version_platforms has_many :cookbook_d...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/collaborator.rb
Ruby
apache-2.0
214
main
1,385
# # represents a "collaboration" - linking a thing that can be collaborated on # (e.g. a "resourceable thing" like a cookbook or tool) with the humans that # help work on that thing # class Collaborator < ApplicationRecord # Associations # -------------------- belongs_to :resourceable, polymorphic: true belongs...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_version_platform.rb
Ruby
apache-2.0
214
main
296
class CookbookVersionPlatform < ApplicationRecord # Associations # -------------------- belongs_to :cookbook_version belongs_to :supported_platform # Validations # -------------------- validates :cookbook_version, presence: true validates :supported_platform, presence: true end
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/universe_cache.rb
Ruby
apache-2.0
214
main
995
class UniverseCache # # Flush both the http cache and the https cache # def self.flush ["http://", "https://"].each do |protocol| new(protocol).delete end end def initialize(protocol) @raw_protocol = protocol end # # Fetch something from the cache # # @param [Proc] the block to...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/supported_platform.rb
Ruby
apache-2.0
214
main
822
require "active_model/validations/chef_version_constraint_validator" class SupportedPlatform < ApplicationRecord include SeriousErrors # Associations # -------------------- has_many :cookbook_version_platforms, dependent: :destroy has_many :cookbook_versions, through: :cookbook_version_platforms # Valida...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_upload.rb
Ruby
apache-2.0
214
main
3,051
require "cookbook_upload/parameters" class CookbookUpload # # Creates a new +CookbookUpload+. # # @param user [User] the user uploading the cookbook # @param params [Hash] the upload parameters # @option params [String] :cookbook a JSON string which contains cookbook # data. # @option params [File] :...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/user.rb
Ruby
apache-2.0
214
main
7,205
class User < ApplicationRecord include Authorizable include PgSearch::Model ALLOWED_INSTALL_PREFERENCES = %w{berkshelf knife librarian policyfile}.freeze # Associations # -------------------- has_many :accounts, dependent: :destroy has_many :owned_cookbooks, class_name: "Cookbook", inverse_of: :owner, d...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/email_preference.rb
Ruby
apache-2.0
214
main
909
class EmailPreference < ApplicationRecord include Tokenable # Associations # -------------------- belongs_to :system_email belongs_to :user # Validations # -------------------- validates :user, presence: true validates :system_email, presence: true validates :token, uniqueness: true # Callbacks...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_dependency.rb
Ruby
apache-2.0
214
main
509
require "active_model/validations/chef_version_constraint_validator" class CookbookDependency < ApplicationRecord include SeriousErrors # Associations # -------------------- belongs_to :cookbook_version belongs_to :cookbook, optional: true # Validations # -------------------- validates :name, presenc...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/account.rb
Ruby
apache-2.0
214
main
1,062
class Account < ApplicationRecord # Associations # -------------------- belongs_to :user # Validations # -------------------- validates :user, presence: true validates :uid, presence: true validates :provider, presence: true validates :oauth_token, presence: true validate :unique_username_and_provi...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/group.rb
Ruby
apache-2.0
214
main
474
class Group < ApplicationRecord include PgSearch::Model validates :name, presence: true, uniqueness: { case_sensitive: false } # rubocop:todo Rails/UniqueValidationWithoutIndex has_many :group_members, dependent: :destroy has_many :members, through: :group_members, source: :user has_many :group_resources, dep...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/ownership_transfer_request.rb
Ruby
apache-2.0
214
main
1,446
class OwnershipTransferRequest < ApplicationRecord include Tokenable # Associations # -------------------- belongs_to :cookbook belongs_to :recipient, class_name: "User", inverse_of: :received_ownership_transfer_requests belongs_to :sender, class_name: "User", inverse_of: :initiated_ownership_transfer_requ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/category.rb
Ruby
apache-2.0
214
main
594
class Category < ApplicationRecord scope :with_name, ->(name) { where(name: name.titleize) } # Callbacks # -------------------- before_save :set_slug # Associations # -------------------- has_many :cookbooks, dependent: :nullify # # Returns the name of the +Category+ parameterized. # # @return ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/tool.rb
Ruby
apache-2.0
214
main
4,223
class Tool < ApplicationRecord include PgSearch::Model ALLOWED_TYPES = %w{knife_plugin ohai_plugin chef_infra_tool chef_infra_handler kitchen_driver powershell_module dsc_resource compliance_profile}.freeze self.inheritance_column = nil # Associations # -------------------- belongs_to :owner, class_name:...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/universe.rb
Ruby
apache-2.0
214
main
4,902
# frozen_string_literal: true module Universe COOKBOOK = "cookbook" VERSION = "version" DEPENDENCY = "dependency" DEPENDENCY_CONSTRAINT = "dependency_constraint" LOCATION_PATH = "location_path" LOCATION_TYPE = "location_type" DOWNLOAD_URL = "download_url" DEPENDENCIES = "dependencies" # TODO: change ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/quality_metric.rb
Ruby
apache-2.0
214
main
1,486
class QualityMetric < ApplicationRecord has_many :metric_results, dependent: :destroy scope :open, -> { where(admin_only: false) } scope :admin_only, -> { where(admin_only: true) } validates :name, uniqueness: true def self.flip_public update_all(admin_only: false) # rubocop:disable Rails/SkipsModelVal...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/metric_result.rb
Ruby
apache-2.0
214
main
431
class MetricResult < ApplicationRecord belongs_to :cookbook_version belongs_to :quality_metric scope :open, -> { joins(:quality_metric).merge(QualityMetric.open) } scope :admin_only, -> { joins(:quality_metric).merge(QualityMetric.admin_only) } scope :sorted_by_name, -> { joins(:quality_metric).order("qualit...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_upload/parameters.rb
Ruby
apache-2.0
214
main
7,699
require "active_model/errors" require "cookbook_upload/archive" require "cookbook_upload/metadata" require "cookbook_upload/document" require "json" require "set" class CookbookUpload class Parameters # # @!attribute [r] tarball # @return [File] The tarball parameter value # attr_reader :tarbal...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_upload/archive.rb
Ruby
apache-2.0
214
main
3,379
require "ffi-libarchive" class CookbookUpload # # This class provides access to cookbook archives. In particular, it supports # finding entries in the archive which have a path matching some regular # expression, and it can read the contents of files given their path. These # are the two primary operations r...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_upload/metadata.rb
Ruby
apache-2.0
214
main
3,399
class CookbookUpload # # Acts as a schema for a cookbook's metadata.json. It only provides fields # for the metadata attributes we use, while remaining flexible enough to # handle any metadata hash. # # @note It is a value object which means that two +Metadata+ objects are # considered to be identical i...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/cookbook_upload/document.rb
Ruby
apache-2.0
214
main
437
class CookbookUpload class Document < SchemaDefiner::SymbolizeStruct # # @!attribute [r] contents # @return [String] The text of the Document # # # @!attribute [r] extension # @return [String] The README extension # attribute :contents, SchemaDefiner::Types::Coercible::Strin...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/concerns/exportable.rb
Ruby
apache-2.0
214
main
316
module Exportable require "csv" def self.included(base) base.extend ClassMethods end module ClassMethods def as_csv CSV.generate do |csv| csv << column_names find_each do |item| csv << item.attributes.values_at(*column_names) end end end end end
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/concerns/authorizable.rb
Ruby
apache-2.0
214
main
1,345
module Authorizable # The list of roles. ROLES = %w{admin}.freeze # # Set the roles on the parent model. # # @example # user.roles = [:employee] #=> 2 # # @param [Array<Symbol, String>] roles # # @return [Integer] # def roles=(roles) roles = Array(roles).map(&:to_s) self.roles_mask ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/concerns/badgeable.rb
Ruby
apache-2.0
214
main
2,077
module Badgeable # The list of badges. # It would be a phenomenally bad idea to reorder this array's elements. # Logic about whether a badge is in the badges_mask is based on the index # of the badge text in this array. If you change the order--and therefore the # index--the integers stored in the database fo...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/models/concerns/tokenable.rb
Ruby
apache-2.0
214
main
336
# # @todo maybe refactor this into "Confirmable"? # module Tokenable private # # Callback: create and assign a confirmation token when a new email is added. # def generate_token(column = :token) loop do self[column] = SecureRandom.hex break unless self.class.exists?(column => self[column]) ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/authorizers/user_authorizer.rb
Ruby
apache-2.0
214
main
323
require "authorizer/base" class UserAuthorizer < Authorizer::Base # # Admins can make other non admin users admins. # def make_admin? user.is?(:admin) && !record.is?(:admin) end # # Admins can revoke other admin users admin role. # def revoke_admin? user.is?(:admin) && user != record end e...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/authorizers/collaborator_authorizer.rb
Ruby
apache-2.0
214
main
748
class CollaboratorAuthorizer < Authorizer::Base # # Owners of a cookbook are the only ones that can transfer ownership and they # can only transfer it to someone that's already a collaborator on # a cookbook. # # @return [Boolean] # def transfer? create? && record.persisted? end # # Owners of...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/authorizers/tool_authorizer.rb
Ruby
apache-2.0
214
main
1,124
class ToolAuthorizer < Authorizer::Base # # Owners of a tool and Supermarket admins can edit it. # # @return [Boolean] # def edit? owner_or_collaborator? || admin? end # # Owners of a tool and Supermarket admins can update it. # # @return [Boolean] # def update? owner_or_collaborator?...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/authorizers/cookbook_authorizer.rb
Ruby
apache-2.0
214
main
1,946
class CookbookAuthorizer < Authorizer::Base # # Owners and collaborators of a cookbook can publish new versions of a cookbook. # def create? owner_or_collaborator? end # # Owners of a cookbook can destroy a cookbook. # def destroy? ENV["OWNERS_CAN_REMOVE_ARTIFACTS"] == "true" ? owner_or_admin...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/extractors/github_extractor.rb
Ruby
apache-2.0
214
main
721
class GithubExtractor < Extractor::Base # @see Extractor::Base#first_name def first_name split_name.first end # @see Extractor::Base#last_name def last_name split_name.last end # @see Extractor::Base#email def email auth["info"]["email"] end # @see Extractor::Base#username def usern...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/extractors/chef_oauth2_extractor.rb
Ruby
apache-2.0
214
main
974
class ChefOauth2Extractor < Extractor::Base # @see Extractor::Base#first_name def first_name auth["info"]["first_name"] end # @see Extractor::Base#last_name def last_name auth["info"]["last_name"] end # @see Extractor::Base#email def email auth["info"]["email"] end # @see Extractor::B...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/views/tools/index.atom.builder
Ruby
apache-2.0
214
main
354
atom_feed language: "en-US" do |feed| feed.title "Tools & Plugins" feed.updated Time.current @tools.each do |tool| feed.entry tool do |entry| entry.title tool.name entry.content tool.description entry.author do |author| author.name tool.maintainer author.uri user_url(tool.o...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/views/cookbooks/index.atom.builder
Ruby
apache-2.0
214
main
469
atom_feed language: "en-US" do |feed| feed.title "Cookbooks" feed.updated safe_updated_at(@cookbooks) @cookbooks.each do |cookbook| feed.entry cookbook, url: cookbook_url(cookbook) do |entry| entry.title cookbook.name entry.content cookbook_atom_content(cookbook.latest_cookbook_version), type: "h...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/views/cookbooks/show.atom.builder
Ruby
apache-2.0
214
main
511
atom_feed language: "en-US" do |feed| feed.title "#{@cookbook.name} versions" feed.updated @cookbook_versions.max_by(&:updated_at).updated_at @cookbook_versions.each do |v| feed.entry(v, url: cookbook_version_url(@cookbook, v)) do |entry| entry.title "#{v.cookbook.name} - v#{v.version}" entry.con...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/views/cookbooks/available_for_adoption.atom.builder
Ruby
apache-2.0
214
main
502
atom_feed language: "en-US" do |feed| feed.title "Cookbooks Available for Adoption" feed.updated safe_updated_at(@cookbooks) @available_cookbooks.each do |cookbook| feed.entry cookbook, url: cookbook_url(cookbook) do |entry| entry.title cookbook.name entry.content cookbook_atom_content(cookbook.l...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/views/users/followed_cookbook_activity.atom.builder
Ruby
apache-2.0
214
main
875
atom_feed language: "en-US" do |feed| feed.title "#{@user.username}'s Followed Cookbook Activity" feed.updated safe_updated_at(@followed_cookbook_activity) @followed_cookbook_activity.each do |cookbook_version| feed.entry cookbook_version, url: cookbook_version_url(cookbook_version.cookbook, cookbook_version...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/groups_controller.rb
Ruby
apache-2.0
214
main
1,168
class GroupsController < ApplicationController before_action :collaborator_groups_feature_check def index @groups = Group.all if params[:q] @groups = @groups.search(params[:q]) end respond_to do |format| format.json end end def new @group = Group.new end def create ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/collaborators_controller.rb
Ruby
apache-2.0
214
main
4,569
class CollaboratorsController < ApplicationController include CollaboratorProcessing before_action :authenticate_user! before_action :find_collaborator, only: [:destroy, :transfer] skip_before_action :verify_authenticity_token, only: [:destroy] # # GET /collaborators?q=jimmy&ineligible_user_ids=[1,2,3] ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/group_members_controller.rb
Ruby
apache-2.0
214
main
2,679
class GroupMembersController < ApplicationController include CollaboratorProcessing before_action :find_group_member, only: [:destroy, :make_admin] before_action :check_admin_member_present, only: :destroy def create if group_member_params[:user_ids].present? user_ids = group_member_params[:user_ids...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/pages_controller.rb
Ruby
apache-2.0
214
main
1,111
class PagesController < ApplicationController before_action :authenticate_user!, only: :dashboard layout false, only: [:robots] # # GET / # # The first page a non-authenticated user sees. The welcome page gives the # user a taste of what Supermarket is all about. # def welcome redirect_to dashboa...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/email_preferences_controller.rb
Ruby
apache-2.0
214
main
283
class EmailPreferencesController < ApplicationController # # GET /unsubscribe/:token # # This will unsubscribe a user from a specific email. # def unsubscribe @email_preference = EmailPreference.find_by!(token: params[:token]) @email_preference.destroy end end
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/users_controller.rb
Ruby
apache-2.0
214
main
2,166
class UsersController < ApplicationController before_action :assign_user before_action :override_search, only: [:tools] # # GET /users/:id # # Display a user and a users cookbooks for a given context. The cookbooks # context is given via the tab paramter. Contexts include cookbooks the user # collabora...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/profile_controller.rb
Ruby
apache-2.0
214
main
1,201
class ProfileController < ApplicationController before_action :authenticate_user!, except: [:update_install_preference] # # PATCH /profile # # Update the current_user's profile # def update if current_user.update(user_params) redirect_to current_user, notice: t("profile.updated") else ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/exceptions_controller.rb
Ruby
apache-2.0
214
main
1,204
class ExceptionsController < ApplicationController # # The default failure application. # def show template = if template_exists?(status_code, "exceptions") "exceptions/#{status_code}" else "exceptions/500" end respond_to do |format| ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/tools_controller.rb
Ruby
apache-2.0
214
main
3,674
class ToolsController < ApplicationController before_action :store_location!, only: [:new] before_action :authenticate_user!, except: [:index, :show, :directory] before_action :assign_tool, only: [:show, :update, :edit, :destroy, :adoption] before_action :override_search # # GET /tools # # Lists all +T...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/application_controller.rb
Ruby
apache-2.0
214
main
1,464
class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :define_search include Supermarket::Authorization include Supermarket::Authentication include Supermarket::LocationStorage include CustomUrlHelper rescue_from( Pundit::NotAuthorizedError, Act...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/sessions_controller.rb
Ruby
apache-2.0
214
main
776
class SessionsController < ApplicationController skip_before_action :verify_authenticity_token, only: [:create] # # GET /sign-in # # Show page with authentication options. # def new; end # # POST /auth/chef_oauth2/callback # # Creates a new session for the user from the OmniAuth Auth hash. # ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/cookbooks_controller.rb
Ruby
apache-2.0
214
main
8,885
class CookbooksController < ApplicationController before_action :assign_cookbook, except: [:index, :directory, :available_for_adoption] before_action :store_location_then_authenticate_user!, only: [:follow, :unfollow, :adoption] # # GET /cookbooks # # Return all cookbooks. Cookbooks are sorted alphabetical...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/cookbook_versions_controller.rb
Ruby
apache-2.0
214
main
1,403
class CookbookVersionsController < ApplicationController before_action :set_cookbook_and_version # # GET /cookbooks/:cookbook_id/versions/:version/download # # Redirects the user to the cookbook artifact # def download CookbookVersion.increment_counter(:web_download_count, @version.id) Cookbook.i...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/transfer_ownership_controller.rb
Ruby
apache-2.0
214
main
2,272
class TransferOwnershipController < ApplicationController before_action :find_transfer_request, only: [:accept, :decline] # # PUT /cookbooks/:id/transfer_ownership # # Attempts to transfer ownership of cookbook to another user and redirects # back to the cookbook. # def transfer @cookbook = Cookboo...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/accounts_controller.rb
Ruby
apache-2.0
214
main
956
class AccountsController < ApplicationController before_action :authenticate_user! # # POST /auth/:provider/callback # # Create a new account with returned OAuth info # for the current user # def create account = current_user.account_from_oauth(request.env["omniauth.auth"]) if account.save ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/irc_logs_controller.rb
Ruby
apache-2.0
214
main
1,437
class IrcLogsController < ApplicationController # # GET /chat # # Redirects to the botbot.me dashboard (list of IRC channels). # def index redirect_to("https://botbot.me/freenode/chef/", allow_other_host: true) end # # GET /chat/:channel/:date # # Redirects to the botbot.me channel log if the...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/concerns/collaborator_processing.rb
Ruby
apache-2.0
214
main
2,399
module CollaboratorProcessing extend ActiveSupport::Concern included do helper_method :add_users_as_collaborators end def add_users_as_collaborators(resource, user_ids, group_id = nil) # sometimes user_ids comes in as a string; need it to be an array user_ids = user_ids.split(",") if user_ids.clas...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1_controller.rb
Ruby
apache-2.0
214
main
1,890
class Api::V1Controller < ApplicationController rescue_from ActiveRecord::RecordNotFound, with: :render_404 skip_before_action :verify_authenticity_token private # # Render the error message with a status of 404 and a message letting the # user know the resource does not exist. # def render_404 er...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/cookbook_uploads_controller.rb
Ruby
apache-2.0
214
main
6,532
require "cookbook_upload" require "mixlib/authentication/signatureverification" class Api::V1::CookbookUploadsController < Api::V1Controller before_action :require_upload_params, only: :create before_action :authenticate_user! attr_reader :current_user class VersionMustExist < RuntimeError; end # # POST ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/health_controller.rb
Ruby
apache-2.0
214
main
501
require "sidekiq/api" class Api::V1::HealthController < Api::V1Controller # # GET /api/v1/health # # An overview of system health. Its HTTP status only reflects the API's # ability to report status. In particular, this endpoint will return a status # of 200 even if Redis and Postgres are both hosed. The re...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/metrics_controller.rb
Ruby
apache-2.0
214
main
443
class Api::V1::MetricsController < Api::V1Controller # # GET /api/v1/metrics # # Various counters # def show @metrics = { total_cookbook_downloads: Cookbook.total_download_count, total_cookbook_versions: CookbookVersion.count, total_cookbooks: Cookbook.count, total_follows: Cookb...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/tools_controller.rb
Ruby
apache-2.0
214
main
2,358
class Api::V1::ToolsController < Api::V1Controller before_action :init_params, except: [:show] # # GET /api/v1/tools # # Return all Tools. Defaults to 10 at a time, starting at the first # Tool when sorted alphabetically. The max number of Tools that can be # returned is set by an environment variable AP...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/quality_metrics_controller.rb
Ruby
apache-2.0
214
main
6,275
class Api::V1::QualityMetricsController < Api::V1Controller before_action :check_cookbook_name_present before_action :check_authorization before_action :find_cookbook_version # # POST /api/v1/quality_metrics/cookstyle_evaluation # # Take the cookstyle evaluation results from Fieri and store them on the ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/universe_controller.rb
Ruby
apache-2.0
214
main
542
class Api::V1::UniverseController < Api::V1Controller # # GET /universe # # Returns a JSON response that should be compatible with the current # Berkshelf API response. It will have cookbooks, all their versions, and # dependency/platform information. # def index universe = universe_cache.fetch do ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/cookbooks_controller.rb
Ruby
apache-2.0
214
main
3,013
class Api::V1::CookbooksController < Api::V1Controller before_action :init_params, only: [:index, :search] before_action :assign_cookbook, only: [:show, :contingent] # # GET /api/v1/cookbooks # # Return all Cookbooks. Defaults to 10 at a time, starting at the first # Cookbook when sorted alphabetically. ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/users_controller.rb
Ruby
apache-2.0
214
main
767
class Api::V1::UsersController < Api::V1Controller # # GET /api/v1/users/:user # # Return the specified user and their associated data. If the user does not # exist, return a 404. # # @example # GET /api/v1/users/chef # def show @user = Account.for( "chef_oauth2" ).joins(:user).with_...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/controllers/api/v1/cookbook_versions_controller.rb
Ruby
apache-2.0
214
main
1,257
class Api::V1::CookbookVersionsController < Api::V1Controller # # GET /api/v1/cookbooks/:cookbook/versions/:version # # Return a specific CookbookVersion. Returns a 404 if the +Cookbook+ or # +CookbookVersion+ does not exist. # # @example # GET /api/v1/cookbooks/redis/versions/1.1.0 # def show ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/mailers/collaborator_mailer.rb
Ruby
apache-2.0
214
main
462
class CollaboratorMailer < ApplicationMailer # # Creates an email to send to people when they have been added as # a collaborator to a resource. # # @param collaborator [Collaborator] # def added_email(collaborator) @resource = collaborator.resourceable @to = collaborator.user.email auto_repl...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/mailers/adoption_mailer.rb
Ruby
apache-2.0
214
main
1,143
class AdoptionMailer < ApplicationMailer # # Sends an email to the owner of a cookbook or tool, letting them know that # someone is interested in taking over ownership. # # @param cookbook_or_tool [Cookbook,Tool] # @param user [User] the interested user # def interest_email(cookbook_or_tool_id, resource...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/mailers/cookbook_mailer.rb
Ruby
apache-2.0
214
main
2,957
class CookbookMailer < ApplicationMailer helper CookbookVersionsHelper # # Creates an email to a user that is a cookbook follower # that notifies them a new cookbook version has been published # # @param cookbook_version [CookbookVersion] the cookbook version that was # published # @param user [User] t...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/mailers/application_mailer.rb
Ruby
apache-2.0
214
main
202
class ApplicationMailer < ActionMailer::Base layout "mailer" def auto_reply_headers_off headers("Auto-Submitted" => "auto-generated") headers("X-Auto-Response-Suppress" => "OOF") end end
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/feature.rb
Ruby
apache-2.0
214
main
1,085
require "redis" module Feature extend Forwardable # feature flag methods delegated to the adapter to wrap the flip/check implementation # if more methods from the adapter need to be exposed, add them to the list of delegated # methods here module_function(*def_delegators("Feature.adapter", :active?, :activa...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/active_model/validations/chef_version_constraint_validator.rb
Ruby
apache-2.0
214
main
1,377
require "active_model" require "chef/version_constraint" require "chef/exceptions" module ActiveModel module Validations # # Validates that strings are formatted as Chef version constraints. # class ChefVersionConstraintValidator < ActiveModel::EachValidator # # Create a new validator. Ca...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/active_model/validations/chef_version_validator.rb
Ruby
apache-2.0
214
main
1,275
require "active_model" require "chef/version_class" require "chef/exceptions" module ActiveModel module Validations # # Validates that strings are formatted as Chef version constraints. # class ChefVersionValidator < ActiveModel::EachValidator # # Create a new validator. Called implicitly...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/supermarket/authentication.rb
Ruby
apache-2.0
214
main
828
module Supermarket module Authentication # # Include the following methods as helper methods. # def self.included(controller) controller.send(:helper_method, :current_user, :signed_in?) end # # The currently logged in user, or nil if there is no user logged in. # # @return [...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/supermarket/authorization.rb
Ruby
apache-2.0
214
main
553
require "pundit" module Supermarket module Authorization include Pundit::Authorization extend ActiveSupport::Concern included do # # Make Pundit's +policy+ view helper accessible # helper_method :policy # # Make Pundit's +policy_scope+ view helper accessible # ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/supermarket/s3_config.rb
Ruby
apache-2.0
214
main
3,207
module Supermarket class S3Config class IncompleteConfig < StandardError; end REQUIRED_S3_VARS = %w{S3_BUCKET S3_REGION}.freeze REQUIRED_S3_STATIC_CREDS_VARS = %w{S3_ACCESS_KEY_ID S3_SECRET_ACCESS_KEY}.freeze attr_accessor :default_path, :environment def initialize(path, environment) @def...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/supermarket/host.rb
Ruby
apache-2.0
214
main
346
module Supermarket module Host def self.full_url if ENV["PORT"].present? && !%w{80 443}.include?(ENV["PORT"]) "#{ENV["PROTOCOL"]}://#{ENV["FQDN"]}:#{ENV["PORT"]}" else "#{ENV["PROTOCOL"]}://#{ENV["FQDN"]}" end end def self.secure_session_cookie? ENV["PROTOCOL"] == ...
github
chef/supermarket
https://github.com/chef/supermarket
src/supermarket/app/lib/supermarket/health.rb
Ruby
apache-2.0
214
main
4,807
# frozen_string_literal: true module Supermarket class Health # # This class encapsulates the logic used to perform health checks on the # system. The methods in here are mostly private and exist solely for their # side-effects, not their return values. # REACHABLE = "reachable" UNKNOWN ...