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 | arbonap/gayify | https://github.com/arbonap/gayify | lib/gayify/cli.rb | Ruby | mit | 19 | master | 380 | require 'thor'
require 'gayify'
module Gayify
class CLI < Thor
desc "spits out a rainbow emoji", "Shows you a rainbow emoji due to the gay agenda"
def rainbow
puts Gayify::Gay.rainbow
end
desc "pluralize", "Pluralizes a word"
method_option :word, :aliases => "-w"
def pluralize
p... |
github | arbonap/gayify | https://github.com/arbonap/gayify | spec/gayify_spec.rb | Ruby | mit | 19 | master | 344 | require "spec_helper"
require "gayify"
describe Gayify::Gay do
it "has a version number" do
expect(Gayify::VERSION).not_to be nil
end
it ".rainbow responds with 🌈 rainbow emoji" do
expect(Gayify::Gay.rainbow).to eql("🌈")
end
it "pluralizes a word" do
expect(Gayify::Gay.pluralize("Gay")).to eq... |
github | cookpad/armg | https://github.com/cookpad/armg | Rakefile | Ruby | mit | 19 | master | 258 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new do |task|
task.options = %w[-c .rubocop.yml]
end
task default: %i[rubocop spec] |
github | cookpad/armg | https://github.com/cookpad/armg | Appraisals | Ruby | mit | 19 | master | 338 | # frozen_string_literal: true
appraise 'ar70' do
gem 'activerecord', '~> 7.0.0'
gem 'concurrent-ruby', '1.3.4' # https://stackoverflow.com/questions/79360526
end
appraise 'ar71' do
gem 'activerecord', '~> 7.1.0'
end
appraise 'ar72' do
gem 'activerecord', '~> 7.2.0'
end
appraise 'ar80' do
gem 'activerecord... |
github | cookpad/armg | https://github.com/cookpad/armg | armg.gemspec | Ruby | mit | 19 | master | 1,604 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'armg/version'
Gem::Specification.new do |spec|
spec.name = 'armg'
spec.version = Armg::VERSION
spec.authors = ['Genki Sugawara', 'Cookpad Inc.']
spec.email... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg.rb | Ruby | mit | 19 | master | 983 | # frozen_string_literal: true
require 'active_support/lazy_load_hooks'
require 'rgeo'
require 'armg/version'
ActiveSupport.on_load(:active_record) do
require 'active_record/connection_adapters/abstract_mysql_adapter'
require 'armg/utils'
require 'armg/wkb_serializer'
require 'armg/wkb_deserializer'
require ... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg/abstract_mysql_adapter_ext.rb | Ruby | mit | 19 | master | 377 | # frozen_string_literal: true
module Armg
module AbstractMysqlAdapterExt
def indexes(*args, &block)
is = super
is.each do |i|
i.lengths = nil if i.type == :spatial && i.respond_to?(:lengths=)
end
is
end
def type_map
@type_map ||= super.tap { |m| m.register_type(/^... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg/wkt_serializer.rb | Ruby | mit | 19 | master | 762 | # frozen_string_literal: true
module Armg
class WktSerializer
DEFAULT_WKB_GENERATOR_OPTIONS = {
type_format: :ewkb,
little_endian: true
}.freeze
DEFAULT_WKT_PARSER_OPTIONS = {
support_ewkt: true
}.freeze
def initialize(factory: nil, wkb_generator_options: {}, wkt_parser_option... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg/wkb_deserializer.rb | Ruby | mit | 19 | master | 440 | # frozen_string_literal: true
module Armg
class WkbDeserializer
DEFAULT_OPTIONS = {
support_ewkb: true
}.freeze
def initialize(factory: nil, **options)
options = DEFAULT_OPTIONS.merge(options)
@wkb_parser = RGeo::WKRep::WKBParser.new(factory, options)
end
def deserialize(mysql... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg/utils.rb | Ruby | mit | 19 | master | 472 | # frozen_string_literal: true
# see https://dev.mysql.com/doc/refman/5.7/en/gis-data-formats.html
module Armg
module Utils
def mysql_geometry_to_wkb(mysql_geometry)
mysql_geometry = mysql_geometry.b
srid = mysql_geometry.slice!(0..3)
mysql_geometry[4] = "\x20"
mysql_geometry.insert(5, sri... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg/wkb_serializer.rb | Ruby | mit | 19 | master | 431 | # frozen_string_literal: true
module Armg
class WkbSerializer
DEFAULT_OPTIONS = {
type_format: :ewkb,
little_endian: true
}.freeze
def initialize(**options)
options = DEFAULT_OPTIONS.merge(options)
@wkb_generator = RGeo::WKRep::WKBGenerator.new(options)
end
def serialize... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg/mysql_geometry.rb | Ruby | mit | 19 | master | 608 | # frozen_string_literal: true
module Armg
class MysqlGeometry < ActiveModel::Type::Value
def type
:geometry
end
def binary?
true
end
def deserialize(value)
case value
when ::String
Armg.deserializer.deserialize(value)
when ActiveModel::Type::Binary::Data
... |
github | cookpad/armg | https://github.com/cookpad/armg | lib/armg/wkt_deserializer.rb | Ruby | mit | 19 | master | 789 | # frozen_string_literal: true
module Armg
class WktDeserializer
DEFAULT_WKB_PARSER_OPTIONS = {
support_ewkb: true
}.freeze
DEFAULT_WKT_GENERATOR_OPTIONS = {
tag_format: :ewkt
# emit_ewkt_srid: true,
}.freeze
def initialize(factory: nil, wkb_parser_options: {}, wkt_generator_op... |
github | cookpad/armg | https://github.com/cookpad/armg | spec/spec_helper.rb | Ruby | mit | 19 | master | 797 | # frozen_string_literal: true
require 'bundler/setup'
require 'active_record'
require 'mysql2'
require 'armg'
require 'erbh'
require 'rspec/match_ruby'
require 'mysql_helper'
include ERBh # rubocop:disable Style/MixinUsage
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config... |
github | cookpad/armg | https://github.com/cookpad/armg | spec/utils_spec.rb | Ruby | mit | 19 | master | 598 | # frozen_string_literal: true
RSpec.describe Armg::Utils do
describe '.mysql_geometry_to_wkb' do
specify do
mysql_geometry = "\xFF\xFF\xFF\xFF\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0\x3F\x00\x00\x00\x00\x00\x00\xF0\xBF"
wkb = Armg::Utils.mysql_geometry_to_wkb(mysql_geometry)
expect(wkb)... |
github | cookpad/armg | https://github.com/cookpad/armg | spec/wkt_spec.rb | Ruby | mit | 19 | master | 1,001 | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Armg do
before :each do
Armg.deserializer = Armg::WktDeserializer.new
Armg.serializer = Armg::WktSerializer.new
end
context 'insert wkt' do
specify do
Geom.create!(id: 4, location: 'Point(-122.1 47.3)')
geom = Geom.find(... |
github | cookpad/armg | https://github.com/cookpad/armg | spec/armg_spec.rb | Ruby | mit | 19 | master | 3,619 | # frozen_string_literal: true
RSpec.describe Armg do
let(:wkt_parser) { RGeo::WKRep::WKTParser.new(nil, support_ewkt: true) }
context 'insert' do
specify do
point = wkt_parser.parse('SRID=3857;Point(-122.1 47.3)')
Geom.create!(id: 4, location: point)
geom = Geom.find(4)
expect(geom.loc... |
github | cookpad/armg | https://github.com/cookpad/armg | spec/mysql_helper.rb | Ruby | mit | 19 | master | 2,218 | # frozen_string_literal: true
class MysqlHelper
MYSQL_HOST = ENV.fetch('ARMG_TEST_MYSQL_HOST', '127.0.0.1')
MYSQL_PORT = ENV.fetch('ARMG_TEST_MYSQL_PORT', 10_056)
MYSQL_USER = ENV.fetch('ARMG_TEST_MYSQL_USER', 'root')
MYSQL_DB = ENV.fetch('ARMG_TEST_MYSQL_DB', 'armg_test')
MYSQL_ENGINE = ENV.f... |
github | cookpad/armg | https://github.com/cookpad/armg | spec/migration_spec.rb | Ruby | mit | 19 | master | 2,641 | # frozen_string_literal: true
RSpec.describe Armg, skip_create_table: true do
let(:table_options) do
if ActiveRecord.gem_version < Gem::Version.new('6.1')
%(options: "#{MysqlHelper::TABLE_OPTIONS}")
elsif MysqlHelper::MYSQL_ENGINE == 'InnoDB'
%(charset: "utf8mb4", collation: "utf8mb4_bin")
el... |
github | Szeliga/time-predicates | https://github.com/Szeliga/time-predicates | Rakefile | Ruby | mit | 19 | master | 330 | # encoding: utf-8
require "rubygems"
begin
require "bundler/setup"
rescue LoadError => e
abort e.message
end
require "rake"
require "rubygems/tasks"
Gem::Tasks.new
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new
task test: :spec
task default: :spec
require "yard"
YARD::Rake::YardocTask.new
task d... |
github | Szeliga/time-predicates | https://github.com/Szeliga/time-predicates | time-predicates.gemspec | Ruby | mit | 19 | master | 1,510 | # -*- encoding: utf-8 -*-
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "time_predicates/version"
require "English"
Gem::Specification.new do |gem|
gem.name = "time-predicates"
gem.version = TimePredicates::VERSION
gem.summary = "... |
github | Szeliga/time-predicates | https://github.com/Szeliga/time-predicates | lib/time_predicates/basic.rb | Ruby | mit | 19 | master | 363 | module TimePredicates
module Basic
def after?(moment)
self > moment
end
def before?(moment)
self < moment
end
def after_or_equal?(moment)
self >= moment
end
def before_or_equal?(moment)
self <= moment
end
end
end
Date.send(:include, TimePredicates::Basic)
... |
github | Szeliga/time-predicates | https://github.com/Szeliga/time-predicates | spec/spec_helper.rb | Ruby | mit | 19 | master | 409 | require "codeclimate-test-reporter"
CodeClimate::TestReporter.start
require "rspec"
require "time_predicates"
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.veri... |
github | Szeliga/time-predicates | https://github.com/Szeliga/time-predicates | spec/time_predicates/basic_spec.rb | Ruby | mit | 19 | master | 3,002 | require "spec_helper"
describe TimePredicates::Basic do
describe "#after?" do
subject(:predicate) { future.after?(past) }
context "for Date" do
let(:future) { Date.parse("2016-03-13") }
let(:past) { Date.parse("2016-03-04") }
it "is true if the provided date is in the past" do
exp... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | Gemfile | Ruby | mit | 19 | master | 573 | source 'https://rubygems.org'
# Declare your gem's dependencies in jsonapi_for_rails.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# Declare any dependencies that are still in development here inste... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | Rakefile | Ruby | mit | 19 | master | 650 | # Rakefile format: http://rake.rubyforge.org/files/doc/rakefile_rdoc.html
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'JsonapiForRails... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | jsonapi_for_rails.gemspec | Ruby | mit | 19 | master | 2,196 | # Gem description, including dependencies
# (see http://guides.rubygems.org/specification-reference/)
# Require gem modules and classes
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'jsonapi_for_rails/version'
Gem::Specification.new do |s|
# Metadata #################################################... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails.rb | Ruby | mit | 19 | master | 1,114 | # TODO: README: add instructions for using sparse fieldsets for setting the
# set of attributes to return (ignore binaries etc)
# TODO: apply sparse fieldsets _after_ including related resources
# TODO: Location header
# TODO: return conformant HTTP status codes
# TODO: adding optional members to documen... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/model.rb | Ruby | mit | 19 | master | 2,798 | module JsonapiForRails::Model
extend ActiveSupport::Concern
included do
#$stderr.puts "JsonapiForRails::Model included into #{self}"
# Define instance methods
class_exec do
def to_jsonapi_hash sparse_fieldset: nil
#$stderr.puts "JsonapiForRails::Controller::Actions::Object#show called"
# attribu... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller.rb | Ruby | mit | 19 | master | 1,688 | require "jsonapi_for_rails/controller/utils/model"
require "jsonapi_for_rails/controller/utils/render"
require "jsonapi_for_rails/controller/before_actions/links"
require "jsonapi_for_rails/controller/before_actions/content_negotiation"
require "jsonapi_for_rails/controller/before_actions/sparse_fieldsets"
require "jso... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/utils/model.rb | Ruby | mit | 19 | master | 896 | module JsonapiForRails::Controller
module Utils
module Model
def self.included receiver
#$stderr.puts "JsonapiForRails::Controller::ModelUtils included into #{receiver}"
receiver.send :include, InstanceMethods
run_macros receiver
end
module InstanceMethods
def jsonapi_model_class_name
... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/utils/render.rb | Ruby | mit | 19 | master | 1,640 | require 'json'
module JsonapiForRails::Controller
module Utils
module Render
def self.included receiver
receiver.send :include, InstanceMethods
run_macros receiver
end
JSONAPI = {
specification: 'http://jsonapi.org/format/',
content_type: 'application/vnd.api+json',
media_range: [
... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/before_actions/relationship.rb | Ruby | mit | 19 | master | 873 | module JsonapiForRails::Controller
module BeforeActions
module Relationship
def self.included receiver
receiver.send :include, InstanceMethods
run_macros receiver
end
def self.run_macros receiver
receiver.instance_exec do
before_action :jsonapi_require_relationship, only: [
:relat... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/before_actions/links.rb | Ruby | mit | 19 | master | 470 | module JsonapiForRails::Controller
module BeforeActions
module Links
def self.included receiver
receiver.send :include, InstanceMethods
run_macros receiver
end
def self.run_macros receiver
receiver.instance_exec do
before_action :jsonapi_links
private :jsonapi_links
end
end
... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/before_actions/content_negotiation.rb | Ruby | mit | 19 | master | 2,170 | module JsonapiForRails::Controller
module BeforeActions
module ContentNegotiation
def self.included receiver
#$stderr.puts "JsonapiForRails::Controller::RecordFromRequest included into #{receiver}"
receiver.send :include, InstanceMethods
run_macros receiver
end
def self.run_macros receiver
... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/before_actions/sparse_fieldsets.rb | Ruby | mit | 19 | master | 883 | module JsonapiForRails::Controller
module BeforeActions
module SparseFieldsets
def self.included receiver
receiver.send :include, InstanceMethods
run_macros receiver
end
def self.run_macros receiver
receiver.instance_exec do
before_action :jsonapi_sparse_fieldsets
private :jsonapi_... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/before_actions/include.rb | Ruby | mit | 19 | master | 557 | module JsonapiForRails::Controller
module BeforeActions
module Include
def self.included receiver
receiver.send :include, InstanceMethods
run_macros receiver
end
def self.run_macros receiver
receiver.instance_exec do
before_action :jsonapi_include
private :jsonapi_include
end
... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/before_actions/record.rb | Ruby | mit | 19 | master | 1,237 | module JsonapiForRails::Controller
module BeforeActions
module Record
def self.included receiver
#$stderr.puts "JsonapiForRails::Controller::RecordFromRequest included into #{receiver}"
receiver.send :include, InstanceMethods
run_macros receiver
end
def self.run_macros receiver
receiver.... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/actions/object.rb | Ruby | mit | 19 | master | 8,945 | module JsonapiForRails::Controller
module Actions
module Object
def self.included receiver
receiver.send :include, InstanceMethods
run_macros receiver
end
module InstanceMethods
# TODO: pagination
def index
@json = {data: []}
jsonapi_model_class.all.each do |record|
@json[:... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | lib/jsonapi_for_rails/controller/actions/relationship.rb | Ruby | mit | 19 | master | 3,444 | module JsonapiForRails::Controller
module Actions
module Relationship
def self.included receiver
receiver.send :include, InstanceMethods
run_macros receiver
end
module InstanceMethods
# GET
def relationship_show
#$stderr.puts "JsonapiForRails::Controller::Actions::Relationship#relatio... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/test_helper.rb | Ruby | mit | 19 | master | 858 | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
require "rails/test_help"
# Filter out Minitest backtrace while allowing backtrace ... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/jsonapi_for_rails_test.rb | Ruby | mit | 19 | master | 2,041 | require 'test_helper'
class JsonapiForRails::Test < ActiveSupport::TestCase
test "Plugin is found" do
#$stderr.puts "JsonapiForRails::Test"
assert_kind_of Module, JsonapiForRails
end
test "Plugin adds 'acts_as_jsonapi_resources' class method to controllers" do
assert ApplicationController.methods.f... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/app/controllers/articles_controller.rb | Ruby | mit | 19 | master | 2,091 | class ArticlesController < ApplicationController
#before_action :log_request
#after_action :log_response
=begin
def index
render json: {data:[]}, content_type: 'application/vnd.api+json'
end
=end
private
def log_request
return unless true or (
request.fullpath.index('/relationships/ta... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/app/controllers/application_controller.rb | Ruby | mit | 19 | master | 302 | 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
acts_as_jsonapi_resources(
content_negotiation: false,
links: true
)
end |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/test/controllers/tags_controller_test.rb | Ruby | mit | 19 | master | 1,920 | require 'test_helper'
class TagsControllerTest < ActionDispatch::IntegrationTest
test "can create tag" do
#$stderr.puts "#{ApplicationController::JSONAPI[:content_type]}"
assert_difference 'Tag.count' do
post(
tags_path,
headers: {
# 'Accept': ApplicationController::JSO... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/test/controllers/articles_controller_test.rb | Ruby | mit | 19 | master | 8,217 | require 'test_helper'
# TODO: how to set the damn Content-Type header in requests?
class ArticlesControllerTest < ActionDispatch::IntegrationTest
test "'@jsonapi_record' is set and '@jsonapi_relationship' is not set when inside 'show' action" do
#skip
get "#{article_path articles(:uk_bank_and_bonuses)}... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/test/models/article_test.rb | Ruby | mit | 19 | master | 1,155 | require 'test_helper'
class ArticleTest < ActiveSupport::TestCase
test "'to_jsonapi_hash' resource 'id's must be strings (http://jsonapi.org/format/1.0/#document-resource-object-identification)" do
record = articles(:uk_bank_and_bonuses).to_jsonapi_hash
#$stderr.puts "#{record.inspect}"
# check if all ... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/config/routes.rb | Ruby | mit | 19 | master | 635 | Rails.application.routes.draw do
# JSONAPI routes
scope '/api/v1' do # Optional scoping
[ # List of your API controllers
:articles, :authors, :header_images, :tags
].each do |resources_name|
resources resources_name do
controller resources_name do
get 'relationships/:rela... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/config/application.rb | Ruby | mit | 19 | master | 419 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
require "jsonapi_for_rails"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/config/puma.rb | Ruby | mit | 19 | master | 1,927 | # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches ... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/config/initializers/callback_terminator.rb | Ruby | mit | 19 | master | 353 | # Be sure to restart your server when you modify this file.
# Do not halt callback chains when a callback returns false. This is a new
# Rails 5.0 default, so it is introduced as a configuration option to ensure
# that apps made with earlier versions of Rails are not affected when upgrading.
ActiveSupport.halt_callbac... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/config/environments/production.rb | Ruby | mit | 19 | master | 3,444 | 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 threaded web serve... |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/db/schema.rb | Ruby | mit | 19 | master | 1,960 | # 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 | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/db/migrate/20160221135010_create_articles.rb | Ruby | mit | 19 | master | 229 | class CreateArticles < ActiveRecord::Migration[5.0]
def change
create_table :articles do |t|
t.string :title
t.string :content
t.references :author, foreign_key: true
t.timestamps
end
end
end |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/db/migrate/20160221135336_create_header_images.rb | Ruby | mit | 19 | master | 213 | class CreateHeaderImages < ActiveRecord::Migration[5.0]
def change
create_table :header_images do |t|
t.string :url
t.references :article, foreign_key: true
t.timestamps
end
end
end |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/db/migrate/20160221135248_create_tags.rb | Ruby | mit | 19 | master | 301 | class CreateTags < ActiveRecord::Migration[5.0]
def change
create_table :tags do |t|
t.string :name
t.timestamps
end
create_table :articles_tags, id: false do |t|
t.references :article, foreign_key: true
t.references :tag, foreign_key: true
end
end
end |
github | doga/jsonapi_for_rails | https://github.com/doga/jsonapi_for_rails | test/dummy/db/migrate/20160221135214_create_authors.rb | Ruby | mit | 19 | master | 200 | class CreateAuthors < ActiveRecord::Migration[5.0]
def change
create_table :authors do |t|
t.string :name
t.string :email
t.string :phone
t.timestamps
end
end
end |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | custom_plan.rb | Ruby | mit | 19 | master | 1,306 | require 'zeus/rails'
# Modifies the behaviour for zeus using its defined scenarios (test, cucumber, etc)
class CustomPlan < Zeus::Rails
# def my_custom_command
# # see https://github.com/burke/zeus/blob/master/docs/ruby/modifying.md
# end
# According to this issue https://github.com/burke/zeus/issues/131
de... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | Gemfile | Ruby | mit | 19 | master | 3,321 | source 'https://rubygems.org'
ruby '2.2.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 2.7.1'
# Use CoffeeScript for .js.coffee assets and views
gem 'c... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | Guardfile | Ruby | mit | 19 | master | 1,007 | # A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Note: if you are using the `direct... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | lib/tasks/code_quality.rake | Ruby | mit | 19 | master | 374 | # all tasks associated with code quality inspection
namespace :code_quality do
desc 'Executes all available code inspection for the current app'
task :check do
`rubycritic app`
`rubocop --format html -o tmp/rubocop.html`
`brakeman -o tmp/brakeman.html`
`rails_best_practices -f html --output-file tmp... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | lib/sassish/sassish.rb | Ruby | mit | 19 | master | 2,010 | # Helper
require File.expand_path(File.join('..', 'sassish', 'view_helper'), __FILE__)
# Engine
require File.expand_path(File.join('..', 'sassish', 'engine'), __FILE__)
# This module adapts almost all the generators associated with the stylesheet organization approach
# described on the Readme file.
module Sassish
#... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | lib/sassish/sassish/engine.rb | Ruby | mit | 19 | master | 345 | module Sassish
# Rails engine for sassish
class Engine < Rails::Railtie
sassish_config = ActiveSupport::OrderedOptions.new
sassish_config[:cache_stylesheet_resources] = false
config.sassish = sassish_config
initializer 'sassish.view_helper' do
ActionView::Base.__send__ :include, Sassish::View... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | lib/sassish/sassish/view_helper.rb | Ruby | mit | 19 | master | 3,173 | module Sassish
# Add the necessary view helpers for Sassish
module ViewHelper
#
# Modifies the stylesheet_link_tag invocation for adding both a dynamic css resource
# and manual resources added for the add_css_reource helper
#
# @param [ String ] manifest, this is the reference for the styleshee... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | lib/sassish/sassish/extensions/generators/scss/assets/assets_generator.rb | Ruby | mit | 19 | master | 2,386 | module Sassish
module Extensions
module Generators
module Scss
module Assets
# An elegant way for monkey patching teh SCSS generator
# TODO: refactor with the sass mokey patch logic
module AssetsGenerator
def self.included(klass)
klass.class_ev... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | lib/sassish/sassish/extensions/generators/sass/assets/assets_generator.rb | Ruby | mit | 19 | master | 2,386 | module Sassish
module Extensions
module Generators
module Sass
module Assets
# An elegant way for monkey patching teh SASS generator
# TODO: refactor with the scss mokey patch logic
module AssetsGenerator
def self.included(klass)
klass.class_ev... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | lib/generators/rails/precompiled_stylesheet_generator.rb | Ruby | mit | 19 | master | 592 | module Rails
module Generators
# Modifies the assets precompile definition for adding the new asset
class PrecompiledStylesheetGenerator < NamedBase
argument :name, type: :string, required: true, banner: 'Resource name'
def add_stylesheet_to_precompilation_assets
inside 'config' do
... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/routes.rb | Ruby | mit | 19 | master | 1,691 | Rails.application.routes.draw do
devise_for :users
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
get 'ping' => 'welcome#ping'
get 'dash... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/application.rb | Ruby | mit | 19 | master | 2,219 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_model/railtie"
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
# Require the... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/unicorn.rb | Ruby | mit | 19 | master | 420 | worker_processes Integer(ENV['WEB_CONCURRENCY'] || 2)
timeout 60
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
end
after_fork do |server, worker|
Signal.trap 'TERM' do
... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/environments/development.rb | Ruby | mit | 19 | master | 1,830 | 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 | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/environments/test.rb | Ruby | mit | 19 | master | 1,700 | 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 | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/environments/production.rb | Ruby | mit | 19 | master | 3,369 | 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 threaded web serve... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/initializers/sidekiq.rb | Ruby | mit | 19 | master | 364 | require 'sidekiq/api'
puts "Redis host: #{ENV['REDIS_SERVICE_HOST']}"
redis_url = Rails.env.development? ? 'redis://127.0.0.1:6379' : "redis://192.168.99.100:6379"
redis_config = { url: redis_url, namespace: 'sidekiq' }
Sidekiq.configure_server do |config|
config.redis = redis_config
end
Sidekiq.configure_client do... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/initializers/shog.rb | Ruby | mit | 19 | master | 378 | if Rails.env.development?
Shog.configure do
match /\s*Rendered\s+(?<view>[^\s]+)\s(within\s(?<layout>[^\s]+)\s)?\((?<time>.*)\)/ do |msg, match|
parts = [" Rendered #{ match["view"].bold }".blue]
parts << "within ".blue + match["layout"].blue.bold if match['layout']
parts << format_time( match[... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/initializers/simple_form.rb | Ruby | mit | 19 | master | 6,456 | # Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
# complete input. You can remove any component from the
# wrapper, change the order or even add your own to the
# stack. The options given below are used to... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/initializers/security_headers.rb | Ruby | mit | 19 | master | 4,442 | ::SecureHeaders::Configuration.configure do |config|
# Strict Transport Security
# is a security feature that lets a web site tell browsers that it should only be communicated with using HTTPS, instead of using HTTP.
# - Browser compatibility:
# IE: 11
# Chrome: > 4
# Firefox: > 4
# Opera: 12
#... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/initializers/devise.rb | Ruby | mit | 19 | master | 12,808 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/initializers/assets.rb | Ruby | mit | 19 | master | 413 | # 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.a... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | config/initializers/simple_form_bootstrap.rb | Ruby | mit | 19 | master | 4,427 | # Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.error_notification_class = 'alert alert-danger'
config.button_class = 'btn btn-primary'
config.boolean_label_class = nil
config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'ha... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | app/helpers/application_helper.rb | Ruby | mit | 19 | master | 581 | # Common helper, remember that we have avoid that each controller loads all existent helpers
# this could be a problem when you try to segment your helper methods, however the app
# always loads both ApplicationHelper and <Current>Helper
module ApplicationHelper
#
# Devise anywhere session stuff
#
def resource_... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | app/models/ability.rb | Ruby | mit | 19 | master | 1,221 | # Class used for describing all behaviour associated with the user abilities
class Ability
include CanCan::Ability
#
# Use this for configuring your abilities
#
# @param [User] user
#
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # g... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | app/models/user.rb | Ruby | mit | 19 | master | 1,601 | # User model wrapped by the devise gem
class User
include Mongoid::Document
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
## Data... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | app/controllers/application_controller.rb | Ruby | mit | 19 | master | 537 | # Base controller for all apps controllers
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
before_filter :run_my_worker
# sets security-related headers automatical... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | app/controllers/welcome_controller.rb | Ruby | mit | 19 | master | 309 | # Controller for testing purpose
class WelcomeController < ApplicationController
# Index page for the app
def index
end
# Ping action for testing purpose, also it could be used in new relic monitoring
def ping
respond_to do |format|
format.html { render text: 'pong!' }
end
end
end |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/spec_helper.rb | Ruby | mit | 19 | master | 3,516 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require ... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/rails_helper.rb | Ruby | mit | 19 | master | 4,945 | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
# specs without zeus (as long as zeus is not running)
def zeus_running?
File.exist? '.zeus.sock'
end
unless zeus_running?
require 'simplecov'
formatters = [SimpleCov::Formatter::HTMLFormatter]
SimpleCov.form... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/features/welcome_spec.rb | Ruby | mit | 19 | master | 771 | require 'rails_helper'
feature 'Welcome Page' do
scenario 'do the thing', :js do
visit '/'
# Just testing the Poltergeist benefits
page.save_screenshot File.join(Rails.root, 'tmp', 'capybara', 'test.png')
expect(page).to have_content 'Foo Application'
element = find '.btn.btn-lg.btn-primary'
... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/features/session_spec.rb | Ruby | mit | 19 | master | 370 | require 'rails_helper'
feature 'Session' do
before do
create :user
end
scenario 'logs into new session' do
visit '/users/sign_in'
within '#new_user' do
fill_in 'user[email]', with: User.first.email
fill_in 'user[password]', with: '123456789'
end
click_button 'Sign In'
expect(... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/helpers/action_view_spec.rb | Ruby | mit | 19 | master | 1,595 | require 'rails_helper'
describe ApplicationHelper do
it '#sassish_stylesheet_link_tag' do
expected_response = "<link rel=\"stylesheet\" media=\"all\" href=\"/assets/application.css\" data-turbolinks-track=\"true\" />"
expect(helper.sassish_stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-tra... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/lib/scaffold_generator_spec.rb | Ruby | mit | 19 | master | 3,105 | require 'rails_helper'
require 'ammeter/init'
require 'rails/generators'
require 'rails/generators/rails/scaffold/scaffold_generator'
describe Rails::Generators::ScaffoldGenerator, type: :generator do
# Tell the generator where to put its output (what it thinks of as Rails.root)
DESTINATION = File.expand_path('../... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/lib/sassish_spec.rb | Ruby | mit | 19 | master | 1,405 | require 'spec_helper'
# Sassish is included and configured by default, the reason for that is that Sassish is coupled with the
# Rails engine and we need to declare a specific configuration on Rails for defining how the sassish
# styles will be look for
# TODO: Sassish should be a gem, this is the reason for that the... |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/lib/sassish_generator_spec.rb | Ruby | mit | 19 | master | 314 | require 'spec_helper'
describe Sassish, type: :generator do
it 'verifies if was monkeypatched' do
expect(Sass::Generators::AssetsGenerator.instance_methods).to include :copy_sass
expect(Sass::Generators::AssetsGenerator.instance_methods).to include :_invoke_from_option_precompiled_stylesheet
end
end |
github | codescrum/rails-template-docker-kubernetes | https://github.com/codescrum/rails-template-docker-kubernetes | spec/factories/users.rb | Ruby | mit | 19 | master | 217 | FactoryGirl.define do
factory :user do
email { Faker::Internet.safe_email("#{Faker::Name.first_name}.#{Faker::Name.last_name}") }
password { '123456789' }
password_confirmation { '123456789' }
end
end |
github | kaosf/conoha | https://github.com/kaosf/conoha | Guardfile | Ruby | mit | 19 | master | 211 | # vim: ft=ruby
guard :minitest do
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
end |
github | kaosf/conoha | https://github.com/kaosf/conoha | conoha.gemspec | Ruby | mit | 19 | master | 1,146 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'conoha/version'
Gem::Specification.new do |spec|
spec.name = "conoha"
spec.version = ConohaVersion::ITSELF
spec.authors = ["ka"]
spec.email = ["ka.kaosf@gmail... |
github | kaosf/conoha | https://github.com/kaosf/conoha | test/test_helper.rb | Ruby | mit | 19 | master | 397 | require 'simplecov'
require 'coveralls'
require 'test/unit'
require 'test/unit/rr'
Coveralls.wear!
if ENV['CI'] != 'true'
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
SimpleCov.start
end
# require order ref.
# http://qiita.com/bsdmad/items/ab8b7d92d965df8bb2d8
# ENV['CI'] != 'true" ref.
# http://... |
github | kaosf/conoha | https://github.com/kaosf/conoha | test/conoha/test_util.rb | Ruby | mit | 19 | master | 1,348 | require 'test_helper'
require 'conoha/util'
class TestConohaUtil < Test::Unit::TestCase
sub_test_case 'HTTPS request utilities' do
setup do
@uri = 'https://example.com/a/b/c'
@payload = {}
@auth_token = '0123456789abcdef'
end
test "https_get" do
any_instance_of(Net::HTTP) { |http... |
github | kaosf/conoha | https://github.com/kaosf/conoha | test/conoha/test_config.rb | Ruby | mit | 19 | master | 1,671 | require 'test_helper'
require 'conoha/config'
class TestConohaConfig < Test::Unit::TestCase
setup do
@config = Conoha::Config.new
end
sub_test_case '#load_from_yaml!' do
test 'normal' do
assert_nothing_raised { @config.load_from_yaml! 'a: 1' }
end
test 'return value is an Array' do
... |
github | kaosf/conoha | https://github.com/kaosf/conoha | lib/conoha.rb | Ruby | mit | 19 | master | 9,322 | require 'conoha/version'
require 'conoha/util'
require 'json'
# :nocov:
class Conoha
def self.init!
load_config!
end
def self.region
@@region || 'tyo1'
end
def self.authenticate!
uri = "https://identity.#{region}.conoha.io/v2.0/tokens"
payload = payload_for_authentication @@username, @@pass... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.