repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
drefuss/rubequ | app/controllers/songs_controller.rb | class SongsController < ApplicationController
before_action :set_song, only: [:show, :lyrics, :queue_add, :edit, :update, :destroy]
# GET /songs
# GET /songs.json
def index
@songs = Song.all
end
# GET /songs/1
# GET /songs/1.json
def show
end
def lyrics
respond_to do |format|
format... |
drefuss/rubequ | app/controllers/root_controller.rb | <reponame>drefuss/rubequ<gh_stars>0
class RootController < ApplicationController
def index
end
def connected
mpd = RubequMpd::Mpd.new
connected = mpd.connected?
mpd.disconnect
respond_to do |format|
format.json { render :json => connected }
end
end
def volume
mpd = RubequMpd::... |
drefuss/rubequ | config/initializers/song_information_init.rb | require 'rubequ_song_information'
include RubequSongInformation
|
drefuss/rubequ | spec/spec_helper.rb | <reponame>drefuss/rubequ
require 'spork'
require 'ostruct'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and... |
drefuss/rubequ | config/initializers/rubequ_mpd_init.rb | <reponame>drefuss/rubequ<filename>config/initializers/rubequ_mpd_init.rb
require 'rubequ_mpd'
include RubequMpd
RubequMpd.mpd_server = "127.0.0.1"
RubequMpd.mpd_port = 6600
|
drefuss/rubequ | lib/rubequ_song_information.rb | require 'discogs'
require 'lyricfy'
module RubequSongInformation
class AlbumCover
def initialize
end
def get_cover(name)
begin
wrapper = Discogs::Wrapper.new("rasplay")
if wrapper.nil?
default_image
else
search = wrapper.search(name)
results = ... |
drefuss/rubequ | db/migrate/20130711024929_add_attachment_mp3_to_songs.rb | <filename>db/migrate/20130711024929_add_attachment_mp3_to_songs.rb
class AddAttachmentMp3ToSongs < ActiveRecord::Migration
def self.up
change_table :songs do |t|
t.attachment :mp3
end
end
def self.down
drop_attached_file :songs, :mp3
end
end
|
drefuss/rubequ | app/views/songs/index.json.jbuilder | json.array!(@songs) do |song|
json.extract! song, :name, :band, :album, :album_cover, :release_date
json.url song_url(song, format: :json)
end
|
drefuss/rubequ | app/views/songs/show.json.jbuilder | <gh_stars>0
json.extract! @song, :name, :band, :album, :album_cover, :release_date, :created_at, :updated_at
|
drefuss/rubequ | spec/models/song_spec.rb | require 'spec_helper'
describe Song do
before(:each) do
@song = FactoryGirl.build(:song)
end
it "should validate that name can not be blank" do
@song.name = ""
@song.should have(1).error_on(:name)
end
it "should validate that band can not be blank" do
@song.band = ""
@song.should have(1... |
drefuss/rubequ | app/models/song.rb | class Song < ActiveRecord::Base
if(Rails.env.test? || Rails.env.development?)
has_attached_file :mp3, :path => "public/music/:file_path/:custom_filename"
end
validates_presence_of :name,
:band,
:mp3
before_create :set_album_cover
default_scope { order('c... |
drefuss/rubequ | spec/factories/songs.rb | <filename>spec/factories/songs.rb
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :song do
name "I'm Sexy And I Know It"
band "LMAFO"
album "Sorry For Party Rocking"
album_cover "http://a5.mzstatic.com/us/r1000/086/Features/1f/76/c9/dj.uqxkqdqp.170x1... |
drefuss/rubequ | spec/controllers/songs_controller_spec.rb | require 'spec_helper'
describe SongsController do
before(:each) do
@song = stub_model(Song, :id => 1)
Song.stub(:find).and_return(@song)
Song.stub(:all).and_return([@song])
Song.stub(:destroy).and_return(true)
Song.any_instance.stub(:in_queue).and_return(false)
Song.any_instance.stub(:save_at... |
drefuss/rubequ | config/initializers/secret_token.rb | # Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to diction... |
pandamouse/rqrcode-rails3 | test/unit/size_calculator_test.rb | require 'test_helper'
class RQRCode::SizeCalculatorTest < ActiveSupport::TestCase
include RQRCode::SizeCalculator
test "size returned is 1 for 'apple'" do
assert_equal(1, minimum_qr_size_from_string('apple'))
end
test "size returned is 5 for 'http://guides.rubyonrails.org/testing.html'" do
assert... |
pandamouse/rqrcode-rails3 | test/dummy/app/controllers/home_controller.rb | <gh_stars>10-100
class HomeController < ApplicationController
def index
respond_to do |format|
format.html
format.svg { render options }
format.png { render options }
format.jpeg { render options }
format.gif { render options }
end
end
private
def options
{:qrcode ... |
pandamouse/rqrcode-rails3 | test/dummy/config/routes.rb | <gh_stars>10-100
Dummy::Application.routes.draw do
get "/home(.:format)", :to => "home#index", :as => :home
get "/", :to => "home#index"
end
|
pandamouse/rqrcode-rails3 | test/integration/navigation_test.rb | <reponame>pandamouse/rqrcode-rails3
require 'test_helper'
class NavigationTest < ActiveSupport::IntegrationCase
test "truth" do
assert_kind_of Dummy::Application, Rails.application
end
test 'svg request returns an SVG file' do
visit home_path
click_link 'SVG'
assert_equal 'image/svg+xml; charset... |
pandamouse/rqrcode-rails3 | test/rqrcode_svg_test.rb | <filename>test/rqrcode_svg_test.rb<gh_stars>10-100
require 'test_helper'
class RQRCode::SVGTest < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, RQRCode
end
end
|
pandamouse/rqrcode-rails3 | rqrcode_rails3.gemspec | <filename>rqrcode_rails3.gemspec
# Provide a simple gemspec so you can easily use your enginex
# project in your rails apps through git.
Gem::Specification.new do |s|
s.name = "rqrcode-rails3"
s.summary = "Render QR codes with Rails 3"
s.description = "Render QR codes with Rails 3"
s.files = D... |
balasankarc/ruby-redis-store | lib/redis/store/version.rb | <filename>lib/redis/store/version.rb
class Redis
class Store < self
VERSION = '1.1.6'
end
end
|
balasankarc/ruby-redis-store | debian/ruby-tests.rake | require 'gem2deb/rake/testtask'
task :default do
Rake::Task[:start_redis].invoke
failed = false
begin
Rake::Task[:test].invoke
rescue
failed = true
end
Rake::Task[:stop_redis].invoke
if failed
fail 'Tests failed'
end
end
task :start_redis do
sh 'redis-server --daemonize yes --port 6379&... |
kete/oembed_provider | lib/oembed_provider.rb | require 'addressable/uri'
require 'oembed_providable'
# set OembedProvider.provide_name, etc. in your config/initializers or somewhere
class OembedProvider
class << self
def provider_url
@@provider_url ||= String.new
end
def provider_url=(url)
@@provider_url = url
end
def provider_na... |
kete/oembed_provider | config/routes.rb | <reponame>kete/oembed_provider
# extend routes for oembed provider endpoint
ActionController::Routing::Routes.draw do |map|
# only one route needed
map.with_options :controller => 'oembed_provider' do |oembed_provider|
oembed_provider.connect 'oembed.:format', :action => 'endpoint'
oembed_provider.connect '... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/test/functional/oembed_provider_controller_test.rb | <gh_stars>1-10
# -*- coding: utf-8 -*-
require 'test_helper'
class OembedProviderControllerTest < ActionController::TestCase
context "The oembed provider controller" do
setup do
@photo = Factory.create(:photo)
end
should "endpoint" do
get :endpoint, :url => "http://example.com/photos/#{@phot... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/app/models/item.rb | <reponame>kete/oembed_provider<filename>test/full_2_3_5_app_with_tests/app/models/item.rb
class Item < ActiveRecord::Base
include OembedProvidable
oembed_providable_as :link, :title => :label
end
|
kete/oembed_provider | test/full_2_3_5_app_with_tests/test/selenium.rb | # -*- coding: utf-8 -*-
require 'test_helper'
# This file is not in integration/ because when run with
# 'rake', it causes segfaults in the test suite
# ATTN: Before runnings these tests, be sure to turn
# off all extensions and popup blockers in Safari
class ActiveSupport::TestCase
self.use_transactional_fixtures... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/config/initializers/oembed_provider.rb | OembedProvider.provider_url = "http://example.com"
OembedProvider.provider_name = "Example.com"
|
kete/oembed_provider | test/full_2_3_5_app_with_tests/test/integration/oembed_test.rb | <gh_stars>1-10
# -*- coding: utf-8 -*-
require 'test_helper'
Webrat.configure do |config|
config.mode = :rails
end
class OembedTest < ActionController::IntegrationTest
context "A providable object when its url is request from the oembed endpoint" do
setup do
@photo = Factory.create(:photo)
@url_wi... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/config/environment.rb | # Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
... |
kete/oembed_provider | lib/oembed_providable.rb | require 'oembed_provider'
require 'builder'
module OembedProvidable #:nodoc:
def self.included(base)
base.send(:include, OembedProvidable::Provided)
end
# use this to make your model able to respond to requests
# against the OembedProviderController
module Provided
def self.included(base)
ba... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/test/unit/oembed_providable_test.rb | # -*- coding: utf-8 -*-
require 'test_helper'
class OembedProvidableTest < ActiveSupport::TestCase
n = 0
context "A model class that includes OembedProvidable" do
context "when declaring oembed_providable_as" do
setup do
n += 1
@a_class_name = "Klass#{n}"
Object.const_set(@a_c... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/test/unit/oembed_provider_test.rb | <gh_stars>1-10
# -*- coding: utf-8 -*-
require 'test_helper'
class OembedProviderTest < ActiveSupport::TestCase
context "The OembedProvider object" do
should "be able to set and return its provider name" do
name = "Media Conglomerate International"
OembedProvider.provider_name = name
assert_equ... |
kete/oembed_provider | rails/init.rb | <reponame>kete/oembed_provider
require 'oembed_provider'
|
kete/oembed_provider | test/full_2_3_5_app_with_tests/db/migrate/20110212022722_create_photos.rb | <filename>test/full_2_3_5_app_with_tests/db/migrate/20110212022722_create_photos.rb
class CreatePhotos < ActiveRecord::Migration
def self.up
create_table :photos do |t|
t.string :title, :url, :null => false
t.string :author_name, :author_url, :thumbnail_url
t.integer :width, :height, :null => fa... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/app/models/photo.rb | class Photo < ActiveRecord::Base
include OembedProvidable
oembed_providable_as :photo
end
|
kete/oembed_provider | test/full_2_3_5_app_with_tests/test/factories.rb | Factory.define :item do |f|
f.sequence(:label) { |n| "a label#{n}"}
f.sequence(:description) { |n| "a description#{n}"}
end
Factory.define :photo do |f|
f.sequence(:title) { |n| "a title#{n}"}
f.sequence(:url) { |n| "http://example.com/photo?id=#{n}"}
f.sequence(:width) { |n| "600"}
f.sequence(:height) { |... |
kete/oembed_provider | app/controllers/oembed_provider_controller.rb | <reponame>kete/oembed_provider
class OembedProviderController < ApplicationController
# Prevents the following error from showing up, common in Rails engines
# A copy of ApplicationController has been removed from the module tree but is still active!
unloadable
# GET /oembed?url=... json by default
# GET /oe... |
kete/oembed_provider | lib/oembed_provider_helper.rb | # include this in your relevant helpers
# to add discoverability link, etc.
module OembedProviderHelper
# hardcodes http as protocol
# http is specified in http://oembed.com/
def oembed_provider_links
host_url = request.host
escaped_request_url = request.url.sub('://', '%3A//')
html = tag(:link, :rel ... |
kete/oembed_provider | test/full_2_3_5_app_with_tests/config/routes.rb | <gh_stars>1-10
ActionController::Routing::Routes.draw do |map|
map.resources :photos
map.resources :items
end
|
FatherofDharma/Palindrome | spec/pal_logic_spec.rb | require('rspec')
require('pal_logic')
describe('Palindrome') do
it("splits an even letter word in half and returns the first half")do
word1 = Palindrome.new()
word1.half("turtle")
expect(word1.first).to(eq(["t", "u", "r"]))
end
it("splits an even letter word in half and returns the last half reverse... |
FatherofDharma/Palindrome | lib/pal_logic.rb | #!/usr/bin/ruby
require('pry')
class Palindrome
def initialize()
end
def half(word)
@word = word
@split_word = word.split("")
@first_half = []
@last_half = []
x = 0
y = @split_word.length - 1
if @split_word.length % 2 == 0
while (x < @split_word.length / 2)
@first_half... |
gibbs/puppet-login_defs | spec/classes/init_spec.rb | require 'spec_helper'
describe 'login_defs', type: :class do
context 'on supported systems' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
it { is_expected.to compile.with_all_deps }
it { is_expected.to create_class('login_defs') }
it { i... |
gibbs/puppet-login_defs | spec/acceptance/options_spec.rb | <filename>spec/acceptance/options_spec.rb
require 'spec_helper_acceptance'
describe 'options' do
pp = <<-MANIFEST
class { 'login_defs':
options => {
'GID_MIN' => {
value => '2000',
},
'HUSHLOGIN_FILE' => {
value => '.hushlogin',
enabled => false,
... |
gibbs/puppet-login_defs | spec/acceptance/init_spec.rb | <filename>spec/acceptance/init_spec.rb
require 'spec_helper_acceptance'
describe 'include class' do
pp = <<-MANIFEST
include ::login_defs
MANIFEST
it 'applies idempotently' do
idempotent_apply(pp)
end
describe file('/etc/login.defs') do
it { is_expected.to exist }
it { is_expected.to be_fil... |
flynnwastaken/seat-allocator | seat-allocator-2010.rb | # This hash holds the 2010 census apportionment populations of the fifty states,
# plus DC and Puerto Rico. This data is the default.
state_pops = {
"Alabama" => 4_802_982, "Alaska" => 721_523, "Arizona" => 6_412_700,
"Arkansas" => 2_926_229, "California" => 37_341_989, "Colorado" => 5_044_930,
"Connecticu... |
landondao1/nginx | metadata.rb | name 'nginx'
maintainer '<NAME>, Inc.'
maintainer_email '<EMAIL>'
license 'Apache-2.0'
description 'Installs and configures nginx'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '8.1.6'
recipe 'nginx', 'Installs nginx package and sets up configuration with Debian apache style with sit... |
hugogzz93/graphql_ar | lib/graphql_relation_helper.rb | <reponame>hugogzz93/graphql_ar<gh_stars>0
# frozen_string_literal: true
module GraphqlRelationHelper
def has_many(relation)
model = relation.to_s.camelcase.singularize
field relation, ["Types::#{model}Type".constantize], null: false do
argument :query, "Types::#{model}QueryType".constantize, required: ... |
hugogzz93/graphql_ar | graphql_ar.gemspec | Gem::Specification.new do |s|
s.name = 'graphql_ar'
s.version = '0.0.0'
s.date = '2019-11-07'
s.summary = 'Helps integrate graphql with active record'
s.authors = '<NAME>'
s.email = '<EMAIL>'
s.files = ['lib/graphql_ar.rb','lib/graphql_mutation.rb', 'lib/graphql_relation_helper.rb']
s.add_runtime_depend... |
hugogzz93/graphql_ar | lib/graphql_mutation.rb | <gh_stars>0
# frozen_string_literal: true
require 'active_support/concern'
# Usage:
# class UserOps < GraphQL::Schema::Object
# include GraphqlMutation
# is_mutation_of User
#
# ...any overwrites here
# end
#
# or inline
#
# UserOps = GraphqlMutation.create_ops_for User
module GraphqlMutation
ex... |
hugogzz93/graphql_ar | lib/graphql_ar.rb | require 'GraphqlRelationHelper'
require 'GraphqlMutation'
module GraphqlAr
def self.GraphqlRelationHelper
GraphqlRelationHelper
end
def self.GraphqlMutation
GraphqlMutation
end
end
|
garrylachman/chef-ultimate-config-cookbook | attributes/default.rb | # Cookbook:: ultimate_config_cookbook
#
# The MIT License (MIT)
#
# Copyright:: 2017, <NAME>
# https://github.com/garrylachman/chef-ultimate-config-cookbook
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# ... |
garrylachman/chef-ultimate-config-cookbook | recipes/yaml_example.rb | # Cookbook:: ultimate_config_cookbook
#
# The MIT License (MIT)
#
# Copyright:: 2017, <NAME>
# https://github.com/garrylachman/chef-ultimate-config-cookbook
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# ... |
garrylachman/chef-ultimate-config-cookbook | resources/json_file.rb | <reponame>garrylachman/chef-ultimate-config-cookbook<filename>resources/json_file.rb
# Cookbook:: ultimate_config_cookbook
#
# The MIT License (MIT)
#
# Copyright:: 2017, <NAME>
# https://github.com/garrylachman/chef-ultimate-config-cookbook
#
# Permission is hereby granted, free of charge, to any person obtaining a co... |
garrylachman/chef-ultimate-config-cookbook | resources/ini_file.rb | # Cookbook:: ultimate_config_cookbook
#
# The MIT License (MIT)
#
# Copyright:: 2017, <NAME>
# https://github.com/garrylachman/chef-ultimate-config-cookbook
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# ... |
jayzz55/ingress | lib/ingress.rb | <gh_stars>1-10
require "ingress/version"
require "ingress/permissions"
|
jayzz55/ingress | lib/ingress/permissions.rb | require "ingress/permissions_repository"
require "ingress/copy_permissions_repository_into_role"
require "ingress/build_permissions_repository_for_role"
module Ingress
class Permissions
class << self
def permissions_repository
@permissions_repository ||= PermissionsRepository.new
end
d... |
jayzz55/ingress | spec/ingress_spec.rb | <reponame>jayzz55/ingress
require "spec_helper"
require "securerandom"
RSpec.describe Ingress do
class TestUser
attr_reader :id, :role_identifiers, :disabled
def initialize(id: nil, role_identifiers: [], disabled: false)
@id = id
@role_identifiers = role_identifiers
@disabled = disabled
... |
jayzz55/ingress | lib/ingress/copy_permissions_repository_into_role.rb | require "ingress/permissions_repository"
module Ingress
module Services
class CopyPermissionsRepositoryIntoRole
class << self
def perform(role_identifier, template_permission_repository)
permission_repository = PermissionsRepository.new
permission_repository.copy_to_role(role_id... |
jayzz55/ingress | lib/ingress/permissions_dsl.rb | <reponame>jayzz55/ingress
require "ingress/permissions_repository"
module Ingress
class PermissionsDsl
attr_reader :role_identifier, :permission_repository
def initialize(role_identifier)
@role_identifier = role_identifier
@permission_repository = PermissionsRepository.new
end
def can_d... |
jayzz55/ingress | lib/ingress/permissions_repository.rb | require "ingress/permission_rule"
module Ingress
class PermissionsRepository
attr_reader :role_rules
def initialize
@role_rules = Hashes.role_rules
@role_subject_action_rule = Hashes.role_subject_action_rule
end
def add_permission(role_identifier, allow, action, subject, conditions = ni... |
jayzz55/ingress | lib/ingress/build_permissions_repository_for_role.rb | <reponame>jayzz55/ingress
require "ingress/permissions_dsl"
module Ingress
module Services
class BuildPermissionsRepositoryForRole
class << self
def perform(role_identifier, &block)
permissions_dsl = PermissionsDsl.new(role_identifier)
permissions_dsl.instance_eval(&block)
... |
khiav223577/rails_compatibility | lib/rails_compatibility/unscope_where.rb | # frozen_string_literal: true
require 'rails_compatibility/active_record'
class << RailsCompatibility
if GTE_RAILS_4_0
def unscope_where(relation)
relation.unscope(:where)
end
else
def unscope_where(relation)
relation.dup.tap{|s| s.where_values = [] }
end
end
end
|
khiav223577/rails_compatibility | lib/rails_compatibility/attribute_types.rb | # frozen_string_literal: true
require 'rails_compatibility'
require 'rails_compatibility/active_record'
class << RailsCompatibility
if ActiveRecord::Base.respond_to?(:attribute_types) # column_types was changed to attribute_types in Rails 5
def attribute_types(klass)
klass.attribute_types
end
elsif ... |
khiav223577/rails_compatibility | test/apply_join_dependency_test.rb | require 'test_helper'
require 'rails_compatibility/apply_join_dependency'
class ApplyJoinDependencyTest < Minitest::Test
def setup
skip if ActiveRecord::VERSION::MAJOR < 4 # Rails 3's includes + pluck will not become left outer joins
@posts = Post.includes(:user)
end
def test_not_become_immutable
Ra... |
khiav223577/rails_compatibility | lib/rails_compatibility/has_include.rb | # frozen_string_literal: true
require 'rails_compatibility'
require 'rails_compatibility/active_record'
class << RailsCompatibility
if GTE_RAILS_6_1
def has_include?(relation, column_name)
relation.send(:has_include?, column_name)
end
elsif GTE_RAILS_5_0
def has_include?(relation, column_name)
... |
khiav223577/rails_compatibility | lib/rails_compatibility.rb | <filename>lib/rails_compatibility.rb<gh_stars>1-10
require 'rails_compatibility/version'
|
khiav223577/rails_compatibility | test/build_joins_test.rb | require 'test_helper'
require 'rails_compatibility/build_joins'
class BuildJoinsTest < Minitest::Test
def setup
@county_ids = County.all.map{|s| [s.name, s.id] }.to_h
@zipcode_ids = Zipcode.all.map{|s| [s.zip, s.id] }.to_h
end
def test_when_many_models_mapping_to_one
reflect = County.reflect_on_asso... |
khiav223577/rails_compatibility | lib/rails_compatibility/active_record.rb | # frozen_string_literal: true
require 'rails_compatibility'
require 'active_record'
class << RailsCompatibility
GTE_RAILS_6_1 = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('6.1.0')
GTE_RAILS_6_0 = Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('6.0.0')
GTE_RAILS_5_2 ... |
khiav223577/rails_compatibility | lib/rails_compatibility/build_joins.rb | <gh_stars>1-10
# frozen_string_literal: true
require 'rails_compatibility'
require 'rails_compatibility/construct_join_dependency'
require 'rails_compatibility/active_record'
class << RailsCompatibility
if GTE_RAILS_6_1
def build_joins(reflect, relation)
join_dependency = construct_join_dependency(reflect... |
khiav223577/rails_compatibility | test/lib/seeds.rb | ActiveRecord::Schema.define do
self.verbose = false
create_table :users, force: true do |t|
t.string :name
t.string :email
t.string :gender
end
create_table :posts, force: true do |t|
t.references :user
t.string :title
end
create_table :counties, force: true do |t|
t.string :name,... |
khiav223577/rails_compatibility | lib/rails_compatibility/apply_join_dependency.rb | # frozen_string_literal: true
require 'rails_compatibility'
require 'rails_compatibility/active_record'
class << RailsCompatibility
if GTE_RAILS_5_2
def apply_join_dependency(relation)
relation.send(:apply_join_dependency)
end
elsif GTE_RAILS_5_1
def apply_join_dependency(relation)
relatio... |
khiav223577/rails_compatibility | lib/rails_compatibility/construct_join_dependency.rb | <filename>lib/rails_compatibility/construct_join_dependency.rb
# frozen_string_literal: true
require 'rails_compatibility'
require 'rails_compatibility/active_record'
class << RailsCompatibility
if GTE_RAILS_6_0
def construct_join_dependency(reflect, relation)
joins = inverse_association_joins(reflect)
... |
khiav223577/rails_compatibility | test/unscope_where_test.rb | <filename>test/unscope_where_test.rb
require 'test_helper'
require 'rails_compatibility/unscope_where'
class UnscopeWhereTest < Minitest::Test
def setup
@females = User.where(gender: 'female')
@males = User.where(gender: 'male')
end
def test_unscope
assert_equal 4, RailsCompatibility.unscope_where(@... |
khiav223577/rails_compatibility | test/has_include_test.rb | <gh_stars>1-10
require 'test_helper'
require 'rails_compatibility/has_include'
class HasIncludeTest < Minitest::Test
def setup
skip if ActiveRecord::VERSION::MAJOR < 4 # Rails 3 doesn't have `has_include?` method
@posts = Post.limit(1).includes(:user)
end
def test_not_become_immutable
assert_equal t... |
khiav223577/rails_compatibility | test/rails_compatibility_test.rb | require 'test_helper'
class RailsCompatibilityTest < Minitest::Test
def setup
end
def test_that_it_has_a_version_number
refute_nil ::RailsCompatibility::VERSION
end
end
|
khiav223577/rails_compatibility | test/attribute_types_test.rb | <reponame>khiav223577/rails_compatibility<gh_stars>1-10
require 'test_helper'
require 'rails_compatibility/attribute_types'
require 'backports/2.4.0/hash/transform_values'
class AttributeTypesTest < Minitest::Test
def setup
end
def test_user
expected_attribute_types = {
'id' => :integer,
'na... |
khiav223577/rails_compatibility | test/pick_test.rb | <filename>test/pick_test.rb
require 'test_helper'
require 'rails_compatibility/pick'
class PickTest < Minitest::Test
def setup
@females = User.where(gender: 'female')
@males = User.where(gender: 'male')
end
def test_pick_single_column
assert_equal 'Pearl', RailsCompatibility.pick(@females.order(:id)... |
khiav223577/rails_compatibility | lib/rails_compatibility/pick.rb | # frozen_string_literal: true
require 'rails_compatibility/active_record'
class << RailsCompatibility
if GTE_RAILS_6_0
def pick(relation, *args)
relation.pick(*args)
end
elsif GTE_RAILS_4_0
def pick(relation, *args)
relation.limit(1).pluck(*args).first
end
else
def pick(relation,... |
scibettas1/eclectictech | vendor/heroku/heroku-buildpack-php/test/spec/composer_spec.rb | <gh_stars>1-10
require_relative "spec_helper"
describe "A PHP application" do
context "with a composer.lock generatead by an old version of Composer" do
it "builds using Composer 1.x" do
new_app_with_stack_and_platrepo('test/fixtures/composer/basic_lock_oldv1').deploy do |app|
expect(app.output).to match(/- ... |
ma2shita/chiliflake | spec/chiliflake_spec.rb | <filename>spec/chiliflake_spec.rb
require "chiliflake"
describe ChiliFlake, "#chiliflake" do
describe "fixed params" do
it "all zero" do
c = ChiliFlake.new(0).send(:chiliflake, ChiliFlake::OFFSET_TS_W_MILLIS, 0, 0)
expect(c).to eq 0
end
it "overflow" do
c = ChiliFlake.new(0)
exp... |
ma2shita/chiliflake | lib/chiliflake.rb | =begin
Pure ruby independent ID generator like the SnowFlake
@see https://github.com/ma2shita/chiliflake
@see https://github.com/twitter/snowflake
@author <NAME>
@example Genenate ID
generator_id = 1
i = ChiliFlake.new(generator_id)
i.generate
=> 522167874144443932
@example Parse for the Flaked ID
ChiliFlake.p... |
springernature/deagol | lib/gollum/frontend/views/editable.rb | module Precious
module Editable
def formats(selected = @page.format)
Gollum::Page::FORMAT_NAMES.map do |key, val|
{ :name => val,
:id => key.to_s,
:selected => selected == key}
end.sort do |a, b|
a[:name].downcase <=> b[:name].downcase
end
end
... |
springernature/deagol | lib/gollum/web_sequence_diagram.rb | require 'net/http'
require 'uri'
require 'open-uri'
class Gollum::WebSequenceDiagram
WSD_URL = "http://www.websequencediagrams.com/index.php"
# Initialize a new WebSequenceDiagram object.
#
# code - The String containing the sequence diagram markup.
# style - The String containing the rendering style.
#
... |
springernature/deagol | lib/gollum/tex.rb | <gh_stars>100-1000
require 'fileutils'
require 'shellwords'
require 'tmpdir'
require 'posix/spawn'
module Gollum
module Tex
class Error < StandardError; end
extend POSIX::Spawn
Template = <<-EOS
\\documentclass[12pt]{article}
\\usepackage{color}
\\usepackage[dvips]{graphicx}
\\pagestyle{empty}
\\pageco... |
springernature/deagol | lib/gollum/frontend/ldap_authentication.rb | require 'net/ldap'
require 'yaml'
require 'digest/md5'
LDAP = YAML.load_file( File.expand_path('../../../../config/ldap.yml', __FILE__) )
module Precious
module LdapAuthentication
AUTH_TOKEN_SEED = '<PASSWORD>'
def authenticate(login, password)
authenticated_user = ldap_login(login, password)
... |
springernature/deagol | lib/gollum/frontend/views/login.rb | module Precious
module Views
class Login < Layout
def title
"Login"
end
end
end
end
|
springernature/deagol | lib/gollum/frontend/views/pages.rb | module Precious
module Views
class Pages < Layout
attr_reader :results, :ref
def title
"Browse Files"
end
def data_path
@path =~ /^\/?(.*?)\/?$/
path = $1 || ''
path << '/' unless path.empty?
" data-path=\"#{path}\""
end
def breadcru... |
springernature/deagol | lib/gollum/frontend/views/history.rb | module Precious
module Views
class History < Layout
attr_reader :page, :page_num
def title
@page.path
end
def versions
i = @versions.size + 1
@versions.map do |v|
i -= 1
{ :id => v.id,
:id7 => v.id[0..6],
:num... |
hanachin/mruby-pkcs5 | mrbgem.rake | MRuby::Gem::Specification.new('mruby-pkcs5') do |spec|
spec.license = 'MIT'
spec.author = '<NAME>'
spec.summary = 'Provide PKCS5 functionality with mruby-digest'
spec.add_dependency 'mruby-digest'
spec.add_dependency 'mruby-pack'
spec.add_dependency 'mruby-string-xor'
end
|
hanachin/mruby-pkcs5 | mrblib/pkcs5.rb | module PKCS5
def self.pbkdf2_hmac(password, salt, iterations, derive_key_bytesize, digest)
hash_key_bytesize = digest.new.digest_length
derived_key = ""
n = (derive_key_bytesize / hash_key_bytesize.to_f).ceil
(1..n).each do |i|
t = u = Digest::HMAC.digest(salt + [i].pack("N"), password, digest)
... |
hanachin/mruby-pkcs5 | test/mrb_pkcs5.rb | <gh_stars>0
# PKCS #5: Password-Based Key Derivation Function 2 (PBKDF2) Test Vectors
# https://tools.ietf.org/html/rfc6070
def dk(vector)
vector.gsub!("\n", '')
vector.gsub!(' ', '')
[vector].pack("H*")
end
assert("PKCS5.pbkdf2_hmac(password, salt, iterations, derive_key_bytesize, digest)") do
assert_equal(d... |
Chyrain/V5ClientWithFramework | V5ClientSDK.podspec | <reponame>Chyrain/V5ClientWithFramework
Pod::Spec.new do |s|
s.name = "V5ClientSDK"
s.version = "1.2.6"
s.summary = "A customer service SDK for users of V5KF.COM used on iOS."
s.description = <<-DESC
It is a customer service SDK used on iOS, which implem... |
AssociationPaupiette/paupiette | app/helpers/dashboard/activity_helper.rb | module Dashboard::ActivityHelper
end
|
AssociationPaupiette/paupiette | db/migrate/20181030150311_create_ambassadorships_join_table.rb | <reponame>AssociationPaupiette/paupiette
class CreateAmbassadorshipsJoinTable < ActiveRecord::Migration[5.2]
def change
create_table :ambassadorships do |t|
t.integer :user_id
t.integer :city_id
t.timestamps
end
add_index :ambassadorships, :user_id
add_index :ambassadorships, :city_... |
AssociationPaupiette/paupiette | app/models/meal.rb | # == Schema Information
#
# Table name: meals
#
# id :bigint(8) not null, primary key
# date :datetime
# host_id :bigint(8)
# capacity :integer
# created_at :datetime not null
# updated_at :datetime not null
# confirmed :integer default(1)
# remaining ... |
AssociationPaupiette/paupiette | db/migrate/20181217130103_add_description_to_meal.rb | <gh_stars>0
class AddDescriptionToMeal < ActiveRecord::Migration[5.2]
def change
add_column :meals, :description, :text
add_column :meals, :formula, :integer
end
end
|
AssociationPaupiette/paupiette | app/controllers/users_controller.rb | class UsersController < ApplicationController
def show
@user = User.find_by(slug: params[:user_slug])
redirect_to root_path and return if @user.nil?
if @user.latitude.present? && @user.longitude.present?
@map_center = { latitude: @user.reduced_latitude, longitude: @user.reduced_longitude }.to_json
... |
AssociationPaupiette/paupiette | app/controllers/my/profile_controller.rb | class My::ProfileController < My::ApplicationController
add_breadcrumb I18n.t('my.profile.name')
def index
@user = current_user
end
def update
@user = current_user
@user.assign_attributes(user_params)
if @user.valid?(:update_profile)
@user.save
redirect_to :my_profile, notice: t('m... |
AssociationPaupiette/paupiette | app/helpers/dashboard/open_meals_helper.rb | <reponame>AssociationPaupiette/paupiette<filename>app/helpers/dashboard/open_meals_helper.rb<gh_stars>0
module Dashboard::OpenMealsHelper
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.