source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | pengwynn/compass-wordpress | https://github.com/pengwynn/compass-wordpress | compass-wordpress.gemspec | Ruby | mit | 89 | master | 2,343 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{compass-wordpress}
s.version = "0.2.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requi... |
github | pengwynn/compass-wordpress | https://github.com/pengwynn/compass-wordpress | Rakefile | Ruby | mit | 89 | master | 1,010 | require 'rubygems'
require 'rake'
def compass_version()
begin
require 'compass'
return ">= "+ Compass::VERSION
rescue LoadError
return ">= 0.10.6"
end
end
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "compass-wordpress"
gem.summary = %Q{Compass extenstion for creating ... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | Capfile | Ruby | mit | 89 | master | 784 | # Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Includes tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
# https://github.com/capistrano/rvm
# https://github.com/capistrano/rbenv
# https... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | Gemfile | Ruby | mit | 89 | master | 1,296 | source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# JavaScript library
gem 'coffee-rails'
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | Guardfile | Ruby | mit | 89 | master | 1,304 | # A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard :minitest do
# with Minitest::Unit
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
# with Minitest::Spec
# w... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/uploaders/user_picture_uploader.rb | Ruby | mit | 89 | master | 555 | # encoding: utf-8
class UserPictureUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :large do
process :resize_and_pad => [400, 400]
end
version :small do
proces... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/uploaders/product_picture_uploader.rb | Ruby | mit | 89 | master | 1,690 | class ProductPictureUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be s... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/user_picture.rb | Ruby | mit | 89 | master | 410 | class UserPicture < ActiveRecord::Base
mount_uploader :picture, UserPictureUploader
belongs_to :user
validates :picture, presence: true
before_save :update_picture_attributes
private
def update_picture_attributes
if picture.present? && picture_changed?
self.picture_content_type = picture.f... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/product_picture.rb | Ruby | mit | 89 | master | 712 | class ProductPicture < ActiveRecord::Base
mount_uploader :picture, ProductPictureUploader
belongs_to :product
validates :picture, presence: true
before_save :update_picture_attributes
def self.search_picture this_params
product_picture = self.all
product_picture = product_picture.joins(:product).w... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/ability.rb | Ruby | mit | 89 | master | 1,134 | class Ability
include CanCan::Ability
def initialize(user)
if user.blank?
# not logged in
cannot :manage, :all
can :create, User
basic_read_only
elsif user.is?(:admin)
# admin
can :manage, :all
elsif user.is?(:manager)
# manager
can :manage, Message
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/message.rb | Ruby | mit | 89 | master | 2,685 | class Message < ActiveRecord::Base
has_many :notifications
belongs_to :messageable, polymorphic: true, counter_cache: true
belongs_to :user
after_create :track_notification
before_create :convert_content
validates :content, presence: true, length: { maximum: 400 }
validates :messageable_type, inclusion:... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/notification.rb | Ruby | mit | 89 | master | 527 | class Notification < ActiveRecord::Base
belongs_to :user
belongs_to :message
scope :user_notification, ->(user) { where(user: user) }
scope :unread_scope, -> { where(read: false) }
scope :read_scope, -> { where(read: true) }
def self.find_my_notifications current_user
notes = self.user_notification(cu... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/user.rb | Ruby | mit | 89 | master | 2,121 | class User < ActiveRecord::Base
has_secure_password
include Rolable
has_many :evaluates
has_many :messages
has_many :user_pictures
has_many :collectionships, foreign_key: "user_id", dependent: :destroy
has_many :collections, through: :collectionships, source: :product
has_many :likeships, foreign_key:... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/likeship.rb | Ruby | mit | 89 | master | 339 | class Likeship < ActiveRecord::Base
belongs_to :user
belongs_to :likeable, polymorphic: true
validates :user_id, presence: true
validates :likeable_id, presence: true
validates :likeable_type, presence:true
def self.likeable(like)
likeable = { likeable_type: like.class.to_s, likeable_id: like.id }
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/evaluate.rb | Ruby | mit | 89 | master | 954 | class Evaluate < ActiveRecord::Base
belongs_to :product, counter_cache: true
belongs_to :user
has_many :messages, as: :messageable
has_many :likeships, as: :likeable, foreign_key: "likeable_id", dependent: :destroy
has_many :likers, through: :likeships, source: :user
validates :title, :details, :product_i... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/product.rb | Ruby | mit | 89 | master | 1,552 | class Product < ActiveRecord::Base
scope :published, -> { where("published_at IS NOT null") }
has_many :messages, as: :messageable
has_many :evaluates
has_many :product_pictures
has_many :collectionships, foreign_key: "product_id", dependent: :destroy
has_many :collectors, through: :collectionships, source... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/models/concerns/user/rolable.rb | Ruby | mit | 89 | master | 750 | class User
module Rolable
extend ActiveSupport::Concern
included do
ROLES = %w[admin manager user]
ROLES_CN = %w[超级管理员 管理员 用户]
ROLES_CHECKBOX = [['admin', '超级管理员'], ['manager', '管理员'], ['user', '用户']]
end
def roles=(roles)
self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/helpers/products_helper.rb | Ruby | mit | 89 | master | 592 | module ProductsHelper
def product_collection_tag product
return fa_icon("bookmark") if current_user.blank?
class_name = "icon_mark_select"
link_title = "收藏"
link_path_method = "post"
if current_user and current_user.collectionship_product_ids.include?(product.id)
class_name = "icon_mark_sele... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/helpers/likeships_helper.rb | Ruby | mit | 89 | master | 712 | module LikeshipsHelper
def likeable_likes_tag like
@like = Object.const_get(like[:likeable_type]).where(id: like[:likeable_id]).first
return "#{fa_icon('heart')} #{@like.likeships.count}人喜欢".html_safe if current_user.blank?
class_name = "icon_like_select"
link_title = "喜欢"
link_path_method = "post... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/helpers/application_helper.rb | Ruby | mit | 89 | master | 368 | module ApplicationHelper
def sortable(column, title = nil)
title ||= column
sort_fa_icon = column == sort_column ? fa_icon("sort-#{sort_direction}") : fa_icon("sort")
direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
link_to "#{title} #{sort_fa_icon}".html_safe, params.merg... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/helpers/sessions_helper.rb | Ruby | mit | 89 | master | 1,214 | module SessionsHelper
def sign_in(user)
session[:user_id] = user.id
@current_user = user
end
def current_user
@current_user ||= sign_in_from_session || sign_in_from_cookies unless defined?(@current_user)
@current_user
end
def current_user?(user)
user==current_user
end
def sign_in_f... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/helpers/user_pictures_helper.rb | Ruby | mit | 89 | master | 214 | module UserPicturesHelper
def user_picture_cover picture_cover, size, opts = {}
picture_cover.present? ? image_tag(picture_cover, opts) : image_tag("default_user_picture/default_#{size}.png", opts)
end
end |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/errors_controller.rb | Ruby | mit | 89 | master | 315 | class ErrorsController < ApplicationController
after_action :destroy_database_connect
def show
render status_code.to_s, status: status_code
end
protected
def status_code
params[:code] || 500
end
def destroy_database_connect
ActiveRecord::Base.clear_active_connections!
end
end |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/likeships_controller.rb | Ruby | mit | 89 | master | 596 | class LikeshipsController < ApplicationController
before_action :find_likeable
def create
current_user.like!(params[:likeable_type], params[:likeable_id])
respond_to do |format|
format.html { redirect_to :back }
format.js
end
end
def destroy
current_user.unlike!(params[:likeable_typ... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/collectionships_controller.rb | Ruby | mit | 89 | master | 510 | class CollectionshipsController < ApplicationController
before_action :signed_in_user
before_action :find_product
def create
current_user.collect!(@product)
respond_to do |format|
format.html { redirect_to :back }
format.js
end
end
def destroy
current_user.uncollect!(@product)
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/messages_controller.rb | Ruby | mit | 89 | master | 1,576 | class MessagesController < ApplicationController
load_and_authorize_resource only: :destroy
before_action :find_product
def index
@message = @product.messages.build
@messages = @product.messages.paginate(page: params[:page])
end
def create
@message = @product.messages.build(message_params.merge... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/sessions_controller.rb | Ruby | mit | 89 | master | 560 | class SessionsController < ApplicationController
def create
@user = User.find_by(email: params[:email].downcase)
respond_to do |format|
if @user && @user.authenticate(params[:password])
sign_in @user
remember_me if params[:remember_me]
format.html { redirect_to :back }
fo... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/evaluates_controller.rb | Ruby | mit | 89 | master | 1,722 | class EvaluatesController < ApplicationController
load_and_authorize_resource only: [:new, :edit, :create, :update, :destroy]
before_action :find_product
before_action :find_evaluate, only: [:show, :edit, :update, :destroy]
def index
@evaluates = @product.evaluates.order(id: :desc)
end
def show
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/products_controller.rb | Ruby | mit | 89 | master | 971 | class ProductsController < ApplicationController
helper_method :sort_column, :sort_direction
before_action :find_product, only: :show
def index
@products = Product.order(sort_column + " " + sort_direction).classify_published(params)
@product_categories = ProductCategory.all
end
def show
@evaluat... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/accounts_controller.rb | Ruby | mit | 89 | master | 1,344 | class AccountsController < ApplicationController
before_action :find_user
layout "user"
def edit
end
def update
if @user.authenticate(params[:user][:password])
@user.skip_password = true
@user.update(name: params[:user][:name], description: params[:user][:description])
flash[:success] ... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/users_controller.rb | Ruby | mit | 89 | master | 808 | class UsersController < ApplicationController
before_action :find_user, only: [:show, :all_evaluates]
layout "user", except: [:new, :create]
def index
@users = User.select("id, name").order("RANDOM()").limit(10)
render json: @users
end
def show
@collections = @user.collections.order("id DESC")
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/user_pictures_controller.rb | Ruby | mit | 89 | master | 857 | class UserPicturesController < ApplicationController
load_and_authorize_resource only: [:create, :destroy]
before_action :find_user
layout "user"
def index
@user_pictures = @user.user_pictures
@user_picture = UserPicture.new
end
def create
@user_picture = @user.user_pictures.build(user_picture... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/application_controller.rb | Ruby | mit | 89 | master | 338 | 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 CanCan::AccessDenied do |exception|
redirect_to root_url, danger: exception.... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/notifications_controller.rb | Ruby | mit | 89 | master | 305 | class NotificationsController < ApplicationController
def index
@notifications = Notification.find_my_notifications current_user
end
def destroy
@notification = Notification.find(params[:id])
@notification.destroy
flash[:success] = "删除成功!"
redirect_to :back
end
end |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/admin/users_controller.rb | Ruby | mit | 89 | master | 1,474 | class Admin::UsersController < Admin::BaseController
before_action :find_user, only: [:show, :edit, :update, :destroy, :destroy_user_picture]
def index
@users = User.search(params)
end
def show
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/admin/evaluates_controller.rb | Ruby | mit | 89 | master | 1,287 | class Admin::EvaluatesController < Admin::BaseController
before_action :find_evaluate, only: [:show, :edit, :update, :destroy, :create_message, :destroy_message]
def index
@evaluates = Evaluate.search(params)
end
def show
end
def edit
end
def update
if @evaluate.update(evaluate_params)
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/admin/products_controller.rb | Ruby | mit | 89 | master | 1,704 | class Admin::ProductsController < Admin::BaseController
before_action :find_product, except: [:index, :new, :create]
def index
@products = Product.search(params)
end
def show
@product_picture = ProductPicture.new
end
def new
@product = Product.new
end
def create
@product = Product.ne... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/admin/messages_controller.rb | Ruby | mit | 89 | master | 862 | class Admin::MessagesController < Admin::BaseController
before_action :find_message, only: [:edit, :update, :destroy]
def index
@messages = Message.search(params)
end
def edit
end
def update
if @message.update(message_params)
flash[:success] = '更新成功!'
redirect_to admin_messages_path
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/admin/product_pictures_controller.rb | Ruby | mit | 89 | master | 867 | class Admin::ProductPicturesController < Admin::BaseController
before_action :find_product_picture, only: [:show, :destroy, :setting_cover]
def create
@product_picture = ProductPicture.new(product_picture_params)
if @product_picture.save
flash[:success] = '成功创建产品图片!'
redirect_to :back
else
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/admin/base_controller.rb | Ruby | mit | 89 | master | 305 | class Admin::BaseController < ApplicationController
before_action :authorized_manage
before_action :signed_in_user
layout "admin"
load_and_authorize_resource
private
def authorized_manage
redirect_to root_path unless current_user.is?(:manager) || current_user.is?(:admin)
end
end |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/controllers/admin/product_categories_controller.rb | Ruby | mit | 89 | master | 1,451 | class Admin::ProductCategoriesController < Admin::BaseController
before_action :find_product_category, only: [:show, :edit, :update, :destroy, :all]
def index
@product_categories = ProductCategory.paginate(page: params[:page])
end
def show
@products = @product_category.products
end
def new
@p... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | app/presenters/notification_presenter.rb | Ruby | mit | 89 | master | 600 | class NotificationPresenter < SimpleDelegator
attr_reader :notification
def initialize(notification, view)
super(view)
@notification = notification
end
def dynamic_select
notification.read ? "read" : "unread"
end
def render_notification
div_for(notification, class: dynamic_select) do
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/deploy.rb | Ruby | mit | 89 | master | 1,471 | # config valid only for Capistrano 3.2.1
lock '3.2.1'
set :application, 'giggle'
set :repo_url, 'git@example.com:me/giggle.git'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'
# Defa... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/application.rb | Ruby | mit | 89 | master | 1,230 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Giggle
class Application < Rails::Application
config.autoload_paths += %W(#{config.root}/lib)... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/routes.rb | Ruby | mit | 89 | master | 1,352 | Rails.application.routes.draw do
resource :session, only: [:create, :destroy]
get '/sign-up', to: 'users#new', as: :sign_up
namespace :admin do
root 'products#index'
resources :products do
member do
patch :setting_cover, :publish_operation
end
end
resources :product_pictures
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/initializers/assets.rb | Ruby | mit | 89 | master | 381 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.ap... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/environments/test.rb | Ruby | mit | 89 | master | 1,661 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/environments/development.rb | Ruby | mit | 89 | master | 1,599 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/environments/production.rb | Ruby | mit | 89 | master | 3,244 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | config/deploy/production.rb | Ruby | mit | 89 | master | 1,970 | # Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary server in each group
# is considered to be the first unless any hosts have the primary
# property set. Don't declare `role :all`, it's a meta role.
role :app, %w{deploy@example.com}
role :web, %w{deploy@example.com}
role :db,... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/test_helper.rb | Ruby | mit | 89 | master | 366 | ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helpe... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/models/product_test.rb | Ruby | mit | 89 | master | 1,028 | require 'test_helper'
class ProductTest < ActiveSupport::TestCase
def setup
@product = products(:iPhone)
end
test "should not save product without name" do
@product.name = nil
assert_not @product.save
end
test "should not save product without product category" do
@product.product_category =... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/models/evaluate_test.rb | Ruby | mit | 89 | master | 716 | require 'test_helper'
class EvaluateTest < ActiveSupport::TestCase
def setup
@evaluate = evaluates(:product_evaluate)
end
test "should not save evaluate without title" do
@evaluate.title = nil
assert_not @evaluate.save
end
test "should not save evaluate without details" do
@evaluate.details... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/models/product_category_test.rb | Ruby | mit | 89 | master | 453 | require 'test_helper'
class ProductCategoryTest < ActiveSupport::TestCase
def setup
@product_category = product_categories(:cell_phones)
end
test "should not save product category without name" do
@product_category.name = nil
assert_not @product_category.save
end
test "should not save product c... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/models/collectionship_test.rb | Ruby | mit | 89 | master | 432 | require 'test_helper'
class CollectionshipTest < ActiveSupport::TestCase
def setup
@collectionship = collectionships(:christelle_iphone)
end
test "should not save collectionship without user_id" do
@collectionship.user_id = nil
assert_not @collectionship.save
end
test "should not save collectio... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/models/notification_test.rb | Ruby | mit | 89 | master | 968 | require 'test_helper'
class NotificationTest < ActiveSupport::TestCase
def setup
@unread_notification = notifications(:unread_christelle_notification)
@read_notification = notifications(:read_christelle_notification)
@user = users(:christelle)
end
test "should find current user notification" do
... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/models/user_test.rb | Ruby | mit | 89 | master | 2,272 | require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = users(:christelle)
end
test "email addresses should be unique" do
duplicate_user = @user.dup
duplicate_user.email = @user.email.upcase
@user.save
assert_not duplicate_user.valid?
end
test "should not save u... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | test/models/message_test.rb | Ruby | mit | 89 | master | 1,523 | require 'test_helper'
class MessageTest < ActiveSupport::TestCase
def setup
@message = messages(:leave_message)
@buy_iphone_message = messages(:buy_iphone_message)
end
test "should not save message without content" do
@message.content = nil
assert_not @message.save
end
test "should not save... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | db/schema.rb | Ruby | mit | 89 | master | 4,301 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | db/seeds.rb | Ruby | mit | 89 | master | 600 | # 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... |
github | minnowlab/giggle | https://github.com/minnowlab/giggle | db/migrate/20140202095649_reset_by_schema.rb | Ruby | mit | 89 | master | 3,637 | class ResetBySchema < ActiveRecord::Migration
def change
create_table "collectionships", force: true do |t|
t.integer "user_id"
t.integer "product_id"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "collectionships", ["user_id", "product_id"], name: "index_collect... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | lxc-ruby.gemspec | Ruby | mit | 89 | master | 819 | require File.expand_path('../lib/lxc/version', __FILE__)
Gem::Specification.new do |s|
s.name = "lxc-ruby"
s.version = LXC::VERSION
s.summary = "Ruby wrapper to LXC"
s.description = "Ruby wrapper to manage LXC (Linux Containers)."
s.homepage = "http://github.com/sosedoff/lxc-ruby"
s.autho... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | Vagrantfile | Ruby | mit | 89 | master | 4,338 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environmen... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | lib/lxc.rb | Ruby | mit | 89 | master | 1,979 | require "posix/spawn"
require "lxc/version"
require "lxc/errors"
module LXC
autoload :Shell, "lxc/shell"
autoload :Configuration, "lxc/configuration"
autoload :ConfigurationOptions, "lxc/configuration_options"
autoload :Container, "lxc/container"
autoload :Status, ... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | lib/lxc/container.rb | Ruby | mit | 89 | master | 6,423 | module LXC
class Container
attr_accessor :name
# Initialize a new LXC::Container instance
# @param [String] name container name
# @return [LXC::Container] container instance
def initialize(name)
@name = name
end
# Get container attributes hash
# @return [Hash]
def to_hash
... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | lib/lxc/configuration.rb | Ruby | mit | 89 | master | 2,082 | module LXC
class Configuration
include LXC::ConfigurationOptions
attr_reader :content
# Initialize a new LXC::Configuration instance
# @param [data] string or hash data (optional)
def initialize(data=nil)
if data.kind_of?(String)
@content = parse(data)
end
end
# Load... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | lib/lxc/configuration_options.rb | Ruby | mit | 89 | master | 535 | module LXC
module ConfigurationOptions
VALID_OPTIONS = [
"lxc.utsname",
"lxc.network.type",
"lxc.network.flags",
"lxc.network.link",
"lxc.network.name",
"lxc.network.hwaddr",
"lxc.network.ipv4",
"lxc.network.ipv6",
"lxc.pts",
"lxc.tty",
"lxc.mount"... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | lib/lxc/shell.rb | Ruby | mit | 89 | master | 2,251 | module LXC
module Shell
extend self
BIN_PREFIX = "/usr/bin"
BIN_FILES = [
"lxc-attach",
"lxc-cgroup",
"lxc-checkconfig",
"lxc-checkpoint",
"lxc-clone",
"lxc-console",
"lxc-create",
"lxc-destroy",
"lxc-execute",
"lxc-freeze",
"lxc-info",
... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | lib/lxc/status.rb | Ruby | mit | 89 | master | 395 | module LXC
class Status
attr_reader :state, :pid
def initialize(state, pid)
@state = state.to_s.downcase
@pid = Integer(pid)
end
def == (instance)
instance.pid == pid && instance.state == state
end
def to_hash
{
"state" => state,
"pid" => pid
... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | spec/spec_helper.rb | Ruby | mit | 89 | master | 489 | $:.unshift File.expand_path("../..", __FILE__)
require 'simplecov'
SimpleCov.start do
add_filter "/.bundle/"
end
require 'lib/lxc'
def fixture_path(filename=nil)
path = File.expand_path("../fixtures", __FILE__)
filename.nil? ? path : File.join(path, filename)
end
def fixture(file)
File.read(File.join(fixtur... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | spec/configuration_spec.rb | Ruby | mit | 89 | master | 760 | require 'spec_helper'
describe LXC::Configuration do
it 'parses config data' do
conf = LXC::Configuration.new(fixture('configuration.txt'))
expect(conf.content).to be_a Hash
expect(conf.attributes).to be_an Array
expect(conf.attributes).to_not be_empty
expect(conf.utsname).to_not be_nil
expe... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | spec/lxc_spec.rb | Ruby | mit | 89 | master | 3,562 | require 'spec_helper'
require 'fileutils'
describe LXC do
describe '.check_binaries' do
LXC::Shell::BIN_PREFIX = '/tmp/lxc'
before do
FileUtils.mkdir_p('/tmp/lxc')
LXC::Shell::BIN_FILES.each do |f|
FileUtils.touch("/tmp/lxc/#{f}")
FileUtils.chmod(0555, "/tmp/lxc/#{f}")
end
... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | spec/container_spec.rb | Ruby | mit | 89 | master | 6,489 | require 'spec_helper'
describe LXC::Container do
subject { LXC::Container.new('app') }
it { should respond_to :name }
it { should respond_to :status }
it { should respond_to :state }
it { should respond_to :pid }
describe '#name' do
it 'should be set to "app"' do
expect(subject.name).to eq 'app... |
github | sosedoff/lxc-ruby | https://github.com/sosedoff/lxc-ruby | spec/status_spec.rb | Ruby | mit | 89 | master | 763 | require 'spec_helper'
describe LXC::Status do
describe '.new' do
let(:status) { LXC::Status.new('RUNNING', '12345') }
it 'makes state downcase' do
expect(status.state).to eq 'running'
end
it 'converts given pid into integer' do
expect(status.pid).to be_an Integer
end
end
descri... |
github | wantedly/step-pretty-slack-notify | https://github.com/wantedly/step-pretty-slack-notify | run.rb | Ruby | mit | 89 | master | 4,719 | #!/usr/bin/env ruby
require "slack-notifier"
class Build
def initialize()
# See below docs for more details about wercker's environment variables:
# http://devcenter.wercker.com/docs/environment-variables/available-env-vars
@app_url = ENV["WERCKER_APPLICATION_URL"] || ""
@build_url ... |
github | wantedly/step-pretty-slack-notify | https://github.com/wantedly/step-pretty-slack-notify | coreos/Vagrantfile | Ruby | mit | 89 | master | 3,373 | # -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
Vagrant.require_version ">= 1.6.0"
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")
# Defaults for config options defined in CONFIG
$num_instances = 1
$update_channel = "alpha"
$e... |
github | wantedly/step-pretty-slack-notify | https://github.com/wantedly/step-pretty-slack-notify | coreos/config.rb | Ruby | mit | 89 | master | 1,897 | require 'erb'
require 'dotenv'
# Create user-data from erb template
Dotenv.load
erb = File.open(File.join(File.dirname(__FILE__), "user-data.yml.erb")) { |f| ERB.new(f.read) }
File.write(File.join(File.dirname(__FILE__), "user-data"), erb.result(binding))
# To automatically replace the discovery token on 'vagrant up'... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | Appraisals | Ruby | mit | 89 | master | 365 | appraise "rails-6.0" do
gem "activerecord", "~> 6.0.0"
end
appraise "rails-6.1" do
gem "activerecord", "~> 6.1.0"
end
appraise "rails-7.0" do
gem "activerecord", "~> 7.0.0"
end
appraise "rails-7.1" do
gem "activerecord", "~> 7.1"
end
appraise "rails-7.2" do
gem "activerecord", "~> 7.2"
end
appraise "rail... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | pg_column_byte_packer.gemspec | Ruby | mit | 89 | master | 1,480 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "pg_column_byte_packer/version"
Gem::Specification.new do |spec|
spec.name = "pg_column_byte_packer"
spec.version = PgColumnBytePacker::VERSION
spec.authors = [
"jcoleman",
]
sp... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | spec/schema_statements_spec.rb | Ruby | mit | 89 | master | 21,459 | RSpec.describe PgColumnBytePacker::SchemaCreation do
let(:migration_class) { ActiveRecord::Migration::Current }
describe "#create_table" do
around(:each) do |example|
run_on_fresh_database do
ActiveRecord::Base.connection.execute("CREATE EXTENSION citext")
migration.suppress_messages do
... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | spec/spec_helper.rb | Ruby | mit | 89 | master | 2,064 | require "bundler/setup"
# In Rails 6 this isn't required in the right order and worked by accident; fixed in rails@0f5e7a66143
require "logger"
require "pg_column_byte_packer"
require "relation_to_struct"
require "db-query-matchers"
require "tempfile"
require "pry"
require_relative "postgresql_spec_helpers"
RSpec.conf... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | spec/postgresql_spec_helpers.rb | Ruby | mit | 89 | master | 2,061 | module PostgresqlSpecHelpers
def with_connection(config, &block)
ActiveRecord::Base.establish_connection(config)
begin
block.call
ensure
ActiveRecord::Base.connection.pool.disconnect!
end
end
def test_configuration
if ActiveRecord.gem_version >= Gem::Version.new("6.1.0")
Act... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | spec/pg_dump_spec.rb | Ruby | mit | 89 | master | 29,990 | require "open3"
RSpec.describe PgColumnBytePacker::PgDump do
def run_shell_command(command, env:)
stdout, stderr, command_status = Open3.capture3(env, command)
raise RuntimeError, "Command failed: `#{command}` (status: #{command_status})\nstdout `#{stdout}`\nstderr: `#{stderr}`" unless command_status.exitst... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | lib/pg_column_byte_packer.rb | Ruby | mit | 89 | master | 10,046 | require "pg_column_byte_packer/version"
require "pg_query"
module PgColumnBytePacker
def self.sql_type_alignment_cache
@@sql_type_alignment_cache ||= {}
end
def self.ordering_key_for_column(connection:, name:, sql_type:, type_schema: nil, primary_key:, nullable:, has_default:)
alignment = PgColumnBytePa... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | lib/pg_column_byte_packer/schema_statements.rb | Ruby | mit | 89 | master | 1,419 | require "active_record"
require "active_record/migration"
require "active_record/connection_adapters/abstract/schema_creation"
module PgColumnBytePacker
module SchemaCreation
def visit_TableDefinition(o)
columns_hash = o.instance_variable_get(:@columns_hash)
sorted_column_tuples = columns_hash.sort_... |
github | braintree/pg_column_byte_packer | https://github.com/braintree/pg_column_byte_packer | lib/pg_column_byte_packer/pg_dump.rb | Ruby | mit | 89 | master | 4,588 | module PgColumnBytePacker
module PgDump
def self.sort_columns_for_definition_file(path, connection:)
sorted_dump_output = []
current_block_start = nil
current_block_body = []
current_table_name = nil
block_begin_prefix_pattern = /\ACREATE TABLE ([^\(]+) \(/
block_end_line_patte... |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | Gemfile | Ruby | mit | 89 | main | 252 | source 'https://rubygems.org'
gemspec
gem 'gem-release'
gem 'pry'
gem 'activerecord', "~> #{ENV['ACTIVE_RECORD_VERSION']}" if ENV['ACTIVE_RECORD_VERSION'].to_s != ''
gem 'sqlite3', "~> #{ENV['SQLITE3_VERSION']}" if ENV['SQLITE3_VERSION'].to_s != '' |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | acts_as_hashids.gemspec | Ruby | mit | 89 | main | 1,576 | lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'acts_as_hashids/version'
Gem::Specification.new do |spec|
spec.name = 'acts_as_hashids'
spec.version = ActsAsHashids::VERSION
spec.platform = Gem::Platform::RUBY
spec.authors = ['dt... |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | lib/acts_as_hashids.rb | Ruby | mit | 89 | main | 291 | module ActsAsHashids
class Exception < ::Exception; end
end
require 'acts_as_hashids/version'
if defined?(Rails::Railtie)
require 'acts_as_hashids/railtie'
elsif defined?(ActiveRecord)
require 'acts_as_hashids/methods'
ActiveRecord::Base.send(:include, ActsAsHashids::Methods)
end |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | lib/acts_as_hashids/railtie.rb | Ruby | mit | 89 | main | 282 | require 'acts_as_hashids/methods'
module ActsAsHashids
class Railtie < Rails::Railtie
initializer 'acts_as_hashids.include_methods' do
ActiveSupport.on_load :active_record do
ActiveRecord::Base.send(:include, ActsAsHashids::Methods)
end
end
end
end |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | lib/acts_as_hashids/core.rb | Ruby | mit | 89 | main | 2,097 | require 'hashids'
module ActsAsHashids
module Core
extend ActiveSupport::Concern
def to_param
id = public_send(self.class.primary_key)
id && self.class.hashids.encode(id)
end
module FinderMethods
def find(ids = nil, &block)
return detect(&block) if block.present? && respon... |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | lib/acts_as_hashids/methods.rb | Ruby | mit | 89 | main | 687 | require_relative 'core'
module ActsAsHashids
module Methods
extend ActiveSupport::Concern
module ClassMethods
def acts_as_hashids(options = {})
include ActsAsHashids::Core unless ancestors.include?(ActsAsHashids::Core)
define_singleton_method :hashids_secret do
secret = opti... |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | spec/spec_helper.rb | Ruby | mit | 89 | main | 1,191 | $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
# Test Coverage
require 'codeclimate-test-reporter'
require 'simplecov'
SimpleCov.start 'rails' do
if ENV['CI']
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path... |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | spec/acts_as_hashids_spec.rb | Ruby | mit | 89 | main | 271 | require 'spec_helper'
describe ActsAsHashids do
it 'has a version number' do
expect(ActsAsHashids::VERSION).not_to be nil
end
it 'defines acts_as_hashids method in ActiveRecord::Base' do
expect(ActiveRecord::Base).to respond_to(:acts_as_hashids)
end
end |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | spec/acts_as_hashids/methods_spec.rb | Ruby | mit | 89 | main | 2,352 | require 'spec_helper'
RSpec.describe ActsAsHashids::Methods do
around :context do |block|
m = ActiveRecord::Migration.new
m.verbose = false
m.create_table :methods_foos, force: true do |t|
end
m.create_table :methods_bars, force: true do |t|
t.string :type
end
begin
block.call... |
github | dtaniwaki/acts_as_hashids | https://github.com/dtaniwaki/acts_as_hashids | spec/acts_as_hashids/core_spec.rb | Ruby | mit | 89 | main | 4,078 | require 'spec_helper'
RSpec.describe ActsAsHashids::Core do
around :context do |block|
m = ActiveRecord::Migration.new
m.verbose = false
m.create_table :core_foos, force: true do |t|
end
m.create_table :core_bars, force: true do |t|
t.integer :core_foo_id, index: true
end
begin
... |
github | benbalter/jekyll-optional-front-matter | https://github.com/benbalter/jekyll-optional-front-matter | jekyll-optional-front-matter.gemspec | Ruby | mit | 89 | main | 1,105 | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("lib", __dir__)
require "jekyll-optional-front-matter/version"
Gem::Specification.new do |s|
s.name = "jekyll-optional-front-matter"
s.version = JekyllOptionalFrontMatter::VERSION
s.authors = ["Ben Balter"]
s.email ... |
github | benbalter/jekyll-optional-front-matter | https://github.com/benbalter/jekyll-optional-front-matter | spec/spec_helper.rb | Ruby | mit | 89 | main | 1,525 | # frozen_string_literal: true
require "jekyll-optional-front-matter"
require "fileutils"
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles =... |
github | benbalter/jekyll-optional-front-matter | https://github.com/benbalter/jekyll-optional-front-matter | spec/jekyll-optional-front-matter/generator_spec.rb | Ruby | mit | 89 | main | 6,625 | # frozen_string_literal: true
describe JekyllOptionalFrontMatter::Generator do
let(:site) { fixture_site("site") }
let(:generator) { described_class.new(site) }
let(:markdown_converter) { generator.send(:markdown_converter) }
let(:markdown_files) { generator.send(:markdown_files) }
let(:pages) { generator.se... |
github | benbalter/jekyll-optional-front-matter | https://github.com/benbalter/jekyll-optional-front-matter | spec/jekyll-optional-front-matter/content_spec.rb | Ruby | mit | 89 | main | 3,175 | # frozen_string_literal: true
describe JekyllOptionalFrontMatter::Generator do
let(:site) { fixture_site("site") }
let(:generator) { described_class.new(site) }
let(:markdown_files) { generator.send(:markdown_files) }
let(:pages) { generator.send(:pages) }
let(:pages_to_add) { generator.send(:pages_to_add) }... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.