text stringlengths 10 2.61M |
|---|
class VegetablesController < ApplicationController
def index
@vegetables= @garden.vegetables.all
end
#def show
#@vegetable=Vegetable.find(params[:id])
#end
def new
@garden = Garden.find(params[:garden_id])
@vegetable = @garden.vegetables.new
end
def create
@garden= Garden.find(p... |
#!/usr/bin/env rake
desc 'adds a remote repo as a subtree'
task :add_remote_subtree, [:repo] do |_, args|
`git remote add -f #{args[:repo]} https://github.com/#{args[:repo]}`
`git merge -s ours --no-commit #{args[:repo]}/master`
`git read-tree --prefix=bundle/#{args[:repo]} -u #{args[:repo]}/master`
`git comm... |
class Like < ApplicationRecord
belongs_to :lesson, counter_cache: :likes_count
belongs_to :user
end
|
class LessonExamsController < ApplicationController
before_filter :find_lesson
def index
end
def new
@exams = current_user.organization.exams
end
def create
@exam = current_user.organization.exams.find(params[:assignment][:exam_id])
if @lesson.attach_exam(@exam)
@lesson.reload
... |
require 'test_helper.rb'
class DeletingAccountsTest < ActionDispatch::IntegrationTest
setup { @account = Account.create! name: 'Jonas' }
test 'deletes account' do
delete "/accounts/#{@account.id}"
assert_equal 204, response.status
end
test 'domains owned by account are deleted with account' do
do... |
class ModuleGenerator < Rails::Generators::NamedBase
source_root File.expand_path('templates', __dir__)
attr_reader :module_name, :module_path
# first, the initialize method
def initialize(args,*options)
super
full_name = file_name.underscore
@module_name = full_name.split('_').last
@module... |
# Analyze the Errors
# I worked on this challenge [by myself].
# I spent [#] hours on this challenge.
# --- error -------------------------------------------------------
#{}"Screw you guys " + "I'm going home." = cartmans_phrase
# This error was analyzed in the README file.
# --- error -----------------------------... |
class ScrapingWorker
include Sidekiq::Worker
sidekiq_options :queue => :scrape_any
def perform(exp_name, account_id, iteration, to_reload = :all)
Mongoid.with_tenant(exp_name) do
account = GoogleAccount.where(:_id => account_id).first
GmailScraper.new.scrap_account(account, iteration, to_reload)
... |
require './lib/generator'
module Messagable
include Generatable
def cleaned_input_message_to_elements(message)
message.downcase.strip.split("")
end
def original_numbers_for_message(message)
cleaned_input_message_to_elements(message).map do |letter|
if alphabet_with_index[letter].nil?
le... |
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
include ApplicationHelper
private
def current_user?
end
helper_method :current_user?
def current_user
... |
class Picture < ApplicationRecord
belongs_to :chapter
mount_uploader :picture, ImagePageUploader
end
|
require 'test_helper'
class CheckInTest < ActiveSupport::TestCase
setup do
@check_in = build(:check_in, user: build(:user))
end
test 'is invalid without required attributes' do
@check_in.update_attributes(user: nil)
assert_not @check_in.valid?
end
test 'is valid with required atttributes' do
... |
require_relative "user"
require_relative "song"
class Playlist
attr_reader :id, :user_id
attr_accessor :song_ids
def initialize(id:, user_id:)
@id = id
@user_id = user_id
@song_ids = []
end
def to_json
return {
"id" => @id,
"user_id" => @user_id,
"song... |
require 'hand'
require 'rspec'
describe Hand do
# subject(:hand) { Hand.new }
describe "#straight_flush?" do
let(:cards_1) { [Card.new(5, :S), Card.new(6, :S), Card.new(7, :S), Card.new(8,:S), Card.new(9,:S)]}
let(:cards_2) { [Card.new(5, :S), Card.new(6, :D), Card.new(7, :S), Card.new(8,:S), Card.new(9,:... |
class ChangeColumnTypeInTempUser < ActiveRecord::Migration
def self.up
change_column :temp_users, :stranger_key, :string
end
def self.down
end
end
|
class Schedule < ActiveRecord::Migration[5.2]
def change
create_table :schedules do |t|
t.integer :student_id
t.integer :classroom_id
t.integer :room_number
t.integer :period
end
end
end
|
require 'screenplay/part'
describe Screenplay::Part do
let(:host) { 'testhost' }
let(:options) { { one: 'one', two: 'two' } }
describe '.play' do
it 'creates a new Part with the params that it got' do
Screenplay::Part.should_receive(:new).with(host, options)
Screenplay::Part.play(host, options)... |
require 'spec_helper'
describe "choices/index.html.erb" do
before(:each) do
assign(:choices, [
stub_model(Choice,
:QuestionID => 1,
:ChoiceAnswers => "Choice Answers"
),
stub_model(Choice,
:QuestionID => 1,
:ChoiceAnswers => "Choice Answers"
)
... |
class RestaurantsController < ApplicationController
before_action :set_restaurant, only: [:show]
def index
@restaurants = Restaurant.all.order(created_at: :desc).page(params[:page]).per(6)
if user_signed_in?
@browsing_histories = BrowsingHistory.where(user_id: current_user.id).order(created_at: :des... |
require 'websocket-client-simple'
module BinanceAPI
class Stream
BASE_ENDPOINT = 'wss://stream.binance.com:9443/'.freeze
def initialize(endpoints, on_open: nil, on_close: nil, on_error: nil, on_message: nil)
raise 'on_open can accept a block only' if !on_open.nil? && !on_open.is_a?(Proc)
raise 'o... |
class Resty < ApplicationController
before_filter :authenticate_player!
def update
it = clazz.find(params[:id])
it.update_attributes(params[param])
it.save!
render :json => it
end
def new
render :json => clazz.new
end
def create
render :json => clazz.create!(params[param])
end
... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# 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 without limitation the rights
#... |
class StudentsController < ApplicationController
skip_before_action :confirm_authentication
def index
students = Student.all.order(:name)
render json: students
end
def show
student = Student.find_by(id: params[:id])
render json: student, serializer: StudentSerializ... |
require 'test_helper'
module Api
module V1
class UsersControllerTest < ActionController::TestCase
# index
test "should get 10 users" do
@request.headers["Accept"] = 'application/x-user+json'
@request.headers["Range"] = 'items=0-9'
get :index, {:token => '0474eee1800353d61a5de09259ee... |
require File.join(File.dirname(__FILE__), 'spec_helper')
JCloneable = java.lang.Cloneable
JComparable = java.lang.Comparable
describe "Class interface support" do
before :each do
@class = Class.new
end
it "should be empty by default" do
@class.interfaces.should be_empty
end
it "should retain in... |
require 'docking_station'
describe DockingStation do
subject(:station) { described_class.new}
let(:bike) { double :bike }
describe '#default' do
it 'allows capacity to be set' do
docking_station = described_class.new(50)
expect(docking_station.capacity).to eq 50
end
it 'it sets a defaul... |
class ProductImage < ApplicationRecord
belongs_to :product
attachment :product_img
end
|
# Módulo de integração com a ferramenta JFlap
#
# Marcelo Guimarães
module JFLAP
def self.included(base)
base.send(:extend, JFLAP::In)
base.send(:include, JFLAP::Out)
end
module Out
# Exporta este autômato para o formato xml lido pelo programa JFLAP.
#
# Para usar esse recurso, deve ser carr... |
class UserDecorator < Draper::Decorator
delegate_all
def last_login_date
object.last_sign_in_at.strftime("%g.%m.%Y %H:%M")
end
def created_date
object.created_at.strftime("%g.%m.%Y %H:%M")
end
end
|
require_relative "piece"
require_relative "errors"
class Board
attr_reader :grid #for the display class
def initialize(populate = true, size = 8)
@grid = Array.new(size) { Array.new(size) { EmptySquare.new } }
populate_grid if populate
end
############################
# Board Control and Access #
... |
module MotiaTools
def self.logger
@logger ||= build_default_logger
end
private
def self.build_default_logger
default = Logger.new(STDOUT)
default.level = Logger::INFO
default.formatter = proc do |severity, datetime, progname, msg|
case severity
when 'INFO' then "#{ms... |
asteroids_map = ARGF.each_line.map(&:chomp).map do |line|
line.split('').map do |value|
value == '#'
end
end
Vector = Struct.new(:x, :y) do
def length
@length ||= Math.sqrt(x ** 2 + y ** 2)
end
def dot(other)
x * other.x + y * other.y
end
def angle(other)
Math.acos(dot(other) / (length ... |
module Blueprints
# Namespace class, inherits from Buildable. Allows adding and finding child blueprints/namespaces and building
# all it's children.
class Namespace < Buildable
cattr_accessor :root
delegate :empty?, :size, :to => :@children
# Creates namespace by name. See Buildable#new.
# @para... |
class AddDefaultValueForVoteValue < ActiveRecord::Migration
def change
remove_column :votes, :vote_value
add_column :votes, :vote_value, :integer, default: 0
end
end
|
module CronSpec
##
# Factory for constructing Day CronValues from a cron specification.
#
class DayFactory < CronSpecificationFactory
# The lower limit for a value representing a day of the month
DayLowerLimit = 1
# The upper limit for a value representing a day of the month
DayUpperLimit =... |
class Friendship < ActiveRecord::Base
belongs_to :sender, :class_name => "User"
belongs_to :receiver, :class_name => "User"
validates :sender_id, :receiver_id, presence: true
validates :sender_id, uniqueness: {scope: :receiver_id}
end
|
class Flashcards
attr_accessor :cards, :answers
def initialize
@cards = [
{ question: "To create a second name for the variable or method.",
answers: ["alias", "begin", "else", "elsif"] },
{ question: "A command that appends two or more objects together.",
answers: ["break", "do", "... |
# frozen_string_literal: true
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = 'The Studio'
if page_title.empty?
base_title
else
page_title + ' | ' + base_title
end
end
def anyone_signed_in?
admin_signed_in? || ... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Users', type: :system do
let!(:me) { create(:user) }
describe 'Log in', js: true do
context 'when valid email and password is filled in' do
before do
visit new_user_session_path
fill_in 'メールアドレス', with: me.email
... |
/*
*/
module GenomeAnnotationFileUtil {
/* A boolean - 0 for false, 1 for true.
@range (0, 1)
*/
typedef int boolean;
/*
file_path or shock_id -- Local path or shock_id of the uploaded file with genome
sequence in GenBank format or zip-file with GenBank files.
... |
#Basic Combos v1.2f.01
#----------#
#Features: Allows heroes to combine their attacks to use greater skills.
# Currently allows a chance for two heroes to cast a stronger
# skill for greater damage if both heroes cast the same spell
# on the same target, and the skill has a combo skill.
#
... |
module RemdineFarendSupport
class Hooks < Redmine::Hook::ViewListener
HOOKS_DIR = 'redmine_farend_support/hooks'
render_on :view_layouts_base_html_head,
:partial => File.join(HOOKS_DIR, '/view_layouts_base_html_head')
render_on :view_account_login_bottom,
:partial => File.join(HOOKS_DIR, 'v... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe InvitationEmailJob, type: :job do
describe '#perform' do
let(:invitation) { FactoryGirl.create(:invitation) }
it 'calls on the InvitationMailer' do
allow(InvitationMailer).to receive_message_chain(:invite, :deliver_now)
Invitat... |
class FontCinzel < Formula
head "https://github.com/google/fonts/raw/main/ofl/cinzel/Cinzel%5Bwght%5D.ttf", verified: "github.com/google/fonts/"
desc "Cinzel"
homepage "https://fonts.google.com/specimen/Cinzel"
def install
(share/"fonts").install "Cinzel[wght].ttf"
end
test do
end
end
|
class Appointment < ActiveRecord::Base
validates_presence_of :start_time, :end_time
belongs_to :user
belongs_to :client
belongs_to :appointment_type
after_initialize :set_end_time_for_appointment_type, :if => Proc.new { |appointment| appointment.appointment_type.present? && appointment.end_time.blank? }
... |
require "stringio"
require "chandler/logger"
module LoggerMocks
class ColorfulStringIO < StringIO
def tty?
true
end
end
private
def stdout
@stdout.string
end
def stderr
@stderr.string
end
def new_logger
@stderr = StringIO.new
@stdout = StringIO.new
Chandler::Logger... |
module ItemtagsHelper
def itemtag_params
params.require(:itemtag)
.permit(:name,
:display_name,
:description,
:default_value_mask,
:store_value)
end
def generate_tag(category, name)
"itemtag-#{category}-#{name.strip.downcase}"
end
def generate_dis... |
class AddIndexToPoints < ActiveRecord::Migration
def change
add_index :points, :list_id
end
end
|
# frozen_string_literal: true
FactoryBot.define do
factory :user do
#name { 'Test' }
sequence(:name) { |n| "name#{n}" }
#email { 'test@example.com' }
sequence(:email) { |n| "sample@sample.com#{n}" }
password { '121212' }
password_confirmation { '121212' }
avatar { fixture_file_upload(Rail... |
require 'test_helper'
class PetshopsControllerTest < ActionDispatch::IntegrationTest
setup do
@petshop = petshops(:one)
end
test "should get index" do
get petshops_url
assert_response :success
end
test "should get new" do
get new_petshop_url
assert_response :success
end
test "shoul... |
class AddIndexToAnimeSearchColumns < ActiveRecord::Migration[6.0]
def change
add_index :animes, :ru_title
add_index :animes, :eng_title
add_index :animes, :romaji_title
end
end
|
class CreateAds < ActiveRecord::Migration
def self.up
create_table :ads do |t|
t.integer :adbackend_id, :offer_id, :width, :height
t.string :name, :review_link
t.text :code
t.date :expires
t.decimal :payout, :precision => 10, :scale => 2
t.timestamps
end
add_index :ads,... |
#
#= ヘルプ管理用コントローラのアクションを定義するモジュール
#
module Concerns::Susanoo::Admin::HelpsController
extend ActiveSupport::Concern
included do
before_action :admin_required
before_action :set_help_content, only: %i(edit update destroy)
layout "explore"
#
#=== ヘルプ管理一覧画面
#
# parent_idがある場合は、紐づくヘルプを返却する
... |
require_relative './controller'
require_relative './models/user'
module GoCLI
# App is your main class
# When you start the program with ./bin/start.sh script, you invoke App.run
# You don't have to change anything in this file
class App
def self.run
form = { steps: [] }
controller = Controller... |
class Article < ApplicationRecord
has_attached_file :article_cover, styles: {large: "600x600>", medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
validates_attachment_content_type :article_cover, content_type: /\Aimage\/.*\z/
has_many :status_managers
has_many :statuses, throu... |
class BaseUser
attr_accessor :name
def initialize options = {}
@name = options[:name] || 'no name'
end
def role_list_value
instance_variable_get "@role_list"
end
def role_value
instance_variable_get "@#{self.class.troles_config.role_field}"
end
def troles_changed?
false
end
... |
require File.expand_path('helper', File.dirname(__FILE__))
class ConfigurationParserTest < ActiveSupport::TestCase
context "exploding the database.yml" do
setup do
@exploded_conf = ActiveRecordShards::ConfigurationParser.explode(YAML::load(IO.read(File.dirname(__FILE__) + '/database_parse_test.yml')))
... |
class TSV
include Enumerable
attr_reader :filepath, :col_sep, :headers, :file_handle
# Optionally pass in a different :col_sep as an optional hash param. The
# default :col_sep is tab.
def initialize(filepath, col_sep: "\t")
@filepath = filepath
@col_sep = col_sep
@file_handle = File.open(filepa... |
# Modify the code below so "Hello!" is printed 5 times.
# say_hello = true
# while say_hello
# puts 'Hello!'
# say_hello = false
# end
say_hello = true
i = 0
while say_hello
puts 'Hello!'
i += 1
say_hello = false if i == 5
end
|
require 'spec_helper'
describe 'ffmpeg' do
describe package('ffmpeg-cm') do
it { should be_installed }
end
describe command('/usr/bin/ffmpeg -version') do
its(:exit_status) { should eq 0 }
end
end
|
class ChangeInterpretationLocales < ActiveRecord::Migration[5.1]
def change
ActiveRecord::Base.record_timestamps = false
Nlp::Package.sync_active = false
begin
convert_interpretations
convert_intents
ensure
ActiveRecord::Base.record_timestamps = true
Nlp::Package.sync_active = ... |
# encoding: utf-8
#
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
# 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 without limitation the rights
#... |
module Jaguar::HTTP2
class Client
def initialize(sock)
@sock = sock
@conn = HTTP2::Client.new
@conn.on(:frame, &method(:on_frame))
@conn.on(:frame_sent, &method(:on_frame_sent))
@conn.on(:frame_received, &method(:on_frame_received))
@conn.on(:promise, &method(:on_promise))
... |
desc "rake task to fetch course term and individual course information from MaIS APIs"
task fetch_courses: :environment do
current_term = Terms.current_term
future_term = Terms.future_terms.first
errors = []
c_api = CourseApi.new
# Get the current term and the very next term
[current_term, future_term].eac... |
#1
=begin
def short_long_short(str1, str2)
str1.length > str2.length ? str2 + str1 + str2 : str1 + str2 + str1
end
p short_long_short('abc', 'defgh') == "abcdefghabc"
p short_long_short('abcde', 'fgh') == "fghabcdefgh"
p short_long_short('', 'xyz') == "xyz"
#2
def century(year)
century = year / 100 + 1
centu... |
class FacilitiesController < ApplicationController
inherit_resources
before_filter :authenticate_user!
filter_resource_access
def create
create! { facilities_path }
end
def update
update! { facility_path(@facility) }
end
end
|
# frozen_string_literal: true
class User
module Stripes
NARROW = /^P?[CD]C$/i.freeze
NATIONAL = /^P?(([CVR]|Stf)C|N(FLt|Aide))$/i.freeze
DISTRICT = /^P?D((Lt)?C|(F(irst)?)?Lt|Aide)$/i.freeze
SQUADRON = /^(P?((Lt)?C|(F(irst)?)?Lt)|Cdr)$/i.freeze
TWO = /^(P?([CVR]C|(D?(FirstLt|(Lt)?C)))|Cdr)$/i.fre... |
class RemoveVkontakteUid < ActiveRecord::Migration
def change
remove_index :users, :vkontakte_uid
remove_column :users, :vkontakte_uid
end
end
|
module TfIdfSimilarity
class Model
include MatrixMethods
extend Forwardable
def_delegators :@model, :documents, :terms, :document_count, :term_index
# @param [Array<Document>] documents documents
# @param [Hash] opts optional arguments
# @option opts [Symbol] :library :gsl, :narray, :nmatrix... |
require_relative 'tuple'
require 'byebug'
class CanvasCoordinateOutOfBoundsException < ArgumentError; end
class Canvas
PPM_MAGIC_NUMBER = 'P3'
MAX_COLOR_VALUE = 255
attr_reader :width, :height, :pixels
def initialize(width, height)
@width = width
@height = height
@pixels = Array.new(width * hei... |
class AddResStatusToPrediction < ActiveRecord::Migration
def change
add_column :predictions, :res_status, :text
end
end
|
require 'funl/client'
require 'funl/blobber'
require 'funl/message-sequencer'
require 'funl/client-sequencer'
require 'socket'
require 'tmpdir'
include Funl
require 'minitest/autorun'
class TestClient < Minitest::Test
attr_reader :log, :client
def setup
@dir = Dir.mktmpdir "funl-test-client-"
@cseq_path... |
# frozen_string_literal: true
module Sleet
class RspecFileMerger
def initialize(files)
@files = files
end
def output
RSpec::Core::ExampleStatusDumper.dump(sorted_examples)
end
private
attr_reader :files
def sorted_examples
examples.sort_by { |hash| hash[:example_id] ... |
class Religion < ActiveRecord::Base
has_many :dosens
has_many :students
end
|
class SellersController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
def update
t = Seller.find(params[:id])
t.update(status_params)
redirect_back(fallback_location: events_path)
end
def create
@seller = Seller.create(seller_params)
if @seller.save
... |
require 'pogoplug/hash_initializer'
module PogoPlug
class File
attr_accessor :name, :id, :type, :size, :mimetype, :parent_id, :properties, :origin, :raw
module Type
FILE = 0
DIRECTORY = 1
STREAM = 2
SYMBOLIC_LINK = 3
end
include HashInitializer
def directory?
@typ... |
require 'spec_helper'
describe Admin::BlogsController do
describe 'PUT blog 修改' do
subject {FactoryGirl.create :blog}
it 'updates a blog extra info' do
put :update, id: subject.id
response.should redirect_to admin_blog_path(subject)
end
end
describe 'POST blog 创建' do
it 'create a bl... |
#---------------------------------------------------------------------------
# Copyright (c) Microsoft Open Technologies, Inc.
# All Rights Reserved. Licensed under the Apache License, Version 2.0.
# See License.txt in the project root for license information.
#---------------------------------------------------------... |
class ApplicationController < ActionController::Base
helper_method :user
protected
def user
@user ||= User.find(params[:id])
end
end
|
# Threat System v1.1
#----------#
#Features: Make enemies target the the most threatening person!
# Damage dealt/health restore adds to a actors threat level, while
# certain note tags can make skills/items modify threat levels.
#
#Usage: Skill/Item Notetags: (Effects user)
# <THREAT_CLE... |
describe 'Dancer' do
let(:dancer) {Dancer.new('Anna')}
it 'has a name' do
expect(dancer.name).to eq('Anna')
end
end
|
require "neovim/buffer"
require "neovim/tabpage"
require "neovim/window"
module Neovim
# Support for +Client#current+ chaining.
#
# @see Client#current
class Current
def initialize(session)
@session = session
end
# Get the line under the cursor.
#
# @return [String]
def line
... |
require 'test_helper'
class SkillsControllerTest < ActionDispatch::IntegrationTest
setup do
@skill = skills(:one)
end
test "should get index" do
get skills_url
assert_response :success
end
test "should get new" do
get new_skill_url
assert_response :success
end
test "should create s... |
module AwesomeBinPack
class Bin
attr_reader :width, :height, :area
attr_accessor :items, :pos_x, :pos_y, :pos_z
def initialize(width, height, pos_x = 0, pos_y = 0, pos_z = 0)
@width = width
@height = height
@items = []
@pos_x = pos_x
@pos_y = pos_y
@pos_z = pos_z
... |
#Attr Methods
# I worked on this challenge [by myself, with:]
# I spent [#] hours on this challenge.
# Pseudocode
# Input:
# Output:
# Steps:
class NameData
attr_reader :name
def initialize
@name = "Cyrus Vattes"
end
end
class Greetings
def initialize
@greeter = NameData.new
end
def hello
... |
class CreateCompetitionEvaluations < ActiveRecord::Migration[5.1]
def change
create_table :competition_evaluations do |t|
t.references :run_record, foreign_key: true
t.integer :competition_point, null: false, default: 0
t.text :competition_evaluation
t.timestamps
end
end
end
|
Gem::Specification.new do |s|
s.name = "assertion_fu"
s.version = "0.3.0"
s.date = "2009-02-05"
s.summary = "Bonus Test::Unit assertions"
s.email = "kyle@kylemaxwell.com"
s.has_rdoc = true
s.authors = ["Kyle Maxwell"]
s.files = %w[README lib/assertion_fu.rb test/assertion_fu_test.rb]
... |
# Helper to ensure a clean execution environment during tests without
# destroying env vars the developer explicitly set.
module EnvStash
# Don't let our tests go wonky because someone forget to unset some env vars.
OVERRIDE_VARS = %w(HUE_BRIDGE_IP HUE_BRIDGE_USER HUE_SKIP_SSDP HUE_SKIP_NUPNP)
def self.stash_ove... |
class AddLikesToSnacks < ActiveRecord::Migration
def change
add_column :snacks, :likes, :integer
end
end
|
RSpec.configure do |config|
config.before(:each) do
stub_request(:post, "https://api.mailchimp.com/2.0/lists/subscribe")
stub_request(:get, /http\:\/\/gravatar\.com\/avatar\/./).
to_return(:status => 200, :body => "", :headers => {})
end
end
|
# frozen_string_literal: true
class ZonesController < ApplicationController
def index
zones = ::V2::Zone.where(parent: params[:parent_code])
render status: :ok, json: { zones: zones.as_json(only: Zone.view_attrs) }
end
def show
query = GetZoneData.new(code: params[:code])
if query.run
rend... |
require File.dirname(__FILE__) + '/../../spec_helper'
describe "/foros/show.html.erb" do
include ForosHelper
before(:each) do
@foro = mock_model(Foro)
@foro.stub!(:titulo).and_return("MyString")
@foro.stub!(:mensaje).and_return("MyText")
@foro.stub!(:puntuacion).and_return("1")
assigns[:for... |
# -*- encoding : utf-8 -*-
class AddUserTagToPayments < ActiveRecord::Migration[5.1]
def change
add_column :payments, :attachedUserID, :integer
end
end
|
class TweetWordsCounter
WORDS_REGEX = /(?!'.*')\b([[a-zA-Z]']+)\b/
TWITTER_SHORT_URL_REGEX = /https:\/\/t.co\/\w{10}/
attr_accessor :word_count, :words_hash, :stop_words
def initialize(stop_words)
@word_count = 0
@words_hash = {}
@stop_words = stop_words
end
def add_tweet(tweet_text)
twe... |
require 'spec'
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rubygems'
require 'active_support'
require 'action_controller'
require 'active_record' # only required for testing optional features, not required by the gem
require 'action_mailer' # on... |
module Vagrant
module Butcher
module Helpers
module Config
def vm_config(env)
@vm_config ||= machine(env).config.vm
end
def butcher_config(env)
@butcher_config ||= machine(env).config.butcher
end
def chef_provisioner(env)
@chef_provisi... |
require 'paysafe/result'
module Paysafe
class GatewayResponse < Result
attributes :processor,
:balance,
:merchant_transaction_id,
:payment_processor_transaction_id,
:lcp_transaction_id,
:lcp_encoded_transaction_id
end
end
|
module Capistrano
class Application < Rake::Application
def initialize
super
@rakefiles = %w{capfile Capfile capfile.rb Capfile.rb} << capfile
end
def name
"cap"
end
def run
Rake.application = self
super
end
def sort_options(options)
options.push(ver... |
class LotRef < ActiveRecord::Base
self.primary_key = :uuid
def self.get_lot(matnr, lifnr, date_code, entry_date)
(0..10).each do |i|
@charg = find_lot(matnr, lifnr, date_code, entry_date)
break if @charg.present?
end
@charg
end
def self.find_lot(matnr, lifnr, date_code, entry_date)
... |
class CreatePartnerAlbums < ActiveRecord::Migration[5.0]
def change
create_table :partner_albums do |t|
t.string :title
t.string :thumbnail
t.integer :status
t.timestamps
end
add_reference :partner_albums, :partner, foreign_key: true
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.