text stringlengths 10 2.61M |
|---|
class Api::GroupsController < ApplicationController
before_action :authenticate!
before_action :set_group, only: %i(show update destroy)
def index
render json: @user.groups, status: :ok
end
def show
render json: @group, status: :ok
end
def create
begin
@group = @user.groups.new(group_... |
#!/usr/bin/env ruby
module Declarations
# When set up a new child, notify all the ancestors
# When add declaration to a parent, update all known children
module SelfMethods
def setup(container, *args)
setup_inheritance(container, args)
macros = [:validates_presence_of, :before_save, :has_many... |
ActiveAdmin.register School do
# See permitted parameters documentation:
# https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
controller do
def permitted_params
par... |
class Follower < ActiveRecord::Base
belongs_to :user
belongs_to :playlist
end |
class PolyTreeNode
attr_reader :parent, :children, :value
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent=(parent_node)
unless @parent.nil?
parent.children.delete(self)
end
@parent = parent_node
return if parent_node.nil?
parent_n... |
class User < ApplicationRecord
include GlobalID::Identification
has_many :twitter_accounts, dependent: :destroy
has_many :tweets
has_many :automated_tweets
has_secure_password
validates :email, presence: true, format: { with: /\A[^@\s]+@[^@\s]+\z/, message: "you must use a valid email address" }
validates_presen... |
require "test_helper"
describe Order do
let(:one) { orders(:one) }
let(:two) { orders(:two) }
describe "validations" do
let(:one) { orders(:one) }
it "must have one or more order items" do
one.orderitems.each do |o|
o.must_be_kind_of Orderitem
end
end
it "can access products... |
require('minitest/autorun')
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative('../fish')
require_relative('../bear')
class RiverTest < Minitest::Test
def setup()
@name = river("Tay")
@fish = [@fish1, @fish2]
end
def test_river_has_fish()
... |
require 'nokogiri'
require 'open-uri'
require 'fileutils'
require "tmpdir"
BASE_URL = 'http://www.tse.or.jp/market/data/listed_companies/b7gje60000023aiz-att/'
@ticker_code_list = {
'市場第一部 (内国株)' => 'b7gje6000003l9u4.xls',
'市場第一部 (外国株)' => 'b7gje60000023aym.xls',
'市場第二部' => 'b7gje60000023aza.xls',
'マザ... |
class RemoveBuyLowestMny2FromStockInfos < ActiveRecord::Migration[5.0]
def change
remove_column :stock_infos, :buy_lowest_mny, :integer
end
end
|
require "bundler/capistrano"
require "json"
load "deploy/assets"
set :repository, "__GIT_REPOSITORY__"
set :scm, :git
set(:branch) { current_branch }
desc "Staging server settings"
task :staging do
server "__STAGING_SERVER__", :app, :web, :db, :primary => true
set :user, "__STAGING_USER__"
end
desc "Production ... |
class PhotosController < ApplicationController
def new
@photo = Photo.new
end
def create
@photo = Photo.new(params[:photo_params])
@photo.the_photo = params[:photo][:the_photo]
@photo.user_id = current_user.id
if @photo.save
params[:photo][:user_id].each do |user_id|
if user_id... |
class Group < ActiveRecord::Base
belongs_to :course_section
has_many :memberships
has_many :students, through: :memberships
end
|
Rails.application.routes.draw do
devise_for :teams
root to: 'games#index'
resources :members
resources :games
end
|
class Bar < ActiveRecord::Base
attr_accessible :name, :logo_uid, :logo, :logo_name, :street, :zipcode, :city, :freebeer, :country, :longitude, :latitude, :gmaps, :homepage, :gcm_id, :user_id
has_many :visits
belongs_to :user
acts_as_gmappable validation: false
image_accessor :logo do
after_assign :resize_i... |
require_relative('node.rb')
class LinkedList
attr_accessor :_list
def initialize()
@_list = nil
end
def create_node(_data)
new_node = Node.new(_data, nil)
return new_node
end
def add(_data)
new_node = create_node(_data)
if @_list.nil?
... |
class Merchant < ApplicationRecord
STATUSES = %w(pending paid complete cancelled)
has_many :products
has_many :orderitems, through: :products
validates :name, presence: true, uniqueness: true
validates :email, presence: true, uniqueness: true
def self.build_from_github(auth_hash)
merchant = Merchant.n... |
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
resources :measure_categories
resources :measurements
end
end
post 'auth/login', to: 'authentication#authenticate'
post 'signup', to: 'users#create'
root 'api/v1/measure_categories#index'
end
|
class CartsController < ApplicationController
def show
cart = Cart.find_by(id: params[:id])
render json: cart.extend(CartRepresenter).to_json
end
def create
cart = Cart.new(cart_params)
if cart.save
render json: { success: true }
else
render json: { success: false, errors: cart... |
require 'rails_helper'
RSpec.describe 'actor show' do
before(:each) do
@s1 = Studio.create!(name: "Marvel", location: "Denver, Colorado")
@m1 = Movie.create!(title: "The Avengers", creation_year: 2012, genre: "Action", studio_id: @s1.id)
@m2 = Movie.create!(title: "Elf", creation_year: 2003, genre: "Come... |
# Get a list of puppet facts associated with servers and write to yaml.
# Borrowed in part from https://github.com/sul-dlss/puppetdb_reporter/
namespace :download do
desc 'Download YAML of puppet facts'
task puppetfacts: :environment do
require 'puppetdb'
require 'yaml'
require 'no_proxy_fix'
facts... |
class Comment < ActiveRecord::Base
validates :body, length: {maximum: 140, too_long: "THIS ISH IS TOO DAMN LONG.... bro"}
belongs_to :post
belongs_to :user
end
|
class ApiController < ApplicationController
#se devuelve solo el status
def status
render json: {
}, status: 201
end
#se devuelve la lista de usuarios registrados
def usuarios
lista = Usuario.all
render :json => lista
end
#se verifican credenciales y se retorna 'ok' o 'error'
def login
#o... |
module Roglew
module GLX
N3DFX_WINDOW_MODE_MESA ||= 0x1
N3DFX_FULLSCREEN_MODE_MESA ||= 0x2
end
end
module GLX_MESA_set_3dfx_mode
module RenderHandle
include Roglew::RenderHandleExtension
functions [
#GLboolean glXSet3DfxModeMESA(GLint mode)
[:glXSet3DfxModeMESA, [:in... |
module TheDecider
def self.tell_me_who_will(description)
team_members = %w(0 Tamara Reed Dave)
"#{team_members[rand(1..3)].upcase} will #{description}."
end
end
|
require_relative '../lib/vws.rb'
describe Vws do
VWS_ACCESSKEY = "your_access_key"
VWS_SECRETKEY = "your_secret_key"
TARGET_ID_TO_DELETE = "a_target_id_to_delete"
TARGET_ID_TO_GET_INFO_ON = "a_target_to_get_info_on"
TARGET_ID_TO_SET_TO_FALSE = "a_target_id_to_set_to_false"
describe "should connect to ... |
class UserExternalAccount < ApplicationModel
belongs_to :user, :class_name => "User", :foreign_key => 'user_id'
validates_presence_of :user_id, :service, :data
end
|
json.array!(@donations) do |donation|
json.extract! donation, :id, :notes, :user_id, :institution_id, :blood_group_id
json.url donation_url(donation, format: :json)
end
|
module Roglew
module GL
MAX_COMBINED_SHADER_OUTPUT_RESOURCES ||= 0x8F39
MAX_COMBINED_SHADER_STORAGE_BLOCKS ||= 0x90DC
MAX_COMPUTE_SHADER_STORAGE_BLOCKS ||= 0x90DB
MAX_FRAGMENT_SHADER_STORAGE_BLOCKS ||= 0x90DA
MAX_GEOMETRY_SHADER_STORAGE_BLOCKS ||= 0x90D7
MAX_S... |
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "static_content/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "static_content"
s.version = StaticContent::VERSION
s.authors = ["Pedro Nascimento", "Sylvestre Mer... |
class AddApproachToClimbs < ActiveRecord::Migration
def change
add_column :climbs, :approach, :text
end
end
|
class Registration < ActiveRecord::Base
belongs_to :event
validates :name,presence:true
validates :email,format:{with:/(\S+)@(\S+)/}
HOW_HEARD_OPTIONS= %w(Newsletter BlogPost Twitter WebSearch Friend Other)
validates :how_heard,
inclusion: {in: HOW_HEARD_OPTIONS}
end |
require 'test_helper'
class NotificationTest < ActiveSupport::TestCase
include Devise::Test::IntegrationHelpers
# def setup
# @instructor = User.create(email: 'adam@instructor.com', password: 'password', password_confirmation: 'password', first_name: 'Adam', last_name: 'Braus', instructor: true, student: fals... |
require 'product.rb'
describe Product do
let(:soda) {Product.new("soda",10)}
it 'has a price' do
expect(soda.price).to eq(10)
end
it 'has a default price' do
cake = Product.new ("cake")
expect(cake.price).to eq(1)
end
it 'has a name' do
cake = Product.new ("cake")
expect(cake.name).... |
require('minitest/autorun')
require('minitest/rg')
require_relative('../student_classes.rb')
class TestStudent < MiniTest::Test
@student
def setup
@student = Student.new("Callum", 16)
end
def test_student_name
assert_equal("Callum", @student.student_name)
end
def test_student_cohort
... |
##
## This module requires Metasploit: http//metasploit.com/download
## Current source: https://github.com/rapid7/metasploit-framework
###
require 'msf/core'
class Metasploit4 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
def initialize(info={})
super(update_info(info,
'Name' ... |
class PhotosController < ApplicationController
def show
user = User.find(params[:user_id])
@title = "#{user.first_name} #{user.last_name}"
@photos = user.photos
end
end
|
require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "user has flags" do
user = User.create(first_name: 'Nathan')
user.update!(flags: {visible: true})
assert_instance_of ActiveFlags::Flag, user.flags_as_collection.first
end
test "user can create several flags at a time" do
user ... |
class Device < ActiveRecord::Migration
def change
remove_column :users, :device, :string
add_column :touch_data, :device, :string
end
end
|
class CreateResourceRequisitions < ActiveRecord::Migration
def self.up
create_table :resource_requisitions do |t|
t.references :requisition_type
t.text :justification
t.string :location
t.string :quantity
t.references :user
t.text :remarks
t.integer :person_incharge
... |
class SecureResqueServer < Resque::Server
use Rack::Auth::Basic, "Restricted Area" do |username, password|
[username, password] == ['admin', 'password']
end
end |
# Tealeaf Academy Prep Course
# Intro to Programming Workbook
# Intermediate Questions - Quiz 2
# Exercise 2
munsters = {
"Herman" => { "age" => 32, "gender" => "male" },
"Lily" => { "age" => 30, "gender" => "female" },
"Grandpa" => { "age" => 402, "gender" => "male" },
"Eddie" => { "age" => 10, "gender" => "m... |
define :fpm_site, :template => "fpm_app.conf.erb", :enable => true do
application_name = params[:name]
include_recipe "php"
template "#{node[:php]['fpm_dir']}/sites-available/#{application_name}.conf" do
if params[:template]
source "#{params[:template]}"
else
source "fpm_app.conf.erb"
e... |
require 'rails_helper'
RSpec.describe "the idea view", type: :feature do
let(:user) { User.create(username: 'Jenna', password: 'password', role:0) }
let(:idea) { Idea.create(name: 'Great idea', body: 'go hiking in a land far away', user_id: user.id) }
context "with valid attributes" do
it "creates and dis... |
# Included in User, Vendor, Product
module Attachments
extend ActiveSupport::Concern
included do
attr_accessor :delete_image
attr_reader :image_remote_url
before_validation { image.clear if delete_image == '1' }
# General image validations
has_attached_file :image, styles: { original: '500x500>', thumb:... |
require 'data_mapper' unless defined?DataMapper
module Yito
module Model
module Booking
#
# It represents a pickup/return place
#
class PickupReturnPlaceDefinition
include DataMapper::Resource
storage_names[:default] = 'bookds_pickup_place_defs'
property :id, Ser... |
class AddOwnToMonsters < ActiveRecord::Migration
def change
add_column :monsters, :own, :integer
end
end
|
require 'rotp'
class EARMMS::SignupController < EARMMS::ApplicationController
helpers EARMMS::SignupHelpers
get '/' do
@title = "Sign up"
@invite = get_invite(request.params["invite"])
unless @invite
next haml :'auth/signup/disabled' unless signups_allowed?
end
haml :'auth/signup/index... |
module ApplicationHelper
include Trap
include Concerns::AuthManagment
include HashtagUrl
def copyright(start_year)
start_year = start_year.to_i
current_year = Time.new.year
if current_year > start_year && start_year > 2000
"#{start_year} - #{current_year}"
elsif start_year > 2000
"#... |
#!/usr/bin/ruby
begin
input = File.open(ARGV[0]).read.split("\n").map(&:to_i)
rescue
puts 'Valid input file from AdventOfCode required as first argument.'
else
combs = (1..(input.length)).flat_map { |n| input.combination(n).to_a }
comb_lengths = combs.map { |arr| arr.reduce(:+) }
puts comb_lengths.count { |c... |
class Customer < ActiveRecord::Base
belongs_to :local
validates_presence_of :name, :mobile_phone
end
|
require 'spec_helper'
#require "factory_girl"
require "factory_girl_init"
describe User do
before(:each) do
@user = Factory(:user)
end
it "should require email" do
@user.email = nil
@user.should_not be_valid
@user.errors.messages[:email].should_not be_nil
end
it "passwords should be equal"... |
json.array!(@upload_managers) do |upload_manager|
json.extract! upload_manager, :id, :filename, :description
json.url upload_manager_url(upload_manager, format: :json)
end
|
Rails.application.routes.draw do
devise_for :users, :controllers => {:registrations => "registrations"}
root 'home#index'
resource :users
resources :posts do
resources :likes
end
get '/home', to: 'home#index'
get '/users/index', to: 'users#index'
get '/profile/:id', to: 'profile#show', as: :s... |
module Api::Helpers
class Result
include Virtus
attribute :success
attribute :resultCode
attribute :message
attribute :data
def initialize(data, error)
@error = error
@data = data
end
def success
@error.success
end
def resultCode
@error.code
end
... |
# Source: https://launchschool.com/exercises/b415a65e
# Q: Write a method that takes one argument, a string containing one or more
# words, and returns the given string with all five or more letter words
# reversed. Each string will consist of only letters and spaces. Spaces
# should be included only when mor... |
class AddIndexToVehiclesVin < ActiveRecord::Migration[5.0]
def change
add_index :vehicles, :vin
end
end
|
class HomeController < ApplicationController
before_action :authenticate_user!
def index
@tweets = Tweet.all.order(created_at: :desc)
@logged_user_tweets_count = Tweet.where(user_id: current_user.id).count
end
end
|
#!/usr/bin/env ruby
# :title: PlanR::Plugins::Parser::ASCII
=begin rdoc
Fallback parser for ASCII documents
(c) Copyright 2016 Thoughtgang <http://www.thoughtgang.org>
=end
require 'tg/plugin'
require 'plan-r/document'
module PlanR
module Plugins
module Parser
=begin rdoc
Parser for ASCII plaintext files. This... |
class PerfectGamesController < ApplicationController
def index
perfects = PerfectGame.all
render json: perfects
end
def show
perfect = PerfectGame.find(params[:id])
render json: perfect, include: [:users]
end
def create
perfect = PerfectGame.create(perfect_... |
class Api::CitiesController < Api::BaseController
def index
cities = City.pluck(:name)
render json: cities
end
end |
TravisBickle::Application.routes.draw do
root :to => 'contents#about_travis'
resources :tax_withholdings
resources :inspections
resources :minimum_wages
# resources :talks
resources :transfer_slips
resources :pickup_locations
resources :documents
resources :notifications
resources :rests
... |
require 'irods4r/directory'
module IRODS4r
#class NotFoundException < Exception; end
class NoFileException < Exception; end
class FileExistsException < Exception; end
# This class proxies a file in an iRODS environment
#
class File
# Create a file resource 'path'. If 'must_not_exist' is true,
#... |
class SearchController < ApplicationController
def index
term = "%#{params[:search].downcase}%"
search_query = <<-SQL
LOWER(name) LIKE ?
OR LOWER(body) LIKE ?
OR LOWER(description) LIKE ?
OR LOWER(source) LIKE ?
SQL
@recipes = Recipe.where(search_query, term, term, term, term)
render 'recipes/inde... |
# This file is app/controllers/entities_controller.rb
class EntitiesController < ApplicationController
respond_to :html, :xml, :json
def index
@current_user ||= Owner.find_by_id(session[:user_id])
respond_to do |format|
format.html {
@entities = Entity.order("updated_at DESC").page(para... |
require 'spec_helper'
describe Polepin do
it "should be valid" do
Polepin.should be_a(Module)
end
end
describe Polepin, 'Loading gems for app classes' do
it "should have required will_paginate so that app models have .paginate" do
User.should respond_to(:paginate)
end
end
|
require 'celluloid'
require 'qless/threaded_worker/util'
require 'qless/threaded_worker/processor'
require 'qless/threaded_worker/fetcher'
module Qless
module ThreadedWorker
##
# The main router in the system. This
# manages the processor state and accepts messages
# from Redis to be dispatched to... |
require_relative 'source'
class EventDetailsParser
attr_accessor :status, :body
def initialize(params)
@params = params
end
def source
Source.find_by(:identifier => @params["identifier"])
end
def message
if !source
"Identifier does not exist"
elsif event_data.empty?
"No event ... |
FactoryGirl.define do
factory :vendor do
name "Amazon"
provider "Amazon Oauth"
expiration "MyExpiration"
description "MyDescription"
instruction "MyInstruction"
helpLink "MyHelpLink"
cashValue "$10"
end
end |
#!/usr/bin/env ruby
require 'rubygems'
require 'ostruct'
require 'optparse'
require 'wartslib'
require 'asfinder'
def main
$asfinder = CAIDA::ASFinder.new ARGV[0]
file = Warts::File.open ARGV[1]
file.add_filters Warts::TRACE
file.read do |trace|
next unless trace.dest_responded?
ip... |
module UsersHelper
def gravatar_for user
gravatar_id = Digest::MD5.hexdigest(user.email.downcase)
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}"
image_tag(gravatar_url, alt: user.name, class: "gravatar")
end
def current_admin user
return unless current_user.admin? && !current_... |
class File
def info
file_info = %x{identify #{path}}.split(" ") rescue nil
file_info = {
:path => file_info[0],
:name => file_info[0].split("/").last,
:format => file_info[1],
:width => file_info[2].split("x")[0].to_i,
:height => file_info[2].split("x")[1].to_i,
:size => fi... |
class Ticket < ActiveRecord::Base
belongs_to :ticket_type
validates :count, :inclusion => {:in=> 1..10}
validate :not_more_than_quantity,:no_past_event
validates :name, presence: true, length: { minimum: 5}
validates :address, presence: true, length: { minimum: 6 }
validates :phone, presence: true, length: ... |
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
# require 'json'
require './load_config' unless ENV["RACK_ENV"] == "production"
require './models'
helpers do
def protected!
unless authorized?
response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
throw(:halt, [401, "Not author... |
class Identity < ActiveRecord::Base
attr_accessible :identity_name, :first_name, :last_name, :company_name, :title, :country, :state, :city, :address, :email, :cell, :phone,
:skype, :messenger, :gtalk, :facebook, :twitter, :linkedin, :flickr, :blog, :youtube, :birthday, :photo_url, :description,
... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{jammit}
s.version = "0.6.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jeremy Ashkenas"]
s.date = %q{2010-11-07}
s.default_executable = %q{jammit}
s.description ... |
file ::File.join(ENV['HOME'], '.ruby-version') do
content node['rocket-fuel']['chruby']['default_ruby']
owner ENV['SUDO_USER'] || node['current_user']
action :create_if_missing
end
|
Given(/^I am not logged in$/) do
end
# this only works in development
# you have to change the url it visits for the homepage
When(/^I visit the website homepage$/) do
visit "http://www.localhost:3000/"
end
Then(/^I should see "([^"]*)" on the page$/) do |text|
expect(page).to have_content text
end
Then(/^I sh... |
require 'spec_helper'
describe Genre do
describe "バリデーション" do
it { should validate_presence_of :title }
it { should validate_uniqueness_of(:name).scoped_to(:parent_id) }
it { should_not allow_value(" ").for(:title) }
describe ".validate_name" do
["_ABC", "javascripts", "stylesheets", "imag... |
class Staff::CustomerSearchForm
include ActiveModel::Model
include StringNormalizer
attr_accessor :family_name_kana, :given_name_kana, :birth_year, :birth_month, :birth_mday,
:address_type, :prefecture, :city, :phone_number, :gender, :postal_code,
:last_four_digits_of_phone_number... |
# encoding: UTF-8
module CDI
module V1
module GameGroups
class AddItemService < GameGroups::UpdateService
include V1::ServiceConcerns::GameGroupParams
record_type ::GameGroup
def changed_attributes
[:items]
end
def record_params
@record_params... |
class User < ActiveRecord::Base
validates :name, :uid, :provider, presence: true
validate :provider_must_be_spotify
def self.find_or_create_from_omniauth(auth_hash)
user = self.find_by(uid: auth_hash["uid"], provider: auth_hash["provider"], name: auth_hash["info"]["name"])
if !user.nil?
return user... |
require File.expand_path('lib/presenters/private/book', Rails.root)
require File.expand_path('lib/response/link', Rails.root)
require File.expand_path('lib/pagination', Rails.root)
module Private
class BooksController < AuthorizedController
def index_options
respond_to do |format|
format.json do
... |
$:.unshift(File.dirname(__FILE__) + '/../lib')
require 'rubygems'
require 'spec'
require 'logger'
gem 'activerecord', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
require 'delayed_job'
require 'sample_jobs'
Delayed::Worker.logger = Logger.new('/tmp/dj.log')
RAILS_ENV = 'test'
# determine the available backends
BAC... |
class ApplicationController < ActionController::Base
protect_from_forgery
def logged_in?
!session[:manager].nil?
end
end
|
# frozen_string_literal: true
require 'json'
class BaseController
attr_reader :params
def initialize(params: {})
@params = params
end
private
def redirect_to(url, opts)
[opts[:status], { 'Location' => url }, []]
end
def render(opts)
[
opts[:status],
{ 'Content-Type' => 'appli... |
privileges do
privilege :manage, :includes => [:create, :read, :update, :delete, :reposition]
privilege :read, :includes => [:index, :show, :search]
privilege :create, :includes => :new
privilege :update, :includes => :edit
privilege :delete, :includes => :destroy
privilege :reposition, :includes => [:move_... |
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authorize
before_filter :refresh_activity
protected
def authorize
if session_provider.user_logged_in?
now = Time.now
activity_time = session_provider.last_activity
if (now - activity_time) > 15.... |
module MdRenderHelper
#Take the text and parse it and highlight any code blocks using the rouge gem
def markdown_render(text)
markdown = Redcarpet::Markdown.new(RougeHTML,
fenced_code_blocks: true,
no_intra_emphasis: true,
autolink: true)
markdown.render(text).html_safe
end
end
|
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe NavigationHelper do
context 'with user logged in' do
let(:user_signed_in?) { true }
let(:current_user) { create(:user) }
it 'generates the correct login link' do
expect(link('login_or_logout')).to eql(
'<a class="red" tit... |
require 'faker'
FactoryGirl.define do
factory :address do |f|
f.street_1 { Faker::Address.street_address}
f.street_2 { Faker::Address.secondary_address}
f.city { Faker::Address.city}
f.state { Faker::Address.state_abbr}
f.zip { Faker::Address.postcode}
end
end |
class ChangefieldsInLocation < ActiveRecord::Migration
def change
change_column :locations, :lat, 'float USING CAST(lat AS float)'
change_column :locations, :lng, 'float USING CAST(lng AS float)'
end
end
|
class CompleteAddress < ActiveRecord::Migration
def change
# Legal name
add_column :dsc_addresses, :organisation, :string, null: false, default: ''
# Version Date at which the BLPU achieved its current state in the real-world
add_column :dsc_addresses, :state_date, :date
# Describes the physic... |
require 'gosu'
class Post
def initialize(window, x, y, width=40, height=400)
@height = height
@width = width
@x = x
@y = y
@color = Gosu::Color.argb(0xaa0000ff)
@window = window
@discs = []
end
def add_disc(disc)
@discs.push(disc)
disc.post = self
... |
#!/usr/bin/env ruby
require 'gli'
require 'monit_install'
# begin # XXX: Remove this begin/rescue before distributing your app
# require 'monit_install'
# rescue LoadError
# STDERR.puts "In development, you need to use `bundle exec bin/monit_install` to run your app"
# STDERR.puts "At install-time, RubyGems will ma... |
class Network
attr_reader :name,
:shows
def initialize(name)
@name = name
@shows = []
end
def add_show(show)
@shows.push(show)
end
def main_characters
main_actor_names = []
@shows.each do |show|
show.characters.select do |character|
if character.name == cha... |
class InvalidSecretException < StandardError; end;
module Tss
# Utilized to fetch secrets from an initialzed +Server+
class Secret
SECRETS_RESOURCE = "secrets".freeze
# Fetch secrets from the server
#
# @param server [Server]
#
# @return [Hash] of the secret and associated file contents... |
require 'spec_helper'
describe 'file a followed by managed_directory' do
let(:chef_run) {
runner = ChefSpec::Runner.new(:step_into => ['managed_directory'])
runner.converge 'managed_directory::t_basic'
}
before(:each) {
Dir.stub(:glob).and_call_original
}
describe 'given only file a' do
befor... |
require 'spec_helper'
module SonyCameraRemoteAPI
describe SonyCameraRemoteAPI::CameraAPIGroupManager do
let(:cam) { @cam }
let(:max_num_values) { 5 }
shared_examples_for 'API group' do | group, shoot_mode, exposure_mode |
before do
set_mode_dial cam, shoot_mode, exposure_mode
end
... |
describe "the values displayed on work_order" do
let(:work_order) { create(:ncr_work_order) }
let(:ncr_proposal) { work_order.proposal }
before do
work_order.setup_approvals_and_observers
login_as(work_order.requester)
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.