text stringlengths 10 2.61M |
|---|
class AddPrecisionToLatLong < ActiveRecord::Migration[5.1]
def up
change_column :activities, :lat, :decimal, :precision => 15, :scale => 10
change_column :activities, :long, :decimal, :precision => 15, :scale => 10
end
def down
change_column :activities, :lat, :decimal
change_column :activities, ... |
module Fog
module AWS
class EC2
class Real
# Modify image attributes
#
# ==== Parameters
# * image_id<~String> - Id of machine image to modify
# * attribute<~String> - Attribute to modify, in ['launchPermission', 'productCodes']
# * operation_type<~String> - ... |
module EvaluationsHelper
def evaluation_status(status, num_evaluated = 0, total = 0)
case status
when 0
# Has not started to evaluate entries
I18n.t('evaluations.status.has_not_started')
when 1
# Has started but hasn't finished
I18n.t('evaluations.status.still_evaluating', entries_... |
class DiscussionsController < ApplicationController
before_action :find_project, only: [:index, :new, :create, :edit, :update, :show]
before_action :find_discussion, only: [:update, :edit, :show]
before_action :get_counts, only: [:index, :show]
before_action :authenticate_user!, except: [:index, :show]
def ... |
class AccountPresenter < BasePresenter
def self.column_names
Account.column_names + ['customer_name', 'customer_type'] - ['account_group_id', 'created_at', 'updated_at']
end
def customer_name
profile.name if profile
end
def customer_type
account_group.class.model_name.human if account_group
en... |
module EnhancedUrlHelper
def current_controller?(options)
=begin
unless request
raise "You cannot use helpers that need to determine the current" "page unlsee your view context provides a Request object" "in a #request method"
end
return false unless request.get? || request.header?
... |
And(/^I expand the "([^"]*)" widget$/) do |widget|
if widget == 'My Pending Approvals'
find(:xpath, ".//div[*[contains(@onclick,'My Pending Approvals') and contains(@class,'unslidedPanel')]]//a").click
else
@mainpage.expandWidget(widget)
end
end
And(/^I select "([^"]*)" option from the "([^"]*)" dropdown... |
class Character < ActiveRecord::Base
belongs_to :avatar
belongs_to :user
belongs_to :location
has_many :items, :as => :itemable
has_many :incidents
belongs_to :equipped_armor, :class_name => "Item"
belongs_to :equipped_weapon, :class_name => "Item"
def hp
(items + incidents).reduce(avatar.skill_se... |
FactoryBot.define do
factory :team do
league { 'NL' }
city { 'Chicago' }
park { 'Wrigley Field' }
sheet_key { 'CHN' }
end
end
|
require "memo_manager/version"
require "memo_manager/manager"
module MemoManager
def self.manage
puts "MemoManager.manage is running..."
Manager.new.manage
puts "done!"
end
end
|
require_relative '../test_helper'
describe Kobol::Requests::Issues do
let(:issues) { Kobol::Requests::Issues.new }
before do
Kobol::Requests::Issues.send(:public, :search_params)
end
it "#search_params" do
properties = { label: ["bug", "refactoring"], language: ["ruby"] }
processed_properties = %... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
attr_accessible :username, :e... |
class Asset < ActiveRecord::Base
## TODO: validate that user can't make a new cash asset
belongs_to :purchase
has_many :accounts, as: :entity, dependent: :destroy
monetize :purchase_amount_cents, :allow_nil => true
monetize :salvage_amount_cents, :allow_nil => true
validates_uniqueness_of :name, :scope =>... |
require 'csv'
class ValidName
def self.find(season, player)
new(season, player).find
end
def initialize(season, player)
@season, @player = season, player
end
def find
available_names.sample
end
private
def available_names
names - used_names
end
def names
CSV.read('data/char... |
# frozen_string_literal: true
require "dry/logic/predicates"
RSpec.describe Dry::Logic::Predicates do
describe "#hash?" do
let(:predicate_name) { :hash? }
context "when value is a hash" do
let(:arguments_list) do
[
[{}],
[foo: :bar],
[{}]
]
end
... |
require 'spec_helper'
describe TechnicalstaffsController do
render_views
describe "GET 'new'" do
let(:teamstat) do
sign_in FactoryGirl.create(:user)
FactoryGirl.create(:teamstat)
end
it "should be successful" do
get 'new', :teamstat_id => teamstat
response.should be_success
... |
class ChangeForeignKeyForEmployeeDocumentsAndExportFields < ActiveRecord::Migration[5.0]
def change
remove_column :employee_documents, :document_template_id
add_column :employee_documents, :document_template_id, :uuid
remove_column :export_fields, :export_format_id
add_column :export_fields, :export_... |
#
# Copyright (c) 2009 RightScale Inc
#
# 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 to use, copy, modify, merge, publish,
# ... |
require "rails_helper"
feature "Delete the Word" do
given!(:user) { create :user_example_com }
given!(:word) { create :word, user: user }
scenario "user can delete his own word" do
sign_in_as "user@example.com"
visit words_path
within "tr", text: word.content do
click_link "Delete"
end
... |
class RemoveColumnAttachmentFromWorkOrders < ActiveRecord::Migration
def change
remove_column :work_orders, :attachment
end
end
|
# Write a program that outputs the lyrics for "Ninety-nine Bottles of Beer on the Wall"
# Your program should print the number of bottles in English, not as a number. For example:
#
# Ninety-nine bottles of beer on the wall,
# Ninety-nine bottles of beer,
# Take one down, pass it around,
# Ninety-eight bottles of beer ... |
class RenameSanctuariesTimesTable < ActiveRecord::Migration
def change
rename_table :sanctuaries_times, :sanctuaries_sessions
end
end
|
require File.dirname(__FILE__) + '/../test_helper'
class ReminderTest < Test::Unit::TestCase
fixtures :reminders
def test_create_reminder
reminder = Reminder.new
reminder.when_due = Date.new(2008, 2, 1)
reminder.title = 'Stuff'
reminder.details = 'More detailed stuff'
reminder.contacts << Cont... |
require 'rake'
require 'tempfile'
def gem_name_split(full_gem_name)
full_gem_name.split('-').join('/')
end
def gem_lib_file(full_gem_name)
"lib/#{gem_name_split(full_gem_name)}.rb"
end
def gem_lib_dir(full_gem_name)
"lib/#{gem_name_split(full_gem_name)}"
end
def gem_version_file(full_gem_name)
"lib/#{gem_na... |
class UserEvent < ActiveRecord::Base
belongs_to :gamestate
has_many :event_inputs, :dependent => :destroy
end
|
require "spec_helper"
module Ayi
describe CSSStrategy do
it "matches css files" do
subject.match_file_name?("example.rb").should be_false
subject.match_file_name?("hello/world.rb").should be_false
subject.match_file_name?('hello.scss').should be_true
subject.match_file_name?('hello.css').... |
class Person
attr_accessor :first_name, :last_name
def full_name
self.first_name
end
end
mike = Person.new
mike.first_name = 'Michael'
mike.last_name = 'Garcia'
p mike.full_name # => 'Michael Garcia' |
module PageObjects
class BookmarksList < Base
def add
click_on 'New Bookmark'
end
def previews
this.all('tr')
end
def selector
'#bookmarks'
end
end
end
|
after :'development:organizations' do
lt_admin = User
.create_with(password: 'admin123')
.find_or_create_by!(email: 'admin@learningtapestry.com')
lt_admin.add_role(:admin, Organization.find_by(name: 'LearningTapestry'))
end
|
require 'aws-sdk-s3'
RSpec.configure do |c|
c.before(:suite) do
s3_config = {
region: ENV.fetch('AWS_REGION', 'us-east-1'),
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID', 'accessKey1'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY', 'verySecretKey1'),
endpoint: ENV.fetch('AW... |
# == Schema Information
#
# Table name: courses
#
# id :integer not null, primary key
# department :string(255)
# name :string(255)
# year :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class Course < ActiveRecord::Base
has_many :exam... |
module Refinery
module Caststone
class Capital < Refinery::Caststone::Component
has_many :compatibles, foreign_key: :component_id
has_many :products, through: :compatibles, inverse_of: :capitals
end
end
end
|
module Sensors
class DesenseBase < Base
attributes :battery_voltage
def payloadHexa
message.payloadHex.gsub(/../) { |pair| pair.hex.chr }
end
def battery_voltage
@battery_voltage ||= values.battery / 1000.0
end
def attribute_units
units = super
units.merge({ battery_... |
class FontGreyQo < Formula
head "https://github.com/google/fonts/raw/main/ofl/greyqo/GreyQo-Regular.ttf", verified: "github.com/google/fonts/"
desc "Grey Qo"
homepage "https://fonts.google.com/specimen/Grey+Qo"
def install
(share/"fonts").install "GreyQo-Regular.ttf"
end
test do
end
end
|
#!/usr/bin/ruby
#
# Geo Coding
require 'bigdecimal'
def LatLngToDecimal(deg, min, sec, cardinal)
# puts "LatLnt to decimal called"
@decimal_min = min / 60.0
@decimal_sec = sec.to_f / 3600
@decimal = deg + @decimal_min + @decimal_sec
@cardinal = cardinal.upcase
case @cardinal
when "N"
puts @decimal.to... |
class Studio < ActiveRecord::Base
has_many :dance_classes
validates :name, :address, :phone, :uniqueness => true
validates :name, :address, :phone, :presence => true
end
|
class User < ApplicationRecord
has_many :reservations
has_many :restaurants, through: :reservations
validates :name, :email, presence: true
validates :email, uniqueness: true
end
|
require_relative 'spec_helper.rb'
RSpec.describe '0/10 DHT' do
describe 'SET' do
it 'should be able to set a value' do
expect($zero10dht.set('test', 'banana')).to eq('OK')
end
it 'should err on an invalid key' do
expect($zero10dht.set('', 'asdf')).to eq('ERR INVALID KEY')
end
end
desc... |
class AddSparcIdToParticipant < ActiveRecord::Migration
def change
add_column :participants, :sparc_id, :integer, :after => :id
add_index "participants", ["sparc_id"], name: "index_participants_on_sparc_id", using: :btree
end
end
|
class SessionHasStudent < ApplicationRecord
belongs_to :session
belongs_to :student
validates :session, presence: true
validates :student, presence: true
end
|
require 'test_helper'
class WebApi::Admin::SortingControllerTest < ActionController::TestCase
def setup
admin_sign_in(create(:admin))
@menu = create :menu
@params = { model_name: :menu, id: @menu.id }
end
def test_should_put_update
@params[:sort_attributes] = { sort: 20 }
put :update, @param... |
module FundAction
class Permissions < Decidim::DefaultPermissions
def permissions
unless user and user.is_a?(Decidim::User)
permission_action.disallow!
return permission_action
end
unless permission_action.scope == :global and
permission_action.subject == :invitat... |
collection User.all, root: :users, object_root: false
attributes :id, :email, :first_name, :last_name
node(:role) { |user| user.roles.first&.name }
|
module Kafka
class InstallGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path("../templates", __FILE__)
def copy_install_files
copy_file "config.yml", "config/kafka.yml"
copy_file "initializer.rb", "config/initializers/#{class_name.underscore}.rb"
end
end
end
|
# encoding: utf-8
module TextUtils
module DateHelper
def time_ago_in_words( from_time )
## note:
# for code/source examples
# check rails helper or padrino(sinatra) helper
# for now this is just a simplified version e.g. no i18n
from_time = from_time.to_time
to_time = Time.now
... |
require 'test_helper'
class RepositoriesControllerTest < ActionDispatch::IntegrationTest
setup do
log_in
@repository = FactoryBot.create(:repository, title: 'Archives')
end
test 'repositories index' do
get repositories_path
assert_response :success
assert_select 'table#repositories' do
... |
class SupplyTeachers::Spreadsheet
class DataDownload
include TelephoneNumberHelper
def sheet_name
'Agency shortlist'
end
def title
['Agency list']
end
def headers
['Agency name', 'Branch name', 'Contact name', 'Contact email', 'Telephone number']
end
def types
... |
require 'file_mover/suffixes'
require 'fileutils'
module FileMover
# add and remove the suffix by renaming the file
#
class Suffix < Filter
include Suffixes
def filter_file tmp_dir, path
target_path = target_pathes tmp_dir, path
FileUtils.mv path, target_path
target_path
end
... |
# tic toc toe
require 'pry'
require 'io/console'
INITIAL_MARKER = ' '.freeze
PLAYER_MARKER = 'X'.freeze
COMPUTER_MARKER = 'O'.freeze
WINNING_LINE = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + # rows
[[1, 4, 7], [2, 5, 8], [3, 6, 9]] + # cols
[[1, 5, 9], [3, 5, 7]] # diagonals
FIRST_... |
require 'spec_helper'
describe "shows/show" do
before(:each) do
@show = assign(:show, stub_model(Show,
:address => "Address",
:town => "Town",
:state => "State",
:zip => "Zip",
:venue => "Venue",
:venue_url => "Venue Url",
:event => "Event",
:ticket => "Ticket",
... |
class Assignee < ActiveRecord::Base
before_save { |assignee| assignee.email = email.downcase }
before_save :first_letter, :check_assigneepresence#, :check_tel
attr_accessible :email, :name, :surname, :tel
validates :name, :presence => true, :length => { :maximum => 50 }
validates :surname, :presence =... |
class RedactorController < ApplicationController
def upload
redactor_upload = RedactorUpload.new
redactor_upload.image = params[:file]
if redactor_upload.save
file_url =
if Fedena.hostname.present? && !FedenaSetting.s3_enabled?
URI.join(Fedena.hostname, URI.encode(redactor_... |
module SmsSenderOts
module MobileNumberNormalizer
def self.normalize_number(number)
n=number.dup
while n.starts_with?('+') || n.starts_with?('0')
n.slice!(0)
end
return n
end
def self.normalize_message(message)
message.encode(Encoding::UTF_8)
end
end
end
|
class AddCommentToFoursquareItems < ActiveRecord::Migration
def change
add_column :foursquare_items, :comment, :string
end
end
|
class User < ApplicationRecord
rolify
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :first_name, uniqueness: { case_sensitive: false },
presence: true,
allow_blank: false
def generate_jwt
... |
require "spec_helper"
describe Susanoo::Admin::PageTemplatesController do
describe "routing" do
it "routes to #index" do
get("/susanoo/admin/page_templates").should route_to("susanoo/admin/page_templates#index")
end
it "routes to #new" do
get("/susanoo/admin/page_templates/new").should rout... |
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless $LOAD_PATH.include?(File.dirname(__FILE__))
require 'addressable/uri'
require 'domainatrix/domain_parser'
require 'domainatrix/url'
require 'uri' # addressable doesn't provide a scanner/extractor
module Domainatrix
VERSION = "0.0.7"
def self.parse(url)
@domai... |
class Comment < ApplicationRecord
belongs_to :transactions, foreign_key: "transaction_id", class_name: "Transaction"
end
|
require 'spec_helper'
describe BetaInvitation do
let (:sender_user) {FactoryGirl.create(:user)}
let (:already_registered_user) {FactoryGirl.create(:user)}
before { @beta_invite = BetaInvitation.new(sender: sender_user, recipient_email:"beta_user@example.com")}
subject{@beta_invite}
it { should respond_to (... |
class Document < ActiveRecord::Base
TYPES = [ "ClassRoom", "ClassTest", "Student", "Subject" ]
mount_uploader :name, DocumentUploader
belongs_to :creator, polymorphic: true
belongs_to :school_branch
has_many :class_rooms, dependent: :destroy
has_many :class_tests, dependent: :destroy
has_many :students... |
class BridalParty < ActiveRecord::Base
belongs_to :reception
has_many :bridal_party_entries
end
|
require 'ruble'
with_defaults :scope => "source.ruby.rails" do |bundle|
snippet "assert_redirected_to" do |snippet|
snippet.trigger = "art"
# FIXME We don't support nested tab stops like this
#snippet.expansion = "assert_redirected_to ${2::action => \"${1:index}\"}"
snippet.expansion = "assert_redir... |
class Album < ActiveRecord::Base
belongs_to :user
has_many :photos
has_many :votes
validates :title, presence: true
validates :rating, numericality: { only_integer: true, allow_blank: true,
greater_than_or_equal_to: 1, less_than_or_equal_to: 5 }
scope :public, -> { where(public: true) }
after_initi... |
module Roadblock
module ActsAsRoadblockRole
extend ActiveSupport::Concern
included do
# belongs_to Roadblock.blockadable_class.model_name.singular.to_sym, class_name: Roadblock.blockadable_class.to_s
# has_many :grants, dependent: :destroy, class_name: Roadblock.grant_class.to_s
# has_many... |
class CreateRoomFamilies < ActiveRecord::Migration
def self.up
create_table :room_families do |t|
t.string :name
t.integer :room_id
t.string :relation
t.integer :age
t.string :sex
t.string :workplace
t.string :title
t.string :mphone
t.timestamps
end
end
... |
# frozen_string_literal: true
require 'twitter'
require 'yaml'
require 'logger'
require 'aws-sdk'
require 'ksdretweet/decision_logic'
require 'ksdretweet/image_url_message'
class Ksdretweet
def initialize
@logger = Logger.new('/var/log/ruby/ksdretweet_logger.log', 16)
# account_config = YAML.load_file('ksdr... |
class GrocersController < ApplicationController
before_action :find_grocer, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!, only: [:show, :new, :edit, :update, :destroy]
def index
@grocers = Grocer.all
end
def show
@need = @grocer.needs.new
@needs = @grocer.needs
end
... |
module ApplicationHelper
def active_class_attribute *paths
if link_active? *paths
"class='active'".html_safe
end
end
def active_class *paths
if link_active? *paths
"active"
end
end
def link_active? *paths
active = false
paths.each do |path|
path_arr = path.split('#'... |
require 'json'
class OrdersService < BaseService
def self.get_orders_for_date(target_date)
order_status = 'unshipped'
uri = URI("#{BASE_URL}/admin/orders.json")
req = Net::HTTP::Get.new(uri.path)
req.set_form_data({:fulfillment_status => order_status, :fields => 'id, name, note, fulfillment_status... |
class Item
attr_reader :name, :price
def initialize(item)
@name = item[:name]
@price = item[:price]
end
def start_sale
puts "a customer walks in, They want some #{@name}"
end
def price_check
puts "here are the retail price. anything above is comission!"
... |
class CreateRoadmaps < ActiveRecord::Migration
def self.up
create_table :roadmaps do |t|
t.column :way_type, :string, :limit => 13
t.column :street_name, :string, :limit =>50
t.column :common_name, :string, :limit =>50
t.column :municipality, :string, :limit=>20
t.column :prefix, :st... |
require 'spec_helper'
describe Topographer::Importer::Mapper::MapperBuilder do
let(:builder) { Topographer::Importer::Mapper::MapperBuilder.new }
describe '#required_mapping' do
it 'should add a new simple required mapping' do
builder.required_mapping('input_column1', 'output_field1')
expect(buil... |
class ExternalEvent
include Mongoid::Document
field :name, type: String
field :place, type: String
field :date, type: Date
field :url, type: String
field :active, type: Boolean, default: true
embedded_in :talk
validates_presence_of :name, :place, :date
scope :by_date, -> { order(date: :desc) }
s... |
# Read about factories at http://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :reuniao do
local "MyString"
data "MyString"
tipo "MyString"
hora "MyString"
end
end
|
class CreateItems < ActiveRecord::Migration
def change
create_table :items do |t|
t.references :order
t.string :item_name
t.string :item_size
t.timestamp
end
end
end
|
class FontLemonada < Formula
head "https://github.com/google/fonts/raw/main/ofl/lemonada/Lemonada%5Bwght%5D.ttf", verified: "github.com/google/fonts/"
desc "Lemonada"
homepage "https://fonts.google.com/specimen/Lemonada"
def install
(share/"fonts").install "Lemonada[wght].ttf"
end
test do
end
end
|
class ClothsController < ApplicationController
# GET /cloths
# GET /cloths.json
def index
@cloths = Cloth.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @cloths }
end
end
# GET /cloths/1
# GET /cloths/1.json
def show
@cloth = Cloth.find(par... |
When(/^I sign up for the mailing list$/) do
@email = 'some@email.com'
signup_for_mailing_list(@email)
end
def signup_for_mailing_list(email)
visit root_url
fill_in 'mailing_email', :with => email
click_button 'loop'
end
When(/^I sign up for the mailing list with that email$/) do
signup_for_mailing_list(@e... |
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... |
require "formula"
class Kf5Kmime < Formula
homepage "http://kde.org/"
head "git://anongit.kde.org/kmime.git"
depends_on "cmake" => :build
depends_on "chigraph/kf5/kf5-extra-cmake-modules" => :build
depends_on "chigraph/kf5/kf5-ki18n"
depends_on "chigraph/kf5/kf5-kcodecs"
depends_on "qt"
def install
... |
#Using .each
#def reverse_each_word (string)
#new_array = string.split(/ /)
#reverse_word=[]
#new_array.each {|word| reverse_word << word.reverse}
#reverse_string=reverse_word.join(" ")
#end
#using .collect
def reverse_each_word (string)
new_array = string.split(/ /)
new_array.collect{|word| word.reverse}... |
require File.join(File.dirname(__FILE__), "spec_helper")
describe Sequel::Plugins::LinkedList do
it "should introduce a 'next' field into the schema"
it "should allow for custom 'next' field specification via :next => 'field_name'"
it "should introduce a 'previous' field into the schema"
it "should allow f... |
class AddLecturerIdToReviews < ActiveRecord::Migration
def change
add_column :reviews, :lecturer_id, :integer
end
end
|
class InquiryRecord < ApplicationRecord
belongs_to :user
belongs_to :dog
has_one :inquiry_form
end
|
class MomentumCms::Admin::SessionsController < MomentumCms::Admin::UserManagementBaseController
before_action :build_moment_cms_user
skip_before_filter :require_login, only: [:new, :create]
skip_before_filter :require_login, except: [:destroy]
skip_before_filter :load_site
before_action :redirect_if_logged_... |
require 'Cloud'
require 'Dbox'
# The inventory task is run every 12 hours
# Give each file 4 tries ~ 48 hours to appear
# Worst case: upload 12:01am Day 1
# 5:00am inventory from Day 1 12:00am comes back, try = 1
# 5:00pm inventory from Day 1 12:00pm comes back, try = 2
# AWS inventory updates 12:00am Day 2
# 5:00am i... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Menus
describe DSL do
let(:described) { Vedeu::Menus::DSL }
let(:instance) { described.new(model) }
let(:model) { Vedeu::Menus::Menu.new(attributes) }
let(:_name) { :vedeu_menus_dsl }
let(:colle... |
class CreateMembers < ActiveRecord::Migration
def self.up
create_table :members do |t|
t.string :username, null: false
t.string :email
t.string :crypted_password
t.string :salt
t.string :remember_token
t.datetime :remember_token_expires_at
t.text :config_dump
t.bool... |
require 'open3'
require 'shellwords'
module ConsoleUtils
module JSONOutput
# The jq formatter uses the external {jq}[http://stedolan.github.com/jq] utility.
class JqFormatter < BaseFormatter
delegate :jq_command, to: :ConsoleUtils
def format(body, args: nil, flags: nil, compact: false, **) #:nod... |
module Offenses
extend ActiveSupport::Concern
class Coder
def initialize(offense_class)
@offense_class = offense_class
end
def dump(obj)
ActiveSupport::JSON.encode(obj.map(&:attributes))
end
def load(json)
return [] if json.blank?
JSON.parse(json).map { |j| @offense_cl... |
require_relative 'lib_requirements.rb'
class CsvRecord
# parent class of Room, Reservation, and Block
attr_reader :id
include Helpers
def initialize(id)
self.class.validate_id(id)
@id = id
end
# Takes either full_path or directory and optional file_name
# Default file name matches class nam... |
module Taxis
class TaxonItem < ActiveRecord::Base
belongs_to :taxon
validates_presence_of :taxonable_type, :message => "is required. Try the attach() method on a Taxon object. "
end
end
|
# frozen_string_literal: true
require 'econfig'
require 'sinatra'
# configure based on environment
class SpotifySearchAPI < Sinatra::Base
extend Econfig::Shortcut
API_VER = 'api/v0.1'
configure do
Econfig.env = settings.environment.to_s
Econfig.root = File.expand_path('..', settings.root)
SecureDB... |
require 'pry'
class Ship
attr_reader :name, :year_built
@@all = []
def initialize name, year_built
@name = name
@year_built
@@all << self
end
def pirates
Pirate.all.select do |pirate|
pirate.ship == self #ship1
end
end
oisjdfoidsjf... |
RSpec.describe RiksbankCurrency::Fetcher do
let(:today_fetcher) { RiksbankCurrency::Fetcher.new(Date.today, 'SEK') }
let(:past_fetcher) { RiksbankCurrency::Fetcher.new(Date.today.prev_month, 'USD') }
describe '.fetcher' do
it 'returns TodayFetcher instance for current day' do
expect(today_fetcher.fetch... |
require 'rspec'
require 'hand'
describe Hand do
let(:card1) {double("card1", :suit => :Hearts, :value => 2)}
let(:card2) {double("card2", :suit => :Spades, :value => 12)}
let(:card3) {double("card3", :suit => :Diamonds, :value => 13)}
let(:card4) {double("card4", :suit => :Clubs, :value => 2)}
let(:card5) {... |
require 'spec_helper'
describe 'vostok' do
before {
connection_stub = stub 'connection', close: true
connection_stub.stub(:is_a?).with(PG::Connection).and_return(true)
connection_stub.stub(:is_a?).with(Hash).and_return(false)
PG::Connection.stub(:new).and_return(connection_stub)
}
let(:import){im... |
require 'rails_helper'
describe 'autos/new', type: :view do
it 'Quero ver um formulário vazio' do
assign(:auto, Auto.new)
assign(:assuntos, create_list(:assunto, 3))
assign(:classes, create_list(:classe, 3))
render
assert_select("form[action=?]", '/autos')
assert_select("select[name=?]", 'a... |
require 'fileutils'
require 'modulesync/cli'
require 'modulesync/constants'
require 'modulesync/git'
require 'modulesync/hook'
require 'modulesync/renderer'
require 'modulesync/util'
module ModuleSync
include Constants
def self.local_file(config_path, file)
"#{config_path}/#{MODULE_FILES_DIR}/#{file}"
end
... |
require 'rake'
require './lib/orocos/version'
begin
require 'hoe'
Hoe::plugin :yard
Hoe::RUBY_FLAGS.gsub!(/-w/, '')
hoe_spec = Hoe.spec('orocos.rb') do |p|
self.developer("Sylvain Joyeux", "sylvain.joyeux@dfki.de")
self.summary = 'Controlling Orocos modules from Ruby'
self.des... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.