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 | jakewilkins/apptokit | https://github.com/jakewilkins/apptokit | test/keycache_test.rb | Ruby | mit | 45 | main | 2,975 | require "test_helper"
require "tempfile"
require "apptokit/key_cache"
class KeyCacheTest < TestCase
TEST_KEYCACHE = Base64.encode64(JSON.generate({
"user:1410449:" => "a66c488331e082f8b904fcd51e62b398cdbbee2a:::#{(DateTime.now + 600).iso8601}",
"installation:1410449" => "v1.f6b9931aa49037765e58b6a2de5663509... |
github | jakewilkins/apptokit | https://github.com/jakewilkins/apptokit | test/config_loader_test.rb | Ruby | mit | 45 | main | 2,374 | # frozen_string_literal: true
require "test_helper"
require "tempfile"
class ConfigLoaderTest < TestCase
def setup
reset!
@loader = Apptokit::ConfigLoader.new
end
def test_loads_conf_from_home_dir
@loader.reload!
assert_equal @loader.env, 'bats'
assert_equal @loader.fetch('private_key_path... |
github | jakewilkins/apptokit | https://github.com/jakewilkins/apptokit | test/test_helper.rb | Ruby | mit | 45 | main | 2,500 | require 'pathname'
require 'minitest/autorun'
ENV['GH_ENV'] = 'bats'
TEST_DIR = Pathname.new(__FILE__).dirname
TMP_DIR = TEST_DIR.dirname.join("tmp")
TEST_HOME_DIR = TMP_DIR.join("home/#{ENV["RUBY_VERSION"]}")
TEST_HOME_CONFIG_DIR = TEST_HOME_DIR.join('.config')
TEST_HOME_APPTOKIT_DIR = TEST_HOME_CONFIG_DIR.join('ap... |
github | jakewilkins/apptokit | https://github.com/jakewilkins/apptokit | test/Rakefile | Ruby | mit | 45 | main | 416 | require "rake/testtask"
current_dir = File.basename(Dir.pwd)
in_ci_build_dir = current_dir == ENV["RUBY_VERSION"]
in_test_dir = current_dir == "test"
$path_prefix = if in_ci_build_dir || in_test_dir
"../"
else
""
end
Rake::TestTask.new(:test) do |t|
t.libs << "#{$path_prefix}test"
t.libs << "#{$path_prefix}s... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | gold_miner.gemspec | Ruby | mit | 45 | main | 1,737 | # frozen_string_literal: true
require_relative "lib/gold_miner/version"
Gem::Specification.new do |spec|
spec.name = "gold_miner"
spec.version = GoldMiner::VERSION
spec.authors = ["Matheus Richard"]
spec.email = ["matheusrichardt@gmail.com"]
spec.summary = "Searches for interesting things in a Slack channe... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | Gemfile | Ruby | mit | 45 | main | 286 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in gold-miner.gemspec
gemspec
gem "rake", "~> 13.3"
gem "standard", "~> 1.54"
group :test do
gem "rspec", "~> 3.13"
gem "timecop"
gem "webmock"
gem "simplecov", require: false
end |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner_spec.rb | Ruby | mit | 45 | main | 1,299 | # frozen_string_literal: true
require "dry/monads"
require "dotenv"
RSpec.describe GoldMiner do
include Dry::Monads[:result]
describe "#mine" do
it "explores, smiths and distributes gold from the given location and date" do
location = "dev"
start_date = Date.parse("2023-10-20")
gold_contain... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/spec_helper.rb | Ruby | mit | 45 | main | 735 | # frozen_string_literal: true
require "simplecov"
SimpleCov.start do
enable_coverage :branch
add_filter "/spec"
end
require "gold_miner"
require "timecop"
require "webmock/rspec"
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
RSpec.configure do |config|
# Enable flags like --only-failures and --nex... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/support/behaves_like_blog_post_writer.rb | Ruby | mit | 45 | main | 292 | RSpec.shared_examples "a blog post writer" do
it { expect(writer_instance).to respond_to(:extract_topics_from).with(1).argument }
it { expect(writer_instance).to respond_to(:give_title_to).with(1).argument }
it { expect(writer_instance).to respond_to(:summarize).with(1).argument }
end |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/support/env_helpers.rb | Ruby | mit | 45 | main | 210 | module EnvHelpers
def with_env(env)
original_env = ENV.to_hash
ENV.update(env)
yield
ensure
ENV.replace(original_env)
end
end
RSpec.configure do |config|
config.include EnvHelpers
end |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/support/test_factories.rb | Ruby | mit | 45 | main | 1,720 | module TestFactories
extend self
def create_author(overridden_attributes = {})
default_attributes = {
id: "author-id",
name: "John Doe",
link: "https://example.com/users/john.doe"
}
GoldMiner::Author.new(**default_attributes.merge(overridden_attributes))
end
def create_gold_conta... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/slack_explorer_spec.rb | Ruby | mit | 45 | main | 3,963 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::SlackExplorer do
describe "#explore" do
it "returns uniq interesting Slack messages sent on dev channel since last friday" do
travel_to "2022-10-07" do
user1 = TestFactories.create_slack_user(id: "user-id-1", name: "User... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/author_config_spec.rb | Ruby | mit | 45 | main | 946 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::AuthorConfig do
describe ".default" do
it "loads the author links from the config file" do
author_config = described_class.default
link = author_config.link_for("matheus")
expect(link).to eq "https://thoughtbot.com... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/helpers_spec.rb | Ruby | mit | 45 | main | 1,296 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::Helpers do
describe GoldMiner::Helpers::Time do
describe ".last_friday" do
it "returns the last Friday when today is Saturday" do
travel_to Date.new(2024, 7, 13) do
result = described_class.last_friday
... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/blog_post_spec.rb | Ruby | mit | 45 | main | 4,260 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::BlogPost do
describe "#to_s" do
it "creates a blogpost from a list of gold nuggets" do
travel_to "2022-10-07" do
author1 = TestFactories.create_author(name: "John Doe", id: "john.doe", link: "https://example.com/john.doe... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/terminal_distributor_spec.rb | Ruby | mit | 45 | main | 369 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::TerminalDistributor do
it_behaves_like "distributor"
describe "#distribute" do
it "prints the blog post to STDOUT" do
blog_post = double("blog_post", to_s: "A blog post")
expect { subject.distribute(blog_post) }.to out... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/messages_query_spec.rb | Ruby | mit | 45 | main | 1,493 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::Slack::MessagesQuery do
describe "#on_channel" do
it "sets the channel to search messages in" do
query = described_class.new
result = query.on_channel("dev")
expect(result.channel).to eq("dev")
end
end
des... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/gold_nugget_spec.rb | Ruby | mit | 45 | main | 681 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::GoldNugget do
describe "#as_conversation" do
it "returns the gold nugget content with the author name and link" do
author = TestFactories.create_author(name: "Matz", id: "the-ruby-matz", link: "https://example.com/matz")
g... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/slack/client_spec.rb | Ruby | mit | 45 | main | 10,461 | # frozen_string_literal: true
RSpec.describe GoldMiner::Slack::Client do
describe ".build" do
it "returns a success monad if api_token is valid" do
token = "valid-token"
stub_slack_auth_test_request(status: 200, token: token)
result = GoldMiner::Slack::Client.build(api_token: token)
exp... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/slack/message_spec.rb | Ruby | mit | 45 | main | 545 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::Slack::Message do
describe "#[]" do
it "returns the message attribute" do
user = TestFactories.create_slack_user
message = described_class.new(
id: "message-1",
text: "TIL",
user: user,
perm... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/blog_post/simple_writer_spec.rb | Ruby | mit | 45 | main | 1,638 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::BlogPost::SimpleWriter do
it_behaves_like "a blog post writer" do
let(:writer_instance) { described_class.new }
end
describe "#extract_topics_from" do
it "delegates to the topic extractor" do
topics = ["topic-#{rand}"]
... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/blog_post/open_ai_writer_spec.rb | Ruby | mit | 45 | main | 12,785 | # frozen_string_literal: true
require "json"
RSpec.describe GoldMiner::BlogPost::OpenAiWriter do
it_behaves_like "a blog post writer" do
let(:writer_instance) do
described_class.new(
open_ai_api_token: "token",
fallback_writer: double("fallback_writer")
)
end
end
describe "#... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/blog_post/writer_spec.rb | Ruby | mit | 45 | main | 716 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::BlogPost::Writer do
describe ".from_env" do
context "when OPEN_AI_API_TOKEN env var is set" do
it "returns an OpenAI writer" do
with_env("OPEN_AI_API_TOKEN" => "test-token") do
writer = described_class.from_env... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | spec/gold_miner/blog_post/simple_writer/topic_extractor_spec.rb | Ruby | mit | 45 | main | 1,872 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe GoldMiner::BlogPost::SimpleWriter::TopicExtractor do
describe "#call" do
it "extracts topics from a message text" do
message = <<~MARKDOWN
TIL: a message about ruby and elixir, javascript, typescript, sql
refactoring, testi... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner.rb | Ruby | mit | 45 | main | 772 | # frozen_string_literal: true
require "dry/monads"
require "zeitwerk"
Zeitwerk::Loader.for_gem.setup
class GoldMiner
include Dry::Monads[:result]
def initialize(explorer:, smith:, distributor:, env_file: ".env")
@explorer = explorer
@smith = smith
@distributor = distributor
@env_file = env_file
... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/slack_explorer.rb | Ruby | mit | 45 | main | 1,699 | require "async"
class GoldMiner
class SlackExplorer
def initialize(slack_client, author_config)
@slack = slack_client
@author_config = author_config
end
def explore(channel, start_on:)
start_on = Date.parse(start_on.to_s)
interesting_messages = interesting_messages_query(channel,... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/helpers.rb | Ruby | mit | 45 | main | 555 | class GoldMiner
module Helpers
module Time
def self.pretty_date(date)
date.strftime("%b %-d, %Y")
end
def self.last_friday
Enumerator.produce(Date.today - 1, &:prev_day).find(&:friday?).to_s
end
end
module Sentence
def self.from(words)
case words.siz... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/gold_nugget.rb | Ruby | mit | 45 | main | 274 | # frozen_string_literal: true
class GoldMiner
GoldNugget = Data.define(:content, :author, :source) do
def as_conversation
<<~MARKDOWN
#{author.name_with_link_reference} says: #{content}
#{author.reference_link}
MARKDOWN
end
end
end |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/author.rb | Ruby | mit | 45 | main | 256 | # frozen_string_literal: true
class GoldMiner
Author = Data.define(:id, :name, :link) do
alias_method :to_s, :name
def name_with_link_reference
"[#{name}][#{id}]"
end
def reference_link
"[#{id}]: #{link}"
end
end
end |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/author_config.rb | Ruby | mit | 45 | main | 503 | # frozen_string_literal: true
require "yaml"
class GoldMiner
class AuthorConfig
DEFAULT_AUTHOR_LINK = "#to-do"
DEFAULT_CONFIG_PATH = "lib/config/author_config.yml"
def self.default
YAML
.load_file(DEFAULT_CONFIG_PATH)
.then { |links| new(links) }
end
def initialize(author... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/blog_post.rb | Ruby | mit | 45 | main | 2,418 | # frozen_string_literal: true
require "async"
class GoldMiner
class BlogPost
def initialize(slack_channel:, gold_nuggets:, since:, writer: SimpleWriter.new)
@slack_channel = slack_channel
@gold_nuggets = gold_nuggets
@since = since
@writer = writer
end
def to_s
Sync do
... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/blog_post_smith.rb | Ruby | mit | 45 | main | 481 | class GoldMiner
class BlogPostSmith
def initialize(blog_post_class: BlogPost, blog_post_writer: BlogPost::Writer.from_env)
@blog_post_class = blog_post_class
@blog_post_writer = blog_post_writer
end
def smith(gold_container)
@blog_post_class.new(
slack_channel: gold_container.or... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/blog_post/open_ai_writer.rb | Ruby | mit | 45 | main | 2,432 | # frozen_string_literal: true
require "openai"
require "json"
class GoldMiner
class BlogPost
class OpenAiWriter
def initialize(open_ai_api_token:, fallback_writer:, open_ai_client: OpenAI::Client)
@openai_client = open_ai_client.new(access_token: open_ai_api_token)
@fallback_writer = fallb... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/blog_post/writer.rb | Ruby | mit | 45 | main | 428 | # frozen_string_literal: true
class GoldMiner
class BlogPost
module Writer
def self.from_env
if ENV["OPEN_AI_API_TOKEN"]
GoldMiner::BlogPost::OpenAiWriter.new(
open_ai_api_token: ENV["OPEN_AI_API_TOKEN"],
fallback_writer: GoldMiner::BlogPost::SimpleWriter.new
... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/blog_post/simple_writer.rb | Ruby | mit | 45 | main | 464 | # frozen_string_literal: true
class GoldMiner
class BlogPost
class SimpleWriter
def initialize(topic_extractor: TopicExtractor)
@topic_extractor = topic_extractor
end
def extract_topics_from(gold_nugget)
@topic_extractor.call(gold_nugget.content)
end
def give_title... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/blog_post/simple_writer/topic_extractor.rb | Ruby | mit | 45 | main | 1,741 | class GoldMiner
class BlogPost
class SimpleWriter
module TopicExtractor
LANGUAGE_MATCHERS = {
"Ruby" => ["ruby", "ruby on rails"],
"Elixir" => ["elixir"],
"JavaScript" => ["javascript", "js", "node", "nodejs", "yarn", "npm"],
"TypeScript" => ["typescript", "ts... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/slack/client.rb | Ruby | mit | 45 | main | 2,443 | # frozen_string_literal: true
require "slack-ruby-client"
class GoldMiner
class Slack::Client
extend Dry::Monads[:result]
def self.build(api_token:, slack_client: ::Slack::Web::Client)
client = new(api_token, slack_client)
begin
client.auth_test
Success(client)
rescue ::... |
github | thoughtbot/gold_miner | https://github.com/thoughtbot/gold_miner | lib/gold_miner/slack/messages_query.rb | Ruby | mit | 45 | main | 1,081 | class GoldMiner
module Slack
class MessagesQuery
attr_reader :channel, :start_date, :topic, :reaction
def initialize(channel: nil, start_date: nil, topic: nil, reaction: nil)
@channel = channel
@start_date = start_date
@topic = topic
@reaction = reaction
end
... |
github | erithmetic/nodeify | https://github.com/erithmetic/nodeify | Rakefile | Ruby | mit | 45 | master | 1,576 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specificati... |
github | erithmetic/nodeify | https://github.com/erithmetic/nodeify | nodeify.gemspec | Ruby | mit | 45 | master | 824 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require 'nodeify/version'
Gem::Specification.new do |s|
s.name = 'nodeify'
s.version = Nodeify::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Derek Kastner']
s.email = ['dkastner+nodeify@gmail.com']
s.ho... |
github | erithmetic/nodeify | https://github.com/erithmetic/nodeify | spec/spec_helper.rb | Ruby | mit | 45 | master | 357 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'nodeify'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}... |
github | erithmetic/nodeify | https://github.com/erithmetic/nodeify | spec/nodeify/java_script_spec.rb | Ruby | mit | 45 | master | 360 | require 'spec_helper'
require 'sprockets'
describe Nodeify::JavaScript do
let(:env) { Sprockets::Environment.new }
describe '#build_source' do
it 'returns a hash with source, length, and digest' do
js = Nodeify::JavaScript.new 'spec/fixtures/application.js'
source = js.render(env, {})
source... |
github | erithmetic/nodeify | https://github.com/erithmetic/nodeify | lib/generators/nodeify/install_generator.rb | Ruby | mit | 45 | master | 492 | require 'rails/generators'
module Nodeify
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)
desc 'Install nodeify'
def create_app_file
inside 'vendor/assets/javascripts' do
copy_file 'package.json'
... |
github | erithmetic/nodeify | https://github.com/erithmetic/nodeify | lib/nodeify/rails.rb | Ruby | mit | 45 | master | 390 | require 'generators/nodeify/install_generator'
require 'nodeify/java_script'
require 'sprockets'
require 'rails'
module Nodeify
class Rails < Rails::Railtie
initializer "nodeify.sprockets.environment" do |app|
app.assets.unregister_processor 'application/javascript', Sprockets::DirectiveProcessor
ap... |
github | erithmetic/nodeify | https://github.com/erithmetic/nodeify | lib/nodeify/java_script.rb | Ruby | mit | 45 | master | 492 | require 'sprockets'
require 'fileutils'
module Nodeify
class JavaScript < Sprockets::DirectiveProcessor
def evaluate(context, options, &blk)
super
file_path = file + '.tmp'
File.open(file_path, 'w') { |f| f.puts @result }
@result = `node -e "var browserify = require('browserify'), _ = pr... |
github | slack-ruby/slack-bot-on-rails | https://github.com/slack-ruby/slack-bot-on-rails | config.ru | Ruby | mit | 45 | master | 267 | # This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require ::File.expand_path('../bot/bot', __FILE__)
Thread.abort_on_exception = true
Thread.new do
Bot.run
end
run Rails.application |
github | slack-ruby/slack-bot-on-rails | https://github.com/slack-ruby/slack-bot-on-rails | Gemfile | Ruby | mit | 45 | master | 1,662 | source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeSc... |
github | slack-ruby/slack-bot-on-rails | https://github.com/slack-ruby/slack-bot-on-rails | bot/bot.rb | Ruby | mit | 45 | master | 267 | class Bot < SlackRubyBot::Bot
@id = 0
def self.next_id
@id = @id % 10 + 1
end
command 'say' do |client, data, match|
Rails.cache.write next_id, { text: match['expression'] }
client.say(channel: data.channel, text: match['expression'])
end
end |
github | slack-ruby/slack-bot-on-rails | https://github.com/slack-ruby/slack-bot-on-rails | config/application.rb | Ruby | mit | 45 | master | 1,455 | require File.expand_path('../boot', __FILE__)
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# requi... |
github | bboe/dolphin | https://github.com/bboe/dolphin | Gemfile | Ruby | bsd-2-clause | 45 | main | 1,140 | # frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'
# Use postgresql as the datab... |
github | bboe/dolphin | https://github.com/bboe/dolphin | config/application.rb | Ruby | bsd-2-clause | 45 | main | 799 | # frozen_string_literal: true
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module DolphinApp
class Application < Rails::Application
# Initialize configuration default... |
github | bboe/dolphin | https://github.com/bboe/dolphin | config/routes.rb | Ruby | bsd-2-clause | 45 | main | 372 | # frozen_string_literal: true
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
devise_for(:users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' })
get 'blacklisted', to: 'application#blacklisted'
resources :d... |
github | bboe/dolphin | https://github.com/bboe/dolphin | config/puma.rb | Ruby | bsd-2-clause | 45 | main | 1,585 | # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches... |
github | bboe/dolphin | https://github.com/bboe/dolphin | config/initializers/session_store.rb | Ruby | bsd-2-clause | 45 | main | 368 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
if Rails.env.production?
Rails.application.config.session_store :cookie_store, domain: "dolphinfolio.com", expire_after: 9999.days, key: '_dolphin_session'
else
Rails.application.config.session_store :cookie_store, expir... |
github | bboe/dolphin | https://github.com/bboe/dolphin | config/initializers/devise.rb | Ruby | bsd-2-clause | 45 | main | 12,711 | # frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render inv... |
github | bboe/dolphin | https://github.com/bboe/dolphin | config/environments/production.rb | Ruby | bsd-2-clause | 45 | main | 5,059 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | bboe/dolphin | https://github.com/bboe/dolphin | lib/tasks/db.rake | Ruby | bsd-2-clause | 45 | main | 247 | # frozen_string_literal: true
namespace :db do
desc 'Update sent and received counts on users'
task recount: :environment do
User.all.each do |user|
User.reset_counters(user.id, :dolphins_sent, :dolphins_received)
end
end
end |
github | bboe/dolphin | https://github.com/bboe/dolphin | app/models/dolphin.rb | Ruby | bsd-2-clause | 45 | main | 1,199 | # frozen_string_literal: true
class Dolphin < ApplicationRecord
belongs_to :from, class_name: :User, counter_cache: :from_count
belongs_to :to, class_name: :User, counter_cache: :to_count
validates :from, :to, presence: { message: 'invalid user' }
validates :source, presence: true
validate :dolphin_yoursel... |
github | bboe/dolphin | https://github.com/bboe/dolphin | app/models/user.rb | Ruby | bsd-2-clause | 45 | main | 547 | # frozen_string_literal: true
class User < ApplicationRecord
devise :omniauthable, omniauth_providers: [:google_oauth2]
validates :email, :name, :image_url, :provider, :uid, presence: true
validates :email, uniqueness: true
validates :nickname, allow_nil: true, presence: true, uniqueness: true
validates :ui... |
github | bboe/dolphin | https://github.com/bboe/dolphin | app/helpers/application_helper.rb | Ruby | bsd-2-clause | 45 | main | 384 | # frozen_string_literal: true
module ApplicationHelper
STOCK_IMAGE_URL = 'https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=50'
def display_user(user)
path = user.image_url == STOCK_IMAGE_URL ? image_path('dolphin.png') : user.image_url
safe_join([image_tag(pa... |
github | bboe/dolphin | https://github.com/bboe/dolphin | app/controllers/dolphins_controller.rb | Ruby | bsd-2-clause | 45 | main | 1,834 | # frozen_string_literal: true
class DolphinsController < AuthenticatedController
before_action :check_params, only: :create
def index
load_index_variables(params: params)
end
def create
from = User.find_by(email: domained_email(params[:dolphin][:from]))
from ||= User.find_by(nickname: params[:dol... |
github | bboe/dolphin | https://github.com/bboe/dolphin | app/controllers/application_controller.rb | Ruby | bsd-2-clause | 45 | main | 440 | # frozen_string_literal: true
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def blacklisted
render 'blacklisted', layout: false
end
def ip_address
re... |
github | bboe/dolphin | https://github.com/bboe/dolphin | app/controllers/users/omniauth_callbacks_controller.rb | Ruby | bsd-2-clause | 45 | main | 1,382 | # frozen_string_literal: true
module Users
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
FAILURE_PATH = 'https://www.google.com'
def after_omniauth_failure_path_for(_scope)
FAILURE_PATH
end
def google_oauth2
access_token = request.env['omniauth.auth']
dom... |
github | bboe/dolphin | https://github.com/bboe/dolphin | db/schema.rb | Ruby | bsd-2-clause | 45 | main | 2,431 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
#... |
github | bboe/dolphin | https://github.com/bboe/dolphin | db/seeds.rb | Ruby | bsd-2-clause | 45 | main | 808 | # frozen_string_literal: true
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
... |
github | bboe/dolphin | https://github.com/bboe/dolphin | db/migrate/20150313031328_change_dolphin_to_store_user_relations.rb | Ruby | bsd-2-clause | 45 | main | 629 | # frozen_string_literal: true
class ChangeDolphinToStoreUserRelations < ActiveRecord::Migration[4.2]
def change
reversible do |dir|
dir.up { execute('TRUNCATE dolphins') }
end
remove_column :dolphins, :from, :string, null: false
remove_column :dolphins, :to, :string, null: false
add_refer... |
github | bboe/dolphin | https://github.com/bboe/dolphin | db/migrate/20150312234743_devise_create_users.rb | Ruby | bsd-2-clause | 45 | main | 495 | # frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[4.2]
def change
create_table(:users) do |t|
# General
t.string :name, null: false
t.string :email, null: false
t.string :image_url, null: false
# Omniauthable
t.string :provider, null: false
... |
github | bboe/dolphin | https://github.com/bboe/dolphin | db/migrate/20150313141735_add_counter_cache_to_users.rb | Ruby | bsd-2-clause | 45 | main | 319 | # frozen_string_literal: true
class AddCounterCacheToUsers < ActiveRecord::Migration[4.2]
def change
add_column :users, :from_count, :integer, null: false, default: 0
add_column :users, :to_count, :integer, null: false, default: 0
add_index :users, :from_count
add_index :users, :to_count
end
end |
github | bboe/dolphin | https://github.com/bboe/dolphin | db/migrate/20200218213348_add_authentication_blacklist.rb | Ruby | bsd-2-clause | 45 | main | 206 | class AddAuthenticationBlacklist < ActiveRecord::Migration[6.0]
def change
create_table(:blacklisted_emails) do |t|
t.string :email, null: false
t.timestamps null: false
end
end
end |
github | bboe/dolphin | https://github.com/bboe/dolphin | db/migrate/20150312215109_create_dolphins.rb | Ruby | bsd-2-clause | 45 | main | 282 | # frozen_string_literal: true
class CreateDolphins < ActiveRecord::Migration[4.2]
def change
create_table :dolphins do |t|
t.string :from, null: false
t.string :to, null: false
t.string :source, null: false
t.timestamps null: false
end
end
end |
github | bboe/dolphin | https://github.com/bboe/dolphin | test/test_helper.rb | Ruby | bsd-2-clause | 45 | main | 1,073 | # frozen_string_literal: true
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
require 'rails/test_help'
require 'minitest/unit'
require 'mocha/minitest'
module ActiveSupport
class TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
... |
github | bboe/dolphin | https://github.com/bboe/dolphin | test/models/dolphin_test.rb | Ruby | bsd-2-clause | 45 | main | 4,748 | # frozen_string_literal: true
require 'test_helper'
require_relative 'user_test'
class DolphinTest < ActiveSupport::TestCase
test 'dolphin time limit' do
(user1 = new_user).save!
(user2 = new_user(email: 'user2@test', uid: 2)).save!
(user3 = new_user(email: 'user3@test', uid: 3)).save!
new_dolphin(f... |
github | bboe/dolphin | https://github.com/bboe/dolphin | test/models/user_test.rb | Ruby | bsd-2-clause | 45 | main | 2,769 | # frozen_string_literal: true
require 'test_helper'
class UserTest < ActiveSupport::TestCase
test 'user destroys when has been dolphined' do
(user1 = new_user).save!
(user2 = new_user(email: 'user2@test', uid: 2)).save!
new_dolphin(from: user2, to: user1).save!
assert_predicate user1, :destroy
en... |
github | bboe/dolphin | https://github.com/bboe/dolphin | test/controllers/omniauth_callbacks_controller_test.rb | Ruby | bsd-2-clause | 45 | main | 2,148 | # frozen_string_literal: true
require 'test_helper'
class OmniAuthCallbacksControllerTest < ActionDispatch::IntegrationTest
test 'should get google_oauth2 callback when allowing all domains' do
mock_omniauth
begin
previous_setting = Rails.configuration.google_client_domain_list
Rails.configurat... |
github | bboe/dolphin | https://github.com/bboe/dolphin | test/controllers/dolphins_controller_test.rb | Ruby | bsd-2-clause | 45 | main | 2,559 | # frozen_string_literal: true
require 'test_helper'
class DolphinsControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
test 'should get index' do
login
get root_path
assert_response :ok
end
test 'should get index when not logged in' do
get root_path
... |
github | platanus/power_api | https://github.com/platanus/power_api | Guardfile | Ruby | mit | 45 | master | 730 | guard :rspec, cmd: "bundle exec rspec" do
spec_dic = "spec/dummy/spec"
# RSpec files
watch("spec/spec_helper.rb") { spec_dic }
watch("spec/rails_helper.rb") { spec_dic }
watch(%r{^spec\/dummy\/spec\/support\/(.+)\.rb$}) { spec_dic }
watch(%r{^spec\/dummy\/spec\/.+_spec\.rb$})
# Engine files
watch(%r{^li... |
github | platanus/power_api | https://github.com/platanus/power_api | power_api.gemspec | Ruby | mit | 45 | master | 1,680 | $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem"s version:
require "power_api/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "power_api"
s.version = PowerApi::VERSION
s.authors = ["Platanus", "Leandro Segovia"]
s.email ... |
github | platanus/power_api | https://github.com/platanus/power_api | Gemfile | Ruby | mit | 45 | master | 597 | source 'https://rubygems.org'
# Declare your gem's dependencies in power_api.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... |
github | platanus/power_api | https://github.com/platanus/power_api | Rakefile | Ruby | mit | 45 | master | 300 | 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", __FILE__)
load "rails/tasks/engine.rake"
load "rails/tasks/statistics.rake"
Bundler::GemHelper.install_tasks |
github | platanus/power_api | https://github.com/platanus/power_api | spec/spec_helper.rb | Ruby | mit | 45 | master | 245 | RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end |
github | platanus/power_api | https://github.com/platanus/power_api | spec/rails_helper.rb | Ruby | mit | 45 | master | 1,416 | require 'simplecov'
require 'coveralls'
formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter::new(formatters)
SimpleCov.start do
add_filter do |src|
r = [
src.filename =~ /lib/,
src.filename =~ /models/,
... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/config/application.rb | Ruby | mit | 45 | master | 666 | require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require "power_api"
module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f
... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/config/environments/development.rb | Ruby | mit | 45 | master | 2,774 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for developme... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/config/initializers/api_pagination.rb | Ruby | mit | 45 | master | 1,174 | ApiPagination.configure do |config|
# If you have more than one gem included, you can choose a paginator.
config.paginator = :kaminari
# By default, this is set to 'Total'
config.total_header = 'X-Total'
# By default, this is set to 'Per-Page'
config.per_page_header = 'X-Per-Page'
# Optional: set this ... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/db/schema.rb | Ruby | mit | 45 | master | 1,460 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/db/migrate/20200227150449_create_portfolios.rb | Ruby | mit | 45 | master | 206 | class CreatePortfolios < ActiveRecord::Migration[5.2]
def change
create_table :portfolios do |t|
t.string :name
t.references :user, foreign_key: true
t.timestamps
end
end
end |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/simple_token_auth_helper_spec.rb | Ruby | mit | 45 | master | 6,370 | RSpec.describe PowerApi::GeneratorHelper::SimpleTokenAuthHelper, type: :generator do
describe "#authenticated_resource" do
let(:authenticated_resource) { "blog" }
let(:resource) { generators_helper.authenticated_resource }
it_behaves_like('ActiveRecord resource') do
describe "#authenticated_resourc... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/controller_actions_helper_spec.rb | Ruby | mit | 45 | master | 5,320 | RSpec.describe PowerApi::GeneratorHelper::ControllerActionsHelper, type: :generator do
describe '#controller_actions=' do
context 'when arg is nil' do
before { generators_helper.controller_actions = nil }
it do
expect(generators_helper.controller_actions).to(
match_array(generators_... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/controller_helper_spec.rb | Ruby | mit | 45 | master | 12,817 | describe PowerApi::GeneratorHelper::ControllerHelper, type: :generator do
describe "#api_main_base_controller_path" do
let(:expected_path) { "app/controllers/api/base_controller.rb" }
def perform
generators_helper.api_main_base_controller_path
end
it { expect(perform).to eq(expected_path) }
... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/pagination_helper_spec.rb | Ruby | mit | 45 | master | 1,964 | RSpec.describe PowerApi::GeneratorHelper::PaginationHelper, type: :generator do
describe "#api_pagination_initializer_path" do
let(:expected_path) { "config/initializers/api_pagination.rb" }
def perform
generators_helper.api_pagination_initializer_path
end
it { expect(perform).to eq(expected_p... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/api_helper_spec.rb | Ruby | mit | 45 | master | 2,597 | RSpec.describe PowerApi::GeneratorHelper::ApiHelper, type: :generator do
describe "#version_number" do
def perform
generators_helper.version_number
end
it { expect(perform).to eq(1) }
end
describe "version_number=" do
context "with invalid version number" do
let(:version_number) { "A... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/rspec_controller_helper_spec.rb | Ruby | mit | 45 | master | 13,578 | describe PowerApi::GeneratorHelper::RspecControllerHelper, type: :generator do
describe "#resource_spec_path" do
let(:expected_path) { "spec/requests/api/exposed/v1/blogs_spec.rb" }
def perform
generators_helper.resource_spec_path
end
it { expect(perform).to eq(expected_path) }
context "w... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/resource_helper_spec.rb | Ruby | mit | 45 | master | 801 | RSpec.describe PowerApi::GeneratorHelper::ResourceHelper, type: :generator do
describe "#resource" do
let(:resource) { generators_helper.resource }
it_behaves_like('ActiveRecord resource')
it_behaves_like('ActiveRecord resource attributes', :resource_attributes)
end
describe "#parent_resource" do
... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/routes_helper_spec.rb | Ruby | mit | 45 | master | 4,917 | RSpec.describe PowerApi::GeneratorHelper::RoutesHelper, type: :generator do
describe "#routes_path" do
let(:expected_path) { "config/routes.rb" }
def perform
generators_helper.routes_path
end
it { expect(perform).to eq(expected_path) }
end
describe "#api_current_route_namespace_line_regex... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/lib/power_api/generator_helper/ams_helper_spec.rb | Ruby | mit | 45 | master | 2,681 | RSpec.describe PowerApi::GeneratorHelper::AmsHelper, type: :generator do
describe "#ams_initializer_path" do
let(:expected_path) { "config/initializers/active_model_serializers.rb" }
def perform
generators_helper.ams_initializer_path
end
it { expect(perform).to eq(expected_path) }
end
des... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/support/test_helpers.rb | Ruby | mit | 45 | master | 266 | module TestHelpers
extend ActiveSupport::Concern
included do
def mock_file_content(expected_path, content_lines)
allow(File).to receive(:readlines).with(
File.join(Rails.root, expected_path)
).and_return(content_lines)
end
end
end |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/support/test_generator_helpers.rb | Ruby | mit | 45 | master | 981 | module TestGeneratorHelpers
extend ActiveSupport::Concern
included do
subject(:generators_helper) { PowerApi::GeneratorHelpers.new(init_params) }
let(:version_number) { "1" }
let(:resource_name) { "blog" }
let(:authenticated_resource) { nil }
let(:parent_resource_name) { nil }
let(:owned_b... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/support/shared_examples/active_record_resource.rb | Ruby | mit | 45 | master | 1,942 | shared_examples 'ActiveRecord resource' do
describe "#id" do
def perform
resource.id
end
it { expect(perform).to eq("blog_id") }
end
describe "#upcase" do
def perform
resource.upcase
end
it { expect(perform).to eq("BLOG") }
end
describe "#upcase_plural" do
def perfo... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/support/shared_examples/active_record_resource_atrributes.rb | Ruby | mit | 45 | master | 4,945 | # rubocop:disable Metrics/LineLength
shared_examples 'ActiveRecord resource attributes' do |attributes_key|
describe "#resource_attributes" do
let(:expected_attributes) do
[
{ name: :id, type: :integer, example: kind_of(Integer), required: false },
{ name: :title, type: :string, example: "'S... |
github | platanus/power_api | https://github.com/platanus/power_api | spec/dummy/spec/helpers/power_api/application_helper_spec.rb | Ruby | mit | 45 | master | 4,689 | require "spec_helper"
describe PowerApi::ApplicationHelper do
describe "#serialize_resource" do
let(:resource) do
build(
:blog,
id: 1,
title: "T",
portfolio_id: 2,
body: "B",
created_at: "2022-01-28T20:30:00.000Z",
updated_at: "2022-01-28T20:40:00.000... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.