text stringlengths 10 2.61M |
|---|
class Api::V1::AlbumsController < ApplicationController
private
def album_params
params.require(:album).permit(:title, :isbn, :publisher, :published_date, :artists, :tracks, :genres)
params.permit(:query)
end
end
|
class AddInventoryToProducts < ActiveRecord::Migration
def change
add_column :products, :inventory, :integer
end
end
|
puts "the value of 40 + 2 is " + {40 + 2}
#throws syntax error because that is not how to interpolate values in Ruby
#One way- string interpolation
puts "the value of 40 + 2 is #{40 + 2} "
#Second way - convert number to string
val = 40 + 2
puts "the value of 40 + 2 is " + val.to_s |
class UserMailer < ApplicationMailer
default from: 'no-reply@jungle.com'
def receipt(order)
@order = order
@url = 'http://0.0.0.0:3000/order/#{@order.id}'
mail(to: @order.email, subject: "Order Confirmation (#{@order.id})")
end
end |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Friendship, type: :model do
it 'should have correct association' do
should belong_to(:user)
should belong_to(:friend)
end
end
|
module StrokeDB
module Util
def verify(*args, &blk)
if block_given? # test for exception
begin
r = yield(*args)
rescue Exception => e
raise VerifyFailed.new(e), "Verification failed!"
else
r or raise VerifyFailed.new(nil), "Verification failed!"
... |
Rails.application.routes.draw do
resources :searches, only: [:search]
root 'searches#search'
end
|
Confy::API.controllers :conferences do
include JsonHelper
get :index do
render_json :'conferences/index.json',
locals: { conferences: Conference.eager(:talks).all }
end
get :upcoming do
render_json :'conferences/index.json',
locals: { conferences: Conference.upcoming.sorted }
end
get ... |
require 'spec_helper'
describe 'Logout' do
context 'when logged in' do
let!(:user) { create(:user, :paul) }
before do
login_as user, root_path
visit logout_path
end
it "doesn't render name" do
expect(page).to have_current_path(root_path)
expect(page).not_to have_content("Ol... |
#!/usr/bin/ruby
require './mars_rover'
require './operator'
describe MarsRover do
let(:mars_rover) { MarsRover.new }
it "starting point at position 0,0" do
expect(mars_rover.position).to eql(ORIGINAL_POSITION)
expect(mars_rover.facing_direction)
end
it "start moving to the NORTH" do
expe... |
class AddGroupableIdAndGroupableTypeInInstantFee < ActiveRecord::Migration
def self.up
add_column :instant_fees, :groupable_type, :string
add_column :instant_fees, :groupable_id, :integer
end
def self.down
remove_column :instant_fees, :groupable_type
remove_column :instant_fees, :groupable_id
e... |
class Post < ActiveRecord::Base
def title
self[:title].titleize
end
end
|
require './test/test_helper'
class TranslateToBrailleTest < Minitest::Test
def test_it_exists_and_has_attributes
message = TranslateToBraille.new(["a"])
assert_instance_of TranslateToBraille, message
end
def test_it_can_translate_word
message = TranslateToBraille.new(["a"])
expected = "0.\n..\n.... |
class AgencyRoutesController < ApplicationController
def index
# Manually encode the params to avoid errors with spaces and such.
@raw_xml = RestClient.get("http://services.my511.org/Transit2.0/GetRoutesForAgency.aspx", :params => {:token => ENV['511_KEY'], :agencyName => params[:agency]})
@route_results = Has... |
require 'test_helper'
class UserTest < ActiveSupport::TestCase
should have_many(:user_friendships)
should have_many(:friends)
test "a user should enter a first name" do
user = User.new
assert !user.save
assert !user.errors[:first_name].empty?
end
test "a user should enter a last name" do
user = User.ne... |
=begin
*******************************************************************************
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 right... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This is a Vagrant to automatically provision a bootstrap node with a
# Chef server.
# See http://www.vagrantup.com/ for info on Vagrant.
require 'json'
base_dir = File.expand_path(File.dirname(File.realpath(__FILE__)))
json_file = Dir[File.join(base_dir,'*.json')]
if json_... |
require 'rails_helper'
RSpec.describe PurchaseAddress, type: :model do
before do
user = FactoryBot.create(:user)
item = FactoryBot.build(:item)
item.image = fixture_file_upload('/files/test_image.jpg')
item.save
@purchase_address = FactoryBot.build(:purchase_address, user_id: user.id, item_id: it... |
require 'rails_helper'
RSpec.describe "recipients/edit", type: :view do
before(:each) do
@recipient = assign(:recipient, Borrower.create!(
:name => "MyString",
:email => "MyString",
:phone => "MyString"
))
end
it "renders the edit recipient form" do
render
assert_select "form[... |
require 'json'
# Class used to publish data
class Publisher
def initialize(client)
@client = client
end
def publish(data_list)
data_list.each do |d|
@client.post '/profile', d.to_json
end
end
end |
class ClientesController < ApplicationController
before_action :set_clientes, except: [:index, :new, :create]
before_action :definirControlador, :quitarBandera
def definirControlador
@controlador = 'clientes'
@controladorSingular = 'el cliente'
end
def quitarBandera
@creacion = false
end
de... |
# @author: Houman Kargaran - 2017
# Defining Object
class Lilie
# Defining an array of hashes to define the content of this product
#
# @param
# @return [Array<Hash>] product details
def self.packs
[
{ :pack => 3, :price => 9.95 },
{ :pack => 6, :price => 16.95 },
... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class Admin::TopicsController < ApplicationController
before_action :require_login
before_action :require_admin_status
def index
@topics = Topic.paginate(page: params[:page], per_page: 20)
end
def show
@fields = displayed_topic_attrs
@topic = Topic.find(params[:id])
end
def new
@fields ... |
# frozen_string_literal: true
RSpec.describe(Dry::Monads::Transformer) do
list = Dry::Monads::List
success = Dry::Monads::Result::Success.method(:new)
failure = Dry::Monads::Result::Failure.method(:new)
some = Dry::Monads::Maybe::Some.method(:new)
none = Dry::Monads::Maybe::None.new
context "2-level compo... |
class Department < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
validates :manager, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
has_many:employee_masters
def self.validate_field(field, value)
validity = Department.ne... |
class FontKaiso < Formula
head "https://moji-waku.com/download/kaiso_next.zip"
desc "Kaiso"
desc "Modern fantasize Japanese font"
homepage "https://moji-waku.com/kaiso/index.html"
def install
parent = File.dirname(Dir.pwd) != (ENV['HOMEBREW_TEMP'] || '/tmp') ? '../' : ''
(share/"fonts").install "#{pa... |
namespace :config do
task :set_paths do
SSHKit.config.command_map[:bower] = File.join(release_path, 'node_modules', 'bower', 'bin', "bower")
SSHKit.config.command_map[:grunt] = File.join(release_path, 'node_modules', 'grunt-cli', 'bin', "grunt")
end
end
namespace :yo do
task :install do
on roles(:app... |
require 'rails_helper'
RSpec.describe 'Exceptions for Production', type: :request do
describe '#show' do
context 'when users hits pages not existing' do
it 'should returns a success response' do
get '/exceptions/show'
expect(response).to be_successful
end
it 'should returns a 2... |
require 'rails_helper'
RSpec.describe Orgadmin::RecipientsController, type: :controller do
let(:org) { FactoryGirl.create(:organization) }
before(:each) do
login_user
subject.current_user.add_role(:admin, org)
end
describe 'index >' do
let(:oc) { FactoryGirl.create(:organization_campaign, organiza... |
# ----------------------------------------------------------------------------
# Frozen-string-literal: true
# Copyright: 2015-2016 Jordon Bedwell - MIT License
# Encoding: utf-8
# ----------------------------------------------------------------------------
require "rspec/helper"
describe Forwardable::Extended do
cl... |
class Athlete < ActiveRecord::Base
after_create { |athlete| athlete.message 'insertAthlete' }
after_update { |athlete| athlete.message 'updateAthlete' }
after_destroy { |athlete| athlete.message 'destroyAthlete' }
def message action
$redis.publish action, self.to_json
end
end
|
plans = [
{destination: "沖縄",price: 10000},
{destination: "北海道",price: 20000},
{destination: "九州",price: 15000}
]
def disp_plans(plans)
puts "旅行プランを選択して下さい!"
plans.each.with_index(1) do |plan, i|
puts "#{i}. #{plan[:destination]}旅行(¥#{plan[:price]})"
end
end
def choose_plans(plans)
while true
pr... |
require "rails_helper"
describe Category do
it { should have_many :product_categories }
it { should have_many(:products).through(:product_categories) }
it { should validate_presence_of :name }
context "uniqueness" do
subject { create(:category) }
it { should validate_uniqueness_of :slug }
end
end
|
class CreateUserRecipes < ActiveRecord::Migration
def change
create_table :user_recipes do |u|
u.integer :user_id
u.integer :recipe_id
end
end
end |
class CreateCrimes < ActiveRecord::Migration[5.0]
def change
create_table :crimes do |t|
t.string :name
t.text :description
t.belongs_to :country, foreign_key: true
t.belongs_to :profile, foreign_key: true
t.string :location
t.date :committed_at
t.date :committed_to
... |
namespace :update_log do
namespace :august do
desc 'Create a test user for use in development'
task update: :environment do
august_logs = [{ date: '6/8/2018', time_of_day: 'PM', distance_in_km: 15, feedback: 'easy run on treadmill',
duration: 75, executed_workout_pace: '4:53min/km... |
class StarsController < ApplicationController
before_action :authenticate_user!
def create
joke = Joke.find(params[:joke_id])
new_star = joke.stars.where(user: current_user).first_or_create(star_params)
new_star.user = current_user
if new_star.save
flash[:notice] = 'Starred!'
current_u... |
# frozen_string_literal: true
module Pulfalight::Document::XMLExport
def self.extended(document)
document.will_export_as(:xml)
end
def export_as_xml
content = client.get_xml(eadid: collection_unitid || unitid)
document = Nokogiri::XML.parse(content)
document = strip_containers(document) unless ex... |
require "s3"
class FilesController < ApplicationController
def index
service = S3::Service.new(:access_key_id => APP_CONFIG["aws"]["access_key_id"],
:secret_access_key => APP_CONFIG["aws"]["secret_access_key"])
path_name = params[:path] || ""
@path = [{
name... |
require_relative 'letter_decoder'
require_relative 'queue'
class Decoder
def decode(morse_code)
letter_decoder = LetterDecoder.new
queue = Queue.new
decoded_word = ""
morse_code.each_char.with_index do |digit, index|
queue.push(digit)
if queue_ends_with_space?(queue)
encoded_lett... |
class CreateMomentumCmsTemplates < ActiveRecord::Migration
def change
create_table :momentum_cms_templates do |t|
t.string :label
t.string :identifier
t.references :site, index: true
t.text :value
t.text :admin_value
t.text :js
t.text :css
t.string :ancestry
t... |
class ManageIQ::Providers::IbmTerraform::ConfigurationManager::ConfiguredSystem < ::ConfiguredSystem
supports :native_console do
_('No Cloud Pak URL') if provider.cpd_endpoint.url.blank?
end
include ProviderObjectMixin
def provider_object(connection = nil)
(connection || connection_source.connect).hos... |
module GssUsps
class Response
HTTP_OK_STATUS = 200
SOAP_OK_STATUS = 0
ERROR_CODES = {
load_and_record_labeled_package: :reject_package_count
}.freeze
def initialize(response, web_method)
@savon = response
@http = response.http
@hash = response.to_hash
@code = res... |
class ChaptersController < ApplicationController
before_action :fetch_book
before_action :fetch_chapter, only:[:show, :destroy, :edit, :update]
def index
end
def new
@chapter = @book.chapters.new
end
def create
@chapter = @book.chapters.new(chapter_params)
if @chapter.save
r... |
When(/^I go to the homepage$/) do
visit root_path
end
Then(/^I should see the introductory message$/) do
assert(body.include? "MongoDB/Rails/React App")
end
And(/^React should be on the page$/) do
assert(body.include? 'data-react-class="Main"')
end
|
class Api::PurchasesController < Api::ApiController
expose :purchase, id: ->{ params[:slug] }, scope: ->{ @active_company.purchases.includes_associated }, find_by: :slug
# POST /api/purchases
def create
purchase.company = @active_company
if purchase.save
render json: purchase.render, status: 201
... |
# frozen_string_literal: true
# Study Preferences Migration
class CreateStudyPreferences < ActiveRecord::Migration[6.1]
def change
create_table :study_preferences do |t|
t.integer :priority
t.integer :requiredTime
t.references :deadline, null: false, foreign_key: true
t.timestamps
en... |
VIA::Application.routes.draw do
# categories
resources :categories, :only => [:index, :show] do
resources :posts, :only => [:index, :show]
end
# posts
resources :posts, :only => [:index, :show] do
resources :comments, :only => [:show]
end
# comments
resources :comments, :only => [:index... |
require 'rubygems'
require 'bundler/setup'
require 'sinatra/base'
require 'json'
require 'mongo'
require 'pp'
base = File.dirname(__FILE__)
# Dir.glob(base + '/lib/*.rb' ).each { |f| require f }
Dir.glob(base + '/resources/*.rb' ).each { |f| require f }
# define json helper
module BSON
class Obj... |
class PollsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :find_poll, only: [:update, :destroy, :pass]
def index
if user_id = params[:user_id]
@polls = Poll.where(user_id: user_id)
else
@polls = Poll.all
end
end
def show
... |
require 'db/migrations/utils'
Sequel.migration do
up do
create_table(:mandate) do
primary_key :id
String :title, null: false
String :reference_number
DynamicEnum :mandate_type_id
MediumBlobField :note
Integer :publish
Integer :lock_version, default: 0, null: false
... |
class CreateJoineTableCharactersTests < ActiveRecord::Migration[5.1]
def change
create_table :joine_table_characters_tests do |t|
t.string :characters
t.string :tests
end
end
end
|
require 'spec_helper'
describe StoresController do
before do
controller.stub(:current_user).and_return(Factory(:user))
end
def valid_attributes
{ name: 'Book Store', user_id: controller.send(:current_user).id }
end
describe "GET index" do
it "assigns all stores as @stores" do
store = Sto... |
Rails.application.routes.draw do
get 'lists/index'
get 'lists/show'
get 'lists/new'
get 'lists/edit'
get 'welcome/index'
get 'welcome/about'
root 'welcome#index'
resources :users, only: [:new, :create]
resources :sessions, only: [:new, :create, :destroy]
resources :lists
# For details on the D... |
class Participant < ActiveRecord::Base
include ActiveRecordEnumerable
belongs_to :cohort
has_many :tubes, :foreign_key => "clinic_id", :primary_key => "clinic_id"
#questa costante in questo caso la scrivo dopo le has_many altrimenti non funziona il reflect_on_all_associations
STRICT_ASSOCIATIONS = reflect_on_a... |
# frozen_string_literal: true
class CreateSavedPosts < ActiveRecord::Migration[5.2]
def change
create_table :saved_posts do |t|
t.string :post_id
t.string :comment_id
t.string :voter_id
t.timestamps
end
end
end
|
class WeddingPhoto < ApplicationRecord
belongs_to :wedding_album, optional: true
mount_uploader :photo, PhotoUploader
end
|
require 'metatron_ruby_client'
require 'forwardable'
module Talis
module Bibliography
# Represents bibliographic manifestations API operations provided by the
# Metatron gem
# {https://github.com/talis/metatron_rb}
#
# In order to perform remote operations, the client must be configured
# wit... |
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require "email_spec"
require "pundit/rspec" # only include if you do not have custom pundit matcher
... |
class BookStore
include HTTParty
attr_reader :url
def html_results
if @base_url =~ /VALUE/
Rails.logger.info @base_url
@base_url = @base_url.gsub("%VALUE%", URI.escape(@options))
Rails.logger.info @base_url
@request = HTTParty.get(@base_url)
else
@request = HTTParty.get(@... |
# frozen_string_literal: true
require 'minitest/autorun'
require 'minitest/emoji'
require './lib/board'
require './lib/player'
require './lib/Render'
class RenderTest < Minitest::Test
def test_it_exists
board = Board.new
render = Render.new(board)
assert_instance_of Render, render
end
def test_it... |
class AddAddressToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :street, :string
add_column :users, :street2, :string
add_column :users, :city, :string
add_column :users, :state, :string
add_column :users, :zip, :integer
add_column :users, :cell, :string
add_column :us... |
class Task < ApplicationRecord
include AASM
validates :text, presence: true
aasm do
state :uncompleted, initial: true
state :on_progress
state :completed
event :complete do
transitions from: [:uncompleted, :on_progress], to: :completed
end
event :unfinish do
transitions from: [:uncompleted, :co... |
require 'rails_helper'
RSpec.describe Archiver::TweetArchiver do
describe '#archive' do
let(:tweet_class) { double('TweetClass') }
let(:tweet_creator) { double('TweetCreator') }
let(:jsc_tweet) { double('JSCTweet', tweet_id: '123456789') }
let(:tweet_client) { double('TweetClient') }
let(:tweet) ... |
require 'spec_helper'
describe User do
before do
@user = FG.build(:user, name: 'Taro Yamada')
end
subject { @user }
specify { expect(subject).to respond_to(:name) }
specify { expect(subject).to respond_to(:participants) }
specify { expect(subject).to respond_to(:events) }
specify { expect(subject).... |
class BillsController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource :account
load_and_authorize_resource :bill, through: :account
def show_shares
respond_to do |format|
format.html { render partial: "bills/shares", content_type: "text/html", locals: { bill: @bi... |
require 'spec_helper'
Dir[File.expand_path('../../../features/support/factories.rb', __FILE__)].each {|f| require f}
describe Subscription do
describe "validations" do
before(:each) do
@attr = {
:given_name => "rspec",
:family_name => "rspec",
:email => "rspec@refinery.com"
}... |
class NewReplyEmailJob < ApplicationJob
queue_as :default
def perform(id)
# Do something later
mail = UsersMailer.welcome_email(id)
#mail.deliver_now
mail.deliver_later
end
end
|
class Admin::TrainsController < Admin::BaseController
before_action :set_train, only: [:show, :edit, :update, :destroy]
def set_train
@train = Train.find(params[:id])
end
def index
@trains = Train.all
end
def show
end
def new
@train = Train.new
end
def create
@train = Train.new(train_params)
if @train.save
... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
class AddAccomodationView2AndAccomodationView3AndComNameAndComDescripionToBoatTypeModification < ActiveRecord::Migration[5.0]
def change
add_column :boat_type_modifications, :accomodation_view_2, :string
add_column :boat_type_modifications, :accomodation_view_3, :string
add_column :boat_type_modifications... |
class Image
attr_reader :style, :url
def initialize(style, url)
@style = style
@url = url
end
end
|
require 'minitest/autorun'
require_relative '../../lib/sleepier'
class TestChildSpec < MiniTest::Unit::TestCase
def setup
@permanent_child_spec = Sleepier::ChildSpec.new('test_1', puts, [], :permanent, :brutal_kill)
@transient_child_spec = Sleepier::ChildSpec.new('test_2', puts, [], :transient, :br... |
Given("I start browser") do
@browser.driver_firefox()
end
When("I access facebook login page") do
@browser.load_page()
end
When("I input email - {string} with password - {string}") do |email, password|
@browser.input(email, password)
end
When("I click login button") do
@browser.login_click()
end
Then("login... |
class ContactMailer < ApplicationMailer
default to: 'tucker.merz@gmail.com'
def contact_us(contact)
@contact = contact
mail(
from: @contact.email,
subject: @contact.subject
)
end
end
|
class PublicController < ApplicationController
include PublicHelper
include Public::ErrorsHelper
helper_method :article_path, :profile_path
def article_path(article)
public_article_path(article.year.year, article.issue.number, article.slug)
end
def profile_path(profile)
author_path(profile)
end
... |
Then /^I see showcase set details page$/ do
page.should have_css(".flash-message")
page.should have_css('.content_sets-show')
page.should have_content(@set_title)
page.should have_content(@filename)
end
When /^I create showcase set$/ do
#Click Showcase
find('.projects').click
sleep 2
#Click Add Set
... |
require 'sinatra/base'
require 'sinatra/flash'
require 'json'
require './lib/hangman_game'
class HangmanApp < Sinatra::Base
enable :sessions
register Sinatra::Flash
helpers do
# Given letter, populate all fields necessary to draw html
def guess(letter)
letter = letter.to_s.downcase.gsub(/[\s]/,... |
class Opening < ApplicationRecord
belongs_to :user
has_many :employments
validates_presence_of :title, :description, :location , :role
end
|
# encoding: utf-8
class ApplicationController < ActionController::Base
protect_from_forgery
# let tweet helper methods be available in the controller
helper TweetsHelper
before_filter :donor_banner
def donor_banner
@donor_banner_enabled = Settings.fetch(:enable_donor_banner, false)
end
# needs to ... |
require_relative 'base_page'
class CustomerDetailsPage < BasePage
def title
"General information"
end
set_url ""
selector :manage_isolated_environment_button, "//a[contains(@href, 'environment')]"
selector :workers_tab, "//span[contains(text(), 'Workers')]"
selector :customers_tab, "//span[contain... |
require_relative 'board.rb'
require_relative 'human_player.rb'
class Game
def initialize(player1 = HumanPlayer.new(:red),
player2 = HumanPlayer.new(:black))
@board = Board.new
@red_player = player1
@black_player = player2
@red_player.board = @board
@black_player.board = @board
@current_pl... |
class Api::V1::CommentsController < Api::V1::BaseController
include Rails.application.routes.url_helpers
before_action :set_current_user, except: :list
#before_action :must_be_himself
def create
@comment = Comment.new(comment_params)
if @comment.save
render json: {status: 200}
else
rend... |
require 'enumerable_methods'
describe "Enumerable" do
let(:arr) { [2, 4, 6] }
let(:hash) { {wow: 'cool', waw: 2} }
describe "#my_each" do
context "given [2,4,6]" do
it "sums up to 12" do
sum = 0
arr.my_each { |e| sum += e }
expect(sum).to eql(12)
end
it... |
require 'rails_helper'
describe BasePresenter do
let(:target) { double }
let(:presenter) { BasePresenter.new target }
it 'initializes the target' do
expect(presenter.target).to eq target
end
it 'initializes the view helpers' do
expect(presenter.v).to eq ActionController::Base.helpers
end
end
|
# frozen_string_literal: true
module Validators
class Notes < Base
include NotesValidatorHelper
def initialize(fields)
@fields = fields
end
def validate(note)
@note = note
fields.each { |field| send(field) }
end
private
attr_reader :fields, :note
def text
... |
class PassionsController < ApplicationController
def show
@passion = Passion.find_by(title: params[:id])
@careers = @passion.passion_careers
end
end
|
class ShipperAccountsController < ApplicationController
def index
@slug = params.dig(:shipper_account, :slug)
@shipper_accounts = Postmen::ShipperAccount.all(slug: @slug)
end
end
|
# We can add an new method to already declared classes using override classes look:
# in rails we use the name `monkey patch` to this technique..
# is like Java Reflection
class String
def to_talk phase = "Default Phase"
phase
end
end
puts "ASDASD".class
puts "ASDASD".to_talk
puts "ASDASD".to_talk "An... |
class Comment < ApplicationRecord
validates :comment, presence: true
end
|
#!/usr/bin/env ruby
=begin
Import KM events from the raw dumps.
=end
require 'rubygems'
require 'kmdb'
if KM::DB::Event.connection.class.to_s =~ /(mysql|pgsql)/i
parser_class = KM::DB::ParallelParser
else
parser_class = KM::DB::Parser
end
parser = parser_class.new(:resume => 'import',
... |
class Image
attr_reader :id,
:image
def initialize(data)
@id = nil
@image = image_hash(data)
end
def image_hash(data)
{
details: {
location: data[:location][:title],
url: data[:urls][:regular]
},
credit: {
photographer: data[:user][:name],
... |
class PaCoveragesController < ApplicationController
before_action :authenticate_user!
before_action :set_pa, only: [:index, :new, :show, :edit, :create, :update, :destroy]
before_action :set_pa_coverage, only: [:show, :edit, :update, :destroy,
:show_master, :edit_master, :up... |
require 'attachment_saver_errors'
class InColumnAttachmentDatastoreError < AttachmentDataStoreError; end
module AttachmentSaver
module DataStores
module InColumn
def self.included(base)
base.attachment_options[:column_name] ||= 'data'
base.attachment_options[:temp_directory] ||= Dir.tmpdir... |
class PostsController < ApplicationController
before_action :authenticate_user!, except:[:index, :show]
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
@comments = @post.comments.all
@comment = @post.comments.new
end
def new
@post = Post.new
end
def create... |
class UserCategory < ApplicationRecord
has_many :category_groups, class_name: 'CategoryGroup', foreign_key: 'category_id'
has_many :groups, through: :category_groups
validates :name, uniqueness: true
end
|
class AssociateDocManager
def initialize(document)
@document = document
end
############################################################
# EXTERNAL (3)
def root_associated_document_map(target='reader')
root = @document.root_document || @document
if root != @document
adm = AssociateDoc... |
require 'logger'
require 'mongo_mapper'
require 'uri'
module Sinatra
module MongoMapper
def self.registered(app)
app.set :mongo_logfile, File.join("log", "mongo-driver-#{app.environment}.log")
end
def mongomapper=(mongo_url)
url = URI(mongo_url)
logfile = ::Logger.new(mongo_logfile... |
# coding: utf-8
require "minitest_helper"
describe "LyricLinesSelection Acceptance Test" do
let(:lyric) { FactoryGirl.create :lyric }
let(:open_node) { find 'span.lyric_word:nth-child(2)' }
let(:close_node) { find 'span.lyric_word:nth-child(6)' }
let(:all_nodes) { all(:css, 'span.lyric_word:nth-child(-n+6)')... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.