text stringlengths 10 2.61M |
|---|
module Smshelper
module Api
class Smstrade < Base
base_uri 'http://gateway.smstrade.de'
def initialize(*args)
config = args.shift
add_query_options! :key => config.smstrade[:api_key]
super
end
def send_message(message)
if message.utf_8
message.t... |
module Stax
module Generators
class NewGenerator < Base
desc 'Create new stax project in give dir.'
source_root File.expand_path('templates', __dir__)
def check_args
usage! if args.size != 1
end
def create_stax_dir
empty_directory(args.first)
self.destinati... |
module ManageIQ::Providers::Amazon::AgentCoordinatorWorker::Runner::ResponseThread
include ScanningMixin
require 'util/xml/xml_utils'
#
# This thread startup method is called by the AgentCoordinatorWorker::Runner
# at the end of the do_before_work_loop method.
#
def start_response_thread
Thread.new d... |
# frozen_string_literal: true
# Policy for setting model
class SettingPolicy < ControllerPolicy
attr_reader :user, :objects
def initialize(user, objects)
@user = user
@objects = objects
end
def change_locale?
true
end
end
|
require "minitest_helper"
class AirbrusshTest < Minitest::Test
def test_configure_yields_config_object
config = Airbrussh.configuration
assert_equal(config, Airbrussh.configure { |c| c })
end
def test_configuration_returns_passed_config
config = Airbrussh::Configuration.new
assert_equal(config, ... |
require 'rails_helper'
describe "get all cabs route", :type => :request do
before { get '/api/v1/cabs'}
it 'returns all cabs' do
expect(JSON.parse(response.body).size).to eq(2)
end
it 'returns status code 200' do
expect(response).to have_http_status(:success)
end
end |
class ApplicationController < ActionController::Base
class NotEnoutFilesSubmitted < StandardError
end
rescue_from NotEnoutFilesSubmitted , :with => :not_enough_files_submitted
rescue_from ActionController::ParameterMissing , :with => :parameter_missing
private
def parameter_missing
render json:{error:... |
# frozen_string_literal: true
require 'stringio'
ENV.delete('GOOS')
ENV.delete('GOFLAGS')
ENV.delete('GO111MODULE')
module Go
include Rmk::Tools
def go_build(name, package, mod: 'readonly', depends: [], goos: nil)
name = goos ? File.join(goos, name) : name
files = go_files(package)
job('go/' + name,... |
require_relative('./stock')
class Customer
attr_accessor :first_name, :last_name, :id, :basket, :address
attr_reader :pword, :bank_balance
def initialize(first_name, last_name, id, basket, address, pword, bank_balance)
@first_name = first_name
@last_name = last_name
@id = id
@basket = basket
@a... |
#
# Carries out the logic that manages the extra procedures that happen to a brand new
# user account.
#
# 1. Send a welcome email
# 2. Set up an initial reputation
#
# Expected contexts:
# user - The new user record.
#
# Created contexts:
# reputation_entry - The reputation entry we created.
# welcome_email -... |
require 'rails_helper'
RSpec.describe Post, type: :model do
context 'writing a new post'
it 'is valid with all attributes present' do
post = Post.create(user_id: 1, title: 'This is a post title', body: 'This is a post body')
expect(post).to be_valid
end
it 'validates user_id' do
post... |
module DataMapper
module Validate
class AcceptanceValidator < GenericValidator
def self.default_message_for_field(field_name)
'%s is not accepted'.t(DataMapper::Inflection.humanize(field_name))
end
def initialize(field_name, options = {})
super
@options = options... |
class User < ActiveRecord::Base
attr_accessible :first_name, :last_name, :name
attr_accessible :avatar, :avatar_file_name
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png", :url => "/assets/users/:id/:style/:basename.:extension", :... |
require 'bambooing'
namespace :bambooing do
desc 'creates entries in bamboo for the current weekdays'
task :create_current_weekdays do
Bambooing::Configuration.load_from_environment!
entries = entry_class::Factory.create_current_weekdays(employee_id: employee_id, exclude_time_off: exclude_time_off)
B... |
module Capybara::Poltergeist
class Server
attr_reader :socket, :fixed_port, :timeout, :custom_host
def initialize(fixed_port = nil, timeout = nil, custom_host = nil)
@fixed_port = fixed_port
@timeout = timeout
@custom_host = custom_host
start
end
def port
@socket.por... |
require "test_helper"
describe User do
let :user { User.new }
let :before_count { User.count }
describe "validations" do
it "can be created with all valid fields" do
before_count
user.wont_be :valid?
user[:name] = "Test First User Name"
user.save!
user.must_be :valid?
us... |
class AddColumnsToEvent < ActiveRecord::Migration[5.2]
def change
add_column :events, :name, :string
add_column :events, :description, :text
add_column :events, :discipline, :string
add_column :events, :date, :string
add_column :events, :ville, :string
add_column :events, :departement, :string... |
require 'rails_helper'
RSpec.describe ContactAccess, type: :model do
let(:contact_access) { build(:contact_access) }
it 'has a valid factory' do
expect(build(:contact_access)).to be_valid
end
context 'validates' do
context 'presence of' do
[:contact, :url, :visiting_date].each do |f|
... |
namespace :db do
desc "Fill database with sample data"
task populate: :environment do
admin = User.create!(name:"Example User",
email: "a@a.com",
password: "secret",
password_confirmation: "secret")
admin.toggle!(:admin)
99.times do |n|
name = Fak... |
class Availability < ActiveRecord::Base
has_many :item_availabilities
has_many :items, through: :item_availabilities
belongs_to :order_item
scope :unreserved, -> { where(order_item_id: nil) }
end |
# encoding: UTF-8
# frozen_string_literal: true
module Geos
module Extensions
VERSION = '2.0.0'.freeze
end
end
|
class Gift < ApplicationRecord
validates :gift_name, presence: true
belongs_to :stock
end
|
class ChangeColumnName < ActiveRecord::Migration
def change
change_table :movies do |t|
t.rename :subscription_id, :subscription
t.rename :Ytube, :youtube
end
def change
rename_column :users, :subscription_id, :subscription
end
end
|
require 'open-uri'
module Timetable
REMOTE_HOST = "www.doc.ic.ac.uk"
REMOTE_PATH = "internal/timetables/:year/:season/class"
REMOTE_FILE = ":course_:start_:end.htm"
class Downloader
attr_accessor :course_id, :season, :weeks, :year
attr_reader :data
def initialize(course_id = nil, year = nil, seas... |
module Jekyll
module Email
class Command < Jekyll::Command
class << self
def init_with_program(prog)
prog.command(:mail) do |c|
c.syntax "mail [options]"
c.description 'Send email about psot'
c.option 'post', '-post POST', 'Post name'
c.acti... |
CARDS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace']
def initialize_deck(deck)
deck << CARDS * 4
deck.flatten!
end
def hit(deck, cards)
cards << deck.delete_at(rand(deck.size))
end
def display_cards(cards)
"#{cards[0..-2].join(', ')} and #{cards[-1]}"
end
def total(cards)
value_without_ace... |
describe "GET /equipos/{equipo_id}" do
before(:all) do
@payload = { email: "murillo@yahoo.com", password: "Teste@123" }
result = Sessions.new.login(@payload)
@user_id = result.parsed_response["_id"]
end
context "obter unico equipo" do
before(:all) do
@payload = {
"thumbnai... |
# frozen_string_literal: true
################################################################################
# Setup
################################################################################
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run ra... |
module Admin
class OrdersController < AdminBaseController
before_action :load_order, only: :update
def index
@orders = Order.list_order.lastest.page(params[:page]).per Settings.per_page
respond_to do |format|
format.html
format.xls { send_data @orders.to_csv(col_sep: "\t") }
... |
describe Pantograph do
describe Pantograph::PluginFetcher do
describe "#fetch_gems" do
before do
current_gem = "yolo"
# We have to stub both a specific search, and the general listing
stub_request(:get, "https://rubygems.org/api/v1/search.json?page=1&query=pantograph-plugin-#{current... |
json.array!(@demands) do |demand_material|
json.extract! demand_material, :id, :pot_id, :material_id, :quantity
json.url demand_material_url(demand_material, format: :json)
end |
require 'spec_helper'
describe Question do
it_behaves_like "a votable object" do
let(:user){FactoryGirl.create(:user)}
let(:votable){FactoryGirl.create(:question)}
let(:votables){user.questions}
end
context "validations" do
it {should belong_to(:user)}
it {should have_many(:answers)}
it ... |
require 'rss'
require 'open-uri'
require 'cgi'
module Noizee
class RSS
def initialize
@clients = Array.new
configs = [Noizee::Configuration.rss].flatten
configs.each do |config|
clients << setup_client(config)
end
checked!
@delay = 10 # seconds
@since = Time.... |
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val = 0, left = nil, right = nil)
# @val = val
# @left = left
# @right = right
# end
# end
# @param {TreeNode} t
# @return {String}
def tree2str(t)
result = ""
return result... |
class CreateLiquidacions < ActiveRecord::Migration
def self.up
create_table :liquidacions do |t|
t.integer :orden_servicio_id
t.integer :cliente_id
t.integer :carpeta_id
t.integer :personal_id
t.integer :documentos_id
t.integer :item
t.integer :fob_dolares
t.integer... |
RSpec.describe Peel do
it "has a version number" do
expect(Peel::VERSION).not_to be nil
end
end
|
require 'rbvmomi'
require 'awesome_print'
require 'trollop'
require 'rbvmomi/trollop'
opts = Trollop.options do
banner <<-EOS
Script to list VMWare snaps.
Usage:
list_snaps.rb [options]
VIM connection options:
EOS
rbvmomi_connection_opts
text <<-EOS
VM location options:
EOS
rbvmomi_data... |
Pod::Spec.new do |s|
s.name = 'BlazeHTMLCell'
s.version = '0.0.11'
s.summary = 'HTML-cell addition to Blaze'
s.license = 'MIT'
s.description = 'Useful HTML-cell addition to Blaze, using DTCoreText and TTTAttributedLabel for performance and link checking'
s.homepage = 'ht... |
class Wallet < ActiveRecord::Base
belongs_to :currency
belongs_to :user
end
|
class AddShowFirstToPages < ActiveRecord::Migration
def change
add_column :pages, :show_first, :boolean, :default => false
end
end
|
#
# Cookbook Name:: goapp
# Recipe:: default
#
# Insert the GO app into the workspace
#
cookbook_file "/usr/local/go/workspace/sainsb.go" do
source "sainsb.go"
mode '0755'
action :create
end
#
# Create the service configuration file for the GO app
#
cookbook_file "/etc/systemd/system/goapp.service" do
source "g... |
class PurchaseBatchesController < ApplicationController
def new
@purchase_batch = PurchaseBatch.new
end
def index
@purchase_batches = PurchaseBatch.all.includes(:purchases, purchases:[:item]).page(params[:page])
end
def create
@purchase_batch = PurchaseBatch.new(purchase_batch_params)
@... |
require 'listing'
describe Listing do
describe '.all' do
it 'returns an array of all the listings' do
listings = Listing.all
expect(listings.first).to be_a(Listing)
expect(listings.first.name).to eq('poshhouse')
end
end
describe '.create' do
it 'can create a new listing' do
... |
class Token
ALGORITHM = "HS256".freeze
SECRET = Rails.application.credentials[Rails.env.to_sym][:jwt_secret]
def self.decode(token)
new(JWT.decode(token, SECRET, algorithm: ALGORITHM).first.symbolize_keys)
rescue JWT::DecodeError
new
end
attr_reader :email, :abilities
def initialize(email: nil,... |
class AddSpeakerInfosToPapers < ActiveRecord::Migration
def change
change_table :papers do |t|
t.string :speaker_name
t.string :speaker_company_or_org
t.string :speaker_title
t.string :speaker_country_code, limit: 8
t.string :speaker_site
end
end
end
|
require 'formula'
class Chswift < Formula
homepage 'https://github.com/neonichu/chswift#readme'
url "https://github.com/neonichu/chswift.git", :tag => "0.4.1"
head 'https://github.com/neonichu/chswift.git'
def install
system 'make', 'install', "PREFIX=#{prefix}"
end
def caveats; <<-EOS.undent
Add... |
require "integration_test_helper"
class OrganisationApiRouteTest < ActionDispatch::IntegrationTest
it "should respond with '404 for a bad route'" do
get "/api/organisations/bad/route", as: :json
assert_equal 404, response.status
assert_equal "404 error", response.body
end
end
|
class MediumDetailsController < ApplicationController
before_action :set_medium_detail, only: [:update]
def index
if params['artist_medium_id'].present?
artist_medium = ArtistMedium
.joins(medium: [:medium_detail, :medium_type])
.find(params['artist_medium_id'])
json_response({
... |
# ordnung/import.rb
#
# import component
#
module Ordnung
class Ordnung
EXCLUDE_PATTERNS = [ ".git", /.*~/ ]
# import from path (all files in directory
# or single entry (path = directory, entry = filename)
#
def import path, entry = nil
path = File.expand_path(path)
if entry
... |
class Sale < ActiveRecord::Base
has_many :order_product
has_many :products, through: :order_product
belongs_to :payment
belongs_to :client, :foreign_key => "client_id", :class_name => "Client"
belongs_to :employee, :foreign_key => "employee_id", :class_name => "User"
scope :sale_last_week, -> {
wher... |
require 'cora'
require 'siri_objects'
require 'win32ole'
#######
# SiriTunes is a Siri Proxy plugin that allows you to play, pause, adjust the volume, skip to the next/previous track, and request specific songs, albums, and artists in iTunes on a Windows PC.
# Check the readme file for more detailed usage instruction... |
# coding: utf-8
module Webgit
class App < Sinatra::Base
set :port, lambda{ PORT }
set :public_folder, File.expand_path("../../../", __FILE__) + '/public'
set :views, File.expand_path("../../../", __FILE__) + '/views'
helpers Helpers
before "/*" do
@repo = Rugged::Repository.new(GIT... |
require "gosu"
class HelloWorldGame < Gosu::Window
def initialize width=800, height=600, fullscreen=false
super
self.caption = "Hello World"
end
def button_down id
close if id == Gosu::KbEscape
end
end
HelloWorldGame.new.show |
module Blogo::Admin
# Responsible for posts management: creation, editing, deletion, preview.
class ProjectsController < BaseController
# GET /admin/posts
#
def index
@projects = Blogo::Project.all
end
# GET /admin/posts/new
#
def new
@project = Blogo::Project.new(published:... |
class Character < ActiveRecord::Base
include Paperclip
has_many :characters_games
has_many :games, :through => :characters_games
has_attached_file :picture, :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :url => "/images/characters/:style/:character_picture", :styles => { :medium => "400... |
FactoryGirl.define do
factory :gold_book, :class => Refinery::GoldBooks::GoldBook do
sequence(:author) { |n| "refinery#{n}" }
end
end
|
require "shesaid/box"
class Face < Box
attr_reader :start_x, :start_y, :width, :height, :end_x, :end_y, :center_x, :center_y
def initialize(face_hash)
face = face_hash["face"]
@start_x = face["x"]
@start_y = face["y"]
@width = face["width"]
@height = face["height"]
@end_x = @start_x + @wid... |
# filename: ex316.ru
PREFIX ab: <http://learningsparql.com/ns/addressbook#>
INSERT
{ ?person a ab:Person . }
WHERE
{
?person ab:firstName ?firstName ;
ab:lastName ?lastName .
}
|
module Ricer::Plugins::Log
class LogServer < Ricer::Plugin
def upgrade_1; Binlog.upgrade_1; end
trigger_is :querylog
permission_is :owner
scope_is :user
has_setting name: :enabled, type: :boolean, scope: :server, permission: :operator, default: true
has_setting name: :logtype, type:... |
class ORS
def self.config(options = [])
@config ||= ORS::Config.new(options)
end
def run args
command, *options = args
klass_string = command.to_s.capitalize
# setup initial config
ORS.config(options)
# determine command to use
if command =~ /-*version/i
puts "ORS v#{ORS::VERS... |
# Euler problem 4
class Problem4
def palindrome?(number)
number = number.to_s
number == number.reverse
end
def caa
number = number.to_s.split('').map(&:to_i)
number.each_with_index do |elem, index|
puts "#{elem} and #{number[-index - 1]}"
end
end
def generate_data
input_array =... |
# frozen_string_literal: true
require 'spec_helper'
describe Dotloop::Participant do
let(:client) { Dotloop::Client.new(access_token: SecureRandom.uuid) }
subject(:dotloop_participant) { Dotloop::Participant.new(client: client) }
describe '#initialize' do
it 'exist' do
expect(dotloop_participant).to_... |
class AddIdToAprofiles < ActiveRecord::Migration
def change
add_column :aprofiles, :academic_id, :integer
end
end
|
class LibrarySerializer < ActiveModel::Serializer
attributes :id, :user_id
belongs_to :user
has_many :books
has_many :tags, through: :books
end
|
class AddDurationToActivities < ActiveRecord::Migration[5.0]
def change
add_column :activities, :duration, :decimal, precision: 8, scale: 3
end
end
|
# == Route Map
#
# Prefix Verb URI Pattern Controller#Action
# root GET / pages#app
# users GET /users(.:format) users#index
# POST /users(.:for... |
# Q25. 配列 keys の各要素を、ハッシュ user がキーとして保持するかどうかを判定するコードを書いてください
# keys = [:age, :name, :hobby, :address]
# user = { name: "saitou", hobby: "soccer", age: 33, role: "admin" }
# 例(意図が伝われば文章は自由に変えていただいて大丈夫です)
# userにはageというキーがあります
# userにはaddressというキーがありません
def q25
keys = [:age, :name, :hobby, :address]
user = { name... |
require 'spec_helper'
describe RelationshipsController do
user = FactoryGirl.create(:user, username: "newuser", email: "newuser@example.com")
other_user = FactoryGirl.create(:user, username: "other", email: "other@example.com")
before { sign_in user }
describe "visit to other users profile and follow" do
... |
require 'test/unit'
require 'basic_rate'
require 'basic_pricer'
class TestBasicPricer < Test::Unit::TestCase
# One day in seconds
ONE_DAY = 60*60*24
DAILY = 50
WEEKLY = 250
MONTHLY = 1500
def setup
@rate = BasicRate.new(DAILY, WEEKLY, MONTHLY)
@start_time = Time.now
end
# Tests to make sur... |
class Cart < ActiveRecord::Base
belongs_to :user # fk user_id
has_many :line_items
has_many :items, through: :line_items
def total
# items.map(&:price).reduce(:+)
total = 0
items.map do |item|
li = self.line_items.find {|li| li.item_id == item.id}
total += (item.price * li.quantity)
... |
require 'test_helper'
class PhoneBookEntryTest < ActiveSupport::TestCase
def test_should_be_valid
assert FactoryGirl.build(:phone_book_entry).valid?
end
# TODO Fix this test.
# test "only user can read entries in private phone books" do
# user = FactoryGirl.create(:user)
# phone_book = FactoryG... |
require 'rails_helper'
describe 'Admin change status' do
it 'to accepted successfully'do
user = User.create(email: 'email@email.com', password: '123456', admin: true)
recipe_type = RecipeType.create(name: 'Sobremesa')
recipe = Recipe.create!(user: user, title: 'Bolo de Cenoura', difficulty: 'Mé... |
require 'spec_helper'
describe 'elasticsearch', :type => 'class' do
context "Repo class" do
let :facts do {
:operatingsystem => 'CentOS',
:kernel => 'Linux',
:osfamily => 'RedHat'
} end
context "Use anchor type for ordering" do
let :params do {
:config => { },
:manage... |
require 'rails_helper'
RSpec.describe TransplantCenterLookupService do
describe '.call' do
context 'when a '
context 'when a the hotline does not exist' do
context 'when a hospital exists in the area' do
it 'returns the transplant center' do
FactoryBot.create(:transplant_center, :out_... |
class Song < ApplicationRecord
self.table_name = "music_playlist_song"
validates_presence_of :video, :title, :artist, :year, :album
end
|
require "formula"
class Lzlib < Formula
homepage "http://www.nongnu.org/lzip/lzlib.html"
url "http://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.6.tar.gz"
sha1 "4a24e4d17df3fd90f53866ace922c831f26600f6"
bottle do
cellar :any
revision 1
sha1 "4b292d57f157ef8169b0aa7278708d8a902b7d72" => :... |
# -*- coding : utf-8 -*-
module Mushikago
module Hotaru
class TextDeleteRequest < Mushikago::Http::DeleteRequest
def path; '/1/hotaru/text/delete' end
request_parameter :domain_name
request_parameter :text_id
request_parameter :forcedelete, :default=>true do |v| (v ? 1 : 0).to_s end
... |
require 'test_helper'
class Api::V1::ChaptersControllerTest < ActionController::TestCase
setup do
@user = valid_user
stub_current_user(user: @user)
end
test 'get show without login' do
WebMock.stub_request(:get, "#{@controller.base_path}/1").to_return(body: chapter.to_json)
unstub_current_user
... |
control "V-61663" do
title "The system must protect audit tools from unauthorized deletion."
desc "Protecting audit data also includes identifying and protecting the
tools used to view and manipulate log data.
Depending upon the log format and application, system and application log
tools may provide th... |
# Display app push requests
# Add using:
# kato log drain add -p event -f json mytestdrain tcp://127.0.0.1:9123
require 'json'
require './drain'
puts "Listening for app push events..."
Drain.run do |event|
event = JSON.parse(event)
if event["Type"] == "stager_start"
name = event["Info"]["app_name"]
puts... |
module MonthlyDistrictData
module Utils
def localized_district
I18n.t("region_type.district")
end
def localized_block
I18n.t("region_type.block")
end
def localized_facility
I18n.t("region_type.facility")
end
def month_headers
months.map { |month| month.value.strf... |
require 'helper'
require 'models/person'
Person.send :include, GlobalID::Identification
class GlobalIDTest < ActiveSupport::TestCase
test 'global id' do
@person = Person.new(5)
@person.global_id.tap do |global_id|
assert_equal Person, global_id.model_class
assert_equal '5', global_id.model_id
... |
# Event: class for events.
class Event < ActiveRecord::Base
# Association for locations.
has_and_belongs_to_many :locations
# Associations for participation.
has_many :participates
has_many :participants, through: :participates, source: 'user'
# Association for event ownership.
belongs_to :owner, class_... |
require "dpkg"
require "lucie/utils"
require "scm"
class Configurator
class Server
CLONE_CLONE_SUFFIX = ".local"
attr_writer :custom_dpkg # :nodoc:
attr_reader :scm
def self.config_directory
File.join Configuration.temporary_directory, "config"
end
def self.clone_directory url
... |
module Types
class PhoneNumberType < Types::BaseScalar
description "A string representation of the phone number"
def self.coerce_input(value, _ctx)
TwilioAdapter.new.lookup(value)
end
def self.coerce_result(value, _ctx)
value.to_s
end
end
end
|
class TargetSkill < ActiveRecord::Base
attr_accessible :employee_id, :skill_id, :level
belongs_to :employee
belongs_to :skill
end
|
# This is a Chef attributes file. It can be used to specify default and override
# attributes to be applied to nodes that run this cookbook.
# Set a default name
#default["starter_name"] = "Sam Doe"
# For further information, see the Chef documentation (https://docs.chef.io/essentials_cookbook_attribute_files.html).
... |
json.array!(@trips) do |trip|
json.extract! trip, :id, :shipname, :timestamp, :latitude, :longitude, :speed, :course, :watertemp, :salinity, :airtemp, :relhumidity, :windspd, :winddir, :barometer, :depth
json.url trip_url(trip, format: :json)
end
|
require 'test_helper'
class PlaceTest < ActiveSupport::TestCase
test "Place URLs should start with http" do
bad_url = "javascript:alert(1)"
place = Place.new(url: bad_url)
refute place.valid?
refute place.errors[:url].empty?
good_url = "http://shopify.com"
place = Place.new(url: good_url)
... |
class User < ActiveRecord::Base
devise :database_authenticatable, :trackable,
:validatable, :omniauthable, omniauth_providers: [:google_oauth2]
belongs_to :school
belongs_to :grove
def self.from_omniauth(access_token)
data = access_token.info
if within_roots?(access_token)
if Teacher.is_... |
require 'serverspec'
set :backend, :exec
describe 'Lsyncd' do
describe service('lsyncd') do
it { should be_enabled }
end
describe file('/etc/lsyncd/lsyncd.conf.lua') do
it { should be_file }
it { should contain '"/var/www/example1"' }
it { should contain '"/var/www/example2"' }
it { should ... |
class RelationAuthorizer < ApplicationAuthorizer
# Users can view all relations
def self.readable_by?(user)
true
end
# Users can create relations
def self.creatable_by?(user)
true
end
# Users can edit relations
def self.updatable_by?(user)
true
end
# Users can delete relations
def ... |
class AddAauToHopManifest < ActiveRecord::Migration
def change
add_column :hop_manifests, :aau, :float
add_column :hop_manifests, :aa_percent, :float
end
end
|
# контроллер товаров
# переопределяется layout для шаблонов
class Content::GoodsController < Content::BaseController
before_action :get_locale
layout 'good'
def item
@good = Good.find_by_slug params[:slug]
raise PageNotFound unless @good.present?
end
def get_item
@good
end
end
|
require 'fileutils'
def makeAllNonExistentDirectories(path)
path =File.expand_path(path)
if not File.exist? path
top = File.dirname(path)
makeAllNonExistentDirectories(top)
Dir.mkdir(path)
end
end
def isFileType(file, extension)
return (("."+extension).eql? File.extname(file))
end
def getFil... |
class CreateAccounts < ActiveRecord::Migration[5.2]
def change
create_table :accounts do |t|
t.string :user
t.string :rakuten_app_id
t.string :yahoo_app_id
t.string :progress
t.timestamps
end
end
end
|
When(/^customer logged in with (.*)$/) do |totalbricknotpresent_account|
@totalbricknotpresent_account = totalbricknotpresent_account.downcase.gsub(" ", "")
on(LoginPage) do |page|
login_data = page.data_for(:acs_totalbirck_notpresent_accounts)
@single_account_data = page.data_for(:acs_totalbirck_notpresen... |
class ControlsController < ApplicationController
def new
@control = Control.new(section_id: params[:section])
end
def create
@control = Control.new(control_params)
if @control.save
redirect_to edit_control_path(id: @control.id)
else
respond_with @control
end
end
def edit
... |
require 'counting_cards/move'
module CountingCards
class Signal
attr_accessor :moves
def initialize(text)
@moves = text[1..-1].split(' ').map { |text| Move.new text }
end
end
end |
require_relative "time_manager"
module Mastermind
module Oscar
class Codemaker
attr_reader :code, :timer, :difficulty, :recorder, :guess
def initialize(difficulty, recorder)
@difficulty = difficulty
@recorder = recorder
end
def start
generate_code
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.