text stringlengths 10 2.61M |
|---|
Given /^I am on the (.+) Home Page$/ do |site|
@site = site.downcase
visit @site, :home_page
end
When(/^I search for "(.*?)"$/) do |term|
on @site, :home_page do |page|
page.search_for term
end
end
Then(/^I should see the "(.*?)" from search results$/) do |first_page|
on @site, :home_page do |page|
... |
class MerchantRevenueSerializer < ActiveModel::Serializer
type :merchant_revenue
attributes :id, :revenue
end
|
# frozen_string_literal: true
module Tasks
# MigrationNameGenerator
class MigrationNameGenerator
def self.generate(name)
timestamp = Time.now.strftime('%Y%m%d%H%M%S')
"#{timestamp}_#{name}.rb"
end
end
end
|
require 'date'
module ValidatesTimeliness
# A date and time parsing library which allows you to add custom formats using
# simple predefined tokens. This makes it much easier to catalogue and customize
# the formats rather than dealing directly with regular expressions.
#
# Formats can be added or removed t... |
ActiveAdmin.register Siginfo do
permit_params :email, :userid,:name, :phonenum, Siglinks_attributes:[:_destroy,:id,:title,:linkpath,:info]
# index do
# selectable_column
# column :id
#
# column :userid
# column :phonenum
# column :links
# column :email
# actions
# end
show do
attr... |
class Electrum < Cask
url 'http://download.electrum.org/electrum-1.9.5.dmg'
homepage 'http://electrum.org/'
version '1.9.5'
sha1 '0815ee20c3a94b998a735577f6486f314a155b3c'
link 'Electrum.app'
end
|
# app/controllers/active_storage/direct_uploads_controller.rb
# frozen_string_literal: true
# original: https://github.com/rails/rails/blob/master/activestorage/app/controllers/active_storage/direct_uploads_controller.rb
class ActiveStorage::DirectUploadsController < ActiveStorage::BaseController
ActiveStorage::Blo... |
require 'spec_helper'
describe Area do
it{ should have_and_belong_to_many :articles }
it{ should belong_to :curator }
describe '#to_param' do
subject(:area){ Area.create(title: 'Hello World') }
it 'includes the parameterized title' do
area.to_param.should == "#{area.id}-hello-world"
end
end... |
module VocabulariSe
class GenericAlgorithm
attr_reader :config
def initialize config
@config = config
end
def exec tag, related_tags
raise NotImplementedError
end
end
end
|
module GroupBuzz
class SlackPoster
def initialize
@slack_webhook = GroupBuzz::SettingsHolder.settings[:slack_webhook]
@slack_channel = GroupBuzz::SettingsHolder.settings[:slack_channel]
@slack_username = GroupBuzz::SettingsHolder.settings[:slack_username]
end
def post(message_post)
... |
module ApiDocGeneration; module FormatFile; class << self
def analyze_file(path)
controller_path = path.split("app/controllers").last
class_name = controller_path.gsub(/controller.*\.rb/, 'controller').classify
klass = class_name.safe_constantize
filelines = File.readlines(path)
actions = klass... |
## DONE!!!
#The sequence of triangle numbers is generated by adding the natural numbers.
#So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
#
#1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
#
#Let us list the factors of the first seven triangle numbers:
#
# 1: 1
# 3: ... |
class WikisController < ApplicationController
before_action :authenticate_user!
before_action :_check_author, only:[:edit, :update, :destroy]
def index
@buttons = [
{label: t('links.wiki.create'), url: new_wiki_path, style: 'primary'},
]
@wikis = Wiki.order(updated_at: :desc).page(params[:pa... |
require "helper"
module Neovim
RSpec.describe Executable do
describe ".from_env" do
it "respects NVIM_EXECUTABLE" do
executable = Executable.from_env("NVIM_EXECUTABLE" => "/foo/nvim")
expect(executable.path).to eq("/foo/nvim")
end
it "returns a default path" do
executab... |
#encoding: utf-8
class User < ActiveRecord::Base
#********全部字段
# :access_token
# :refresh_token
# :openid
# :nickname
# :sex
# :province
# :city
# :country
# :headimgurl
# :today_gua_count
# :last_get_time
# :hy_count 好友数量
# :hy_is_award 50个好友是否已经兑换
# :award_1
# :award_2
# :award_3
... |
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "like_a_boss/version"
Gem::Specification.new do |s|
s.name = "like_a_boss"
s.version = LikeABoss::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Dane Harrigan"]
s.email = ["dane.harrigan@gmail.com"]... |
class Spree::SpecialOffer < ActiveRecord::Base
belongs_to :taxon
# NOTE: change semantics, respecting foreign_key on this model
belongs_to :popular_product, class_name: 'Spree::Product', foreign_key: "popular_product_id"
belongs_to :best_product, class_name: 'Spree::Product', foreign_key: "best_product_id"
... |
module Uploader
# Route model
#
# @attr source [String]
# @attr start_node [String]
# @attr end_node [String]
# @attr start_time [String] format: ISO 8601 UTC time
# @attr start_time [String] format: ISO 8601 UTC time
#
Route = Struct.new(:source, :start_node, :end_node, :start_time, :end_time)
end
|
# frozen_string_literal: true
class Firestore::LoginUser < Firestore::Base
COLLECTION_NAME = 'login_user'
def self.genders
%w[未設定 男性 女性]
end
def self.prefectures
%w[未設定 東京都 神奈川県 埼玉県 千葉県 大阪府 京都府 兵庫県 奈良県 愛知県 岐阜県 三重県 福岡県 北海道 青森県 岩手県 宮城県 秋田県 山形県 福島県 茨城県 栃木県 群馬県 新潟県 富山県 石川県 福井県 山梨県 長野県 静岡県 滋賀県 和歌山県 鳥取県 島根... |
require "application_system_test_case"
class CompaniesTest < ApplicationSystemTestCase
setup do
@company = companies(:one)
end
test "visiting the index" do
visit companies_url
assert_selector "h1", text: "Companies"
end
test "creating a Company" do
visit companies_url
click_on "New Comp... |
# frozen_string_literal: true
module EVSS
module PCIU
class PhoneNumber < BaseModel
attribute :country_code, String
attribute :number, String
attribute :extension, String
attribute :effective_date, DateTime
validates :number, presence: true
validates :number, format: { with: ... |
FactoryGirl.define do
factory :planes do
story_id { rand(1..5)}
name { ["Material Plane", "Fire Plane", "Water Plane", "Wind Plane", "Earth Plane"].sample }
colour { ["Silver", "Red", "Blue", "White", "Green"].sample }
description { ["This place is cool", "I wish I could visit ... |
require "rails_helper"
describe "Feed", type: :feature do
it "has an activity when a user has their question answered", js: true do
register_a_user("nando@example.com", "Nando", "Hasselhoff")
ask_question("Do I need a CS degree?", "I want to be a web developer.")
click_link_or_button "Nando"
log_out... |
# coding: utf-8
Pod::Spec.new do |s|
s.name = "WeexBaofu"
s.version = "0.0.1"
s.summary = "Weex baofu"
s.description = <<-DESC
Weexplugin 宝付
DESC
s.homepage = "https://github.com/WUBOSS/weex-baofu"
s.license = {
:type => 'MIT',
:text =>... |
class AddGeomToSections < ActiveRecord::Migration
def self.up
add_column :sections, :geom, :geometry, :srid =>4326
end
def self.down
remove_column :sections, :geom
end
end
|
require 'rest-client'
require 'binance_api/base'
require 'binance_api/result'
module BinanceAPI
class Brokerage < BinanceAPI::Base
def create_subaccount(options = {})
params = base_params(options)
process_request(:post, "#{BASE_URL}/sapi/v1/broker/subAccount", params)
end
def get_subaccount... |
# frozen_string_literal: true
require "gaf/config"
require "gaf/version"
module Gaf
autoload :Processor, "gaf/processor"
class Error < StandardError; end
def self.configure
yield(config) if block_given?
end
def self.config
@config ||= Gaf::Config.new
end
end
|
#!/usr/bin/ruby
require './microtest'
def react(s)
s.chars.reduce("") do |memo, x|
y = memo[-1]
if !y.nil? && x != y && x.upcase == y.upcase
if memo.length == 1
""
else
memo[0..memo.length - 2]
end
else
memo + x
end
end
end
def best_removal(s)
"abcdefghijklmnopqrstuvwxyz"
.chars
.m... |
require_relative "../config/environment.rb"
require 'active_support/inflector'
class InteractiveRecord
def self.table_name
self.to_s.downcase.pluralize
end
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS students (
id INTEGER PRIMARY KEY,
name TEXT,
grade INTEGER
... |
require 'rails_helper'
RSpec.describe Product, type: :model do
it { should belong_to(:search) }
it 'has a valid factory' do
expect(create(:product)).to be_valid
end
context 'with api' do
let!(:search) { create(:search, query: 'Nikon') }
before do
allow(search).to receive(:api_data).and_ret... |
require 'rails/generators/base'
module CanPlay
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates", __FILE__)
desc "Creates a can_play initializer and copy locale files to your application."
def copy_initializer
template "c... |
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :set_search
protected
def set_search
@q = Course.ransack(params[:q])
@courses = @q.result
end
def configure_permitted_parameters
devise_parameter_saniti... |
# encoding: utf-8
class ReportGenerators::CampaignReport < ReportGenerators::Base
def self.can_process? type
type == RowsCampaign
end
def add_to document
if has_data_for_the_report?
add_information_to document
end
end
private
def has_data_for_the_report?
!rows_campaign.empty? and !rows... |
class Shops::Admin::SalesMenController < Shops::Admin::BaseController
before_action :set_sales_man, only: [:show, :update, :destroy]
# GET /sales_men
# GET /sales_men.json
def index
@sales_men = current_shop.sales_men.includes(:user)
end
# GET /sales_men/1
# GET /sales_men/1.json
def show
# re... |
Given(/^You are in the Suspense page$/) do
visit AutomationHomePage
on(LoginPage).login_yml
on(LandingPage).menus.when_present(10).click
sleep(1)
on(LandingPage).suspense.when_present(10).click
end
And (/^I see Closing Validations/) do
sleep(5)
expect(on(SuspensePage).closingValidations.present?).to be_t... |
class TableController < ApplicationController
caches_page :index, :table
def index
expires_in TableSetter::App.cache_timeout.minutes
if stale? :last_modified => Table.fresh_yaml_time, :public => true
@tables = Table.all
end
end
def table
@table = Table.new(params[:slug])
expires_in ... |
require 'rspec'
require 'TowersOfHanoi'
describe "TowersOfHanoi" do
subject(:game) { TowersOfHanoi.new }
describe "#initialize" do
it "makes an array of arrays with size 3" do
expect(game.board).to eq( [[3,2,1], [], []] )
end
end
describe "#move" do
let(:new_move) { [0, 2] }
it "changes... |
class MemberSkill
include Mongoid::Document
include Mongoid::Timestamps
store_in database: 'sribulancer_development', collection: 'member_skills'
belongs_to :freelancer_member
belongs_to :freelancer_review
belongs_to :skill
index({freelancer_member_id: 1})
end
|
class AddAveragePriceToStations < ActiveRecord::Migration[5.1]
def change
add_column :stations, :average_price, :integer
end
end
|
class Relationship < ActiveRecord::Base
attr_accessible :followed_id, :follower_id
# 在 relationship 表中存在的用户之间的关系为 跟踪的人(follower) 与 被跟踪的人(followed)
# 他们代表着用户与用户的跟踪关系之间的主动与被动的关系
belongs_to :follower, class_name: "User"
belongs_to :followed, class_name: "User"
# 一个关系, 两者都不允许为空
validates :follower, presence... |
namespace :streetline do
desc "Updates the parking status on a schedule"
task update_status: :environment do
ParkingSpaceHelper.update_status_db
end
end
|
class RPNCalculator
# TODO: your code goes here!
def initialize
@rpn=[]
end
def push num
@rpn << num
end
def plus
unless @rpn.size<2
sum=@rpn.pop.to_f+@rpn.pop.to_f
@rpn << sum
else
raise "calculator is empty"
end
end
def minus
unless @rpn.size<2
second_number=@rpn... |
class NewsReader::Scraper
ARTICLES_PER_SECTION = 10 # Number of articles per section to download
# Gets the Sections
def self.scrape_sections(home_url)
html = open(home_url)
page = Nokogiri::HTML(html)
# The drop(2).first(5) is due to selecting the sections we want. The first ... |
FactoryGirl.define do
factory :cell do
content %w(axe sword lance ire tree hill).sample
factory :test_cell do
puzzle { build(:puzzle) }
row_number (1..10).to_a.sample
column_number (1..10).to_a.sample
end
end
end
|
require "minitest/autorun"
#Uncomment requirement code when file is created
#require "./hangman.rb"
describe Hangman do
it "isn't finished when it starts" do
game = Hangman.new
assert game.finished? == false
end
it "removes letter from alphabet after it is guessed" do
game = Hangman.new("bird")
... |
class Tile
TOP = 0
RIGHT = 1
BOTTOM = 2
LEFT = 3
FILLED = '#'
EMPTY = '.'
attr_reader :id, :code, :grid
def initialize(lines)
parts = lines.split("\n")
@id = parts.shift.sub(/Tile (\d+):/, '\1').to_i
@grid = parts.map{ |l| l.split('').map{ |c| c == FILLED ? 1 : 0 } }
generate_code
... |
class ApiWikisController < ApplicationController
before_action :set_wiki
# GET /*relative_path
def show
render json: @api_wiki, serializer: VisibleWikiSerializer
end
private
def set_wiki
@api_wiki = ApiWiki.find_by(slug: params[:slug])
end
end
|
class RemoveZipCodeTable < ActiveRecord::Migration[5.0]
def change
drop_table :zip_codes
end
end
|
class ChangeColumnName < ActiveRecord::Migration
def change
rename_column :agencies, :jurisdiction, :jurisdiction_type
end
end
|
# Define the events (if producing)
EventDefinitions do
define_event('call_joined', version: '1.0.0') do
defined_as do
'A call has been requested by client'
end
payload_contains do
field('call_params', type: 'string', definition: 'Call Parameters')
end
end
define_event('status_changed... |
require 'rails_helper'
describe HotelsController, type: :controller do
context 'stubbed api calls' do
before(:each) do
# Stubs needed but i did not implemented it.
# Takes longer to run specs but its ok for this example task
# allow(controller).to receive(Hotels::SuggestionsService).and_return... |
# -*- coding: utf-8 -*-
=begin
Os números primos possuem várias aplicações dentro da Computação, por
exemplo na Criptografia. Um número primo é aquele que é divisível apenas por
um e por ele mesmo. Faça um programa que peça um número inteiro e determine
se ele é ou não um número primo.
=end
puts "===================... |
module TimeRangeConcern
extend ActiveSupport::Concern
included do
has_one :time_range, foreign_key: :information_id, dependent: :destroy
accepts_nested_attributes_for :time_range
scope :default_order, ->{
where('time_ranges.end is null').
joins(:time_range).
order('time_ranges.begin... |
# frozen_string_literal: true
require 'yaml/store'
require 'ostruct'
class Config
def initialize(file)
@store = YAML::Store.new(file)
end
def for_host(name)
@store.transaction(true) do
case (service = @store.fetch(name, Service::NotFound))
when Service::NotFound
Service::NotFound
... |
# == Schema Information
#
# Table name: discounts
#
# id :integer not null, primary key
# description :text
# image_url :string(255)
# name :string(255)
# status :string(255)
# tail :integer
# created_at :datetime
# updated_at :datetime
#
class Discount < ActiveRecord::... |
ActionController::Routing::Routes.draw do |map|
# Contacts path
map.resources :contacts
# Companies path
map.resources :companies
# Homepage path
map.root :controller => "contacts"
end
|
class BookNotificationWorker
include Sidekiq::Worker
def perform(user, message)
puts 'This fucking #{user.name} need to return this fucking book'
end
end
|
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/multistage'
require 'mina/puma'
# require 'mina_sidekiq/tasks'
# require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
require 'mina/rvm' # for rvm support. (https://rvm.io)
set :rvm_use_path, '/usr/local/rvm/scripts/rvm'
# shared d... |
require 'selenium-webdriver'
require 'yaml'
class Driver
attr_accessor :driver
@driver = nil
$focus_driver = nil
# to initialize browser via start method
def initialize(browser = Config.browser)
begin
start(browser)
Log.info("#{browser} browser started...")
rescue Standard... |
# == Schema Information
#
# Table name: notifications
#
# id :integer not null, primary key
# user_id :integer
# worker_id :integer
# organization_id :integer
# cost :float
# length :integer
# status :string(255)
# notification_type ... |
# frozen_string_literal: true
module Validators
module Tickets
class AvoidOne < Validators::Tickets::Base
TICKET_TYPE = Ticket::TICKET_TYPES.fetch(:avoid_one)
private
def validate_type
return [] unless (available - reserved) == 1
["You have to add one more 'avoid_one' ticket t... |
# frozen_string_literal: true
module GraphQL
module Tracing
module AppsignalTrace
include PlatformTrace
# @param set_action_name [Boolean] If true, the GraphQL operation name will be used as the transaction name.
# This is not advised if you run more than one query per HTTP request, for exam... |
# This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2011, Sebastian Staudt
require 'socket'
# This module is included by all classes implementing server functionality
#
# It provides basic name resolution features.
module Server
# Creat... |
class UrlParser
def initialize(url)
@new_url = url
end
def scheme
@scheme = @new_url.split(":").first
end
def domain
@domain = @new_url.split("://").last.split(":").first
end
def port
@port = @new_url.split(":").last.split("/").first
if @port == "" && scheme == "http"
"80"
... |
class LeaguesController < ApplicationController
before_action :authenticate_user!
def new
@league = League.new
@todays_meetings = Meeting.where("created_at >= ?", Time.zone.now.beginning_of_day)
end
def index
@todays_meetings = Meeting.where("created_at >= ?", Time.zone.now.beginning_of_day)
end... |
class AddIndex < ActiveRecord::Migration
def change
add_index :entries, [:title]
add_index :entry_word_relations, [:word_id]
add_index :words, [:surface_form]
add_index :words, [:pos]
add_index :words, [:basic_form]
add_index :keywords, [:entry_id, :word_id]
add_index :keywords, [:word_id]... |
# Consolidating the business of round-having.
module HasRound
extend ActiveSupport::Concern
included do
scope :without_round, -> { where('round_id IS NULL OR round_id = ""') }
end
def round
Round.find(round_id) if round_id?
end
def round?
round_id? && !!round
end
def round_type
... |
# 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... |
class AdministratorPanelController < ApplicationController
before_action :set_article, only: [:activate, :deactivate]
def show
if params[:category].blank?
@articles = Article.all
else
@category_id = Category.find_by(name: params[:category]).id
@articles = Article.where(category_id: @categ... |
# frozen_string_literal: true
class Patient < ApplicationRecord
validates :code, :external_code, :source, :zone_code, :announced_on, presence: true
validates :zone_code, format: %r{\A[a-z\-]+/[a-z\-]+/[a-z\-]+/[a-z0-9\-]+/[a-z0-9\-]+\z}
STATUSES = %w[unknown confirmed hospitalized recovered migrated deceased].f... |
class WeatherPoro
attr_reader :datetime,
:date,
:time,
:sunrise,
:sunset,
:temperature,
:min_temp,
:max_temp,
:feels_like,
:humidity,
:uvi,
:visibility,
... |
require 'rails_helper'
RSpec.describe 'Creating Articles', type: :feature do
before do
@user = User.create!(email: 'bob@bob.com', password: 'Password1234')
login_as(@user)
end
scenario 'A user creates a new article' do
visit '/'
click_link 'New Article'
fill_in 'Title', with: 'Creating first article'
... |
# Teskal
#
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTI... |
require 'yaml'
require 'iphoto'
require 'rubygems'
require 'gallery'
class PhotoRoller
@@photo_mapping = {
#'file_name' => :userfile,
:caption => :caption,
:comment => :'extrafield.Description'
# GalleryRemote does not support keywords
#:keyword_string => :'extrafield.Keywords'
}
@@escapes =... |
require_relative 'test_helper'
describe "GestionAcademique" do
describe "prealables" do
it_ "signale une erreur lorsque fichier inexistant", :intermediaire do
FileUtils.rm_f '.cours.txt'
genere_erreur( /fichier.*[.]cours.txt.*existe pas/ ) do
ga( 'prealables INF3105' )
end
end
... |
class User < ActiveRecord::Base
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.email = auth.info.email
user.image = auth.info.image
us... |
class TeamsController < ApplicationController
def index
@teams = Team.all
end
def show
@team = Team.find params[:id]
@members = @team.members.to_a
@members.shuffle! if params[:shuffle]
@solutions = Solution.where(user: @team.members).
map { |s| [[s.assignment_id, s.user_id], s] }.to_h... |
class CreateRelations < ActiveRecord::Migration
def change
create_table :relations do |t|
t.references :follower
t.references :following
t.timestamps
end
add_index :relations, :follower_id
add_index :relations, :following_id
end
end
|
require 'rails_helper'
describe 'Array Operations' do
let(:num_rows) { 100000 }
let(:num_cols) { 10 }
it 'measures different ways of parsing strings to arrays' do
#"0,1,2,3,...999"
string_of_comma_separated_nums = (0..19999).to_a.inject("") {|str, v| str += "#{v}," }[0...-1]
measurement = Benchwarme... |
require 'rails_helper'
RSpec.describe Product, type: :model do
describe 'Validations' do
it 'should create new product if validations true' do
@category = Category.new(name: 'Props')
@product = Product.new(name: 'Blue Suede Shoes', price: 10, quantity: 20, :category => @category)
@product.valid... |
class HellowsController < ApplicationController
before_action :set_hellow, only: [:show, :edit, :update, :destroy]
# GET /hellows
# GET /hellows.json
def index
@hellows = Hellow.all
end
# GET /hellows/1
# GET /hellows/1.json
def show
end
# GET /hellows/new
def new
@hellow = Hellow.new
... |
class BoardFree < ActiveRecord::Base
has_one :board, as: :boardable, dependent: :destroy
accepts_nested_attributes_for :board
belongs_to :user
def user_id
board.user_id
end
end
|
class RenameShippingToShippingCentsInQuotations < ActiveRecord::Migration[5.1]
def change
rename_column :quotations, :shipping, :shipping_cents
end
end
|
class Category < ApplicationRecord
validates :name, presence: true, uniqueness: { case_sensitive: false }
has_many :teachers
def as_json(options = {})
super(options.merge({ except: [:created_at,:updated_at] }))
end
end
|
class CreateEntries < ActiveRecord::Migration
def change
create_table :entries do |t|
t.string :nick
t.integer :r1
t.integer :r2
t.integer :r3
t.integer :r4
t.integer :r5
t.integer :r6
t.references :tournament, index: true
t.timestamps
end
end
end
|
module Gradebook
module Components
module Models
class ExamSet < Base
include Rounding
properties :scores, :name, :planner_name, :aggregates, :attendance_report, :obj_id, :term_name, :term_exam,
:planner_exam, :group_exam, :scoring_type, :show_percentage, :maximum_mark, :... |
module MinceDynamoDb
module DataSanitizer
def self.prepare_field_for_storage(field)
field.is_a?(Numeric) ? field : field.to_s
end
def self.prepare_hash_for_storage(hash)
hash.each{|key, value| hash[key] = prepare_field_for_storage(value) }
end
end
end
|
class Predicate < ActiveRecord::Base
has_and_belongs_to_many :namespaces
def self.create args
id = args.delete :id
name = args.delete :name
fn = args.delete :fn
super name: name, fn: fn, fields: args.to_json
end
end
|
module Ng
class ModelGenerator < Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
argument :dependencies, type: :array, default: []
def variables
@class_name = name.classify
@file_name = name.underscore
@deps = dependencies.unshift("$resource"... |
require 'spec_helper'
require 'belafonte/senora'
module Belafonte
describe Senora do
before(:each) do
described_class.data.clear
end
describe '.data' do
it 'is a Hash' do
expect(described_class.data).to be_a(Hash)
end
end
describe '.store' do
let(:key) {:key}
... |
# Quick-Sort Advanced
# The previous version of Quicksort was easy to understand, but it was not optimal. It required copying the numbers into other arrays, which takes up more space and time. To make things faster, one can create an "in-place" version of Quicksort, where the numbers are all sorted within the array it... |
module Admin
class DashboardController < ApplicationController
layout 'dashboard'
before_action :authenticate_admin_user!
end
end
|
namespace :kube do
desc "Build with docker"
task :build do
invoke "docker:build"
end
task :push_images do
invoke "docker:push_images"
end
task :deploy do
if ENV['build'] != 'false'
invoke "kube:build"
end
invoke "kube:apply"
end
task :pods do
sh "#{kubecmd} get pods"
... |
class V1::Dashboards::Manager::FilesController < V1::BaseController
include V1::MessageHelper
before_filter :setup
skip_before_filter :authenticate_user_from_token!, only: [:download]
def upload_info
# flow testChunk true
render status: 201, json: ""
end
def upload
sf = SysFile.create(name: pa... |
class UsersController < ApplicationController
before_action :redirect_to_login_page_if_not_logged_in, except: [:new, :show, :create]
def index
redirect_to root
end
def show
@transactions = Transaction.all
@user = User.find(session[:user_id])
if session[:user_id] == params[... |
class StatusLabels::OptionsSerializer < ApplicationSerializer
object_as :status_label
attributes(
:id,
:name,
:status_type,
)
end
|
class Ether < BinData::Record
endian :big
hide :type_or_vlan, :original_ether_type
IPV4 = 0x0800
mac_addr :dst
mac_addr :src
uint16 :type_or_vlan
bit3 :vlan_pcp, :onlyif => :has_vlan?
bit1 :vlan_dei, :onlyif => :has_vlan?
bit12 :vlan_id, :onlyif => :... |
class BadgesController < ApplicationController
#before_action :set_badge, only: [:show, :edit, :update, :destroy, :camera, :print, :snapshot, :crop, :generate]
load_and_authorize_resource except: :lookup
# GET /badges
# GET /badges.json
def index
@badges = Badge.paginate(page: params[:page])
end
# G... |
# == Schema Information
# Schema version: 20110313064440
#
# Table name: password_resets
#
# id :integer(4) not null, primary key
# forgot_code :string(255)
# merchant_id :integer(4)
# ip_address :string(255)
# created_at :datetime
# updated_at :datetime
# used :string(0)
#
class Passwor... |
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe UniformNotifier::JavascriptAlert do
it 'should not notify message' do
expect(UniformNotifier::JavascriptAlert.inline_notify(title: 'javascript alert!')).to be_nil
end
it 'should notify message' do
UniformNotifier.alert = true
expect... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.