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 | monkrb/glue | https://github.com/monkrb/glue | lib/monk/glue/settings.rb | Ruby | mit | 19 | master | 325 | require 'yaml'
def monk_settings(key)
$monk_settings ||= YAML.load_file(root_path("config", "settings.yml"))[RACK_ENV.to_sym]
unless $monk_settings.include?(key)
message = "No setting defined for #{key.inspect}."
defined?(logger) ? logger.warn(message) : $stderr.puts(message)
end
$monk_settings[key]
... |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | cuba-contrib.gemspec | Ruby | mit | 19 | master | 612 | Gem::Specification.new do |s|
s.name = "cuba-contrib"
s.version = "3.1.0"
s.summary = "Cuba plugins and utilities."
s.description = "Includes various helper tools for Cuba."
s.authors = ["Cyril David"]
s.email = ["me@cyrildavid.com"]
s.homepage ... |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | lib/cuba/with.rb | Ruby | mit | 19 | master | 224 | class Cuba
module With
def with(dict = {})
old, env["cuba.vars"] = vars, vars.merge(dict)
yield
ensure
env["cuba.vars"] = old
end
def vars
env["cuba.vars"] ||= {}
end
end
end |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | lib/cuba/prelude.rb | Ruby | mit | 19 | master | 220 | require "uri"
class Cuba
module Prelude
def urlencode(str)
URI.encode_www_form_component(str)
end
def escape_html(str)
Rack::Utils.escape_html(str)
end
alias :h :escape_html
end
end |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | lib/cuba/mote.rb | Ruby | mit | 19 | master | 1,290 | require "mote"
class Cuba
module Mote
include ::Mote::Helpers
def self.setup(app)
app.settings[:mote] ||= {}
app.settings[:mote][:views] ||= File.expand_path("views", Dir.pwd)
app.settings[:mote][:layout] ||= "layout"
end
def partial(template, locals = {})
mote(mote_path(te... |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | lib/cuba/text_helpers.rb | Ruby | mit | 19 | master | 848 | class Cuba
module TextHelpers
def markdown(str)
Markdown.new(str).to_html
end
def truncate(str, length, ellipses = "...")
return str if !str || str.length <= length
sprintf("%.#{length}s#{ellipses}", str)
end
def nl2br(str)
str.to_s.gsub(/\n|\r\n/, "<br>")
end
d... |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | test/text_helpers.rb | Ruby | mit | 19 | master | 1,238 | # encoding: utf-8
require_relative "helper"
setup do
obj = Object.new
obj.extend Cuba::TextHelpers
end
test "truncate" do |helper|
assert_equal "the q...", helper.truncate("the quick brown", 5)
assert_equal "same string", helper.truncate("same string", 11)
end
test "markdown" do |helper|
require "blueclo... |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | test/mote.rb | Ruby | mit | 19 | master | 2,748 | require_relative "helper"
test "doesn't override already existing settings" do
Cuba.settings[:mote] ||= {}
Cuba.settings[:mote][:views] = "./templates"
Cuba.settings[:mote][:layout] = "guest"
Cuba.plugin Cuba::Mote
assert_equal "./templates", Cuba.settings[:mote][:views]
assert_equal "guest", Cuba.settin... |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | test/with.rb | Ruby | mit | 19 | master | 875 | require_relative "helper"
Cuba.plugin Cuba::With
test do
class UserPhotos < Cuba
define do
on root do
res.write "uid: %d" % vars[:user_id]
res.write "site: %s" % vars[:site]
end
end
end
class Photos < Cuba
define do
on ":id/photos" do |id|
with user_id: id ... |
github | cyx/cuba-contrib | https://github.com/cyx/cuba-contrib | test/helper.rb | Ruby | mit | 19 | master | 218 | $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
require "cuba"
require "cuba/contrib"
def assert_response(body, expected)
arr = []
body.each { |line| arr << line }
assert_equal arr, expected
end |
github | technicalpickles/capistrano-campfire | https://github.com/technicalpickles/capistrano-campfire | Rakefile | Ruby | mit | 19 | master | 1,403 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "capistrano-campfire"
gem.summary = %Q{Post to Campfire from capistrano}
gem.description = %Q{ capistrano-tinder is a very simple library for making a Campfire room accessible from capistrano. All it does i... |
github | technicalpickles/capistrano-campfire | https://github.com/technicalpickles/capistrano-campfire | capistrano-campfire.gemspec | Ruby | mit | 19 | master | 2,186 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "capistrano-campfire"
s.version = "0.2.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requi... |
github | technicalpickles/capistrano-campfire | https://github.com/technicalpickles/capistrano-campfire | spec/spec_helper.rb | Ruby | mit | 19 | master | 247 | $LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'capistrano/campfire'
require 'spec'
require 'spec/autorun'
require 'capistrano/spec'
Spec::Runner.configure do |config|
end |
github | technicalpickles/capistrano-campfire | https://github.com/technicalpickles/capistrano-campfire | spec/capistrano-campfire_spec.rb | Ruby | mit | 19 | master | 5,245 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Capistrano::Campfire do
let :configuration do
config = Capistrano::Configuration.new
config.extend(Capistrano::Spec::ConfigurationExtension)
config.extend(Capistrano::Campfire)
config
end
context "loaded into a configur... |
github | technicalpickles/capistrano-campfire | https://github.com/technicalpickles/capistrano-campfire | lib/capistrano/campfire.rb | Ruby | mit | 19 | master | 2,014 | require 'capistrano'
require 'tinder'
module Capistrano
module Campfire
class RoomCollection
def initialize(campfire_options)
rooms_options = campfire_options[:rooms]
# if no rooms specified, let's assume the campfire_options has everything
# so let's fake it
unless rooms_o... |
github | junegunn/ansi256 | https://github.com/junegunn/ansi256 | ansi256.gemspec | Ruby | mit | 19 | master | 974 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ansi256/version'
Gem::Specification.new do |spec|
spec.name = "ansi256"
spec.version = Ansi256::VERSION
spec.authors = ["Junegunn Choi"]
spec.email = ["junegu... |
github | junegunn/ansi256 | https://github.com/junegunn/ansi256 | test/test_ansi256.rb | Ruby | mit | 19 | master | 13,134 | # frozen_string_literal: true
$VERBOSE = true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'ansi256'
require 'minitest/autorun'
class TestAnsi256 < Minitest::Test
def cfmt(col)
col.to_s.rjust(5).fg(232).bg(col)
end
# TODO: assertions :p
def test_256_color_table
puts (0..7).map { |... |
github | junegunn/ansi256 | https://github.com/junegunn/ansi256 | lib/ansi256.rb | Ruby | mit | 19 | master | 7,652 | # frozen_string_literal: true
require 'set'
require 'ansi256/version'
require 'ansi256/code'
require 'ansi256/mixin'
module Ansi256
class << self
attr_accessor :truecolor
def fg(code, str = nil)
if str
wrap str, Ansi256.fg(code)
elsif NAMED_COLORS.include?(code)
"\e[#{CODE[code]... |
github | junegunn/ansi256 | https://github.com/junegunn/ansi256 | lib/ansi256/code.rb | Ruby | mit | 19 | master | 665 | module Ansi256
CODE = {
reset: 0,
bold: 1,
dim: 2,
italic: 3,
underline: 4,
inverse: 7,
strikethrough: 9,
black: 30,
red: 31,
green: 32,
yellow: 33,
blue: 34,
magenta: 35,
cyan: 36,
white: 37,
on_black: 40,
on_red: 41,
on_green: 42,
on_yell... |
github | junegunn/ansi256 | https://github.com/junegunn/ansi256 | lib/ansi256/mixin.rb | Ruby | mit | 19 | master | 2,062 | # frozen_string_literal: true
module Ansi256
class << self
def enabled= bool
if bool
String.class_eval do
[:fg, :bg, :plain].each do |name|
undef_method(name) if method_defined?(name)
end
def fg code
Ansi256.fg(code, self)
end
... |
github | intercom/requisite | https://github.com/intercom/requisite | Rakefile | Ruby | apache-2.0 | 19 | master | 268 | require 'bundler/gem_tasks'
require 'rake/testtask'
require "bundler"
Bundler.require
Rake::TestTask.new('test') do |test|
test.libs << 'lib'
test.libs << 'test'
test.test_files = FileList['test/**/*_test.rb']
test.warning = false
test.verbose = true
end |
github | intercom/requisite | https://github.com/intercom/requisite | requisite.gemspec | Ruby | apache-2.0 | 19 | master | 987 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'requisite/version'
Gem::Specification.new do |gem|
gem.name = 'requisite'
gem.version = Requisite::VERSION
gem.authors = ['James Osler']
gem.email =... |
github | intercom/requisite | https://github.com/intercom/requisite | lib/requisite.rb | Ruby | apache-2.0 | 19 | master | 223 | require 'requisite/version'
require 'requisite/boundary_object'
require 'requisite/boolean'
require 'requisite/api_model'
require 'requisite/bad_request_error'
require 'requisite/bad_type_error'
require 'action_controller' |
github | intercom/requisite | https://github.com/intercom/requisite | lib/requisite/boundary_object.rb | Ruby | apache-2.0 | 19 | master | 2,549 | module Requisite
class BoundaryObject
class << self
def attribute(name, options={})
attribute_keys << name
define_method(name) do
resolved_name = options[:rename] || name
result = self.send(:convert, resolved_name)
result = self.send(:parse_typed_hash, resolved_... |
github | intercom/requisite | https://github.com/intercom/requisite | lib/requisite/api_model.rb | Ruby | apache-2.0 | 19 | master | 2,905 | require 'json'
module Requisite
class ApiModel < BoundaryObject
attr_reader :model
def initialize(model={})
@model = case model
when ActionController::Parameters
Hash[model.to_unsafe_h.map { |k, v| [k.to_sym, v] }]
when Hash
Hash[model.map { |k, v| [k.to_sym, v] }]
el... |
github | intercom/requisite | https://github.com/intercom/requisite | lib/requisite/bad_type_error.rb | Ruby | apache-2.0 | 19 | master | 209 | module Requisite
class BadTypeError < StandardError
attr_accessor :message
def initialize(value, desired_class)
@message = "Value: #{value} not of type #{desired_class}"
end
end
end |
github | intercom/requisite | https://github.com/intercom/requisite | test/requisite/api_user_test.rb | Ruby | apache-2.0 | 19 | master | 5,742 | require 'test_helper'
require 'benchmark'
# Example Object
class ApiUser < Requisite::ApiModel
serialized_attributes do
attribute :id, type: String
attribute :user_id
attribute :email, type: String
attribute :name, type: String
attribute :created_at, type: Integer
attribute :last_seen_user_ag... |
github | intercom/requisite | https://github.com/intercom/requisite | test/requisite/api_model_test.rb | Ruby | apache-2.0 | 19 | master | 13,838 | require 'test_helper'
module Requisite
class DummyApiModel < Requisite::ApiModel
end
describe ApiModel do
it 'creates methods from serialized_attributes block' do
DummyApiModel.serialized_attributes { attribute :a; attribute :b }
response = DummyApiModel.new
def response.a; 'A'; end
... |
github | intercom/requisite | https://github.com/intercom/requisite | test/requisite/api_event_test.rb | Ruby | apache-2.0 | 19 | master | 840 | require 'test_helper'
## Example Object
class ApiEvent < Requisite::ApiModel
serialized_attributes do
attribute! :event_name, type: String
attribute :id, type: String
attribute :user_id, type: String
attribute :email, type: String
attribute :metadata, scalar_hash: true
end
end
module Requisite... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | Gemfile | Ruby | mit | 19 | master | 1,349 | source "https://rubygems.org"
ruby "2.3.1"
gem "acts-as-taggable-on"
gem "autoprefixer-rails"
gem "bootstrap-sass"
gem "bourbon"
gem "carrierwave"
gem "coffee-rails", "~> 4.1.0"
gem "daemons"
gem "delayed_job_active_record"
gem "dotenv-rails"
gem "email_validator"
gem "errorapp_notifier"
gem "flutie"
gem "font-awesom... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | Rakefile | Ruby | mit | 19 | master | 405 | # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
task(:default).clear
task default: [:spec]
if defined? RSpec
task(:s... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/routes.rb | Ruby | mit | 19 | master | 626 | Rails.application.routes.draw do
mount RailsAdmin::Engine => "/admin", as: "rails_admin"
namespace :api, defaults: { format: "json" } do
namespace :v1 do
resources :conferences, only: [:index]
resources :devices, only: [:create]
end
namespace :v2 do
resources :conferences, only: [:in... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/application.rb | Ruby | mit | 19 | master | 1,861 | 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 | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/initializers/assets.rb | Ruby | mit | 19 | master | 576 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")
Rails.application.config.assets.precompile += %w( public.css )
# Add additional assets to the asset load p... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/initializers/rails_admin.rb | Ruby | mit | 19 | master | 1,205 | require_relative 'rpush'
RailsAdmin.config do |config|
config.authorize_with do
authenticate_or_request_with_http_basic('rubyconferences admin') do |username, password|
username == ENV['ADMIN_USER'] && password == ENV['ADMIN_PASSWORD']
end
end
config.actions do
all
end
config.model Confer... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/initializers/simple_form_bootstrap.rb | Ruby | mit | 19 | master | 4,625 | # Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'btn btn-default'
config.boolean_label_class = nil
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'ha... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/initializers/rpush.rb | Ruby | mit | 19 | master | 4,843 | Rpush.configure do |config|
# Supported clients are :active_record, :redis and :mongoid
config.client = :active_record
# Options passed to Redis.new
# config.redis_options = {}
# Frequency in seconds to check for new notifications.
config.push_poll = 2
# The maximum number of notifications to load fro... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/environments/production.rb | Ruby | mit | 19 | master | 3,731 | 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 | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/environments/development.rb | Ruby | mit | 19 | master | 1,717 | 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 on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | config/environments/staging.rb | Ruby | mit | 19 | master | 238 | require_relative "production"
Mail.register_interceptor(
RecipientInterceptor.new(ENV.fetch("EMAIL_RECIPIENTS"))
)
Rails.application.configure do
# ...
# config.action_mailer.default_url_options = { host: ENV.fetch("HOST") }
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/schema.rb | Ruby | mit | 19 | master | 5,771 | # encoding: UTF-8
# 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 sou... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/seeds.rb | Ruby | mit | 19 | master | 886 | require 'net/http'
require 'uri'
conferences = YAML.load(File.read("#{Rails.root}/db/rubyconferences.yml"))
Conference.delete_all
conferences.each do |attributes|
conference = Conference.new
conference.name = attributes["name"]
conference.location = attributes["location"]
conference.website = attributes["webs... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20160322074640_drop_announcements.rb | Ruby | mit | 19 | master | 418 | class DropAnnouncements < ActiveRecord::Migration
def up
drop_table :announcements
end
def down
create_table "announcements", force: :cascade do |t|
t.string "body", null: false
t.boolean "sent", default: false, null: false
t.datetime "created_at", ... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20150605155446_add_null_constraint_to_conferences.rb | Ruby | mit | 19 | master | 536 | class AddNullConstraintToConferences < ActiveRecord::Migration
def change
change_column :conferences, :name, :string, null: false
change_column :conferences, :location, :string, null: false
change_column :conferences, :twitter_username, :string, null: false
change_column :conferences, :image_url, :str... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20150521072853_create_announcements.rb | Ruby | mit | 19 | master | 238 | class CreateAnnouncements < ActiveRecord::Migration
def change
create_table :announcements do |t|
t.string :body, null: false
t.boolean :sent, default: false, null: false
t.timestamps null: false
end
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20150612213117_add_type_to_conferences.rb | Ruby | mit | 19 | master | 272 | class AddTypeToConferences < ActiveRecord::Migration
def change
add_column :conferences, :type, :string, default: "RubyConference"
change_column :conferences, :type, :string, null: false, index: true
change_column_default :conferences, :type, nil
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20151017171417_rpush_2_0_0_updates.rb | Ruby | mit | 19 | master | 2,531 | class Rpush200Updates < ActiveRecord::Migration
module Rpush
class App < ActiveRecord::Base
self.table_name = 'rpush_apps'
end
class Notification < ActiveRecord::Base
self.table_name = 'rpush_notifications'
end
end
def self.update_type(model, from, to)
model.where(type: from).upd... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20160715182553_remove_location_not_null_constraint_from_conferences.rb | Ruby | mit | 19 | master | 415 | class RemoveLocationNotNullConstraintFromConferences < ActiveRecord::Migration
def change
change_column :conferences, :location, :string, null: true
change_column :conferences, :image_url, :string, null: true
change_column :conferences, :website, :string, null: true
change_column :conferences, :start_... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20150418212433_create_conferences.rb | Ruby | mit | 19 | master | 280 | class CreateConferences < ActiveRecord::Migration
def change
create_table :conferences do |t|
t.string :name
t.string :location
t.string :twitter_username
t.string :image_url
t.text :description
t.timestamps null: false
end
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20160319174500_create_conference_announcements.rb | Ruby | mit | 19 | master | 278 | class CreateConferenceAnnouncements < ActiveRecord::Migration
def change
create_table :conference_announcements do |t|
t.string :body
t.boolean :sent, default: false, null: false
t.integer :conference_id
t.timestamps null: false
end
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | db/migrate/20150614163801_add_conference_type_to_devices.rb | Ruby | mit | 19 | master | 286 | class AddConferenceTypeToDevices < ActiveRecord::Migration
def change
add_column :devices, :conference_type, :integer, default: 0
change_column :devices, :conference_type, :integer, null: false, index: true
change_column_default :devices, :conference_type, nil
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/controllers/conferences_controller.rb | Ruby | mit | 19 | master | 489 | class ConferencesController < ApplicationController
layout "public"
def new
@conference = Conference.new
end
def create
@conference = Conference.new(conference_params)
if @conference.save
render :thanks
else
render :new
end
end
private
def conference_params
par... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/controllers/announcements_controller.rb | Ruby | mit | 19 | master | 416 | class AnnouncementsController < ApplicationController
http_basic_authenticate_with(
name: ENV["ADMIN_USER"],
password: ENV["ADMIN_PASSWORD"]
)
def index
@pending_announcements = ConferenceAnnouncement.pending
end
def send_notification
@announcement = ConferenceAnnouncement.find(params[:id])
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/controllers/application_controller.rb | Ruby | mit | 19 | master | 391 | 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 authenticate
unless ENV["API_SECRET"].blank?
authenticate_or_request_with_http_token do |token, options... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/controllers/api/v2/conferences_controller.rb | Ruby | mit | 19 | master | 323 | class Api::V2::ConferencesController < Api::BaseController
def index
@conferences = conferences
end
private
def conferences
@conferences || Conference.tagged_with(
search_params,
any: true
).v2_conferences
end
def search_params
params[:tags].split(",") if params[:tags]
end
e... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/controllers/api/v1/devices_controller.rb | Ruby | mit | 19 | master | 415 | class Api::V1::DevicesController < Api::BaseController
skip_before_action :verify_authenticity_token, only: :create
def create
creator = DeviceCreator.new(device_params)
if creator.create
head :ok
else
render json: creator.device.errors, status: :unprocessable_entity
end
end
priva... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/controllers/api/v1/conferences_controller.rb | Ruby | mit | 19 | master | 518 | class Api::V1::ConferencesController < Api::BaseController
skip_before_action :authenticate
respond_to :json, :ics
def index
@conferences = conferences
respond_with do |format|
format.ics { render text: conferences_calendar, type: :ics }
end
end
private
def default_tag
"ruby"
end... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/controllers/api/v3/conferences_controller.rb | Ruby | mit | 19 | master | 205 | class Api::V3::ConferencesController < Api::V2::ConferencesController
private
def conferences
@conferences || Conference.tagged_with(
search_params,
any: true
).upcoming
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/uploaders/base_uploader.rb | Ruby | mit | 19 | master | 427 | class BaseUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
File.join(
"uploads",
model.class.to_s.underscore,
mounted_as.to_s,
id_partition.to_s,
model.id.to_s
)
end
def extension_white_list
%w(jpg jpeg gif png svg)
end
private
def id_partiti... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/jobs/announcement_job.rb | Ruby | mit | 19 | master | 248 | class AnnouncementJob < ActiveJob::Base
queue_as :default
def perform(announcement)
Device.all.each_with_index do |device|
AnnouncementSender.new(announcement, device.token).run
end
announcement.update(sent: true)
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/services/date_formatter.rb | Ruby | mit | 19 | master | 1,637 | class DateFormatter
delegate :day, :month, :year, to: :start_date_text, prefix: true
delegate :day, :month, :year, to: :end_date_text, prefix: true
def initialize(start_date, end_date)
@start_date = start_date
@end_date = end_date
end
def to_s
if same_date?
simple
else
formatted
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/services/conferences_calendar.rb | Ruby | mit | 19 | master | 690 | class ConferencesCalendar
def initialize(conferences, calendar_name)
@conferences = conferences
@calendar_name = calendar_name
end
def to_ical
calendar.to_ical
end
private
attr_reader :conferences, :calendar_name
def calendar
Icalendar::Calendar.new.tap do |cal|
cal.x_wr_calname ... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/services/device_cleanup.rb | Ruby | mit | 19 | master | 330 | class DeviceCleanup
def self.run
new.run
end
def run
import_feedbacks
remove_devices
end
private
def import_feedbacks
Rpush.apns_feedback
end
def remove_devices
Rpush::Apns::Feedback.find_each do |feedback|
Device.find_by(token: feedback.device_token).try(:destroy)
end
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/services/device_creator.rb | Ruby | mit | 19 | master | 366 | class DeviceCreator
attr_reader :device
def initialize(params)
@params = params
end
def create
@device ||= Device.find_or_create_by(
token: token,
conference_type: conference_type
)
end
private
attr_reader :params
def token
params[:token]
end
def conference_type
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/services/announcement_sender.rb | Ruby | mit | 19 | master | 504 | class AnnouncementSender
def initialize(announcement, device_token)
@announcement = announcement
@device_token = device_token
end
def run
Rpush::Apns::Notification.new(
app: ios_app,
device_token: device_token,
alert: body,
data: { id: announcement.conference_id }
).save!
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | app/models/conference.rb | Ruby | mit | 19 | master | 1,388 | class Conference < ActiveRecord::Base
acts_as_taggable
geocoded_by :location
mount_uploader :logo, LogoUploader
with_options if: :active? do |object|
object.validates :website, presence: true
object.validates :location, presence: true
object.validates :start_date, presence: true
object.valida... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/spec_helper.rb | Ruby | mit | 19 | master | 481 | if ENV.fetch("COVERAGE", false)
require "simplecov"
SimpleCov.start "rails"
end
require "webmock/rspec"
# http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.syntax = :expect
end
config.mock_with :rspec do |mo... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/rails_helper.rb | Ruby | mit | 19 | master | 730 | ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "rspec/rails"
require "shoulda/matchers"
Dir[Rails.root.join("spec/support/**/*.rb")].each { |file| require file }
module Features
# Extend this module in spec/support/features/*.rb
include Formulaic::Dsl
end
modul... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/uploaders/base_uploader_spec.rb | Ruby | mit | 19 | master | 652 | require "spec_helper"
describe BaseUploader do
describe "store_dir" do
it "should have id_partition included" do
model_id = 123
uploader = BaseUploader.new
model = double(id: model_id)
allow(uploader).to receive(:model).and_return(model)
expect(uploader.store_dir).to match(/000\/00... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/jobs/announcement_job_spec.rb | Ruby | mit | 19 | master | 1,169 | require 'rails_helper'
describe AnnouncementJob, type: :job do
let(:conference) { create :conference }
it "will create rpush notifications" do
Rpush::Apns::App.create!(
name: "ios_app",
environment: "sandbox",
certificate: File.read(
"spec/support/fixtures/cert_without_password.pem"
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/services/announcement_sender_spec.rb | Ruby | mit | 19 | master | 1,204 | require "rails_helper"
describe AnnouncementSender do
describe "run" do
let(:conference) { create :conference }
context "when ios app exists" do
it "will send push notifications for given device token" do
announcement = create(:conference_announcement)
Rpush::Apns::App.create!(
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/services/date_formatter_spec.rb | Ruby | mit | 19 | master | 1,300 | require "rails_helper"
describe DateFormatter do
describe "#to_s" do
context "start date and end date are same" do
it "results formatted start date" do
date = Date.parse("June 29, 2015")
formatter = DateFormatter.new(date, date)
expect(formatter.to_s).to eq("June 29, 2015")
e... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/services/conferences_calendar_spec.rb | Ruby | mit | 19 | master | 721 | require "rails_helper"
describe ConferencesCalendar do
describe "#to_ical" do
it "will generate ical for given conferences with name" do
conference = create(:conference)
name = "foo"
conferences_calendar = ConferencesCalendar.new([conference], name)
ical = conferences_calendar.to_ical
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/services/device_creator_spec.rb | Ruby | mit | 19 | master | 2,059 | require "rails_helper"
describe DeviceCreator do
describe "#create" do
context "when params are given" do
context "when device already exists" do
it "will not create a new device" do
device = create(:device)
params = {
token: device.token,
conference_type... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/services/device_cleanup_spec.rb | Ruby | mit | 19 | master | 613 | require "rails_helper"
describe DeviceCleanup do
describe "#run" do
it "will import feedback from Rpush" do
allow(Rpush).to receive(:apns_feedback)
DeviceCleanup.run
expect(Rpush).to have_received(:apns_feedback)
end
it "will delete devices from feedback table" do
device = crea... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/models/device_spec.rb | Ruby | mit | 19 | master | 1,187 | require 'rails_helper'
describe Device, type: :model do
describe "validations" do
describe "token" do
it { should validate_presence_of(:token) }
it "will not create device with same token and conference_type" do
token = "same-token"
ruby_conference_type = "ruby"
create(:devic... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/models/conference_spec.rb | Ruby | mit | 19 | master | 4,159 | require "rails_helper"
RSpec.describe Conference, :type => :model do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:twitter_username) }
context "#validations" do
let(:location) { "India" }
let(:conference) { create(:conference, active: true, location: location) }
before ... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/models/conference_announcement_spec.rb | Ruby | mit | 19 | master | 296 | require "rails_helper"
RSpec.describe ConferenceAnnouncement, type: :model do
describe "#validations" do
it { should validate_presence_of(:conference_id) }
it { should validate_presence_of(:body) }
end
describe "#associations" do
it { should belong_to :conference }
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/support/geocode_helper.rb | Ruby | mit | 19 | master | 360 | Geocoder.configure(lookup: :test)
Geocoder::Lookup::Test.add_stub(
"New York, NY", [
{
"latitude" => 40.7143528,
"longitude" => -74.0059731,
"address" => "New York, NY, USA",
"state" => "New York",
"state_code" => "NY",
"country" => "United States",
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/support/requests/requests_helper.rb | Ruby | mit | 19 | master | 316 | module Requests
module JsonHelpers
def json
@json ||= JSON.parse(response.body)
end
end
module LoginHelpers
def token_auth
{
"HTTP_AUTHORIZATION" => ActionController::HttpAuthentication::Token.encode_credentials(
ENV["API_SECRET"]
)
}
end
end
end |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/requests/api/v2/conferences_spec.rb | Ruby | mit | 19 | master | 1,687 | require "rails_helper"
describe "/api/v2/conferences" do
describe "get conferences" do
context "for JSON" do
it "will render all required keys for v2" do
create(:conference, :ruby)
get "/api/v2/conferences", { tags: "ruby" }, token_auth
expect(json.count).to eq(1)
expect(j... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/requests/api/v1/conferences_spec.rb | Ruby | mit | 19 | master | 2,432 | require "rails_helper"
describe "/api/v1/conferences" do
describe "get conferences" do
context "for JSON" do
it "will render all required keys for v1" do
create(:conference, :ruby)
get "/api/v1/conferences"
expect(json.count).to eq(1)
expect(json.first.keys).to eq(
... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/requests/api/v3/conferences_spec.rb | Ruby | mit | 19 | master | 1,327 | require "rails_helper"
describe "/api/v3/conferences" do
describe "get conferences" do
context "for JSON" do
it "will render all required keys for v3" do
create(:conference, :ruby)
get "/api/v3/conferences", { tags: "ruby" }, token_auth
expect(json.count).to eq(1)
expect(j... |
github | conferencesapp/rubyconferences-server | https://github.com/conferencesapp/rubyconferences-server | spec/factories/conferences.rb | Ruby | mit | 19 | master | 635 | FactoryGirl.define do
factory :conference do
name "Conference Name"
location "New York, NY"
start_date Date.today
end_date Date.today
twitter_username "twiiter"
image_url "image_url"
website "foo.bar"
active true
trait :ruby do
tag_list "ruby"
end
trait :javascript ... |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | Rakefile | Ruby | mit | 20 | master | 437 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/real/**/*_test.rb"]
end
Rake::TestTask.new(:tests_meant_to_fail) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileLis... |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | Gemfile | Ruby | mit | 20 | master | 296 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in minitest_rerun_failed.gemspec
gemspec
gem "minitest"
gem "minitest-reporters"
gem "rake"
gem "rubocop-minitest"
gem "rubocop-rake"
gem "rubocop-rails-omakase", require: false, group: :development |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | minitest_rerun_failed.gemspec | Ruby | mit | 20 | master | 1,513 | # frozen_string_literal: true
require_relative "lib/minitest_rerun_failed/version"
Gem::Specification.new do |spec|
spec.name = "minitest-rerun-failed"
spec.version = MinitestRerunFailed::VERSION
spec.authors = [ "Søren Houen" ]
spec.email = [ "s@houen.net" ]
spec.summary ... |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | lib/minitest_rerun_failed.rb | Ruby | mit | 20 | master | 219 | # frozen_string_literal: true
require "minitest/reporters"
require_relative "minitest_rerun_failed/failed_tests_reporter"
module MinitestRerunFailed
class Error < StandardError; end
# Your code goes here...
end |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | lib/minitest_rerun_failed/failed_tests_reporter.rb | Ruby | mit | 20 | master | 4,558 | # frozen_string_literal: true
module Minitest
module Reporters
# Source: https://www.houen.net/2021/08/23/minitest-rerun-failed-tests/
# License: MIT
#
# Outputs failed tests to screen and / or file
# Allows to rerun only failed tests with minitest if added to Minitest::Reporters.use!
#
#... |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | test/real/minitest_rerun_failed_test.rb | Ruby | mit | 20 | master | 2,896 | # frozen_string_literal: true
require "test_helper"
# Which number test to run and fail
FAIL_TEST_NAME = ENV["FAIL_TEST_NAME"]
# Choose which reporter config to use for failing the test and generating output
case FAIL_TEST_NAME
when nil
Minitest::Reporters.use!(
[
Minitest::Reporters::ProgressReporter.ne... |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | test/meant_to_fail/another_example_test.rb | Ruby | mit | 20 | master | 333 | # frozen_string_literal: true
require "test_helper"
Minitest::Reporters.use!(
[
Minitest::Reporters::ProgressReporter.new,
Minitest::Reporters::FailedTestsReporter.new
]
)
class AnotherExampleTest < Minitest::Test
def test1
assert false
end
def test2
raise
end
def test3
assert fal... |
github | houen/minitest-rerun-failed | https://github.com/houen/minitest-rerun-failed | test/meant_to_fail/example_test.rb | Ruby | mit | 20 | master | 542 | # frozen_string_literal: true
require "test_helper"
Minitest::Reporters.use!(
[
Minitest::Reporters::ProgressReporter.new,
Minitest::Reporters::FailedTestsReporter.new
]
)
class ExampleTest < Minitest::Test
def test1
assert false
end
def test2
raise
end
def test3
assert false
en... |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/type/mistral_workflow.rb | Ruby | apache-2.0 | 19 | master | 1,693 | Puppet::Type.newtype(:mistral_workflow) do
desc <<-EOT
This allows manifests to declare a workflow to be created or removed
in Mistral.
mistral_workflow { "my_workflow":
ensure => present,
definition_file => "/home/workflows/my_workflow.yaml",
is_public => yes,
}
Known problems... |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/type/mistral_api_uwsgi_config.rb | Ruby | apache-2.0 | 19 | master | 703 | Puppet::Type.newtype(:mistral_api_uwsgi_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from /etc/mistral/mistral-api-uwsgi.ini'
newvalues(/\S\/\S/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
... |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/type/mistral_config.rb | Ruby | apache-2.0 | 19 | master | 1,417 | Puppet::Type.newtype(:mistral_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from /etc/mistral/mistral.conf'
newvalues(/\S+\/\S+/)
end
newproperty(:value, :array_matching => :all) do
desc 'The value of the setting to be defined.'
def insync?(is)... |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/provider/mistral.rb | Ruby | apache-2.0 | 19 | master | 315 | require 'puppet/provider/openstack/auth'
require 'puppet/provider/openstack/credentials'
require File.join(File.dirname(__FILE__), '..','..', 'puppet/provider/mistral_workflow_requester')
class Puppet::Provider::Mistral < Puppet::Provider::MistralWorkflowRequester
extend Puppet::Provider::Openstack::Auth
end |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/provider/mistral_workflow_requester.rb | Ruby | apache-2.0 | 19 | master | 2,308 | require 'csv'
require 'puppet'
require 'timeout'
class Puppet::Provider::MistralWorkflowRequester < Puppet::Provider::Openstack
# This class only overrides the request method of the Openstack provider
# because Mistral behaves differently when creating workflows.
# The mistral client allows the creation of multi... |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/provider/mistral_api_uwsgi_config/ini_setting.rb | Ruby | apache-2.0 | 19 | master | 222 | Puppet::Type.type(:mistral_api_uwsgi_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def self.file_path
'/etc/mistral/mistral-api-uwsgi.ini'
end
end |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/provider/mistral_workflow/openstack.rb | Ruby | apache-2.0 | 19 | master | 2,347 | require File.join(File.dirname(__FILE__), '..','..','..', 'puppet/provider/mistral')
Puppet::Type.type(:mistral_workflow).provide(
:openstack,
:parent => Puppet::Provider::Mistral
) do
desc <<-EOT
Mistral provider to manage workflow type
EOT
@credentials = Puppet::Provider::Openstack::CredentialsV3.new
... |
github | openstack/puppet-mistral | https://github.com/openstack/puppet-mistral | lib/puppet/provider/mistral_config/openstackconfig.rb | Ruby | apache-2.0 | 19 | master | 200 | Puppet::Type.type(:mistral_config).provide(
:openstackconfig,
:parent => Puppet::Type.type(:openstack_config).provider(:ruby)
) do
def self.file_path
'/etc/mistral/mistral.conf'
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.