text stringlengths 10 2.61M |
|---|
class SessionsController < ApplicationController
def login
user = User.find_by(username: params[:username])
if user && user.authenticate(params[:password])
token = encode_token(user.id)
render json: {user: UserSerializer.new(user), token: token}
else
render json: {errors: "Hey, either yo... |
module Inesita
module Store
def store
self
end
def update_dom
$console.warn "Use 'render!' instead of 'update_dom'"
render!
end
def render!
root_component.render!
end
attr_reader :root_component
def with_root_component(component)
@root_component = compo... |
ENV["SINATRA_ENV"] ||= "development"
require_relative './config/environment'
# Type `rake -T` on your command line to see the available rake tasks.
task :console do
Pry.start
end
task :default => [:spec]
desc 'run Rspec specs'
task :spec do
sh 'rspec spec'
end
|
class AttendanceMailer < ApplicationMailer
def checkout_notifier(attendance_id, time_spent_this_month)
find_attendance(attendance_id)
@time_spent_this_month = (time_spent_this_month + @attendance.time_spent).round(2)
mail(to: @attendance.attender.email,
subject: "Attendance summary for #{@attend... |
#puts elle affiche la phrase entre guillemet}
puts "On va compter le nombre d'heures de travail à THP"
#puts affiche une phrase avec le résultat de l'opération dans #{}
puts "Travail : #{10 * 5 * 11}"
#puts affiche une phrase avec le résultat de l'opération dans #{}
puts "En minutes ça fait : #{10 * 5 * 11 * 60}"
#puts... |
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'solution'
describe AutoIncrement do
describe '#get_next_id' do
it 'increments...' do
a = AutoIncrement.new
(1..10).each do |i|
value(a.get_next_id).must_equal i
end
end
end
describe '#acknowledge' do
it... |
module Inventory
class SaveHarvestBatch
prepend SimpleCommand
attr_reader :user,
:args,
:id,
:cultivation_batch_id,
:batch,
:harvest_name,
:harvest_date,
:location_id,
:uom
def initialize(user, args)
@user = user
@args = HashWithIndifferentAcce... |
require 'spec_helper'
describe TheGrid::Api::Command::Paginate do
let(:relation){ double("ActiveRecord::Relation", :count => 25).as_null_object }
context "when options are missed" do
after(:each){ subject.execute_on(relation, {}) }
it "returns first page" do
relation.should_receive(:offset).with(0)... |
module Docopt
VERSION = '0.5.0'
extend self
@usage = ''
def self.usage
@usage
end
class DocoptLanguageError < SyntaxError
end
class Exit < RuntimeError
def initialize(message='')
super("#{message}\n#{Docopt.usage}".strip)
end
end
class Pattern
attr_accessor :children
... |
class Conversation < ApplicationRecord
has_many :conversation_memberships
has_many :users, :through => :conversation_memberships
end
|
class UsersController < ApplicationController
before_action :admin_access, only: [:index, :destroy]
def index
@users = User.all
end
def show
user = User.find(params[:id])
if current_user.admin? || current_user == user
@user = user
@type = type(@user)
else
redirect_to root_path... |
$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
require 'qml'
require 'pathname'
module Examples
module Todo
VERSION = '0.1'
class TodoController
include QML::Access
register_to_qml
property(:title) { '' }
property(:description) { '' }
property(:due_date) { '' }
... |
require File.dirname(__FILE__) + '/../test_helper'
class BodyControllerTest < ActionController::TestCase
fixtures :users, :bodies
# Replace this with your real tests.
def setup
@controller = BodyController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.ne... |
class TasksController < ApplicationController
expose(:task, attributes: :task_params)
expose(:tasks)
expose(:category)
expose(:categories)
def create
if task.save
redirect_to task, notice: 'Task was successfully created.'
else
render :new
end
end
def update
if task.save
... |
class Chest < ActiveRecord::Base
has_many :order_items
before_save :update_price
def price
chest_items.collect { |oi| oi.valid? ? (oi.price) : 0 }.sum
end
end |
# word_to_digit.rb
# Write a method that takes a sentence string as input, and returns the same
# string with any sequence of the words 'zero', 'one', 'two', 'three', 'four',
# 'five', 'six', 'seven', 'eight', 'nine' converted to a string of digits.
# Pseudo-Code:
# Data Structure:
# input: a sentence string
# output... |
module GnomeVersion
def gnome_version
patched_version = `apt-cache show gnome-session | awk '/Version/ { print $2 }'`.strip
# Cut patch and keep only x.y.z
version = patched_version.scan(/\d+\.\d+(?:\.\d+)?/).first
return version || '0.0'
end
def gnome_version_constraint(constraint)
version... |
Rails.application.routes.draw do
resources :niches do
collection do
post :move
get :highlight
end
end
resources :items
post 'free_item', action: :show_free_item, controller: 'welcome'
post 'new_request', action: :new, controller: 'free_item_requests'
post 'give_away', action: :give_awa... |
class CreateCards < ActiveRecord::Migration
def change
create_table :cards do |t|
t.integer :suit_cd
t.integer :denomination_cd
t.integer :card_set_id
t.timestamps null: false
end
end
end
|
class ApplicationController < ActionController::API
before_action :authenticate_request
attr_reader :current_user
rescue_from Exceptions::InvalidCredentials do
render json: { error: 'invalid credentials' }, status: :unauthorized
end
rescue_from Exceptions::InvalidToken do
render json: { error: 'inva... |
#
# Cookbook Name:: aligent-magento-dev-ubuntu
# Recipe:: magento2-cron
#
# Copyright 2016, Aligent Consulting
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including... |
require 'base64'
RSpec.describe ::Ayte::Chef::Cookbook::ElasticSearch::Request do
def create_request
::Ayte::Chef::Cookbook::ElasticSearch::Request.new
end
describe ::Ayte::Chef::Cookbook::ElasticSearch::Request::BasicAuthorization do
def create_auth(user, password)
klass = ::Ayte::Chef::Cookbook:... |
# frozen_string_literal: true
FactoryBot.define do
factory :crafting_component do
item_crafting { nil }
component { nil }
amount { 1 }
end
end
|
# encoding: UTF-8
# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0
module TwitterCldr
module Resources
module Requirements
class GitRequirement
attr_reader :repo_url, :ref
def initialize(repo_url, ref)
@repo_url = repo_url
@ref = ref
... |
class ContinentsController < ApplicationController
before_action :find_plane
def index
@continents = Continent.all
end
def show
@continent = Continent.find(params[:id])
end
def new
@continent = Continent.new
end
def edit
@continent = Continent.find(params[:id])
end
def create
... |
json.array!(@student_logs) do |student_log|
json.extract! student_log, :id, :branch_id, :student_id, :sequence_no, :log_entry_date, :log_entry_contents, :log_engry_person
json.url student_log_url(student_log, format: :json)
end
|
module Goodreads
module Authors
# Get author details
#
def author(id, params={})
params[:id] = id
data = request('/author/show', params)
Hashie::Mash.new(data['author'])
end
# Search for an author by name
#
def author_by_name(name, params={})
params[:id] = name
... |
class RenameBranchesMenuCategoriesToBranchMenuCategories < ActiveRecord::Migration
def change
rename_table :branches_menu_categories, :branche_menu_categories
end
end
|
# Monsters
class
MonstersController < ApplicationController
load_and_authorize_resource
skip_authorize_resource only: [:home, :search]
# Вывод всех монстров
def index
authorize! :index, Monster
@letter = Monster.letterize(params[:letter])
@monsters = Monster.letter(@letter).page(1).per(10)
e... |
class User < ActiveRecord::Base
validates :email,
:password_digest,
:session_token,
presence: true
has_many :clips
end
|
# == Schema Information
#
# Table name: queue_items
#
# id :integer not null, primary key
# user_id :integer
# locked :string(255) default(""), not null
# queueable_id :integer
# queueable_type :string(255) default(""), not null
# queueable_subtype :s... |
class ProductsController < ApplicationController
require 'json'
def index
@products = Product.all
end
def show
@product = Product.find(params[:id])
end
def edit
@product = Product.find(params[:id])
end
def update
@product = Product.find(params[:id])
delta = (product_params[:quan... |
require "minitest_helper"
describe LyricsHelper do
let(:text) { "Can you\nfeel it?" }
let(:line) { text.split("\n").first }
let(:word) { text.split(' ').first }
describe "#build_granular_lyric_for" do
it "must wrap every word in the text with HTML span tags" do
build_granular_lyric_for(text)
... |
# frozen_string_literal: true
require_relative '../lib/connect_four'
require_relative '../lib/game_printer'
require_relative '../lib/game'
describe ConnectFour do
let(:game) do
instance_double(
Game,
won?: false,
draw?: false,
change_player: nil,
make_move: nil,
current_playe... |
$LOAD_PATH.unshift './lib'
require 'em-xmpp/connection'
require 'em-xmpp/helpers'
if ARGV.empty?
puts "usage: #{__FILE__} <jid> [<pass>] [certificates-dir]"
exit 0
end
jid = ARGV.first
pass = ARGV[1]
server = ARGV[2]
port = ARGV[3]
certdir = ARGV[4]
module RosterClient
attr_reader :roster
include... |
class ApplicationController < ActionController::Base
include SessionsHelper
before_filter :authenticate_user, except: [:new, :create]
protect_from_forgery with: :exception
private
def authenticate_user
if session[:user_id] == nil
redirect_to sign_in_path
end
end
end
|
class Udipity::UDPHandler < EventMachine::Connection
def receive_data data
Udipity::Datagram.new(data).run callback
end
private
def callback
EM::DefaultDeferrable.new.callback { |r|
data = r || 'No data'
send_data(data + "\n")
}
end
end
|
module Drill
module Model
def self.included(base)
base.class_eval do
end
end
module ClassMethods
def client
@client ||= Drill::Client.new
end
def client=(client)
@client = client
end
end
extend ClassMethods
c... |
module CyberarmEngine
class Element
class Progress < Element
def initialize(options = {}, block = nil)
super(options, block)
@fraction_background = Background.new(background: @style.fraction_background)
self.value = options[:fraction] || 0.0
end
def render
@frac... |
class Blogger < ApplicationRecord
has_many :posts
has_many :destinations, through: :posts
validates :name, uniqueness: true
validates :age, numericality: {greater_than: 0}
validates :bio, length: {minimum: 30}
def max_likes
max_likes = 0
self.posts.each do |post|
... |
require 'rails_helper'
RSpec.describe Color, type: :model do
it { should have_valid(:name).when('Blue', 'Red') }
it { should_not have_valid(:name).when(nil, '') }
it { should have_many(:cards) }
it "Contains colors" do
color = Color.create(name: 'Blue')
expect(color.name).to eq('Blue')
end
end
|
class AddGamesCountsToPlayers < ActiveRecord::Migration
def change
add_column :players, :winning_streak_count, :integer, default: 0, null: false
add_column :players, :losing_streak_count, :integer, default: 0, null: false
end
end
|
require File.dirname(__FILE__) + '/../../spec_helper'
require 'set'
describe "Set#==" do
it "returns true when the passed Object is a Set and self and the Object contain the same elements" do
Set[] == Set[]
Set[1, 2, 3].should == Set[1, 2, 3]
Set["1", "2", "3"].should == Set["1", "2", "3"]
Set[1... |
require "pp"
def parse_time_element(te,from,to)
ret = []
if te =~ /^\d+$/
ret << te.to_i
elsif te =~ /^[*]$/
ret = (from..to).to_a
elsif te =~ /,/
te.split(',').each do |e|
if e =~ /^\d+$/
ret << e.to_i
elsif e =~ /-/
ret += parse_time_element(e,from,to)
else
... |
module LdapServices
class LdapConn
def initialize
connect
end
def configure(settings)
@settings = settings
self
end
def connect
if @settings.nil?
user_config = JSON.parse(File.read("userconfig.json"), {:symbolize_names => true})
@settings = {
:h... |
class WelcomeMailer < ApplicationMailer
def welcome_user(user)
@user = user
@email = @user.email
mail(to: @email, subject: 'Welcome to Force of Nature Mission Control!')
end
def approved(user)
@user = user
@email = @user.email
mail(to: @email, subject: 'Welcome to Force of Nature... |
class AddColumnEventtIdToInvitation < ActiveRecord::Migration
def change
add_column :invitations, :eventt_id, :integer
end
end
|
describe ProfileSearcher do
subject { described_class.new(query: query) }
let!(:user_1) { create(:user) }
let!(:user_2) { create(:user) }
let!(:user_3) { create(:user) }
let!(:user_4) { create(:user) }
let!(:profile_1) { create(:profile, user: user_1, first_name: "ben") }
let!(:profile_2) { cre... |
class Photo < ActiveRecord::Base
belongs_to :user
has_many :comments, dependent: :destroy
has_many :likes, dependent: :destroy
has_many :qrcodes
has_many :tags, dependent: :destroy
mount_uploader :file, PhotoUploader
validate :validate_minimum_image_size, on: :create
scope :title_search, ->(title) { whe... |
class Api::V1::JukeboxListSongsController < ApplicationController
# before_action :set_jukebox_list_song, only: [:show, :update, :destroy]
# GET /jukebox_list_songs
def index
@jukebox_list_songs = JukeboxListSong.all
render json: @jukebox_list_songs
end
# GET /jukebox_list_songs/1
def show
re... |
class CreateBets < ActiveRecord::Migration[5.1]
def change
create_table :bets do |t|
t.references :book, foreign_key: true
t.float :spread
t.boolean :open
t.string :team
t.string :gameID
t.datetime :start
t.timestamps
end
end
end
|
class WantsController < ApplicationController
def index
@wants = Want.where(:user => current_user).order('position')
end
def create
Want.create!(user: current_user, list_entry_id: params[:list_entry_id])
respond_to do |format|
format.html { redirect_to geek_list_path(GeekList::AUSSIE_MID_YEAR_... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['VAGRANT_NO_PARALLEL'] = 'yes'
Vagrant.configure(2) do |config|
config.vm.provision "shell", path: "bootstrap.sh"
# Perforce Master Server
config.vm.define "p4server" do |p4server|
p4server.vm.box = "centos/7"
p4server.vm.hostname = "p4server.example.com"
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "DotNetCoreBaseBox"
# Forwarded port mapping host and guest machines
# - host is the machine on which you run "vagrant up"
# Default port here is 8080, which means the api wil... |
class World2
attr_reader :living_cells
def initialize
@living_cells = []
end
def add_living_at(location)
living_cells.push(location)
end
def alive_at?(location)
living_cells.include?(location)
end
def empty?
# living_cells.empty?
living_cells.count.zero?
end
end
|
class ShoesController < ApplicationController
before_action :set_shoe, only: [:show, :edit, :update]
before_action :check_if_user_has_organization
before_action :cannot_edit_if_delivered, only: [:edit, :update]
# GET /shoes
# GET /shoes.json
def index
@shoes = Shoe.where(organization_id: current_user.o... |
class ActivitiesController < ApplicationController
def index
@activities = Activity.has_tickets_left.order_by_date.paginate(page: params[:page], per_page: 6)
end
def show
@activity = Activity.find(params[:id])
end
end
|
class User < ApplicationRecord
has_secure_password
has_many :subscriptions, dependent: :nullify
VALID_EMAIL_REGEX = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
validates :email, presence: true, uniqueness: true, format: VALID_EMAIL_REGEX, unless: :from_oauth?
serialize :oauth_raw_data
store_accessor(... |
class CreatePlayerStats < ActiveRecord::Migration
def change
create_table :player_stats do |t|
t.integer :rushing_attempts
t.integer :rushing_yards
t.integer :rushing_touchdowns
t.integer :fumbles
t.integer :receptions
t.integer :receiving_yards
t.integer :receiving_touch... |
class AddOriginUrlToConsentForm < ActiveRecord::Migration[5.2]
def change
add_column :consent_forms, :origin_url, :string
end
end
|
require 'rails_helper'
describe TrelloApi do
let(:client) { TrelloApi.new(ENV['TRELLO_KEY'], ENV['TRELLO_TOKEN']) }
context 'getters', :vcr do
it '#get_card_name' do
expect(client.get_card_name('4D061Xdw')).to eql 'Test #get_card_name'
end
it '#set_card_name' do
name = client.set_card_nam... |
class TracksController < ApplicationController
before_action :set_track, only: [:show, :edit, :update, :destroy]
before_action :authenticate_account!
@roles = ["Author", "PC Chair", "PC Member", "Chair"]
# GET /tracks
# GET /tracks.json
def pundit_user
current_account
end
def index
@tracks =... |
class PlayinglocationsController < ApplicationController
before_filter :authenticate_user!, :only => [:new, :create, :destroy]
def new
@title = "New Playing Location"
@teamstat = Teamstat.find_by_id(params[:teamstat_id]) || not_found
@playinglocation = Playinglocation.new(:teamstat_id => @teamstat.id)
... |
class IncomeValuesController < ApplicationController
before_action :authenticate_user!
before_action :set_incomevalue, only: [:show, :edit, :update, :destroy]
before_action :user?, only: [:show, :edit, :update, :destroy]
def index
@income_values = IncomeValue.where(user_id: current_user.id,).order(year_month: "D... |
class ProvidersDatatable < ApplicationDatatable
delegate :edit_provider_path, to: :@view
private
def data
providers.map do |provider|
[].tap do |column|
column << provider.rut
column << provider.name
links = []
links << link_to('Ver', provider, class: 'btn btn-primary ... |
require 'sinatra'
require 'json'
API = '/api/v1'.freeze
def json(path)
path_with_req_method = path.gsub(API, "#{API}/#{request_method}")
ruby_file = ".#{path_with_req_method}.rb"
return "#{ruby_file} is absent" unless File.exists?(ruby_file)
eval(File.read(ruby_file)).to_json
end
def request_method
@requ... |
class ProjectTodo < ActiveRecord::Base
belongs_to :basecamp_project_todo
belongs_to :project
end
|
require 'socket'
Process.setrlimit(:NOFILE, Process.getrlimit(:NOFILE).first)
if ARGV.size < 2
abort "Usage: #{__FILE__} <host> <port-range> <port-range>\n" +
"e.g #{__FILE__} google.com 20..23 70..90"
end
ports = []
pool = []
sockets = []
host = ARGV[0]
ARGV[1..-1].map {|s| s.split('..').map(&:to_i)}.each { ... |
class AddLikesToComments < ActiveRecord::Migration[6.0]
def change
add_column :comments, :likes, :integer, :default => 0
end
end
|
class Employer < ApplicationRecord
has_secure_password
has_many :pars
validates :username , length: {minimum: 4}
validates :email , presence: true , uniqueness: true , length: {minimum: 5}
validates :role , presence: true
def auth_by_email
user=Employer.find_by(email: self.email.downcase)
.try(... |
class FontSecularOne < Formula
head "https://github.com/google/fonts/raw/main/ofl/secularone/SecularOne-Regular.ttf", verified: "github.com/google/fonts/"
desc "Secular One"
homepage "https://fonts.google.com/specimen/Secular+One"
def install
(share/"fonts").install "SecularOne-Regular.ttf"
end
test do
... |
class PostsTag
include ActiveModel::Model
attr_accessor :title, :content, :name, :user_id
with_options presence:true do
validates :title
validates :content
validates :name
end
def save
post = Post.create(title: title, content: content, user_id: user_id)
tag = Tag.where(name: name).first... |
require 'time'
module Venice
class ReceiptVerificationError < StandardError; end
# 21000: The App Store could not read the JSON object you provided.
class InvalidJSONObjectError < ReceiptVerificationError; end
# 21002: The data in the receipt-data property was malformed.
class MalformedReceiptDataError < R... |
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def id_as_code(n=7) # преобразует id объекта в число типа 000001
(self.id.to_s.length >= 7) ? self.id.to_s : "#{"0"*(n - self.id.to_s.length)}#{self.id}"
end
def split_by_locale(t) # текст должен выглядеть вот так: "русский {engl... |
class Timer
def seconds
@hours = 0
@minutes = 0
@seconds = 0
end
def seconds=(val)
if val >= 3600
@hours = val/3600
temp = val%3600
@minutes = temp/60
@seconds = temp%60
elsif
@minutes = val/60
@seconds = val%60
end
end
def time_string
DateTime.new(2014,1,1,@hours,@minutes,@s... |
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
def after_sign_in_path_for(resource)
if resource.is_a?(User)
'/dashboard'
else
'/overview'
end
en... |
class AngellistStartupWorker
include Sidekiq::Worker
def perform(company_name)
company = Company.find_by(name: company_name)
# if it does not exist, then why are we pulling in the angellist data
return unless company
company_slug = company.permaname
client = AngellistApi::Client.new
angl_... |
require 'spec_helper'
describe "validate_schema_types_matcher" do
before :all do
define_model :item do
plugin :validation_helpers
def validate
validates_schema_types :name, :message => "Not a valid string"
end
end
end
subject{ Item }
it "should require an attribute" do
... |
require 'spec_helper'
describe BlogDataController do
before(:each) do
@controller.stub(:authenticate_user!)
@controller.stub(:has_admin_credentials?)
end
def valid_attributes
{ :client_id => 1, :social_network_id => 1, :start_date => "01-01-2012".to_date, :end_date => "31-01-2012".to_date, :unique_... |
module ApplicationHelper
def page?
return false unless signed_request
page ? true : false
end
def page
@page ||= signed_request.page
end
def canvas?
return false unless signed_request
!page?
end
def signed_request
@signed_request
end
end
|
class CashRegister
attr_accessor :total, :items, :with_discount, :last_transaction_amount
def initialize(with_discount = 0)
@total = 0
@with_discount = with_discount
@items = []
end
def discount
self.with_discount
end
def add_item(title,price,quantity = 1)
@total += price*quantity
quantity.times do
... |
class Partner
class Service < ApplicationRecord
self.table_name = 'partner_services'
belongs_to :partner, class_name: 'Partner', required: false
belongs_to :service, class_name: 'BaseService', required: false
class << self
def base_columns
%w[service_id name]
end
end
end
en... |
#==============================================================================
#
# • modern algebra Monster Catalogue v1.4 Add-on:
# • Kill Counts, Elements and States Resistance,
# Drop Items (including Extra Drops from Yanfly),
# and Stealable Items from Yanfly Script
# by : DrDhoom
# -- Last Updated: 2... |
class Router
def initialize(meals_controller, customers_controller)
@meals_controller = meals_controller
@customers_controller = customers_controller
end
def run
@running = true
while @running
display_tasks
user_action = gets.chomp
route_to(user_action)
end
end
def dis... |
class UsersController < ApplicationController
before_action :set_user, only: :finish_signup
layout "persons", only: [:edit, :update]
# GET/PATCH /users/:id/finish_signup
def finish_signup
# authorize! :update, @user
if request.patch? && params[:user] #&& params[:user][:email]
if @user.update(use... |
execute "apt-get-update" do
command "apt-get update"
end
if node[:development] == true
node[:apache][:user] = "vagrant"
node[:apache][:group] = "vagrant"
end
require_recipe "apt"
require_recipe "apache2"
require_recipe "apache2::mod_php5"
require_recipe "apache2::mod_rewrite"
require_recipe "apache... |
class ItemsController < ApplicationController
def index
@keyword = params[:keyword]
if @keyword.present?
results = RakutenWebService::Ichiba::Item.search({
keyword: @keyword,
imageFlag: 1,
hits: 20,
})
@items = results.map do |result|
item = Item.find_or_ini... |
require "./lib/special_item.rb"
describe SpecialItem do
context "item isi Sulfuras, and does not need to be sold" do
it "does not change sellIn " do
item = SpecialItem.new("Sulfuras", 10, 10)
GildedRose.new(item).update_quality
expect(item.sell_in).to eq(10)
end
it "it does not chang... |
module Pretentious
# Contains references to scoped variables
class Context
# list of variable names to use. i j are not there on purpose
VARIABLE_NAMES = %w(a b c d e f g h k l m n o p q r s t u v w x y z)
attr_accessor :declared_names, :variable_map,
:previous_declarations
def i... |
# frozen_string_literal: true
class NodesController < ApplicationController
before_action :assign_network
def new
@node = @network.nodes.new
end
def edit
@node = Node.find(params[:id])
end
def show
respond_to do |format|
format.json do
node = Node.find(params[:id])
if... |
require 'angel'
include Angel
namespace :twitter do
task process: [:environment] do
bot_name = ENV["BOT_NAME"]
last_tweet = Timeline.last.tweet_id.to_i
TwitterClient.mentions_timeline({:since_id => last_tweet}).each do |tweet|
#avoid duplicate tweets by exiting if already processed tweets come back... |
class Notifier < ActionMailer::Base
def support_notification(sender)
@sender = sender
mail(:to => "mvjohn100@gmail.com",
:from => sender.email,
:subject => "Query")
end
end
|
require 'spec_helper'
describe CpuJob do
describe "process" do
before :each do
@job = CpuJob.new
end
it "should take more than two seconds to run" do
@job.process
delta = @job.ended_at - @job.started_at
puts "CpuJob delta = #{delta}"
delta.should be > 2
end
end
end
|
class Meal < ApplicationRecord
validates_presence_of :mealName, :message => 'Please Enter a Meal '
validates :mealName, length: {minimum: 2}
validates_presence_of :description, :message => 'Please Enter a description '
validates :description, length: {minimum: 2}
validates... |
module FogTracker
# Tracks a single Fog collection in a single account.
# Each {CollectionTracker} instance is tightly bound to an {AccountTracker}.
class CollectionTracker
# An Array of Fog::Model objects, all of the same resource type (class)
attr_reader :collection
# Creates an object for tracki... |
require "application_system_test_case"
class BotsTest < ApplicationSystemTestCase
test "Navigate to bots list" do
users(:admin).update(chatbot_enabled: true)
Feature.with_chatbot_enabled do
admin_go_to_agents_index
assert has_text?("admin/weather")
click_link "My awesome weather bot admin/... |
class AccountsController < ApplicationController
def index
accounts = Account.all
if (name = params[:name])
accounts = accounts.where name: name
end
render json: accounts, response: 200
end
def show
account = Account.find params[:id]
render json: account, response: 200
end
def ... |
module Fog
class Bluebox
class Real
# Get details of a product
#
# ==== Parameters
# * product_id<~Integer> - Id of flavor to lookup
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO
def get_product(product_id)
request(... |
Pod::Spec.new do |s|
s.platform = :ios
s.name = 'ReusableAuthentication'
s.swift_versions = ['4.0','4.2', '5.0']
s.version = '0.8.0'
s.summary = 'ReusableAuthentication is a powerful, pure-Swift library for Reuse Your Login and Signup Page with UI and Validations.'
s.requires_... |
require 'spec_helper'
require 'rails_helper'
require 'fakeweb'
require 'fetcher/updater'
require 'delorean'
def mock_web(url, file)
FakeWeb.register_uri(:any, url, body: IO.read("spec/fetcher/pages/#{file}"), content_type: "text/html")
end
def pretend_to_obtain_books(file)
mock_web Fetcher::SOUTHWARK_LOGINFORM_U... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.