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 | troessner/reek | https://github.com/troessner/reek | samples/smelly_source/redcloth.rb | Ruby | mit | 4,125 | master | 35,859 | # vim:ts=4:sw=4:
# = RedCloth - Textile and Markdown Hybrid for Ruby
#
# Homepage:: http://whytheluckystiff.net/ruby/redcloth/
# Author:: why the lucky stiff (http://whytheluckystiff.net/)
# Copyright:: (cc) 2004 why the lucky stiff (and his puppet organizations.)
# License:: BSD
#
... |
github | troessner/reek | https://github.com/troessner/reek | samples/smelly_source/inline.rb | Ruby | mit | 4,125 | master | 20,733 | #!/usr/local/bin/ruby -w
##
# Ruby Inline is a framework for writing ruby extensions in foreign
# languages.
#
# == SYNOPSIS
#
# require 'inline'
# class MyClass
# inline do |builder|
# builder.include "<math.h>"
# builder.c %q{
# long factorial(int max) {
# int i=max, result=1;
#... |
github | troessner/reek | https://github.com/troessner/reek | samples/smelly_source/optparse.rb | Ruby | mit | 4,125 | master | 47,967 | #
# optparse.rb - command-line option analysis with the OptionParser class.
#
# Author:: Nobu Nakada
# Documentation:: Nobu Nakada and Gavin Sinclair.
#
# See OptionParser for documentation.
#
# == Developer Documentation (not for RDoc output)
#
# === Class tree
#
# - OptionParser:: front end
# - OptionParser::Sw... |
github | troessner/reek | https://github.com/troessner/reek | features/support/env.rb | Ruby | mit | 4,125 | master | 579 | # frozen_string_literal: true
require_relative '../../lib/reek'
require_relative '../../lib/reek/cli/application'
require 'aruba/cucumber'
#
# Provides runner methods used in the cucumber steps.
#
class ReekWorld
def reek(args)
run_command_and_stop("reek --no-color --no-documentation #{args}", fail_on_error: fa... |
github | troessner/reek | https://github.com/troessner/reek | features/step_definitions/sample_file_steps.rb | Ruby | mit | 4,125 | master | 1,976 | # frozen_string_literal: true
require_relative '../../samples/paths'
Given(/^the smelly file '(.+)'$/) do |filename|
write_file(filename, SAMPLES_DIR.join('smelly_source').join(filename).read)
end
Given(/^the smelly file "(.+)" in the directory "(.+)"$/) do |filename, directory|
FileUtils.mkdir_p directory
wri... |
github | troessner/reek | https://github.com/troessner/reek | features/step_definitions/reek_steps.rb | Ruby | mit | 4,125 | master | 3,001 | # frozen_string_literal: true
When /^I run reek (.*)$/ do |args|
reek(args)
end
When 'I run the code climate reek runner' do
run_command_and_stop 'code_climate_reek'
end
When /^I pass "([^"]*)" to reek *(.*)$/ do |stdin, args|
reek_with_pipe(stdin, args)
end
When /^I pass a stdin to reek *(.*) with:$/ do |arg... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | Rakefile | Ruby | mit | 4,115 | main | 842 | # frozen_string_literal: true
require_relative "config/application"
Rails.application.load_tasks
desc "Fetch all feeds."
task fetch_feeds: :environment do
Feed::FetchAll.call
end
desc "Lazily fetch all feeds."
task lazy_fetch: :environment do
if ENV["APP_URL"]
uri = URI(ENV["APP_URL"])
# warm up server... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | Gemfile | Ruby | mit | 4,115 | main | 1,539 | # frozen_string_literal: true
ruby_version_file = File.expand_path(".ruby-version", __dir__)
ruby File.read(ruby_version_file).chomp if File.readable?(ruby_version_file)
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "dotenv-rails"
gem "rails", "~> 8.1.0"
gem "bcry... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/helpers/url_helpers.rb | Ruby | mit | 4,115 | main | 906 | # frozen_string_literal: true
module UrlHelpers
def expand_absolute_urls(content, base_url)
doc = Nokogiri::HTML.fragment(content)
[["a", "href"], ["img", "src"], ["video", "src"]].each do |tag, attr|
doc.css("#{tag}[#{attr}]").each do |node|
url = node.get_attribute(attr)
next if url ... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/repositories/feed_repository.rb | Ruby | mit | 4,115 | main | 958 | # frozen_string_literal: true
class FeedRepository
MIN_YEAR = 1970
def self.fetch(id)
Feed.find(id)
end
def self.fetch_by_ids(ids)
Feed.where(id: ids)
end
def self.update_feed(feed, name, url, group_id = nil)
feed.name = name
feed.url = url
feed.group_id = group_id
feed.save
en... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/repositories/story_repository.rb | Ruby | mit | 4,115 | main | 3,202 | # frozen_string_literal: true
class StoryRepository
extend UrlHelpers
def self.add(entry, feed)
enclosure_url = entry.enclosure_url if entry.respond_to?(:enclosure_url)
Story.create(
feed:,
title: extract_title(entry),
permalink: extract_url(entry, feed),
enclosure_url:,
body... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/repositories/user_repository.rb | Ruby | mit | 4,115 | main | 266 | # frozen_string_literal: true
class UserRepository
def self.fetch(id)
return nil unless id
User.find(id)
end
def self.setup_complete?
User.any?
end
def self.save(user)
user.save
user
end
def self.first
User.first
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/utils/sample_story.rb | Ruby | mit | 4,115 | main | 2,214 | # frozen_string_literal: true
SAMPLE_BODY = <<~HTML
<p>Tofu shoreditch intelligentsia <a href="#">umami</a>, fashion axe photo booth
try-hard terry richardson quinoa actually fingerstache meggings fixie. Aesthetic
salvia vinyl raw denim, keffiyeh master cleanse tonx selfies mlkshk occupy twee
street art gentri... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/utils/authorization.rb | Ruby | mit | 4,115 | main | 603 | # frozen_string_literal: true
class Authorization
attr_accessor :user, :authorized
class NotAuthorizedError < StandardError; end
def initialize(user)
self.user = user
self.authorized = false
end
alias authorized? authorized
def check(record)
raise(NotAuthorizedError) unless record.user_id =... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/utils/opml_parser.rb | Ruby | mit | 4,115 | main | 1,092 | # frozen_string_literal: true
require "nokogiri"
module OpmlParser
class << self
def call(contents)
feeds_with_groups = Hash.new { |h, k| h[k] = [] }
outlines_in(contents).each do |outline|
if outline_is_group?(outline)
group_name = extract_name(outline.attributes).value
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/utils/content_sanitizer.rb | Ruby | mit | 4,115 | main | 215 | # frozen_string_literal: true
module ContentSanitizer
def self.call(content)
Loofah.fragment(content.gsub(/<wbr\s*>/i, ""))
.scrub!(:prune)
.scrub!(:unprintable)
.to_s
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/utils/feed_discovery.rb | Ruby | mit | 4,115 | main | 475 | # frozen_string_literal: true
module FeedDiscovery
class << self
def call(url)
get_feed_for_url(url) do
urls = Feedbag.find(url)
return false if urls.empty?
get_feed_for_url(urls.first) { return false }
end
end
private
def get_feed_for_url(url)
response = ... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/sessions_controller.rb | Ruby | mit | 4,115 | main | 700 | # frozen_string_literal: true
class SessionsController < ApplicationController
skip_before_action :authenticate_user, only: [:new, :create]
def new
authorization.skip
end
def create
authorization.skip
user = SignInUser.call(params[:username], params[:password])
if user
session[:user_id]... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/debug_controller.rb | Ruby | mit | 4,115 | main | 422 | # frozen_string_literal: true
class DebugController < ApplicationController
skip_before_action :complete_setup, only: [:heroku]
skip_before_action :authenticate_user, only: [:heroku]
def index
authorization.skip
render(
locals: {
queued_jobs_count: GoodJob::Job.queued.count,
pendin... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/tutorials_controller.rb | Ruby | mit | 4,115 | main | 240 | # frozen_string_literal: true
class TutorialsController < ApplicationController
def index
authorization.skip
CallableJob.perform_later(Feed::FetchAllForUser, current_user)
@sample_stories = StoryRepository.samples
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/settings_controller.rb | Ruby | mit | 4,115 | main | 355 | # frozen_string_literal: true
class SettingsController < ApplicationController
def index
authorization.skip
end
def update
authorization.skip
setting = Setting.find(params[:id])
setting.update!(setting_params)
redirect_to(settings_path)
end
private
def setting_params
params.exp... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/imports_controller.rb | Ruby | mit | 4,115 | main | 277 | # frozen_string_literal: true
class ImportsController < ApplicationController
def new
authorization.skip
end
def create
authorization.skip
Feed::ImportFromOpml.call(params["opml_file"].read, user: current_user)
redirect_to("/setup/tutorial")
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/application_controller.rb | Ruby | mit | 4,115 | main | 640 | # frozen_string_literal: true
class ApplicationController < ActionController::Base
before_action :complete_setup
before_action :authenticate_user
after_action -> { authorization.verify }
private
def authorization
@authorization ||= Authorization.new(current_user)
end
def complete_setup
redirec... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/exports_controller.rb | Ruby | mit | 4,115 | main | 295 | # frozen_string_literal: true
class ExportsController < ApplicationController
def index
xml = Feed::ExportToOpml.call(authorization.scope(Feed.all))
send_data(
xml,
type: "application/xml",
disposition: "attachment",
filename: "stringer.opml"
)
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/profiles_controller.rb | Ruby | mit | 4,115 | main | 587 | # frozen_string_literal: true
class ProfilesController < ApplicationController
def edit
authorization.skip
render(locals: { user: current_user })
end
def update
authorization.skip
if current_user.update(user_params)
redirect_to(news_path, flash: { success: t(".success") })
else
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/stories_controller.rb | Ruby | mit | 4,115 | main | 843 | # frozen_string_literal: true
class StoriesController < ApplicationController
def index
order = current_user.stories_order
@unread_stories = authorization.scope(StoryRepository.unread(order:))
end
def update
json_params = JSON.parse(request.body.read, symbolize_names: true)
story = authorizatio... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/passwords_controller.rb | Ruby | mit | 4,115 | main | 1,317 | # frozen_string_literal: true
class PasswordsController < ApplicationController
skip_before_action :complete_setup, only: [:new, :create]
skip_before_action :authenticate_user, only: [:new, :create]
before_action :check_signups_enabled, only: [:new, :create]
def new
authorization.skip
end
def create
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/feeds_controller.rb | Ruby | mit | 4,115 | main | 1,433 | # frozen_string_literal: true
class FeedsController < ApplicationController
def index
@feeds = authorization.scope(FeedRepository.list.with_unread_stories_counts)
end
def show
@feed = FeedRepository.fetch(params[:feed_id])
authorization.check(@feed)
@stories = StoryRepository.feed(params[:feed_... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/controllers/fever_controller.rb | Ruby | mit | 4,115 | main | 818 | # frozen_string_literal: true
class FeverController < ApplicationController
skip_before_action :complete_setup, only: [:index, :update]
protect_from_forgery with: :null_session, only: [:update]
def index
authorization.skip
render(json: FeverAPI::Response.call(fever_params))
end
def update
autho... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/tasks/remove_old_stories.rb | Ruby | mit | 4,115 | main | 530 | # frozen_string_literal: true
module RemoveOldStories
class << self
def call(number_of_days)
stories = old_stories(number_of_days)
feeds = pruned_feeds(stories)
stories.delete_all
feeds.each { |feed| FeedRepository.update_last_fetched(feed, Time.now) }
end
private
def old_s... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/user.rb | Ruby | mit | 4,115 | main | 1,396 | # frozen_string_literal: true
class User < ApplicationRecord
has_secure_password
encrypts :api_key, deterministic: true
has_many :feeds, dependent: :delete_all
has_many :groups, dependent: :delete_all
validates :username, presence: true, uniqueness: { case_sensitive: false }
validate :password_challenge... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/subscription.rb | Ruby | mit | 4,115 | main | 514 | # frozen_string_literal: true
class Subscription < ApplicationRecord
belongs_to :user
STATUSES = ["active", "past_due", "unpaid", "canceled"].freeze
validates :user_id, presence: true, uniqueness: true
validates :stripe_customer_id, presence: true, uniqueness: true
validates :stripe_subscription_id, presen... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/group.rb | Ruby | mit | 4,115 | main | 312 | # frozen_string_literal: true
class Group < ApplicationRecord
UNGROUPED = Group.new(id: 0, name: "Ungrouped")
belongs_to :user
has_many :feeds
validates :name, presence: true, uniqueness: { scope: :user_id }
validates :user_id, presence: true
def as_fever_json
{ id:, title: name }
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/application_record.rb | Ruby | mit | 4,115 | main | 531 | # frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
def self.boolean_accessor(attribute, key, default: false)
store_accessor(attribute, key)
define_method(key) do
value = super()
value.nil? ? default : CastBoolean.call(value)
end
alias_met... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/feed.rb | Ruby | mit | 4,115 | main | 954 | # frozen_string_literal: true
class Feed < ApplicationRecord
has_many :stories, -> { order(published: :desc) }, dependent: :delete_all
has_many :unread_stories, -> { unread }, class_name: "Story"
belongs_to :group
belongs_to :user
delegate :name, to: :group, prefix: true, allow_nil: true
validates :url, ... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/story.rb | Ruby | mit | 4,115 | main | 918 | # frozen_string_literal: true
class Story < ApplicationRecord
belongs_to :feed
has_one :user, through: :feed
validates_uniqueness_of :entry_id, scope: :feed_id
delegate :group_id, :user_id, to: :feed
scope :unread, -> { where(is_read: false) }
UNTITLED = "[untitled]"
def headline
title.nil? ? UN... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/migration_status.rb | Ruby | mit | 4,115 | main | 262 | # frozen_string_literal: true
module MigrationStatus
def self.call
migrator = ActiveRecord::Base.connection.pool.migration_context.open
migrator.pending_migrations.map do |migration|
"#{migration.name} - #{migration.version}"
end
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/models/setting/user_signup.rb | Ruby | mit | 4,115 | main | 294 | # frozen_string_literal: true
class Setting::UserSignup < Setting
boolean_accessor :data, :enabled, default: false
validates :enabled, inclusion: { in: [true, false] }
def self.first
first_or_create!
end
def self.enabled?
first_or_create!.enabled? || User.none?
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api.rb | Ruby | mit | 4,115 | main | 272 | # frozen_string_literal: true
module FeverAPI
API_VERSION = 3
PARAMS = [
:as,
:before,
:favicons,
:feeds,
:groups,
:id,
:items,
:links,
:mark,
:saved_item_ids,
:since_id,
:unread_item_ids,
:with_ids
].freeze
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/cast_boolean.rb | Ruby | mit | 4,115 | main | 363 | # frozen_string_literal: true
module CastBoolean
TRUE_VALUES = Set.new(["true", true, "1"]).freeze
FALSE_VALUES = Set.new(["false", false, "0"]).freeze
def self.call(boolean)
if (TRUE_VALUES + FALSE_VALUES).exclude?(boolean)
raise(ArgumentError, "cannot cast to boolean: #{boolean.inspect}")
end
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/feed/export_to_opml.rb | Ruby | mit | 4,115 | main | 564 | # frozen_string_literal: true
module Feed::ExportToOpml
class << self
def call(feeds)
builder =
Nokogiri::XML::Builder.new do |xml|
xml.opml(version: "1.0") do
xml.head { xml.title("Feeds from Stringer") }
xml.body { feeds.each { |feed| feed_outline(xml, feed) } }
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/feed/find_new_stories.rb | Ruby | mit | 4,115 | main | 599 | # frozen_string_literal: true
module Feed::FindNewStories
STORY_AGE_THRESHOLD_DAYS = 3
def self.call(raw_feed, feed_id, latest_entry_id = nil)
stories = []
raw_feed.entries.each do |story|
break if latest_entry_id && story.id == latest_entry_id
next if story_age_exceeds_threshold?(story) || S... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/feed/fetch_one.rb | Ruby | mit | 4,115 | main | 876 | # frozen_string_literal: true
module Feed::FetchOne
class << self
def call(feed)
raw_feed = fetch_raw_feed(feed)
new_entries_from(feed, raw_feed).each do |entry|
StoryRepository.add(entry, feed)
end
FeedRepository.update_last_fetched(feed, raw_feed.last_modified)
FeedRepo... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/feed/create.rb | Ruby | mit | 4,115 | main | 311 | # frozen_string_literal: true
module Feed::Create
def self.call(url, user:)
result = FeedDiscovery.call(url)
return false unless result
name = ContentSanitizer.call(result.title.presence || result.feed_url)
Feed.create(name:, user:, url: result.feed_url, last_fetched: 1.day.ago)
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/feed/import_from_opml.rb | Ruby | mit | 4,115 | main | 1,463 | # frozen_string_literal: true
module Feed::ImportFromOpml
class << self
def call(opml_contents, user:)
feeds_with_groups = OpmlParser.call(opml_contents)
# It considers a situation when feeds are already imported without
# groups, so it's possible to re-import the same subscriptions.xml just
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/feed/fetch_all.rb | Ruby | mit | 4,115 | main | 222 | # frozen_string_literal: true
require "thread/pool"
module Feed::FetchAll
def self.call
pool = Thread.pool(10)
Feed.find_each { |feed| pool.process { Feed::FetchOne.call(feed) } }
pool.shutdown
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/feed/fetch_all_for_user.rb | Ruby | mit | 4,115 | main | 241 | # frozen_string_literal: true
require "thread/pool"
module Feed::FetchAllForUser
def self.call(user)
pool = Thread.pool(10)
user.feeds.find_each { |feed| pool.process { Feed::FetchOne.call(feed) } }
pool.shutdown
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/story/mark_feed_as_read.rb | Ruby | mit | 4,115 | main | 214 | # frozen_string_literal: true
module MarkFeedAsRead
def self.call(feed_id, timestamp)
StoryRepository
.fetch_unread_for_feed_by_timestamp(feed_id, timestamp)
.update_all(is_read: true)
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/story/mark_group_as_read.rb | Ruby | mit | 4,115 | main | 481 | # frozen_string_literal: true
module MarkGroupAsRead
KINDLING_GROUP_ID = 0
SPARKS_GROUP_ID = -1
def self.call(group_id, timestamp)
return unless group_id
if [KINDLING_GROUP_ID, SPARKS_GROUP_ID].include?(group_id.to_i)
StoryRepository
.fetch_unread_by_timestamp(timestamp).update_all(is_r... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/read_feeds_groups.rb | Ruby | mit | 4,115 | main | 656 | # frozen_string_literal: true
class FeverAPI::ReadFeedsGroups
class << self
def call(authorization:, **params)
if params.key?(:feeds) || params.key?(:groups)
{ feeds_groups: feeds_groups(authorization) }
else
{}
end
end
private
def feeds_groups(authorization)
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/response.rb | Ruby | mit | 4,115 | main | 597 | # frozen_string_literal: true
module FeverAPI::Response
ACTIONS = [
FeverAPI::Authentication,
FeverAPI::ReadFeeds,
FeverAPI::ReadGroups,
FeverAPI::ReadFeedsGroups,
FeverAPI::ReadFavicons,
FeverAPI::ReadItems,
FeverAPI::ReadLinks,
FeverAPI::SyncUnreadItemIds,
FeverAPI::SyncSavedIte... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/read_favicons.rb | Ruby | mit | 4,115 | main | 409 | # frozen_string_literal: true
class FeverAPI::ReadFavicons
ICON = "R0lGODlhAQABAIAAAObm5gAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
class << self
def call(params)
if params.key?(:favicons)
{ favicons: }
else
{}
end
end
private
def favicons
[
{
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/write_mark_item.rb | Ruby | mit | 4,115 | main | 593 | # frozen_string_literal: true
module FeverAPI::WriteMarkItem
class << self
def call(authorization:, **params)
if params[:mark] == "item"
authorization.check(Story.find(params[:id])) if params.key?(:id)
mark_item_as(params[:id], params[:as])
end
{}
end
private
def ... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/sync_unread_item_ids.rb | Ruby | mit | 4,115 | main | 454 | # frozen_string_literal: true
module FeverAPI::SyncUnreadItemIds
class << self
def call(authorization:, **params)
if params.key?(:unread_item_ids)
{ unread_item_ids: unread_item_ids(authorization) }
else
{}
end
end
private
def unread_item_ids(authorization)
a... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/write_mark_group.rb | Ruby | mit | 4,115 | main | 271 | # frozen_string_literal: true
module FeverAPI::WriteMarkGroup
def self.call(authorization:, **params)
if params[:mark] == "group"
authorization.check(Group.find(params[:id]))
MarkGroupAsRead.call(params[:id], params[:before])
end
{}
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/read_feeds.rb | Ruby | mit | 4,115 | main | 351 | # frozen_string_literal: true
module FeverAPI::ReadFeeds
class << self
def call(authorization:, **params)
if params.key?(:feeds)
{ feeds: feeds(authorization) }
else
{}
end
end
private
def feeds(authorization)
authorization.scope(FeedRepository.list).map(&:as... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/authentication.rb | Ruby | mit | 4,115 | main | 266 | # frozen_string_literal: true
module FeverAPI::Authentication
def self.call(authorization:, **_params)
feeds = authorization.scope(Feed)
last_refreshed_on_time = (feeds.maximum(:last_fetched) || 0).to_i
{ auth: 1, last_refreshed_on_time: }
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/write_mark_feed.rb | Ruby | mit | 4,115 | main | 267 | # frozen_string_literal: true
module FeverAPI::WriteMarkFeed
def self.call(authorization:, **params)
if params[:mark] == "feed"
authorization.check(Feed.find(params[:id]))
MarkFeedAsRead.call(params[:id], params[:before])
end
{}
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/read_items.rb | Ruby | mit | 4,115 | main | 1,241 | # frozen_string_literal: true
module FeverAPI::ReadItems
class << self
def call(authorization:, **params)
return {} unless params.key?(:items)
item_ids = params[:with_ids].split(",") if params.key?(:with_ids)
{
items: items(item_ids, params[:since_id], authorization),
total_it... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/sync_saved_item_ids.rb | Ruby | mit | 4,115 | main | 494 | # frozen_string_literal: true
module FeverAPI::SyncSavedItemIds
class << self
def call(authorization:, **params)
if params.key?(:saved_item_ids)
{ saved_item_ids: saved_item_ids(authorization) }
else
{}
end
end
private
def saved_item_ids(authorization)
all_st... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/fever_api/read_groups.rb | Ruby | mit | 4,115 | main | 387 | # frozen_string_literal: true
module FeverAPI::ReadGroups
class << self
def call(authorization:, **params)
if params.key?(:groups)
{ groups: groups(authorization) }
else
{}
end
end
private
def groups(authorization)
[Group::UNGROUPED, *authorization.scope(Grou... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | app/commands/user/sign_in_user.rb | Ruby | mit | 4,115 | main | 276 | # frozen_string_literal: true
module SignInUser
def self.call(username, submitted_password)
user = User.find_by(username:)
return unless user
user_password = BCrypt::Password.new(user.password_digest)
user if user_password == submitted_password
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | docker/init_or_update_env.rb | Ruby | mit | 4,115 | main | 1,050 | # frozen_string_literal: true
require "securerandom"
module Secrets
def self.generate_secret(length)
SecureRandom.hex(length)
end
end
pg_user = ENV.fetch("POSTGRES_USER", "stringer")
pg_password = ENV.fetch("POSTGRES_PASSWORD", Secrets.generate_secret(32))
pg_host = ENV.fetch("POSTGRES_HOSTNAME", "stringer-p... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/puma.rb | Ruby | mit | 4,115 | main | 1,995 | # frozen_string_literal: true
# This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
#
# Puma starts a configurable number of processes (wo... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/application.rb | Ruby | mit | 4,115 | main | 1,950 | # frozen_string_literal: true
require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
# require "action_ma... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/routes.rb | Ruby | mit | 4,115 | main | 1,398 | # frozen_string_literal: true
require_relative "../lib/admin_constraint"
Rails.application.routes.draw do
scope :admin, constraints: AdminConstraint.new do
mount GoodJob::Engine => "good_job"
resources :settings, only: [:index, :update]
get "/debug", to: "debug#index"
end
resource :profile, only: ... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/initializers/filter_parameter_logging.rb | Ruby | mit | 4,115 | main | 523 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password)
# and filtered from the log file. Use this to limit dissemination of sensitive
# information. See the ActiveSupport::ParameterFilter documentation for
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/initializers/session_store.rb | Ruby | mit | 4,115 | main | 233 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
session_config = { key: "_stringer_session", expire_after: 2.weeks }
Rails.application.config.session_store(:cookie_store, **session_config) |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/initializers/inflections.rb | Ruby | mit | 4,115 | main | 666 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflec... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/initializers/content_security_policy.rb | Ruby | mit | 4,115 | main | 1,112 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
# Rails.application.configure... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/environments/production.rb | Ruby | mit | 4,115 | main | 2,922 | # frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in
# config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better pe... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/environments/development.rb | Ruby | mit | 4,115 | main | 2,158 | # frozen_string_literal: true
require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in
# config/application.rb.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eage... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | config/environments/test.rb | Ruby | mit | 4,115 | main | 1,905 | # frozen_string_literal: true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.applic... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/rails_helper.rb | Ruby | mit | 4,115 | main | 1,059 | # frozen_string_literal: true
require "spec_helper"
ENV["RAILS_ENV"] ||= "test"
require_relative "support/coverage"
require_relative "../config/environment"
# Prevent database truncation if the environment is production
if Rails.env.production?
abort("The Rails environment is running in production mode!")
end
requi... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/spec_helper.rb | Ruby | mit | 4,115 | main | 3,424 | # frozen_string_literal: true
RSpec.configure do |config|
config.expect_with(:rspec) do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/lib/admin_constraint_spec.rb | Ruby | mit | 4,115 | main | 783 | # frozen_string_literal: true
RSpec.describe AdminConstraint do
def make_request(session: {})
request = ActionDispatch::Request.new({})
request.session = session
request
end
it "matches when the session user is an admin" do
user = create(:user, admin: true)
request = make_request(session: { ... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/repositories/story_repository_spec.rb | Ruby | mit | 4,115 | main | 14,517 | # frozen_string_literal: true
RSpec.describe StoryRepository do
describe ".add" do
def create_feed(url: "http://blog.golang.org/feed.atom")
double(url:)
end
it "normalizes story urls" do
feed = create_feed
entry = double(url: "//blog.golang.org/context", title: "", content: "")
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/repositories/group_repository_spec.rb | Ruby | mit | 4,115 | main | 450 | # frozen_string_literal: true
RSpec.describe GroupRepository do
describe ".list" do
it "lists groups ordered by lower name" do
group1 = create(:group, name: "Zabba")
group2 = create(:group, name: "zlabba")
group3 = create(:group, name: "blabba")
group4 = create(:group, name: "Babba")
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/repositories/user_repository_spec.rb | Ruby | mit | 4,115 | main | 1,130 | # frozen_string_literal: true
RSpec.describe UserRepository do
describe ".fetch" do
it "returns nil when given id is nil" do
expect(described_class.fetch(nil)).to be_nil
end
it "returns the user for the given id" do
user = default_user
expect(described_class.fetch(user.id)).to eq(user... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/repositories/feed_repository_spec.rb | Ruby | mit | 4,115 | main | 3,106 | # frozen_string_literal: true
RSpec.describe FeedRepository do
describe ".fetch" do
it "finds and returns found feed" do
feed = create(:feed)
result = described_class.fetch(feed.id)
expect(result).to eq(feed)
end
end
describe ".fetch_by_ids" do
it "finds all feeds by id" do
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/jobs/callable_job_spec.rb | Ruby | mit | 4,115 | main | 262 | # frozen_string_literal: true
RSpec.describe CallableJob do
it "calls the callable" do
callable = ->(*, **) {}
expect { described_class.perform_now(callable, "foo", bar: "baz") }
.to invoke(:call).on(callable).with("foo", bar: "baz")
end
end |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/authentication_spec.rb | Ruby | mit | 4,115 | main | 1,694 | # frozen_string_literal: true
RSpec.describe "authentication" do
before { create(:user) }
it "redirects to login when accessing news while logged out" do
visit(news_path)
expect(page).to have_current_path(login_path)
end
it "redirects to login when accessing starred while logged out" do
visit(st... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/feed_status_spec.rb | Ruby | mit | 4,115 | main | 700 | # frozen_string_literal: true
RSpec.describe "feed status bubbles" do
it "shows a green status for a healthy feed" do
login_as(default_user)
create(:feed, status: :green)
visit("/feeds")
expect(page).to have_css(".status.green")
end
it "shows a red status for a feed that has never successfully... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/add_feed_spec.rb | Ruby | mit | 4,115 | main | 1,195 | # frozen_string_literal: true
RSpec.describe "adding a feed" do
def stub_discovery(url:, title: "My Feed")
feed = instance_double(Feedjira::Parser::Atom, title:, feed_url: url)
expect(FeedDiscovery).to receive(:call).with(url).and_return(feed)
end
def submit_feed(url)
visit(feeds_new_path)
fill_... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/feeds_index_spec.rb | Ruby | mit | 4,115 | main | 2,145 | # frozen_string_literal: true
RSpec.describe "feeds/index" do
it "displays a list of feeds" do
login_as(default_user)
create_pair(:feed)
visit "/feeds"
expect(page).to have_css("li.feed", count: 2)
end
it "displays message to add feeds if there are none" do
login_as(default_user)
visi... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/feed_edit_spec.rb | Ruby | mit | 4,115 | main | 2,127 | # frozen_string_literal: true
RSpec.describe "feeds/edit" do
def visit_edit_feed
feed = create(:feed)
visit("/feeds/#{feed.id}/edit")
end
it "does not show a group selector when the user has no groups" do
login_as(default_user)
visit_edit_feed
expect(page).to have_no_select("group-id")
en... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/account_setup_spec.rb | Ruby | mit | 4,115 | main | 1,207 | # frozen_string_literal: true
RSpec.describe "account setup" do
def fill_in_fields(username:, confirm: "my-password")
fill_in("Username", with: username)
fill_in("Password", with: "my-password")
fill_in("Confirm", with: confirm)
click_on("Next")
end
it "allows a user to sign up" do
visit "/"... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/good_job_spec.rb | Ruby | mit | 4,115 | main | 630 | # frozen_string_literal: true
RSpec.describe "admin/good_job" do
it "displays the GoodJob dashboard" do
login_as(create(:user, admin: true))
a11y_skip = [
"aria-required-children",
"color-contrast",
"document-title",
"landmark-unique",
"landmark-one-main",
"page-has-headin... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/multi_user_isolation_spec.rb | Ruby | mit | 4,115 | main | 1,063 | # frozen_string_literal: true
RSpec.describe "multi-user data isolation" do
it "does not show another user's stories on the news page" do
create(:story, feed: create(:feed, user: create(:user)))
login_as(default_user)
visit(news_path)
expect(page).to have_content("You've reached RSS Zero")
end
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/login_spec.rb | Ruby | mit | 4,115 | main | 1,144 | # frozen_string_literal: true
RSpec.describe "login" do
def submit_login(username:, password:)
visit("/")
fill_in("Username", with: username)
fill_in("Password", with: password)
click_on("Login")
end
it "allows a user to log in" do
user = create(:user)
submit_login(username: user.userna... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/stories_index_spec.rb | Ruby | mit | 4,115 | main | 5,196 | # frozen_string_literal: true
RSpec.describe "stories/index" do
it "displays the stories" do
create(:story, title: "My Story")
login_as(default_user)
visit news_path
expect(page).to have_content("My Story")
end
it "does not display read stories" do
create(:story, :read, title: "My Story")
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/heroku_spec.rb | Ruby | mit | 4,115 | main | 467 | # frozen_string_literal: true
RSpec.describe "heroku setup" do
it "displays the heroku setup page without authentication" do
visit("/heroku")
expect(page).to have_content("One more thing")
end
it "displays the scheduler task instructions" do
visit("/heroku")
expect(page).to have_content("rake ... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/profile_spec.rb | Ruby | mit | 4,115 | main | 2,698 | # frozen_string_literal: true
RSpec.describe "profile page" do
before do
login_as(default_user)
visit(edit_profile_path)
end
it "allows the user to edit their username" do
fill_in_username_fields(default_user.password)
click_on("Update username")
expect(page).to have_text("Logged in as new_... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/archive_spec.rb | Ruby | mit | 4,115 | main | 1,252 | # frozen_string_literal: true
RSpec.describe "archive" do
def create_read_stories(count)
count.times { create(:story, :read) }
end
it "displays read stories" do
login_as(default_user)
create(:story, :read, title: "Old Story")
visit(archive_path)
expect(page).to have_content("Old Story")
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/keyboard_shortcuts_spec.rb | Ruby | mit | 4,115 | main | 3,468 | # frozen_string_literal: true
RSpec.describe "keyboard shortcuts" do
after { visit(logout_path) }
def create_stories_and_visit
create(:story, title: "First Story", body: "First Body")
create(:story, title: "Second Story", body: "Second Body")
visit(news_path)
end
it "opens a story with j" do
... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/starred_spec.rb | Ruby | mit | 4,115 | main | 2,969 | # frozen_string_literal: true
RSpec.describe "starred" do
it "displays starred stories" do
login_as(default_user)
create(:story, :starred, title: "Fave Story")
visit(starred_path)
expect(page).to have_content("Fave Story")
end
it "shows a message when no stories are starred" do
login_as(de... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/feed_show_spec.rb | Ruby | mit | 4,115 | main | 2,557 | # frozen_string_literal: true
RSpec.describe "feeds/show" do
def create_and_visit_feed(story_title: nil)
feed = create(:feed)
create(:story, feed:, title: story_title) if story_title
visit("/feed/#{feed.id}")
feed
end
it "displays the feed name" do
login_as(default_user)
feed = create_a... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/import_spec.rb | Ruby | mit | 4,115 | main | 1,830 | # frozen_string_literal: true
RSpec.describe "importing feeds" do
it "allows skipping the import" do
login_as(default_user)
visit(feeds_import_path)
click_on("Not now")
expect(page).to have_content("We're getting you some stories to read")
end
it "allows importing feeds" do
login_as(defaul... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/export_spec.rb | Ruby | mit | 4,115 | main | 332 | # frozen_string_literal: true
RSpec.describe "exporting feeds" do
it "allows exporting feeds" do
login_as(default_user)
feed = create(:feed, :with_group)
click_on "Export"
xml = Capybara.string(Downloads.content_for(page, "stringer.opml"))
expect(xml).to have_css("outline[title='#{feed.name}']"... |
github | stringer-rss/stringer | https://github.com/stringer-rss/stringer | spec/system/tutorial_spec.rb | Ruby | mit | 4,115 | main | 462 | # frozen_string_literal: true
RSpec.describe "tutorial" do
def visit_tutorial
expect(CallableJob).to receive(:perform_later)
visit(setup_tutorial_path)
end
it "displays the tutorial page" do
login_as(default_user)
visit_tutorial
expect(page).to have_content("Stringer is simple")
end
i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.