text stringlengths 10 2.61M |
|---|
require "weary"
module Tumblr
class Client < Weary::Client
API_VERSION = "v2"
USER_AGENT = "Tumblr API Client (Ruby)/#{Tumblr::VERSION} (+http://github.com/mwunsch/tumblr)"
POST_OPTIONS = [
:state, :tags, :tweet, :date, :format, :slug, :source_url, :source_title,
:title, :body, # Text posts... |
class Order
attr_reader :created_at, :passengers_count, :has_children, :has_cargo, :address_from, :address_to
attr_accessor :id, :assigned_taxi
def initialize(created_at, passengers_count, address_from, address_to, assigned_taxi)
@created_at = created_at
@passengers_count = passengers_count
@has_chil... |
class Game
attr_accessor :human_player, :enemies
def initialize(player_name)
robot_1 = Player.new("Josiane")
robot_2 = Player.new("José")
robot_3 = Player.new("Hervé")
robot_4 = Player.new("Eglantine")
@enemies = [robot_1, robot_2, robot_3, robot_4]
@human_player = HumanPlayer.new(player_name)
end
de... |
class Dog < ActiveRecord::Base
belongs_to :user
has_many :walks
has_one :park, through: :user
end
|
describe Dealer do
describe '#total, #hit' do
it 'behaves properly' do
dealer = Dealer.new(Card.new(:heart, 'J'), Card.new(:heart, '6'))
expect(dealer.total).to eq 16
dealer.hit(Card.new(:heart, 'A'))
expect(dealer.total).to eq 17
end
end
describe '#finished?' do
context 'les... |
class UpdateRecipes < ActiveRecord::Migration
def change
add_column :recipes, :parent_id, :integer
rename_column :recipes, :price, :cost
change_table :recipe_ingredients do |t|
t.decimal :cost
t.decimal :total_cost
t.decimal :quantity
t.integer :ingredient_id
t.integer :... |
# == Schema Information
#
# Table name: proxies
#
# id :uuid not null, primary key
# body_format :string
# name :string
# proxy_request_type :string
# proxy_url :text
# slug :string
# target_request_type :string
# target_url ... |
# == Schema Information
#
# Table name: posts
#
# id :bigint not null, primary key
# caption :text
# author_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Post < ApplicationRecord
validates :author_id, :caption, :phot... |
require 'pry' # giving us access to pry to search
class String # creating a class called String
def sentence? # this instanct method(due to self being in the method ) we want to check if a string ends in a sentecne
self.end_with?(".") # we use the self method to refer to the sentence in which we are calling on ... |
# Neither of these methods are my work, but after spending over an hour trying myself
# I thought these were the most elegant solutions that I could understand.
def old_roman_numeral(num)
return "Please use a positive integer." if num <= 0
roman = ""
roman << "M" * (num / 1000)
roman << "D" *... |
class UsersController < ApplicationController
# Be sure to include AuthenticationSystem in Application Controller instead
#include AuthenticatedSystem
before_filter :load_user, :only => [:show, :edit, :update, :destroy]
before_filter :new_user, :only => :new
filter_access_to :all
filter_access_to [:show, :e... |
# frozen_string_literal: true
module SFRest
# Manipulates SF cron jobs.
class Cron
# @param [SFRest::Connection] conn
def initialize(conn)
@conn = conn
end
# Gets a list of cron jobs
# @param [Integer] page
# @param [Integer] items per page
def get_cron_jobs(page = nil, limit = n... |
require_relative 'mpan_cache'
require 'date'
# Import the one line file format
class SingleLineImporter
def initialize(publisher, meta)
@mpan_column = meta[:mpan]
@date_column = meta[:date]
@readings_columns = meta[:readings]
@estimated_flags = meta[:estimated_flags]
@header_row ... |
require File.expand_path(File.dirname(__FILE__) + '/../bonus_drink')
describe BonusDrink do
specify { expect(BonusDrink.total_count_for(0)).to eq 0 }
specify { expect(BonusDrink.total_count_for(1)).to eq 1 }
specify { expect(BonusDrink.total_count_for(3)).to eq 4 }
specify { expect(BonusDrink.total_count_for(... |
class AddSessionToExercise < ActiveRecord::Migration[5.1]
def change
add_reference :exercises, :session, foreign_key: true
end
end
|
class CarsController < ApplicationController
layout "mypage"
def index
@cars = Car.where(user_id: current_user.id).order("updated_at ASC")
end
def new
@car = Car.new
end
def show
@car = Car.find(params[:id])
@histories = @car.histories.order("updated_at DESC")
end
def create
@car... |
class TerraformProviderFincloud < Formula
desc 'Terraform provider for Financial Cloud'
homepage "https://github.com/samjegal/terraform-provider-fincloud"
url "https://github.com/samjegal/terraform-provider-fincloud/releases/download/v1.0.1/terraform-provider-fincloud.osx.tar.gz"
sha256 "ed49f868284d556... |
class OEIS
# a(n) is the least k > n such that n divides k^4.
def self.a254734(n)
(n+1..2*n).find { |k| k**4 % n == 0 }
end
end
|
class Plan < ApplicationRecord
belongs_to :category
has_many :subscriptions
has_many :logs
has_many :check_ins, through: :subscriptions
validates :title, presence: true
validates :overview, presence: true
validates :category, presence: true
default_scope { order(rating: :desc, sub_count: :desc) }
d... |
class FontGfsNeohellenic < Formula
head "https://github.com/google/fonts.git", verified: "github.com/google/fonts", branch: "main", only_path: "ofl/gfsneohellenic"
desc "GFS Neohellenic"
homepage "https://fonts.google.com/specimen/GFS+Neohellenic"
def install
(share/"fonts").install "GFSNeohellenic.ttf"
... |
require '_spec_helper'
describe 'Loading Zone' do
let(:timestamp) { 1_560_274_556_158 }
describe Pallet do
let(:pallet) { Pallet.new(1, 50) }
describe 'attributes' do
it "has 'id'" do
expect(pallet.id).to be(1)
end
it "has 'weight'" do
expect(pallet.weight).to be(50)
... |
# 10% on all goods, except books, food, and medical products that are exempt.
# additional sales tax applicable on all imported goods at a rate of 5%, with no exemptions.
# for a tax rate of n%, a shelf price of p contains (np/100 rounded up to the nearest 0.05) amount of sales tax.
# OUTPUT
# Output 1: 1 book : 12.... |
class CountriesController < ApplicationController
include WhiteListHelper
# GET /countries/:country_name
def show
@country = white_list(params[:country_name])
@institutions = Institution.where(["country LIKE ?", @country])
respond_to do |format|
format.html # show.html.erb
end
end
en... |
class Image < ActiveRecord::Base
attr_accessible :imageable_id, :imageable_type, :file, :imageable
belongs_to :imageable, :polymorphic => true
validates :imageable_id, :imageable_type, :presence => true
mount_uploader :file, ImageTypeUploader
end
|
require 'rails_helper'
RSpec.describe Upload, type: :model do
it 'has valid factory' do
expect(build_stubbed(:upload)).to be_valid
end
end
|
class User < ApplicationRecord
has_secure_password
validates :username, presence: true, uniqueness: true
# has_many :ratings, dependent: :destroy
# has_many :stories, through: :ratings
has_many :user_stories, dependent: :destroy
has_many :stories, through: :user_stories
end
|
#!/usr/bin/env ruby
require 'json'
require 'base64'
require 'digest/sha1'
require 'fileutils'
FILES_JSON_FILENAME = 'files.json'
COMMITS_LIMIT = 10
argv = ARGV
if argv.length != 4
puts "Usage: command <release-dir> <stored-dir> <commit-hash> <encoded_commit-message>"
exit 1
end
release_dir = argv[0]
stored_dir... |
# encoding: utf-8
require 'spec_helper'
module Ktl
shared_examples 'a shuffle plan' do
let :plan do
described_class.new(zk_client, options)
end
let :zk_client do
double(:zk_client, utils: zk_utils)
end
let :zk_utils do
double(:zk_utils)
end
let :options do
{}
... |
class RemoveRawEventUrlFromAssessment < ActiveRecord::Migration
def up
remove_column :assessments, :raw_event_url
end
def down
add_column :assessments, :raw_event_url, :string
end
end
|
#
# Cookbook Name:: hdfsdu
# Recipe:: deploy
#
# Copyright 2017, Bloomberg Finance L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unle... |
module Hermes
module Model
##
# Model used for storing quotes of users in particular channels.
#
class Quote < Sequel::Model
plugin :timestamps, :created => :created_at, :updated => :updated_at
##
# Validates the instance before creating or saving a record.
#
#
def... |
require 'rails_helper'
RSpec.describe "New Bulk Discount Page" do
describe "as a merchant" do
before :each do
@merchant1 = Merchant.create!(name: 'Hair Care')
visit merchant_bulk_discounts_path(@merchant1)
click_link "Create New Discount"
end
it "has a form to create a new Discount" ... |
# Simple rock, paper, scissors, lizard, spock game vs. cpu
WEAPON_CHOICES = %w(rock paper scissors spock lizard)
def prompt(message)
puts "=> #{message}"
end
def determine_winner(winning_moves, player_choice, cpu_choice)
if winning_moves[player_choice.to_sym].include?(cpu_choice)
"You win!"
elsif player_ch... |
require 'rails_helper'
describe 'users can crud courses' do
before :each do
@my_user = User.create(user_name: 'Casey', about: 'Way cool', password: '475523', password_confirmation: '475523')
visit '/login'
fill_in "User name", with: "Casey"
fill_in "Password", with: "475523"
click_on "Login!"
... |
require 'beanstalk-client'
module Rhouse
# Observes events on the beanstalk queue. This is meant to be an abstract base
# class for all workers. Derived classes must implement the handle_event and
# configuration_file protocol.
class Worker
# The name of the worker
attr_reader :name
# The c... |
class Player < ActiveRecord::Base
belongs_to :game
belongs_to :team
belongs_to :user
class << self
def for_user(game,user)
team_ids = game.teams.pluck(:id)
Player.where(team_id: team_ids, user_id: user.id).first
end
end
def top_scorer?
team_ids = self.team.game.teams.pluck(:id)
... |
require 'spec_helper'
describe 'drbd::default' do
context 'Ubuntu' do
platform 'ubuntu'
it 'converges successfully' do
expect { :chef_run }.to_not raise_error
end
end
context 'CentOS' do
platform 'centos'
it 'converges successfully' do
expect { :chef_run }.to_not raise_error
... |
FactoryBot.define do
factory :pet do
name { 'helga'}
breed {'bulldog inglês'}
gender { 'fêmea'}
description { 'uma cadela grande e das cores branca e mel'}
avatar { 'https://static.vecteezy.com/system/resources/previews/001/200/031/non_2x/dog-png.png' }
association :localization
user { ass... |
# encoding: UTF-8
class MessagesController < ApplicationController
#wyświetlanie wiadomości
def show
begin
@message = current_user.received_messages.find(params[:id])
rescue ActiveRecord::RecordNotFound
logger.error("Proba dostępu do wiadomości z obcej skrzynki id =#{params[:message_id]}")
... |
# frozen_string_literal: true
module RTALogger
# this module generates object instance
module LogFactory
def self.create_repository(type, config_json = '')
lib_file = @log_repositories[type.to_sym]
raise "unregistered repository class: #{type.to_s}" if lib_file.nil? || lib_file.empty?
begin
... |
class Trama
def initialize(data)
@data = data
end
def to_s
msg = ''
@data.each {|char| msg << char.chr}
return msg
end
end |
#
# Cookbook:: openvpn
# Recipe:: service
#
# Copyright:: 2009-2013, Chef Software, Inc.
# Copyright:: 2015, Chef Software, Inc. <legal@chef.io>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License a... |
class ChangeTypeColumnInFloors < ActiveRecord::Migration
def change
rename_column :floors, :type, :floor_type
end
end
|
require 'optparse'
require 'logger'
require 'rcapdissector'
def main(*args)
opts = {
:cap_files => [],
:wlan_keys => [],
}
$log = Logger.new(STDOUT)
$log.level = Logger::INFO
opt_parser = OptionParser.new
opt_parser.on("-v",
"--verbose",
... |
# frozen_string_literal: true
require "spec_helper"
RSpec.describe ColorGenerators::BaseColorGenerator do
subject(:generator) { described_class.new(color_string, seed) }
let(:seed) { instance_double("GeoPattern::Seed") }
let(:seed_value1) { 2616 }
let(:seed_value2) { 2 }
let(:color_string) { "#ff00ff" }
... |
require 'rails_helper'
RSpec.feature "Sessions", type: :feature do
before { FactoryGirl.create :user, email: 'test@email.pl',
password: 'sosecure' }
context 'when entering valid credentials' do
it 'signs in the user' do
sign_in 'test@email.pl', 'sosecure'
expec... |
require 'csv'
# PARSING
# TODO - let's read/write data from beers.csv
filepath = 'data/beers.csv'
csv_options = { col_sep: ',', quote_char: '"', headers: :first_row }
beers = []
CSV.foreach(filepath, csv_options) do |row|
# Here, row is an array of columns
beers << {name: row["Name"], appearance: row["Appeara... |
module Noid
class Template
attr_reader :template
# @param [String] template A Template is a coded string of the form Prefix.Mask that governs how identifiers will be minted.
def initialize template
@template = template
parse_template
end
def mint n
str = prefix
str += n2... |
# frozen_string_literal: true
# Home to all custom exceptions
class HomeMaintenance
class Error < StandardError; end
# When the input to the Action is invalid
class InvalidInputError < Error
def initialize(msg = 'Action config is invalid')
super
end
end
# When the calculated path to the CSV f... |
require 'lib/bitmap'
describe Bitmap do
it "deve ser possivel criá-lo" do
b = Bitmap.new [[1]]
end
it "deve saber armazenar um bitmap simples" do
b = Bitmap.new [[1]]
b.bitmap.should == [[1]]
end
it "deve saber armazenar um bitmap simples, mas com zero" do
b = Bitmap.new [[0]]
b.bitmap.... |
class PostsController < ApplicationController
before_filter :authenticate_user!, only: [:new, :create]
def new
@post = Post.new
end
def create
@post = Post.new (post_params)
@post.user = current_user
if @post.save!
redirect_to @post
else
... |
class Post < ApplicationRecord
has_many :comments
validates_presence_of :title
validates_presence_of :body
end
|
class WinningPart < ActiveRecord::Base
belongs_to :game
has_many :winners , :dependent => :destroy
# to store array in coordinates field
serialize :coordinates
has_attached_file :image_part, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
validates_attachment_c... |
class FavoritesController < ApplicationController
def index
@collection=Collection.find(params[:collection_id])
@favorites=@collection.favorites
@quotes=@collection.quotes
end
def new
end
def show
end
def create
@quote=Quote.find(params[:quote_id])
if @quote.favorites.create!(favor... |
class AddTimeStampsToParkingPasses < ActiveRecord::Migration[5.0]
def change
add_column(:parking_passes, :created_at, :datetime)
add_column(:parking_passes, :updated_at, :datetime)
end
end
|
require 'spec_helper'
class SomeMapper
def initialize(entry, config); end
def map; end
end
describe Jekyll::Contentful::Mappers::Base do
let(:entry) { EntryDouble.new('foo') }
subject { described_class.new(entry, {}) }
describe 'class methods' do
describe '::mapper_for' do
it 'returns default map... |
class AddColumnInvoicePrefixToStores < ActiveRecord::Migration
def self.up
add_column :stores, :invoice_prefix, :string
end
def self.down
remove_column :stores, :invoice_prefix
end
end
|
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts 'Run `bundle install` to install missing gems'
exit e.status_code
end
require 'minitest/autorun'
require 'shoulda-context'
require 'rack/test'
require 'mocha/s... |
# U2.W4: SOLO CHALLENGE Calculate the Median!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I worked on this challenge by myself.
# 1. Pseudocode
# What is the input? An array of values
# Wha... |
class ArticlesController < ApplicationController
#Before actions allow for methods to exist in more than one function
#set_user, require_same_user, and require_admin = methods
#[all] that are within brackets are the defined function included
before_action :set_article, only: [:edit, :update, :show, :destroy, :u... |
class TopicsController < ApplicationController
def index
@topics = Topic.includes(:favorite_users).search(params[:search]).paginate(page: params[:page], per_page: 10)
@all_ranks = Topic.find(Favorite.group(:topic_id).order('count(topic_id) desc').limit(10).pluck(:topic_id))
if params[:tag_name]
... |
# ================================================================
# Created: 2015/03/13
# Author: Thomas Nguyen - thomas_ejob@hotmail.com
# Purpose: set of Selenium methods that should universally work on all websites
# Source: http://anahorny.blogspot.in/2011/08/selenium-webdriver-ruby-tutorial.html
# ===============... |
require 'custom_devise_sessions_controller'
class HomeController < ApplicationController
before_action :authenticate_user!, except: [:health_check, :login, :sso]
def welcome
case current_user.role
when :admin
redirect_to admin_home_welcome_path
when :fellow
redirect_to fellow_home_welcom... |
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'hello_world'
class HelloWorldTest < Minitest::Test
def test_no_strange_name
assert_equal 'Hello, !', HelloWorld.hello(''), 'When giving an empty string, it is strange, but should have a space and punctuation'
end
def test_no_name
asser... |
class BookingSeat < ApplicationRecord
belongs_to :booking_ticket
belongs_to :seat
end
|
require 'spec_helper'
RSpec.describe ImageHandler do
subject(:handler) { described_class.new }
before { handler.new_image(3, 3) }
it "outputs correctly to STDOUT" do
expect { handler.show_image }.to output("OOO\nOOO\nOOO\n").to_stdout
end
end
|
class CreatePeople < ActiveRecord::Migration[5.2]
def change
create_table :people do |column|
column.string :name
column.integer :health
end
end
end |
require 'test_helper'
class WorkflowsControllerTest < ActionController::TestCase
include AuthenticatedTestHelper
include SharingFormTestHelper
def setup
@member = Factory :user
@project = @member.person.projects.first
login_as @member
end
test "extracts metadata on create" do
assert_differ... |
class Flight < ApplicationRecord
belongs_to :from_airport, class_name: 'Airport'
belongs_to :to_airport, class_name: 'Airport'
has_many :bookings
validates :from_airport_id, presence: true
validates :to_airport_id, presence: true
validates :departure_time, presence: true
validates :duration, presence: tr... |
module Messages
###########################################################
# メソッド:loadMessage
# 概 要:ローカライズ用テーブルデータ(多言語データ)を読み込み、
# ハッシュに格納する
# 引 数:なし
# 戻 り 値:なし
###########################################################
def loadMessage
# 取得対象カラムの判定
lang = 'jp'
l... |
class EmailsController < ApplicationController
def new
@group = Group.includes(:users).find(params[:group_id])
@user = @group.users.find(params[:user_id])
@email = @user.emails.build
end
def create
@group = Group.includes(:users).find(params[:group_id])
@user = @group.users.find(params[:user_... |
module Admin
class NewsController < BaseController
load_and_authorize_resource except: :create
def index
end
def create
@news = News.new news_params
@news.save!
redirect_to [:edit, :admin, @news], notice: flash_message
end
def update
@news.update! news_params
r... |
class Point
class Cell
class Index < Trailblazer::Cell
def show_points
concept('point/cell/show', collection: model['points'])
end
def new_points_form
concept('point/cell/new', model['model'])
end
def navbar
concept('point/cell/navbar', nil)
end
... |
class Localregion < ActiveRecord::Base
belongs_to :country
has_many :wines
end
|
class RemoveJsonColumns < ActiveRecord::Migration[5.2]
def change
remove_column :users, :photos
remove_column :places, :photos
end
end
|
module GogogibbonTools
class ApplicationController < ActionController::Base
class MailchimpConfigurationException < Exception
end
rescue_from MailchimpConfigurationException, :with => :render_403
def not_configured!
raise MailchimpConfigurationException
end
def render_403
rende... |
# Given a string that consists of some words and an assortment of non-alphabetic characters, write a method that returns that string with all of the non-alphabetic characters replaced by spaces. If one or more non-alphabetic characters occur in a row, you should only have one space in the result (the result should neve... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe V1::AccountsController, type: :controller do
before :each do
allow(controller).to receive(:authenticate_request).and_return(user)
allow(controller).to receive(:current_user).and_return(user)
end
let(:user) { FactoryGirl.create(:user) }
... |
# Write a script that accepts a string as a parameter and find the longest word within the string.
require 'pry'
def longest_word(sentence)
array = sentence.split(" ")
puts array.inject { |f, s| f.length > s.length ? f : s }
end
puts "Enter a sentence"
sentence = gets.strip
longest_word(sentence) |
module Bsale
class PaymentType < Base
def all
Bsale.response('payment_types', self)
end
def find(id:)
id = id.to_i
raise 'You must need to pass an ID' if id.zero?
Bsale.response("payment_types/#{id}", self)
end
def attributes
%i(
href
id
nam... |
# Fake rails
module ActiveRecord
class Base
attr_accessor :resource_name, :attributes
@@store = {
"1" => {id: 1, title: 'bar title', student_id: 1234}
}
def initialize(attributes = {})
self.resource_name = self.class.to_s.downcase.singularize
self.attributes = attributes
att... |
require 'spec_helper'
require 'user'
require 'update'
module MorningPages
describe User do
let(:params) {{ :email => 'foo@example.com', :username => 'foo' }}
context "creation" do
it "must have an email and username" do
user = User.new(params)
user.email.should == params[:email]
... |
require 'spec_helper'
describe 'Doctor' do
let(:doctor) { Doctor.new({name: "Dr. Smith", specialty_id: 1 }) }
let(:doctor2) { Doctor.new({name: "Dr. Smith", specialty_id: 1}) }
let(:doctor3) { Doctor.new({name: "Dr. Belmonti", specialty_id: 2 }) }
describe '#initialize' do
it 'has a readable id' do
... |
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest: 8443, host: 8443
# too many levels of symlinks therefore we use --links
config.vm.synced_folder ".", "/vagrant", type: "rsync",
rsync__args: ["--verbose", "--archive", "--delete", "-z", "--links"]
confi... |
require 'spec_helper'
describe Recordatorio do
let(:user) { User.new(email:"omar.ogp@hotmail.com", password:"omargarcia") }
before do
@r = user.recordatorios.build(fecha_prestamo:Date.today, fecha_entrega:Date.tomorrow, contacto:"Deer lord", concepto:"cd", detalle:"ninguno", regresado:false)
end
subject... |
require 'rails_helper'
describe Poll do
let(:poll) { Poll.instance }
let(:anytime) { Time.now }
describe 'start' do
it 'updated the deadline and returns tryue' do
expect(poll.start '2015-10-11 09:00:00 UTC').to be_truthy
expect($redis[:deadline]).to eq '2015-10-11 09:00:00 UTC'
end
it '... |
module Spree
BaseController.class_eval do
def build_searcher params
searcher_class = Spree::Core::Search::FiltersBase
searcher_class.new(params).tap do |searcher|
searcher.current_user = try_spree_current_user
searcher.current_currency = current_currency
end
end
end
end
|
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
#! /bin/ruby
require 'yaml'
FILE_PATH = "#{File.expand_path(File.dirname(__FILE__))}/.program_wid_list.yml"
def activate_program(program_name, program_command)
program_wid = get_wid_if_open program_name
if program_wid
bring_to_top program_wid
else
program_wid = execute program_command
store_wid prog... |
require 'builder'
module Fog
module TerremarkEcloud
class Compute < Fog::Service
requires :terremark_ecloud_username, :terremark_ecloud_password
recognizes :versions_endpoint
request_path 'fog/compute/requests/terremark_ecloud'
request :delete_vm
request :get_catalog
request... |
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'eventmachine'
require "em-hiredis"
require 'fiber'
require "redis/connection/synchrony"
require "redis"
require "redis/connection/ruby"
describe Objvent::Model do
around(:each) {|example|
res = nil
EM.synchrony do
Redis::Ob... |
module Lokka
module Redirector
def self.registered(app)
app.set :redirector, []
app.get '/admin/plugins/redirector' do
haml :"inline:redirector/index", :layout => :"admin/layout"
end
app.post '/admin/plugins/redirector' do
# TODO: register redirect path
path_from, p... |
# encoding: utf-8
require File.expand_path('../spec_helper', __FILE__)
describe Darian do
it "should return own version" do
expect(Darian::VERSION).to be_a(String)
end
it "should convert by argument class" do
expect(Darian.from_earth(Time.now)).to be_a(Darian::Time)
expect(Darian.from_earth(Dat... |
require 'mongoid'
require 'formtastic-separate_html5_date_and_time/processor'
module Mongoid
module ProcessSeparateDateAndTimePickerInputs
def process_attributes(attrs = nil, role = :default, guard_protected_attributes = true)
super Formtastic::SeparateDateAndTimePickerInput::Processor.process(attrs), role... |
class CommentsController < ApplicationController
def create
# 以下spots/showをrenderしている為の記述
@spot = Spot.find(params[:spot_id])
@comment = Comment.new
@comments = @spot.comments.all.order(created_at: :desc)
# ここまで
spot = Spot.find(params[:spot_id])
comment = current_user.comments.new(comment... |
class AddIsGoodToTicketDetails < ActiveRecord::Migration[5.2]
def change
add_column :ticket_details, :is_good, :boolean, default: true
end
end
|
class CreateScheduleitemModel < ActiveRecord::Migration
def self.up
create_table :scheduleitems do |t|
t.column :eventtime, :datetime
t.column :eventtitle, :string
t.column :eventdescription, :string
end
end
def self.down
drop_table :scheduleitems
end
end |
class Admin::ImagesController < Admin::AdminController
def index
@images = Image.order('created_at desc')
end
def new
@image = Image.new
end
def create
@image = Image.new(params[:image])
@image.user = current_user
if @image.save
flash[:success] = "The image has been successfully ... |
require 'grouped_pagination'
require 'title_trimmer'
class Institution < ActiveRecord::Base
include Seek::Rdf::RdfGeneration
title_trimmer
acts_as_yellow_pages
validates :title, :uniqueness=>true
scope :default_order, order("title")
validates_format_of :web_page, :with=>/(^$)|(^(http|https):\/\/[a-z0-... |
current_dir = File.dirname(__FILE__)
begin
require "yaml"
require "erb"
config = YAML.load ERB.new(File.read(File.join(current_dir, "../config/knife.yml"))).result(binding)
rescue
puts "Does config/knife.yml file exist?"
end
# Chef config
log_level :info
log_location STDOUT
cache_ty... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.