text stringlengths 10 2.61M |
|---|
class ForgotmailsController < ApplicationController
before_action :set_forgotmail, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /forgotmails
# GET /forgotmails.json
def index
@forgotmails = Forgotmail.all
end
# GET /forgotmails/1
# GET /forgotmails/1.json
def ... |
require 'crates'
require 'thor'
module Crates
class CLI < Thor
desc 'get_rates', 'load rates'
method_option :base_currency, default: 'USD'
method_option :target_currencies, default: 'GBP'
method_option :best, type: :boolean, aliases: '-b'
method_option :amount
method_option :date
def se... |
class Appointment < ActiveRecord::Base
belongs_to :doctor
belongs_to :patient
attr_accessible :end_time, :start_time, :doctor_id, :patient_id
validates :doctor,
presence:true
validates :patient,
presence:true
end
|
class CreateSentimentCaches < ActiveRecord::Migration
def change
create_table :sentiment_caches do |t|
t.timestamp :tweet_when
t.decimal :score, precision: 6, scale: 3
t.string :tweet_text
t.string :tweet_author
t.integer :num_tweets
t.references :company, index: {:unique=>true... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Automate installation of a Ubuntu VM, with docker+tools and webfact container.
#
# USAGE: see vagrant.md
# See also https://docs.vagrantup.com,
# provider-specific configuration for VirtualBox
# https://docs.vagrantup.com/v2/virtualbox/configuration.html
########
#... |
require 'wicked_pdf'
require 'combine_pdf'
require_relative './htmlentities'
require_relative './helpers'
require_relative './sparql_queries'
module DocumentGenerator
class DeliveryNote
include DocumentGenerator::Helpers
def generate(path, data)
id = data['id']
path_supplier = "/tmp/#{id}-deliv... |
class FontKanit < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/kanit"
desc "Kanit"
homepage "https://fonts.google.com/specimen/Kanit"
def install
(share/"fonts").install "Kanit-Black.ttf"
(share/"fonts").install "Kanit-BlackItal... |
class CreateOrderLogs < ActiveRecord::Migration
def self.up
create_table :order_logs do |t|
t.integer :order_id
t.integer :user_id
t.string :log
t.timestamps
end
end
def self.down
drop_table :order_logs
end
end
|
require 'rest-client'
require 'json'
require_relative '../lib/engine'
require 'minitest/autorun'
class TestEngine < MiniTest::Test
def setup
@engine = Engine.new
@request_body = {
"arguments": [
{
"id": '123',
"input": [
[
... |
#require "gtk3"
#load 'Sauvegarde.rb'
load 'Plateau.rb'
load 'Highscore.rb'
# Coeur et gestion du jeu
# @attr_reader plateau [Plateau] le plateau de jeu
# @attr_reader nom_joueur [String]
# @attr nom_joueur_label [Gtk::Label]
# @attr_reader temps_de_jeu
# @attr window [Gtk::Window] composant Gtk de la fenêtre
# @attr_... |
# This simple file shows how Ruby creates an Object Class, in this case "Song". The "methods" within this class (initialize, first_test_method, name, etc...),
# are used do stuff to the original Song object. There are different ways to do this, a few are shown below:
class Song
def initialize(name, artist, duration... |
require 'rails_helper'
RSpec.describe Garden do
describe 'relationships' do
it { should have_many(:plots) }
end
describe 'instance methods' do
before :each do
@garden = Garden.create!(name: "Sunshine Gardens", organic: true)
@plot_1 = @garden.plots.create!(number: 10, size: "Big", direction... |
# frozen_string_literal: true
module MFCCase
# Версия модуля
VERSION = '0.6.8'
end
|
=begin
no termina con ;
#comentarios en linea
el begin y end deben ir pegados a comienzo
utilizar los parentesis solo cuando no se este ejecutando una funcion de dsl
Snackcase uso de _ para la separacion de palabras
scamelcase o algo asi para separar las palabras por mayuscula
=end
|
# rails generate repres:dosser:swagger administration --version 2
require 'rails/generators'
class Repres::Dosser::SwaggerGenerator < Rails::Generators::NamedBase
# https://github.com/erikhuda/thor/blob/master/lib/thor/base.rb#L273
class_option :version, type: :numeric, required: false, default: 1, desc: 'a posit... |
class Account::PostsController < ApplicationController
before_action :authenticate_user!
before_action :find_params, only: [:edit, :update, :destroy]
def index
@posts = current_user.posts.paginate(:page => params[:page], :per_page => 4)
end
def edit
if @post.user != current_user
flash[:warning]... |
class CreateMhpSkills < ActiveRecord::Migration[5.0]
def change
create_table :mhp_skills do |t|
t.string :name
t.integer :skill_system_id
t.integer :required_point
t.timestamps
end
add_index :mhp_skills, :skill_system_id
end
end
|
class TwitterDatum < ActiveRecord::Base
include Datum
belongs_to :social_network
set_type :twitter_data
comparable_metrics :total_followers, :total_mentions, :ret_tweets, :total_clicks, :interactions_ads, :total_interactions, :total_prints, :favorites, :lists
def new_followers
previous_datum.present... |
require 'rails_helper'
RSpec.describe Admin::TeamsController, type: :controller do
let(:valid_attributes) { { slug: 'test', name: 'test' } }
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
let(:valid_session) { {} }
describe "GET #index" do
it "assigns all team... |
require 'spec_helper'
describe 'campaigns/show' do
include CampaignExampleHelpers
let(:campaign) { create_campaign_with_tier_taglines }
let(:charity) { campaign.charity }
let(:donation_order) { DonationOrder.new }
let(:campaign_stat) { mock('CampaignStat') }
before do
assign(:campaign, ... |
require File.expand_path("../lib/jaguar/version", __FILE__)
Gem::Specification.new do |gem|
gem.name = "jaguar"
gem.version = Jaguar::VERSION
gem.license = "MIT"
gem.authors = ["Tiago Cardoso"]
gem.email = ["cardoso_tiago@hotmail.com"]
gem.description = "Evented HTTP Ser... |
require 'rails_helper'
describe Pii::Attribute do
let(:first_name_utf8) { 'José' }
let(:first_name_ascii) { 'Jose' }
subject { described_class.new(raw: first_name_utf8) }
describe '#ascii' do
it 'transliterates' do
expect(subject.ascii).to eq first_name_ascii
end
end
# rubocop:disable Unne... |
class MadeBy
include Neo4j::ActiveRel
from_class :Product
to_class :Brand
type :MADE_BY
end |
class GridLayer < RenderLayer
def render(g,width,height)
if battle.info[:grid_show]
grid_ratio = battle.info[:grid_ratio]
g.color = Color::WHITE
current_x = 0
current_y = 0
battle.objects.values.select{|o| o[:layer]=='background'}.each do |o|
img = battle.load_image(o[:ima... |
class EncounterSerializer < ActiveModel::Serializer
attributes :id, :description, :name
has_one :campaign
has_many :creatures
has_many :characters
class CreatureSerializer < ActiveModel::Serializer
attributes :id, :name, :creature_type, :str, :dex, :con, :int, :wis, :cha, :challenge_rating, :armor_class,... |
#write your code here
def echo(word)
word
end
def shout(word)
word.upcase
end
def repeat(word, n=2)
[word]*n*' '
end
def start_of_word(word,n)
word[0..(n-1)]
end
def first_word(word)
word.split.first
end
def titleize(title)
little_words = %w[and the over]
title =
title.split.map... |
#encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
require 'pony'
require 'sqlite3'
def is_barber_exists? db, name
db.execute('select * from barbers where name=?', [name]).length > 0
end
def seed_db db, barbers
barbers.each do |barber|
if !is_barber_exists? db, barber
db.execu... |
namespace :db do
desc "Fill database with sample data"
task populate: :environment do
User.create!(name: "Example User",
email: "example@railstutorial.org",
password: "foobar",
password_confirmation: "foobar")
99.times do |n|
name = Faker::Name.name
... |
class CreateRequests < ActiveRecord::Migration[5.0]
def change
create_table :requests do |t|
t.integer :song_id, null: false
t.integer :artist_id, null: false
t.integer :genre_id, null: false
t.integer :source_id, null: false
t.integer :requestlog_id, null: false
t.integer :lis... |
require 'test_helper'
class StudentsMustChangePasswordOnFirstSigningInTest < ActionDispatch::IntegrationTest
def setup
log_in_as_student
end
test "students cannot create students" do
# Student can go to student index
get students_path
assert_select 'h1', "Students#index"
# Student only sees... |
class AnnualReport
class Categories
class CategoryWithMonthlyValues < Base
private
attr_reader :data
public
def initialize(data)
super(data)
end
def total
values.sum
end
def average_total
average_values.sum.fdiv(average_values.count)
... |
require_relative 'test_helper'
class SimpleTestCase < Test::Unit::TestCase
def test_successful_run
assert true
end
def test_failed_run
assert_equal false, true, "test assertion message"
end
# This line prevents tests from SimpleTestCase class from being executed
@@test_suites.delete(SimpleTestCase... |
require 'rails_helper'
RSpec.describe(Account, :type => :model) do
it 'can deposit' do
account = Account.new('Indra', 1_000_000)
account.deposit(500_000)
expect(account.amount).to(eq(1_500_000))
end
it 'can withdraw' do
account = Account.new('Indra', 1_000_000)
account.withdraw(500_000)
e... |
class AnswerQuestion < AiBase
def initialize(result)
@request_data = result
question_id = result['parameters']['id']
@url = "questions/#{question_id}/answers"
@intent = "posted your answer"
end
def prepare_payload
{
'content' => request_data['parameters']['content']
}
end
def p... |
class Comment < ActiveRecord::Base
attr_accessible :cuerpo, :noticia_id, :persona_id, :updated_at, :edited
belongs_to :persona
belongs_to :noticia
end
|
class NotificationsController < ApplicationController
def index
@grid = NotificationsGrid.new(params[:notifications_grid])
respond_to do |f|
f.html do
if @current_user.is_admin?
@grid.scope {|scope| scope.page(params[:page]) }
else
@grid.scope {|scope| scope.where(:receiver_id => @current_us... |
require "spec_helper"
RSpec.describe "Day 24: It Hangs in the Balance" do
let(:runner) { Runner.new("2015/24") }
let(:input) do
<<~TXT
1
2
3
4
5
7
8
9
10
11
TXT
end
describe "Part One" do
let(:solution) { runner.execute!(input, part: 1) }... |
When /^I edit the conference$/ do
fill_in "Name", with: "MLS"
click_button "commit"
end
When /^I create a new conference$/ do
fill_in "Name", with: @new_conference.name
select @edit_league.name, from: 'conference[league_id]'
click_button "commit"
end
Then /^the changes to the conference should be s... |
#!/usr/bin/env jruby
require 'java'
require 'cache'
require 'code_search'
require 'view_matrix'
require 'uri'
require 'fileutils'
#import 'abstractor.cluster.hierarchical.DerivedAgglomerativeClusterer'
#import 'abstractor.cluster.hierarchical.AgglomerativeClusterer'
#import 'abstractor.cluster.hierarchical.CompleteLi... |
require 'stock_quote'
class Stock < ActiveRecord::Base
has_many :closes
def fetch_closes(days_old)
results = StockQuote::Stock.history(symbol, Date.today - days_old, Date.today)
results.each do |result|
close = Close.find_or_create_by(stock_id: id, date: result.date)
close.open = result.open
... |
class Subject < ApplicationRecord
belongs_to :education
validates :title, presence: true
end
|
class ContractTemplate < ActiveRecord::Base
belongs_to :contract_partner
belongs_to :interval
has_many :contracts
end
|
class AddColDiscountToLeaseBooking < ActiveRecord::Migration
def change
add_column :leasingx_lease_bookings, :discount, :tinyint, :default => 0
end
end
|
# == Schema Information
# Schema version: 3
#
# Table name: groups
#
# id :integer(11) not null, primary key
# name :string(255)
# desc :text
# permalink :string(255)
# published :boolean(1)
# gcategory_id :integer(11)
# created_at ... |
class ApplicationController < ActionController::API
PAGE_TOKEN = 'EAASZBQhnIYvQBAFcIn7pbyLxsam6absGnOAA0UZAReTA7bgppLyRVAZAStaOssxGUlqSpEV48bwhj7MDvOrZAAZCqhhP9epbxWdhMktLmMm9u0qoiAPVx5ON1WH7gIJxR5G4blpWVdKEGqCZBACaayyZAqtdCEkelzMSrCnRVw4rwZDZD'
RESPONSES_HASH = {
'is nikhil stupid?' => 'Yes he is',
'what... |
class AddIndexToCreatorEvents < ActiveRecord::Migration
def change
add_index :events, [ :creator_id , :date ], unique: true
end
end
|
Rails.application.routes.draw do
root to: 'categories#index'
resources :categories, only: [:index, :show] do
resources :recipes, only: [:new, :create]
end
resources :recipes, except: [:new, :create] do
resources :ingredients, except: [:show]
end
get 'login', to: 'sessions#new'
post 'login', to:... |
# frozen_string_literal: true
class DiscountSerializer < ActiveModel::Serializer
attributes :id, :kind, :name, :count, :price, :product_ids
end
|
class Address < ActiveRecord::Base
attr_accessible :name, :address, :neighbourhood, :description, :longitude, :latitude, :studio_id
belongs_to :studio
geocoded_by :address
after_validation :geocode
end
|
class AddUserIdToSurl < ActiveRecord::Migration[5.2]
def change
change_column :shortened_urls, :user_id, :integer, :null => false
end
end
|
class Job < ActiveRecord::Base
#extend ::Geocoder::Model::ActiveRecord
belongs_to :user
has_many :comments
validates :user_id, presence: true
validates :job_title, presence: true
validates :job_address, presence: true
validates :job_contact_name, presence: true
validates :job_contact_phone, presence: ... |
class Teacher::QuestionsController < ApplicationController
layout 'teacher'
before_filter :get_teacher_and_course, :get_exam
# GET /teacher/courses/1/exams/1/questions
# GET /teacher/courses/1/exams/1/questions.json
def index
@questions = Question.where(:exam_id => @exam.id).order(:position).page(params[:... |
json.array!(@clientes) do |cliente|
json.extract! cliente, :id, :name, :description, :nif, :address, :city, :telephone, :email
json.url cliente_url(cliente, format: :json)
end
|
# frozen_string_literal: true
module RubyNext
module Language
module Rewriters
class EndlessMethod < Base
SYNTAX_PROBE = "obj = Object.new; def obj.foo() = 42"
MIN_SUPPORTED_VERSION = Gem::Version.new("2.8.0")
def on_def_e(node)
context.track! self
replace(node... |
class AddNicknameToFacebookUsers < ActiveRecord::Migration
def change
add_column :facebook_users, :nickname, :string
end
end
|
require "rails_helper"
RSpec.describe Operation, type: :model do
it { is_expected.to belong_to(:sleep) }
it { is_expected.to belong_to(:user) }
it { is_expected.to define_enum_for(:operation_type).with_values(stop: 0, start: 1) }
context "when all attributes are valid except for redundant sleep_id" do
con... |
require 'spec_helper'
describe "Adding and removing notifications" do
let(:user) { User.create(username: "Test") }
let(:message_notification) { NotifyMe::Notification.create(:message => "This is a test msg")}
it "stores new notifications" do
user.notifications << message_notification
user.notifications.reload... |
Given /the following events exist/ do |events_table|
events_table.hashes.each do |event|
Event.create! event
end
end
Then /(.*) seed events should exist/ do | n_seeds |
Event.count.should be n_seeds.to_i
end
Then /I should see the correct number of events cards/ do
num_events = Event.all.size
num_ev... |
# encoding: UTF-8
module API
module V1
class Presentations < API::V1::Base
helpers API::Helpers::V1::PresentationsHelpers
helpers API::Helpers::V1::SharedParamsHelpers
helpers API::Helpers::V1::SharedServiceActionsHelpers
before do
authenticate_user
end
namespace :p... |
class Contract < ActiveRecord::Base
audited
attr_accessor :step, :subject, :email, :cc, :cco, :message
has_and_belongs_to_many :users, :validate => false
belongs_to :client
belongs_to :proposal
belongs_to :user
belongs_to :comercial_agent, :class_name => 'User'
belongs_to :intermediary, :class_name => 'User... |
class Post < ActiveRecord::Base
belongs_to :category
validates_associated :category
validates :email, presence: true
validates :title, presence: true
validates :title, length: { in: 5..100 }
validates :body, presence: true
validates :price, presence: true
validates :price, numericality: { greater_than... |
MultipleMan.configure do |config|
# A connection string to your local server. Defaults to localhost.
config.connection = {
addresses: ['192.168.99.100:5673', '192.168.99.100:5674', '192.168.99.100:5675']
}
# The topic name to push to. If you have multiple
# multiple man apps, this should be unique per ap... |
Dado('que o usuário esteja na pagina inicial do google') do
@google_page = GooglePage.new
@google_page.load
end
Quando('realizar a pesquisa {string}') do |pesquisa|
@google_page.pesquisar(pesquisa)
@pesquisa = pesquisa
end
Então('sistema deve retornar os resultados de acordo com o que foi pesquisado') do
ex... |
require_relative 'spec_helper'
require 'pp'
describe 'App' do
let(:headers) {
{
"Content-Type": "application/json"
}
}
let(:realm) { ENV['quickbooks_realm'] }
let(:secret) { ENV['quickbooks_access_secret'] }
let(:token) { ENV['quickbooks_access_token'] }
let(:order) {
{
"email": nil... |
require "horseman/dom/document"
module Horseman
class Response
attr_reader :body, :headers, :document
def initialize(body, headers={})
@body = body
@headers = headers
@document = Dom::Document.new(@body)
end
def[](key)
@headers[key]
end
end
end
|
class Rol < ActiveRecord::Base
validates_presence_of :nombre, :message => "no debe ser vacío"
def self.nombres
roles_conjunto = Rol.find(:all)
@roles = Array.new
for rol in roles_conjunto
@roles << rol.nombre
end
@roles
end
end
|
class Contest < ApplicationRecord
validates :battlepets,
length: {minimum: 2, message: "are too short (minimum is 2)"}
validates_presence_of :contest_type
validates_inclusion_of :contest_type, :in => %w( simple )
validates :battlepet_traits,
length: {minimum: 1, maximum: 1, message: "are too long or too... |
#encoding: utf-8
class FriendMailer < ActionMailer::Base
add_template_helper(ApplicationHelper)
default from: APP_DATA["email"]["from"]["normal"]
def invite(params)
mail(:to => params[:email], :subject => params[:subject]) { |format| format.html { render :text => params[:body] }}
end
end
|
class AddTwitterIdToCars < ActiveRecord::Migration
def change
add_column :cars, :twitter_id, :integer, :after => :meter_fare
add_column :cars, :twitter_name, :string, :after => :twitter_id
add_column :cars, :access_token, :string, :after => :twitter_name
end
end
|
# Keep track of the conditions for a query. This is needed due to where clauses
# being chainable.
module Geotab
module Concerns
module Conditionable
def conditions
@conditions ||= {}
end
# Conditions should be cleared after each .all class so that new
# queries do not use previou... |
class Creditcard < ApplicationRecord
validates :number, presence: true, length: {in: 16..19}, numericality: true
validates :expiration, presence: true, numericality: true
validates :cvc, presence: true, length: {in: 3..4}, numericality: true
validates :avs_street, presence: true
validates :avs_zip, presence: ... |
class Micropost < ApplicationRecord
belongs_to :user
validates :content,length:{maximum:10},
presence:true
end
|
class CreatePushes < ActiveRecord::Migration[5.0]
def change
create_table :pushes do |t|
t.jsonb :data, null: false, default: {}
t.timestamps
end
end
end
|
class Patron
attr_reader(:name, :id)
define_method(:initialize) do |attributes|
@name = attributes.fetch(:name)
@id = attributes[:id]
end
define_singleton_method(:all) do
patrons = []
returned_patrons = DB.exec("SELECT * FROM patrons ;")
returned_patrons.each() do |patron|
name = pat... |
# frozen_string_literal: true
module Vedeu
# This module is the direct interface between Vedeu and your
# terminal/ console, via Ruby's IO core library.
#
module Terminal
end # Terminal
# :nocov:
# See {file:docs/events/view.md#\_resize_}
Vedeu.bind(:_resize_, delay: 0.25) { Vedeu.resize }
# :no... |
class Image < ActiveRecord::Base
attr_accessible :description, :title, :image_object
belongs_to :image_reference, polymorphic: true
has_attached_file :image_object,
:styles => { :portrait => "300X600", :thumb => "75x75>" },
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/amazon_s3.yml",
... |
module Helpers
module Authentication
def sign_in(user_arg)
visit login_path
fill_in 'Email', with: user_arg.email
fill_in 'Password', with: user_arg.password
click_button 'Log in'
end
def incorrect_sign_in(user_arg)
visit login_path
fill_in 'Email', with: user_arg.emai... |
class AddRightToUserRegions < ActiveRecord::Migration[5.0]
def change
add_column :user_regions, :right, :boolean
end
end
|
class RestoAdmin::MenuItemsController < RestoAdmin::BaseApiController
include CleanPagination
before_action :build_options, only: [:create, :update]
def index
@menu_items = if params[:category_id]
@branch_group.menu_items_by_category(params[:category_id])
else
@branch_group.menu_items
... |
require 'im_magick/command/collector'
require 'im_magick/command/emitter'
module ImMagick
module Command
class NotImplemented < StandardError
end
class Base
include Emitter
def initialize(*args, &block)
yield self if block_given?
end
... |
require 'test_helper'
class InvitationsControllerTest < ActionController::TestCase
def login
session[:login] = @user
end
setup do
@user = users(:one)
@event = events(:one)
@invitation = invitations(:one)
login
end
test "should get new" do
get :new, event_id: @event.id
assert_res... |
require 'usiri/toleo'
require 'usiri/mwisho'
class ChaguoCLI
attr_accessor :jina, :siti, :alama, :urefu, :toleo
def initialize
@jina = nil
@siti = nil
@alama = nil
@urefu = nil
@toleo = nil
@toleo_usiri = Usiri::TOLEO
end
def fasili_chaguo mfasili
mfasili.ban... |
class SubRequest < ApplicationRecord
belongs_to :group
belongs_to :user
has_many :sendees, dependent: :destroy
has_many :replies, through: :sendees
has_one :selected_sub, dependent: :destroy
after_create :send_to_sendees
validates_presence_of :start_date_time
validates_presence_of :end_date_time
val... |
module V1
class FollowsController < ApplicationController
include ExceptionHandler
before_action :set_followed_user, only: %i[create destroy]
def create
@follow = current_user.follow(@followed_user)
render json: @follow, status: :created
end
def destroy
current_user.unfollow(@f... |
require_relative '../../spec_helper'
describe MangoPayV1::Withdrawal, :type => :feature do
let(:new_user) {
user = MangoPayV1::User.create({
'Tag' => 'test',
'Email' => 'my@email.com',
'FirstName' => 'John',
'LastName' => 'Doe',
'CanRegisterMeanO... |
module Admin
class BaseController < ApplicationController
before_action :verify_staff
def current_ability
@current_ability ||= AdminAbility.new(current_user)
end
def download_emails
if params[:project_id].present?
project = Project.find(params[:project_id])
@emails = proj... |
class AddHoursToPlanningConfirmation < ActiveRecord::Migration
def change
add_column :planning_confirmations, :hours, :float, default: 0.0
end
end
|
require 'json'
def to_upper_case(event:, context:)
begin
puts "Received Request: #{event}"
{
statusCode: 200,
body: event["body"].upcase,
}
rescue StandardError => e
puts e.message
puts e.backtrace.inspect
{
statusCode: 400,
body: e.message,
}.to_json
e... |
class RiotApi
BASE_URL = "https://euw.api.pvp.net"
GLOBAL_URL = "https://global.api.riotgames.com"
RIOT_API_KEY = ENV['RIOT_API_KEY']
def get_response(url)
response = RestClient.get(url)
JSON.parse(response)
end
def get_challenger_league
challenger_league_url = "#{BASE_URL}/api/lol/EUW/v2.5/l... |
module SlackServices
module ChannelsImporter
extend Client
def import
channels = client.channels_list.fetch('channels') { [] }
channels.each do |channel_attributes|
begin
import_channel(channel_attributes)
rescue => ex
Rails.logger.error(ex.message)
end... |
#!/usr/bin/env ruby
# (c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
# Utility for listing the contents of a Plan R repo
require 'plan-r/application/cli'
require 'plan-r/repo'
class App < PlanR::CliApplication
# inspect needs nothing
def self.disable_plugins?; true; end
def self.disable_jruby?; tr... |
class V1::Dashboards::DashboardController < V1::CacheController
#before_filter authorize_user!
api :GET, "/dashboard/menu", "List dashboad role specific menu"
param :edit, String, "request menu items for edit by given role name"
meta "## if no `:edit` params passed, just return role specific menu items"
def ... |
class CommentsController < ApplicationController
def create
#before_action :authenticate_user!, :except => [:create]
@article = Article.find(params[:article_id])
# т.е внутри статьи создаем комментарий который передается через параметры
#@article.comments.create(comment_params)
article = @articl... |
class AdminMailer < Base
default to: ADMIN_EMAIL
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.admin_mailer.new_merchant.subject
#
def new_merchant(merchant)
@merchant = merchant
greeting("Admin")
mail from: SENDER_EMAIL
end
def upd... |
# frozen_string_literal: true
require_relative 'human_size/version'
require_relative 'human_size/overloads'
#
# Add docs
#
module HumanSize
#
# Add docs
#
class Size
def self.human_size(bytes, a_kilobyte_is_1024_bytes = true)
suffixes_table = {
# Unit prefixes used ... |
class Admin::TeamsController < ApplicationController
before_filter :authorize_admin
layout "admin"
# GET /teams
# GET /teams.json
def index
@teams = Team.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @teams }
end
end
# GET /teams/1
# GET ... |
RSpec.describe S3WebsiteDeploy::CachePolicy do
describe S3WebsiteDeploy::CachePolicy::Policy do
describe "#match?" do
def policy(pattern)
S3WebsiteDeploy::CachePolicy::Policy.new(pattern, { "cache_control" => "max-age=600" })
end
context "with exact pattern" do
it "matches exact... |
Blog::Application.routes.draw do
#Create
get "posts/new" => 'posts#new', :as => "new_post"
post "posts/" => 'posts#create'
#Update
get "posts/:id/edit" => 'posts#edit', :as =>"edit_post"
patch "posts/:id" => 'posts#update'
#Read
get "posts" => 'posts#index'
get "posts/:id" => 'posts#show', :as => "... |
class Api::V1::UsersController < ApplicationController
def index
case params[:type]
when 'friends'
users = current_user.friends
when 'incoming_requests'
users = current_user.requested_friends
else
friend_ids = current_user.friends&.pluck(:id)
pending_ids = current_user.pending_... |
require 'auth/hatenagroup_auth'
class TestHatenaGroupAuth < Test::Unit::TestCase
def setup
@obj = HatenaGroup.new('generation1991', 'api_key', 'sec_key')
end
def test_initialize
assert_equal('generation1991', @obj.group_name)
assert_equal('http://generation1991.g.hatena.ne.jp/', @obj.group_url)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.