text stringlengths 10 2.61M |
|---|
Rails.application.routes.draw do
root 'pages#home'
get '/home', to: 'pages#home'
#get '/reviews', to: 'reviews#index'
#get '/reviews/new', to: 'reviews#new', as: 'new_review'
#post '/reviews', to: 'reviews#create'
#get '/reviews/:id/edit', to: 'reviews#edit', as: 'edit_review'
#patch '/reviews/:i... |
require "bundler/gem_tasks"
require "rspec/core"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList["spec/**/*_spec.rb"]
end
require "rdoc/task"
require "anonymizable/version"
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = "rdoc"
rdoc.title = "anonymizable #{Anonymi... |
class AddCoordinatesToLocations < ActiveRecord::Migration[5.0]
def change
add_column :locations, :latitude, :decimal, precision: 10, scale: 6
add_column :locations, :longitude, :decimal, precision: 10, scale: 6
end
end
|
class CardExpirationPage < Howitzer::Web::Page
validate :element_presence, :card_expiration
element :expiration_date, '#expiration'
def self.expiration_date
given.expiration_date_element
end
def fill_expiration_date(value)
expiration_date_element.set(value)
end
end
|
require 'spec_helper'
describe SimpleHdGraph::Renderer::PlantUML::Context do
include ExampleLoader
let(:parser) { SimpleHdGraph::Parser.new }
let(:renderer) { SimpleHdGraph::Renderer::PlantUML::Context.new }
describe '#render' do
describe 'simple' do
before {
@nodes = parser.parse(read_exam... |
# frozen_string_literal: true
module Analysers
class BaseAnalyser
def initialize(sorter: Sorter.new)
@sorter = sorter
end
def generate_analysis(logs:)
Analysis.new(title, log_entries(logs))
end
private
attr_accessor :sorter
def log_entries(logs)
log_entries = analyse... |
require 'spec_helper'
require 'gitlab_post_receive'
describe GitlabPostReceive do
let(:repository_path) { "/home/git/repositories" }
let(:repo_name) { 'dzaporozhets/gitlab-ci' }
let(:actor) { 'key-123' }
let(:changes) { "123456 789012 refs/heads/tést\n654321 210987 refs/tags/tag" }
let(:wrongly_encoded_c... |
class CategoryGroup < ApplicationRecord
validates :name, presence: true
has_many :categories
end
|
class TweetsController < ApplicationController
before_filter :get_zombie
def get_zombie
@zombie = Zombie.find(params[:zombie_id])
end
def index
@tweets = @zombie.tweets
end
end
|
require 'rails_helper'
describe StructureCreator do
def audit_payload(data)
payload = { 'audit' => data }
expect(payload).to match_response_schema('retrocalc/audit')
payload
end
let!(:field1) { create(:field) }
let!(:field2) { create(:field) }
let!(:structure_wegoaudit_id) { SecureRandom.uuid }
... |
require 'rails_helper'
RSpec.describe "As a visitor" do
describe "if submit a review for a book as a user who already has one" do
it "won't let me" do
user = User.create(username: "test")
book = Book.create(title: "test1", pages: 666, pub_date: "1/1/1970")
Review.create(user: user, book: book,... |
# frozen_string_literal: true
require 'rails_helper'
require_relative '../../app/presenters/features'
describe Features do
describe '.wiki_ed?' do
context 'when the url is dashboard-testing.wikiedu.org' do
before do
allow(ENV).to receive(:[]).with('dashboard_url').and_return('dashboard-testing.wiki... |
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include SessionsHelper
rescue_from "Exception" do |exception|
line_num = Integer(exception.backtrace[0].split("... |
Factory.define :spent_time do |spent_time|
spent_time.spent_time 10
spent_time.day Date.today
spent_time.task_id :task
end |
Then /^I click on Report a Problem$/ do
menuList = @driver.find_element(:class, "menu_n").find_element(:class, "first_item")
menu = menuList.find_element(:id,"menulink")
menu.click
menuList.find_element(:link_text, "Report a problem").click
end
Then /^It open a popup$/ do
wait = Selenium::WebDriver::Wait.new... |
class AddOngoingToProjects < ActiveRecord::Migration[6.0]
def change
add_column :projects, :ongoing, :boolean, default: true
add_index :projects, :ongoing
end
end
|
require 'spec_fast_helper'
require 'hydramata/works/work'
require 'hydramata/works/presentation_structure'
require 'hydramata/works/conversions/presented_fieldsets'
module Hydramata
module Works
describe Conversions do
include Conversions
context '#PresentedFieldsets' do
let(:work) do
... |
# == Schema Information
#
# Table name: i18n_keys
#
# id :integer not null, primary key
# key_name :string
# created_at :datetime not null
# updated_at :datetime not null
#
class I18nKey < ActiveRecord::Base
has_many :translations
has_one :i18n_name, class_name: 'ShopType', f... |
require 'test_helper'
class RecipeTest < ActiveSupport::TestCase
setup do
@author = Author.create(name: "someone")
@r2 = Recipe.create(name: 'Lasagne Végétarienne', ingredients: 'Champignon pate',
author: @author)
end
test "search_recipes should return full singredient before do... |
class ChangeSalutationAndDesignationFromUser < ActiveRecord::Migration
def change
rename_column :users, :salutation_field, :salutation
rename_column :users, :designation_field, :designation
end
end
|
class Partner < ApplicationRecord
mount_uploader :logo, LogoUploader
has_many :missions, dependent: :destroy
end
|
class ProgramsController < ApplicationController
respond_to :html, :json
def index
@programs = Program.today
if user_signed_in?
@channel_ids = current_user.channels.map(&:id)
@title_ids = current_user.titles.map(&:id)
end
respond_with @programs
end
end
|
# == Schema Information
#
# Table name: artifact_with_versions
#
# id :integer not null, primary key
# artifact_id :integer
# version_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
describe ArtifactWithVersion do
it 'should return proper proper... |
require 'pygments'
require 'redcarpet'
require 'RedCloth'
require 'nokogiri'
class Gust
extend Pygments
class << self
def parse(code, options = {})
return plain_text(code) unless options[:filename]
case options[:filename]
when /.*\.png$/ then image(options[:url])
when /.*\.markdo... |
class Event < ApplicationRecord
belongs_to :user
validates :start, presence: true
validates :end, presence: true
end
|
class Project < ActiveRecord::Base
attr_accessible :category_id, :name, :requirements, :user_id
belongs_to :user
belongs_to :category
validates :name, :presence => true
validates :requirements, :presence => true
validates :user_id, :presence => true
validates :category_id, :presence => true
end
|
FactoryGirl.define do
factory :neighborhood do
name { Faker::Address.city }
factory :neighborhood_with_everything do
venues { create_list(:venue_with_everything, rand(5..10)) }
end
end
end
|
class Api::BaseApiController < ApplicationController
respond_to :json
skip_before_filter :verify_authenticity_token
def authenticate_api_user!
user = User.find(params[:user_id])
return invalid_access unless user.authentication_token == params[:auth_token]
set_current_user user
end
def current... |
class CreateAffiliateEvents < ActiveRecord::Migration
def self.up
create_table :affiliate_events do |t|
t.column :affiliate_user_id, :integer
t.column :event_type, :string
t.column :event_id, :integer
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
... |
{
en: {
ui: {
contacts: {
form: {
add_phone: 'Add A Phone Number',
contact_for: 'Contact for',
}
},
customer_portal: {
account: 'Account',
jobs: 'Jobs',
damper_history: 'Damper History',
damper_inspection: 'Damper Inspection',
... |
class PostsController < ApplicationController
def index
posts = Post.all
render json: {
posts: ActiveModelSerializers::SerializableResource.new(posts, each_serializer: PostSerializer),
message: 'Posts list fetched successfully',
status: :ok,
type: 'Success'
}
end
end
|
require "./lib/queue"
class EventReporter
puts "Welcome to the Event Reporter! To exit just type exit or quit."
def initialize
@quit_repl = false
end
def start
puts "type help to get started"
prompt = "->"
until @quit_repl
print prompt
input = gets.chomp
if input == "quit" ||... |
module Protocolize
class Protocol < ActiveRecord::Base
before_save :set_protocol
def set_protocol
self.random = get_random
self.created_at = DateTime.now.utc
self.protocol = "#{get_project_code}#{get_timestamp}#{self.random}"
end
def get_random
SecureRandom.alphanumeric... |
Vagrant.configure("2") do |config|
# Virtual OS
config.vm.box = "centos/7"
# PrivateIP
config.vm.network "private_network", ip: "192.168.33.10"
# Synced Folder
config.vm.synced_folder "./", "/vargrant", type:"virtualbox"
# Provisioning Script
config.vm.provision :shell, :path => "provision.sh"
end
|
ActiveAdmin.register Book do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted... |
class Status
attr_accessor :id, :name, :symbol
def initialize(options = {})
options = options.symbolize_keys
@id, @name, @symbol = options[:id], options[:name], options[:symbol]
end
@@statuses ||= [
Status.new(:id => 1, :name => 'Návrh', :symbol => 'draft' ),
Status.new(:id => 50, :... |
module Pajama
class List
CARD_QUERY_OPTIONS = {
members: true,
member_fields: 'username',
}
def initialize(client, list_id)
@client = client
@trello_list = ::Trello::List.find(list_id)
end
def cards
@trello_list.cards(CARD_QUERY_OPTIONS).map { |tc| Card.new(@client,... |
class PicturesController < ApplicationController
load_and_authorize_resource
before_action :find_picture, only: [:approve, :disapprove]
def approve
if @picture.approve!
head :ok
else
head :not_modified
end
end
def disapprove
if @picture.disapprove!
head :ok
else
... |
class ProfilesController < ApplicationController
before_filter :require_login
def show
@user = find_user
@user.extend(Avatarable)
end
def edit
add_breadcrumb 'Профиль', profile_path
add_breadcrumb 'Редактирование'
@user = find_user
@user.additional_emails.build
end
def updat... |
# -*- coding: utf-8 -*-
#
# Unauthorized controller for welcome page.
# All session attributes are cleared and user session
# is nullified.
# TODO: This should inherit from the ApplicationController, which means the
# authentication/authorization needs to be de-coupled from this as well. If I
# change it now the autho... |
require "rails_helper"
require "capybara/rspec"
RSpec.describe QuestionsController, :type => :controller do
describe "GET index" do
it "is valid when Responds Successfully" do
expect(response.status).to eq(200)
end
end
describe "GET show" do
it "Shows a list of questions" do
visit "/questions"
e... |
class Users::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
skip_before_action :authenticate_user!, :authenticate_user_from_token!, :only => [:create, :new]
skip_before_action :verify_signed_out_user, :only => [:destroy], :if => Proc.new {|c| c.request.f... |
class ChangeEditRating < ActiveRecord::Migration[6.1]
def change
remove_column :reviews, :raiting
add_column :reviews, :rating, :integer
end
end
|
class ChangeColumnF < ActiveRecord::Migration[5.2]
def change
rename_column :list_furnitures, :type, :f_type
end
end
|
Gem::Specification.new do |s|
s.name = 'rails-flat-ui'
s.version = '0.1.0'
s.date = '2015-09-04'
s.summary = "Rails assets packaging for flat-ui"
s.description = "Rails assets packaging for flat-ui based on http://designmodo.github.io/Flat-UI/"
s.license = 'MIT'
s.aut... |
Given /^I am on the TCCC website home page$/ do
@selenium.start_new_browser_session
@selenium.open "http://www.twincitiescodecamp.com"
end
When /^I click on "([^"]*)"$/ do |text|
@selenium.click "link=#{text}", :wait_for => :page
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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... |
#!/usr/bin/env ruby
# A few helpful tips about the Rules file:
#
# * The string given to #compile and #route are matching patterns for
# identifiers--not for paths. Therefore, you can’t match on extension.
#
# * The order of rules is important: for each item, only the first matching
# rule is applied.
#
# * Item i... |
require_relative "sha256lib.rb"
# -------
# Default
# -------
if !defined? $input
# default
$input = "abc"
$message = $input.unpack("B*")[0]
# argument passed
$message = ARGV[0] if ARGV[0] # accept binary message string
# calculate padded message
$padded = padding($message)
end
# --------------
# Mess... |
require_relative('language_error')
class NotMatchingArgsCountError < LanguageError
def initialize(provided, expected)
super("Function call incorrect, #{provided} arg(s) provided, #{expected} arg(s) expected")
end
end |
class TutorsController < ApplicationController
before_filter :authenticate_user!, except: [:show]
before_action :set_user, only: [:show, :edit, :update, :destroy]
def index
@class_search = true
@search_page = true
if params[:sort] == 'min_price_asc'
sort = 'min_price ASC'
elsif params[:sort... |
class AddUseridPasswordInServer < ActiveRecord::Migration
def up
add_column :servers, :server_user, :string
add_column :servers, :server_password, :string
end
def down
remove_column :servers, :server_user
remove_column :servers, :server_password
end
end
|
require 'rspec/given'
require './kata1_roman_numeral_converter'
RSpec::Given.use_natural_assertions
describe RomanNumeralConverter do
Given(:converter) { RomanNumeralConverter.new }
context "when converting from arabic to roman" do
Then { converter.convert(1) == "I" }
Then { converter.convert(2) == "II" ... |
require 'mail'
class Mailer
def self.send(new_drops, drops, books)
set_defaults
now = Time.now.strftime('%-d %B')
message = ''
message += '<strong>PRICE DROPS</strong><br>'+
new_drops.map(&:to_screen).join('<br>') + '<br><br>' if new_drops.any?
message += '<strong>DISCOUNTED</st... |
class UsersController < ApplicationController
before_action :authenticate_user
before_action :authenticate_owner, only: [:update]
before_action :authenticate_admin, only: [:destroy]
def index
render json: User.all
end
def show
render json: user
end
def me
render json: current_user
end
... |
#<Encoding:UTF-8>
require_relative '../../lib/parser/parser'
describe Parser::Parser, ".parse" do
context "Parsing simple.js" do
before do
stream = File.read File.expand_path('../../js-files/simple.js', __FILE__)
@parser = Parser::Parser.new stream
@comments = @parser.parse
end
... |
class ArtsController < ApplicationController
before_action :set_art, only: [:show, :edit, :update, :destroy]
before_filter :authenticate_user!
# GET /arts
# GET /arts.json
def index
#@moment = Moment.find(params[:moment_id])
#@arts = current_user.arts.where(moment_id: @moment.id)
@arts = Art.wher... |
# column index is a number of column - 1.
# For example: the column called TotalTrials is 5. 5-1 = 4, so COLUMN_INDEX equals to 4.
COLUMN_INDEX = 4
# script assumes that the input and output files are in the current folder
SOURCE_FILE_NAME = 'data.csv'
OUTPUT_FILE_NAME = 'result.csv'
# you don't need to change anyth... |
require 'test_helper'
class BookingsTest < MiniTest::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def setup
@resource ||= Resource.first_or_create!(name: 'A resource', description: 'A description')
end
def teardown
Resource.delete_all
Booking.delete_all
... |
class PermissionService
extend Forwardable
attr_reader :user, :controller, :action
def_delegators :user, :platform_admin?, :vendor_admin?, :registered_user?
def initialize(user)
@user = user|| User.new
end
def allow?(controller, action)
@controller = controller
@action = action
case
... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# config.vbgues... |
# == Schema Information
#
# Table name: access_logs
#
# id :bigint not null, primary key
# denied_reason :string
# success :boolean not null
# created_at :datetime not null
# updated_at :datetime not null
# code_id :bigint
# door_id :bigint ... |
require_relative "lib/saddlebag/version"
Gem::Specification.new do |spec|
spec.name = "saddlebag"
spec.version = Saddlebag::VERSION
spec.authors = ["Ying"]
spec.email = ["yingwitmon.win@gmail.com"]
spec.homepage = "http://mygemserver.com"
spec.summary = "Summary of Saddlebag."
... |
module Fog
module Compute
class Google
class Mock
def set_target_https_proxy_ssl_certificates(_proxy_name, _certs)
# :no-coverage:
Fog::Mock.not_implemented
# :no-coverage:
end
end
class Real
def set_target_https_proxy_ssl_certificates(proxy... |
class HomeController < ApplicationController
def index
@projects = Project.find(:all, :order => "id desc", :limit => 5)
end
end
|
require 'rails_helper'
RSpec.describe FaqSerializer, :type => :serializer do
describe "attributes" do
before do
@faq = FactoryGirl.create :faq_director
@serialized = ActiveSupport::JSON.decode(serialize(@faq))
end
it "should only include id, question, answer, and user as an attribute" do
... |
#!/usr/bin/env ruby
require __dir__ + '/../bootstrap'
require 'thor'
include FreeKindleCN
class CLI < Thor
desc "asin", "download by ASIN"
def asin(*asins)
Updater.fetch_info(asins.select { |asin| Item.is_valid_asin? asin })
end
desc "list", "download by lists"
def list
logger.info "#{Time.now}: U... |
class Empleado < ActiveRecord::Base
belongs_to :departamento
belongs_to :puesto
has_one :centro, through: :departamento
has_many :captures
def self.search(query)
where("num_empleado like ?", "%#{query}%")
end
scope :ordenado, ->{ order("num_empleado ASC") }
end
|
require 'spec_helper'
describe CompanyPolicy do
subject { CompanyPolicy.new(user, company) }
describe 'as owner' do
let(:company) { FactoryGirl.create(:company, owner: user) }
describe 'for a user' do
let(:user) { FactoryGirl.build(:user) }
it { should permit_action(:show) }
it { sh... |
class BabyInfantFeeding < ApplicationRecord
belongs_to :infant_feeding_label
belongs_to :infant_feeding_month, optional: true
end
|
class Beer < ActiveRecord::Base
validates_presence_of :name, :style_id
belongs_to :style
before_create :set_drink_date, unless: :drink_on_date?
private
def set_drink_date
style = Style.find(self.style_id)
style_aging_time = style.aging_time_months
self.drink_on_date = (Date.today + style_aging_t... |
#class Customer
# attr_accessor :name, :email
#
# def initialize(name, email)
# @name, @email = name, email
# end
#end
Customer = Struct.new(:name, :email) do
def name_with_email
"#{name} <#{email}>"
end
end
customer = Customer.new("Dave", "dave@example.com")
puts customer.inspect
puts customer.name_with... |
require 'sqlite3'
require_relative 'replies'
require_relative 'questionsfollows'
class Users
attr_accessor :id, :fname, :lname
def self.find_by_id(id)
users = QuestionsDBConnection.instance.execute(<<-SQL, id)
SELECT * FROM users WHERE id = ?
SQL
users.map { |datum| Users.n... |
class AddChangeOrderFileToChangeOrders < ActiveRecord::Migration[5.0]
def change
add_column :change_orders, :change_order_file, :string
end
end
|
When(/^I view the following menu options:$/) do |table|
previous_top_menu = ''
menu_items = ''
table.hashes.each do |row|
top_menu = row["top_menu"]
sub_menu = row["sub_menu"]
on(StatementsPage) do |page|
page.wait_for_navigation_menu_to_load
if( previous_top_menu != top_menu )
m... |
# encoding: US-ASCII
require 'binary_struct'
require 'uuidtools'
require 'stringio'
require 'memory_buffer'
require 'fs/xfs/allocation_group'
require 'fs/xfs/inode_map'
require 'fs/xfs/inode'
require 'rufus/lru'
module XFS
# ////////////////////////////////////////////////////////////////////////////
# // Data d... |
class TasksController < ApplicationController
before_filter :authenticate_user!, :except => [:index]
def index
@task = Task.new
@tasks = Task.all.order(created_at: :desc)
end
def create
@task = Task.new(tasks_params)
if @task.save
redirect_to root_path
else
redirect_to root_path... |
class AddFieldsToUsersProducts < ActiveRecord::Migration[5.2]
def change
add_column :users_products, :paid_at, :datetime
add_column :users_products, :amount, :decimal
change_column :users_products, :is_paid, :boolean, default: false
end
end
|
class AddAttachmentUrl < ActiveRecord::Migration[5.1]
def change
add_column :items ,:attachment_url , :string
end
end
|
module Cmc
def self.table_name_prefix
'cmc_'
end
end
|
class NotificationMailer < MandrillMailer::MessageMailer
default from: 'hvatayka@galchonok.heroku.com', from_name: "Galchonok"
def request_data(request_object)
receiver = 'alona.tarasova@gmail.com'
text_data = parse_request(request_object)
html_data = parse_html_request(request_object)
Rails.logg... |
class GenresController < ApplicationController
def index
@genres = Genre.all
end
def new
@genre = Genre.new
end
def create
@genre = Genre.new(genre_params)
if @genre.save
flash[:success] = "You have successfully created an genre!"
redirect_to genres_path
else
flash... |
require 'lotus/model'
require 'lotus/mailer'
Dir["#{ __dir__ }/instalytics/**/*.rb"].each { |file| require_relative file }
Lotus::Model.configure do
##
# Database adapter
#
# Available options:
#
# * Memory adapter
# adapter type: :memory, uri: 'memory://localhost/instalytics_development'
#
# * ... |
require 'spec_helper'
describe "opendata_agents_nodes_mypage", dbscope: :example do
let(:site) { cms_site }
let!(:node_dataset) { create :opendata_node_dataset }
let(:node_mypage) { create :opendata_node_mypage, filename: "mypage", basename: "mypage" }
let!(:node_my_dataset) { create :opendata_node_my_dataset,... |
require_relative "transaction"
require_relative "transaction_history"
class Statement
HEADER = "date || credit || debit || balance"
def initialize(log)
@log = log
end
def print
HEADER + get_body
end
private
attr_reader :log
def get_body
statement = ""
@log.reverse.each do |transac... |
#encoding: utf-8
require 'rubygems'
require 'pry'
require 'bundler/setup'
class ValidTree
class ParamsError < StandardError
attr_reader :full_messages
def initialize(message = '')
@full_messages = message
end
end
attr_reader :opts
def initialize(opts)
@error_params = []
@opts = op... |
class Probe::Calibration < ActiveRecord::Base
set_table_name "probe_calibrations"
include Changeable
acts_as_replicatable
self.extend SearchableModel
@@searchable_attributes = %w{name description}
class <<self
def searchable_attributes
@@searchable_attributes
end
end
belongs_to ... |
# frozen_string_literal: true
FactoryBot.define do
sequence(:pages) { |n| n.to_s }
end
|
require 'rails_helper'
describe Idv::ScanIdController do
before do |test|
stub_sign_in unless test.metadata[:skip_sign_in]
allow(Figaro.env).to receive(:enable_mobile_capture).and_return('true')
end
describe '#new' do
it 'renders the scan id page' do
get :new
expect(response).to render_t... |
# frozen_string_literal: true
class Api::V1::SportsController < Api::V1::BaseController
skip_before_action :authenticate_api_v1_user!
def index
sports = Sport.all
render json: sports, each_serializer: SportSerializer
end
def show
sport = Sport.find(params[:id])
render json: sport
end
end
|
Pod::Spec.new do |spec|
spec.name = "yourFramework"
spec.version = "0.0.1"
spec.summary = "A short description of yourFramework."
spec.description = <<-DESC
DESC
spec.homepage = "http://EXAMPLE/yourFramework"
spec.license = "MIT (example)"
spec.author ... |
module HtmlUnit
# Reopen HtmlUnit's HttpMethod class to add convenience methods.
class HttpMethod
# Loosely compare HttpMethod with another object, accepting either an
# HttpMethod instance or a symbol describing the method. Note that :any is a
# special symbol which will always return true.
#
... |
require 'dry-validation'
module Dry::Validation::Matchers
class Key
attr_reader :key
module Filled
def matches?(schema)
super
@matched &&= @when_not_filled.include?('must be filled')
end
def failure_message
return unless super
@failure_message << 'must be f... |
def valid_number?(num)
num.to_i.to_s == num
end
puts "Welcome to the Loan Calculator! Lets find out your monthly payment.\n"
loop do # main loop
loan_amount = ''
loop do
puts "Please enter the total amount of your loan:"
loan_amount = gets.chomp
if valid_number?(loan_amount) && loan_amount.to_i > 0
... |
json.array!(@usuario_gustos) do |usuario_gusto|
json.extract! usuario_gusto, :id, :idUsuarioGusto, :idGustoU, :idUsuarioG
json.url usuario_gusto_url(usuario_gusto, format: :json)
end
|
feature "viewing the temperature" do
it 'is 20 by default' do
visit('/')
expect(page.find('#temperature')).to have_content '20'
end
end
|
# encoding : utf-8
require 'lib/motion/splash_generator/size'
require 'lib/motion/splash_generator/image'
namespace :splashes do
desc "Creates splash images for all devices"
task :generate do
splash_image_sizes.each do |size|
Motion::SplashGenerator::Image.new(size).tap do |splash_image|
spl... |
require 'pry'
class Song
# code goes here
attr_accessor :title, :artist
def initialize(title=[])
@title = title
end
def serialize
file = Tempfile.new(["#{@title.split(' ').join('_').downcase}", ".txt"], "tmp")
file.write("#{self.artist.name} - #{self.title}")
file.close
end
end
|
require File.dirname(__FILE__) + '/../test_helper'
require 'products_controller'
# Re-raise errors caught by the controller.
class ProductsController; def rescue_action(e) raise e end; end
class ProductsControllerTest < Test::Unit::TestCase
include AuthenticatedTestHelper
fixtures :products, :users, :sellers, :ro... |
require 'sinatra'
require 'sinatra/streaming'
require 'sinatra/url_for'
require 'redis'
require 'json'
require 'haml'
require 'byebug'
require './lib/buster'
class Windowing < Sinatra::Base
helpers Sinatra::UrlForHelper
helpers Sinatra::Streaming
set connections: [], r: Redis.new
set :server, :thin
use Rack... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.