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 | norman/friendly_id | https://github.com/norman/friendly_id | test/benchmarks/object_utils.rb | Ruby | mit | 6,218 | master | 2,680 | require File.expand_path("../../helper", __FILE__)
# This benchmark compares the timings of the friendly_id? and unfriendly_id? on various objects
#
# integer friendly_id? 6.370000 0.000000 6.370000 ( 6.380925)
# integer unfriendly_id? 6.640000 0.010000 6.650000 ( 6.646057)
# AR::Base fri... |
github | norman/friendly_id | https://github.com/norman/friendly_id | test/benchmarks/finders.rb | Ruby | mit | 6,218 | master | 2,440 | require File.expand_path("../../helper", __FILE__)
require "ffaker"
# This benchmark tests ActiveRecord and FriendlyId methods for performing a find
#
# ActiveRecord: where.first 8.970000 0.040000 9.010000 ( 9.029544)
# ActiveRecord: where.take 8.100000 0.030000 8.1300... |
github | norman/friendly_id | https://github.com/norman/friendly_id | gemfiles/Gemfile.rails-6.1.rb | Ruby | mit | 6,218 | master | 427 | source "https://rubygems.org"
gemspec path: "../"
gem "activerecord", "~> 6.1.4"
gem "railties", "~> 6.1.4"
# Database Configuration
group :development, :test do
platforms :jruby do
gem "activerecord-jdbcmysql-adapter", "~> 61.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
gem "kramdown"
end... |
github | norman/friendly_id | https://github.com/norman/friendly_id | gemfiles/Gemfile.rails-6.0.rb | Ruby | mit | 6,218 | master | 427 | source "https://rubygems.org"
gemspec path: "../"
gem "activerecord", "~> 6.0.0"
gem "railties", "~> 6.0.0"
# Database Configuration
group :development, :test do
platforms :jruby do
gem "activerecord-jdbcmysql-adapter", "~> 51.1"
gem "activerecord-jdbcpostgresql-adapter", "~> 51.1"
gem "kramdown"
end... |
github | norman/friendly_id | https://github.com/norman/friendly_id | gemfiles/Gemfile.rails-7.1.rb | Ruby | mit | 6,218 | master | 427 | source "https://rubygems.org"
gemspec path: "../"
gem "activerecord", "~> 7.1.0"
gem "railties", "~> 7.1.0"
# Database Configuration
group :development, :test do
platforms :jruby do
gem "activerecord-jdbcmysql-adapter", "~> 61.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
gem "kramdown"
end... |
github | norman/friendly_id | https://github.com/norman/friendly_id | gemfiles/Gemfile.rails-7.0.rb | Ruby | mit | 6,218 | master | 427 | source "https://rubygems.org"
gemspec path: "../"
gem "activerecord", "~> 7.0.0"
gem "railties", "~> 7.0.0"
# Database Configuration
group :development, :test do
platforms :jruby do
gem "activerecord-jdbcmysql-adapter", "~> 61.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
gem "kramdown"
end... |
github | norman/friendly_id | https://github.com/norman/friendly_id | gemfiles/Gemfile.rails-7.2.rb | Ruby | mit | 6,218 | master | 427 | source "https://rubygems.org"
gemspec path: "../"
gem "activerecord", "~> 7.2.0"
gem "railties", "~> 7.2.0"
# Database Configuration
group :development, :test do
platforms :jruby do
gem "activerecord-jdbcmysql-adapter", "~> 61.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
gem "kramdown"
end... |
github | norman/friendly_id | https://github.com/norman/friendly_id | gemfiles/Gemfile.rails-8.0.rb | Ruby | mit | 6,218 | master | 427 | source "https://rubygems.org"
gemspec path: "../"
gem "activerecord", "~> 8.0.0"
gem "railties", "~> 8.0.0"
# Database Configuration
group :development, :test do
platforms :jruby do
gem "activerecord-jdbcmysql-adapter", "~> 61.0"
gem "activerecord-jdbcpostgresql-adapter", "~> 61.0"
gem "kramdown"
end... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id.rb | Ruby | mit | 6,218 | master | 4,019 | require "active_record"
require "friendly_id/base"
require "friendly_id/object_utils"
require "friendly_id/configuration"
require "friendly_id/finder_methods"
# @guide begin
#
# ## About FriendlyId
#
# FriendlyId is an add-on to Ruby's Active Record that allows you to replace ids
# in your URLs with strings:
#
# #... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/generators/friendly_id_generator.rb | Ruby | mit | 6,218 | master | 1,096 | require "rails/generators"
require "rails/generators/active_record"
# This generator adds a migration for the {FriendlyId::History
# FriendlyId::History} addon.
class FriendlyIdGenerator < ActiveRecord::Generators::Base
# ActiveRecord::Generators::Base inherits from Rails::Generators::NamedBase which requires a NAME... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/simple_i18n.rb | Ruby | mit | 6,218 | master | 3,345 | require "i18n"
module FriendlyId
# @guide begin
#
# ## Translating Slugs Using Simple I18n
#
# The {FriendlyId::SimpleI18n SimpleI18n} module adds very basic i18n support to
# FriendlyId.
#
# In order to use this module, your model must have a slug column for each locale.
# By default FriendlyId look... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/finders.rb | Ruby | mit | 6,218 | master | 3,564 | module FriendlyId
# @guide begin
#
# ## Performing Finds with FriendlyId
#
# FriendlyId offers enhanced finders which will search for your record by
# friendly id, and fall back to the numeric id if necessary. This makes it easy
# to add FriendlyId to an existing application with minimal code modification... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/base.rb | Ruby | mit | 6,218 | master | 11,241 | module FriendlyId
# @guide begin
#
# ## Setting Up FriendlyId in Your Model
#
# To use FriendlyId in your ActiveRecord models, you must first either extend or
# include the FriendlyId module (it makes no difference), then invoke the
# {FriendlyId::Base#friendly_id friendly_id} method to configure your des... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/sequentially_slugged.rb | Ruby | mit | 6,218 | master | 820 | require_relative "sequentially_slugged/calculator"
module FriendlyId
module SequentiallySlugged
def self.setup(model_class)
model_class.friendly_id_config.use :slugged
end
def resolve_friendly_id_conflict(candidate_slugs)
candidate = candidate_slugs.first
return if candidate.nil?
... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/history.rb | Ruby | mit | 6,218 | master | 4,424 | module FriendlyId
# @guide begin
#
# ## History: Avoiding 404's When Slugs Change
#
# FriendlyId's {FriendlyId::History History} module adds the ability to store a
# log of a model's slugs, so that when its friendly id changes, it's still
# possible to perform finds by the old id.
#
# The primary use ... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/slugged.rb | Ruby | mit | 6,218 | master | 16,102 | require "friendly_id/slug_generator"
require "friendly_id/candidates"
module FriendlyId
# @guide begin
#
# ## Slugged Models
#
# FriendlyId can use a separate column to store slugs for models which require
# some text processing.
#
# For example, blog applications typically use a post title to provide ... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/initializer.rb | Ruby | mit | 6,218 | master | 4,013 | # FriendlyId Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `friendly_id` class method or defining
# methods in your model.
#
# To learn more, check out... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/scoped.rb | Ruby | mit | 6,218 | master | 5,581 | require "friendly_id/slugged"
module FriendlyId
# @guide begin
#
# ## Unique Slugs by Scope
#
# The {FriendlyId::Scoped} module allows FriendlyId to generate unique slugs
# within a scope.
#
# This allows, for example, two restaurants in different cities to have the slug
# `joes-diner`:
#
# c... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/object_utils.rb | Ruby | mit | 6,218 | master | 2,406 | module FriendlyId
# Instances of these classes will never be considered a friendly id.
# @see FriendlyId::ObjectUtils#friendly_id
UNFRIENDLY_CLASSES = [
Array,
FalseClass,
Hash,
NilClass,
Numeric,
Symbol,
TrueClass
]
# Utility methods for determining whether any object is a friend... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/slug.rb | Ruby | mit | 6,218 | master | 307 | module FriendlyId
# A FriendlyId slug stored in an external table.
#
# @see FriendlyId::History
class Slug < ActiveRecord::Base
belongs_to :sluggable, polymorphic: true
def sluggable
sluggable_type.constantize.unscoped { super }
end
def to_param
slug
end
end
end |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/candidates.rb | Ruby | mit | 6,218 | master | 1,673 | require "securerandom"
module FriendlyId
# This class provides the slug candidate functionality.
# @see FriendlyId::Slugged
class Candidates
include Enumerable
def initialize(object, *array)
@object = object
@raw_candidates = to_candidate_array(object, array.flatten(1))
end
def each... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/slug_generator.rb | Ruby | mit | 6,218 | master | 920 | module FriendlyId
# The default slug generator offers functionality to check slug candidates for
# availability.
class SlugGenerator
def initialize(scope, config)
@scope = scope
@config = config
end
def available?(slug)
if @config.uses?(::FriendlyId::Reserved) && @config.reserved_wo... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/finder_methods.rb | Ruby | mit | 6,218 | master | 4,061 | module FriendlyId
module FinderMethods
# Finds a record using the given id.
#
# If the id is "unfriendly", it will call the original find method.
# If the id is a numeric string like '123' it will first look for a friendly
# id matching '123' and then fall back to looking for a record with the
... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/migration.rb | Ruby | mit | 6,218 | master | 783 | MIGRATION_CLASS =
if ActiveRecord::VERSION::MAJOR >= 5
ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
else
ActiveRecord::Migration
end
class CreateFriendlyIdSlugs < MIGRATION_CLASS
def change
create_table :friendly_id_slugs do |t|
t.string :slug, nu... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/configuration.rb | Ruby | mit | 6,218 | master | 3,495 | module FriendlyId
# The configuration parameters passed to {Base#friendly_id} will be stored in
# this object.
class Configuration
attr_writer :base
# The default configuration options.
attr_reader :defaults
# The modules in use
attr_reader :modules
# The model class that this configura... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/reserved.rb | Ruby | mit | 6,218 | master | 1,758 | module FriendlyId
# @guide begin
#
# ## Reserved Words
#
# The {FriendlyId::Reserved Reserved} module adds the ability to exclude a list of
# words from use as FriendlyId slugs.
#
# With Ruby on Rails, FriendlyId's generator generates an initializer that
# reserves some words such as "new" and "edit" ... |
github | norman/friendly_id | https://github.com/norman/friendly_id | lib/friendly_id/sequentially_slugged/calculator.rb | Ruby | mit | 6,218 | master | 2,284 | module FriendlyId
module SequentiallySlugged
class Calculator
attr_accessor :scope, :slug, :slug_column, :sequence_separator
def initialize(scope, slug, slug_column, sequence_separator, base_class)
@scope = scope
@slug = slug
table_name = scope.connection.quote_table_name(base... |
github | ddollar/foreman | https://github.com/ddollar/foreman | Gemfile | Ruby | mit | 6,149 | main | 267 | source "http://rubygems.org"
gemspec
group :test do
gem 'rake'
gem 'fakefs'
gem 'rspec', '~> 3.5'
gem "simplecov", :require => false
gem 'timecop'
end
group :development do
gem 'aws-s3'
gem 'ronn-ng'
gem 'yard', '~> 0.9.11'
gem 'automatiek'
end |
github | ddollar/foreman | https://github.com/ddollar/foreman | foreman.gemspec | Ruby | mit | 6,149 | main | 631 | $:.unshift File.expand_path("../lib", __FILE__)
require "foreman/version"
Gem::Specification.new do |gem|
gem.name = "foreman"
gem.license = "MIT"
gem.version = Foreman::VERSION
gem.author = "David Dollar"
gem.email = "ddollar@gmail.com"
gem.homepage = "https://github.com/ddollar/foreman"
gem... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman.rb | Ruby | mit | 6,149 | main | 307 | require "foreman/version"
module Foreman
def self.runner
File.expand_path("../../bin/foreman-runner", __FILE__)
end
def self.ruby_18?
defined?(RUBY_VERSION) and RUBY_VERSION =~ /^1\.8\.\d+/
end
def self.windows?
defined?(RUBY_PLATFORM) and RUBY_PLATFORM =~ /(win|w)32$/
end
end |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/engine.rb | Ruby | mit | 6,149 | main | 12,248 | require "foreman"
require "foreman/env"
require "foreman/process"
require "foreman/procfile"
require "tempfile"
require "fileutils"
require "thread"
class Foreman::Engine
# The signals that the engine cares about.
#
HANDLED_SIGNALS = [ :TERM, :INT, :HUP, :USR1, :USR2 ]
attr_reader :env
attr_reader :options... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/env.rb | Ruby | mit | 6,149 | main | 672 | require "foreman"
class Foreman::Env
attr_reader :entries
def initialize(filename)
@entries = File.read(filename).gsub("\r\n","\n").split("\n").inject({}) do |ax, line|
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
key = $1
case val = $2
# Remove single quotes
when /\A'(.*)'... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/procfile.rb | Ruby | mit | 6,149 | main | 2,028 | require "foreman"
# Reads and writes Procfiles
#
# A valid Procfile entry is captured by this regex:
#
# /^([A-Za-z0-9_-]+):\s*(.+)$/
#
# All other lines are ignored.
#
class Foreman::Procfile
EmptyFileError = Class.new(StandardError)
# Initialize a Procfile
#
# @param [String] filename (nil) An optional ... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export.rb | Ruby | mit | 6,149 | main | 1,019 | require "foreman"
require "foreman/helpers"
require "pathname"
module Foreman::Export
extend Foreman::Helpers
class Exception < ::Exception; end
def self.formatter(format)
begin
require "foreman/export/#{ format.tr('-', '_') }"
classy_format = classify(format)
formatter = constantize(... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/helpers.rb | Ruby | mit | 6,149 | main | 1,312 | module Foreman::Helpers
# Copied whole sale from, https://github.com/defunkt/resque/
# Given a word with dashes, returns a camel cased version of it.
#
# classify('job-name') # => 'JobName'
def classify(dashed_word)
dashed_word.split('-').each { |part| part[0] = part[0].chr.upcase }.join
end # Tries t... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/cli.rb | Ruby | mit | 6,149 | main | 5,726 | require "foreman"
require "foreman/helpers"
require "foreman/engine"
require "foreman/engine/cli"
require "foreman/export"
require "foreman/version"
require "shellwords"
require "thor"
require "yaml"
class Foreman::CLI < Thor
include Foreman::Helpers
map ["-v", "--version"] => :version
class_option :procfile,... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/process.rb | Ruby | mit | 6,149 | main | 1,966 | require "foreman"
require "shellwords"
class Foreman::Process
attr_reader :command
attr_reader :env
# Create a Process
#
# @param [String] command The command to run
# @param [Hash] options
#
# @option options [String] :cwd (./) Change to this working directory before executing the process
# @o... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/base.rb | Ruby | mit | 6,149 | main | 3,441 | require "foreman/export"
require "pathname"
require "shellwords"
class Foreman::Export::Base
attr_reader :location
attr_reader :engine
attr_reader :options
attr_reader :formation
# deprecated
attr_reader :port
def initialize(location, engine, options={})
@location = location
@engine = engi... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/supervisord.rb | Ruby | mit | 6,149 | main | 281 | require "erb"
require "foreman/export"
class Foreman::Export::Supervisord < Foreman::Export::Base
def export
super
Dir["#{location}/#{app}.conf"].each do |file|
clean file
end
write_template "supervisord/app.conf.erb", "#{app}.conf", binding
end
end |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/bluepill.rb | Ruby | mit | 6,149 | main | 237 | require "erb"
require "foreman/export"
class Foreman::Export::Bluepill < Foreman::Export::Base
def export
super
clean "#{location}/#{app}.pill"
write_template "bluepill/master.pill.erb", "#{app}.pill", binding
end
end |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/systemd.rb | Ruby | mit | 6,149 | main | 898 | require "erb"
require "foreman/export"
class Foreman::Export::Systemd < Foreman::Export::Base
def export
super
Dir["#{location}/#{app}*.target"]
.concat(Dir["#{location}/#{app}*.service"])
.concat(Dir["#{location}/#{app}*.target.wants/#{app}*.service"])
.each do |file|
clean file
... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/launchd.rb | Ruby | mit | 6,149 | main | 530 | require "erb"
require "foreman/export"
class Foreman::Export::Launchd < Foreman::Export::Base
def export
super
engine.each_process do |name, process|
1.upto(engine.formation[name]) do |num|
port = engine.port_for(process, num)
command_args = process.command.split(/\s+/).map{|arg|
... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/daemon.rb | Ruby | mit | 6,149 | main | 838 | require "erb"
require "foreman/export"
class Foreman::Export::Daemon < Foreman::Export::Base
def export
super
(Dir["#{location}/#{app}-*.conf"] << "#{location}/#{app}.conf").each do |file|
clean file
end
write_template "daemon/master.conf.erb", "#{app}.conf", binding
engine.each_process... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/inittab.rb | Ruby | mit | 6,149 | main | 1,118 | require "foreman/export"
class Foreman::Export::Inittab < Foreman::Export::Base
def export
error("Must specify a location") unless location
inittab = []
inittab << "# ----- foreman #{app} processes -----"
index = 1
engine.each_process do |name, process|
1.upto(engine.formation[name]) do ... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/upstart.rb | Ruby | mit | 6,149 | main | 1,045 | require "erb"
require "foreman/export"
class Foreman::Export::Upstart < Foreman::Export::Base
def export
super
master_file = "#{app}.conf"
clean File.join(location, master_file)
write_template master_template, master_file, binding
engine.each_process do |name, process|
process_master_fi... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/export/runit.rb | Ruby | mit | 6,149 | main | 942 | require "erb"
require "foreman/export"
class Foreman::Export::Runit < Foreman::Export::Base
ENV_VARIABLE_REGEX = /([a-zA-Z_]+[a-zA-Z0-9_]*)=(\S+)/
def export
super
engine.each_process do |name, process|
1.upto(engine.formation[name]) do |num|
process_directory = "#{app}-#{name}-#{num}"
... |
github | ddollar/foreman | https://github.com/ddollar/foreman | lib/foreman/engine/cli.rb | Ruby | mit | 6,149 | main | 2,502 | require "foreman/engine"
class Foreman::Engine::CLI < Foreman::Engine
module Color
ANSI = {
:reset => 0,
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:magenta => 35,
:cyan ... |
github | ddollar/foreman | https://github.com/ddollar/foreman | tasks/release.rake | Ruby | mit | 6,149 | main | 1,756 | require "time"
desc "Build the manual"
task :man do
ENV['RONN_MANUAL'] = "Foreman Manual"
ENV['RONN_ORGANIZATION'] = "Foreman #{Foreman::VERSION}"
sh "ronn -w -s toc -r5 --markdown man/*.ronn"
end
desc "Commit the manual to git"
task "man:commit" => :man do
sh "git add README.md"
sh "git commit -am 'update... |
github | ddollar/foreman | https://github.com/ddollar/foreman | tasks/dist.rake | Ruby | mit | 6,149 | main | 2,627 | require "erb"
require "fileutils"
require "tmpdir"
def assemble(source, target, perms=0644)
FileUtils.mkdir_p(File.dirname(target))
File.open(target, "w") do |f|
f.puts ERB.new(File.read(source)).result(binding)
end
File.chmod(perms, target)
end
def assemble_distribution(target_dir=Dir.pwd)
distribution... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/helper_spec.rb | Ruby | mit | 6,149 | main | 450 | require "spec_helper"
describe "spec helpers" do
describe "#preserving_env" do
after { ENV.delete "FOO" }
it "should remove added environment vars" do
old = ENV["FOO"]
preserving_env { ENV["FOO"] = "baz" }
expect(ENV["FOO"]).to eq(old)
end
it "should reset modified environment var... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/spec_helper.rb | Ruby | mit | 6,149 | main | 3,509 | require "simplecov"
SimpleCov.start do
add_filter "/spec/"
end
require "rspec"
require "timecop"
require "pp"
require "fakefs/safe"
require "fakefs/spec_helpers"
$:.unshift File.expand_path("../../lib", __FILE__)
def mock_export_error(message)
expect { yield }.to raise_error(Foreman::Export::Exception, message)
... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman_spec.rb | Ruby | mit | 6,149 | main | 284 | require "spec_helper"
require "foreman"
describe Foreman do
describe "VERSION" do
subject { Foreman::VERSION }
it { is_expected.to be_a String }
end
describe "runner" do
it "should exist" do
expect(File.exist?(Foreman.runner)).to eq(true)
end
end
end |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/procfile_spec.rb | Ruby | mit | 6,149 | main | 1,842 | require 'spec_helper'
require 'foreman/procfile'
require 'pathname'
require 'tmpdir'
describe Foreman::Procfile, :fakefs do
subject { Foreman::Procfile.new }
it "can load from a file" do
write_procfile
subject.load "Procfile"
expect(subject["alpha"]).to eq("./alpha")
expect(subject["bravo"]).to eq... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/helpers_spec.rb | Ruby | mit | 6,149 | main | 564 | require "spec_helper"
require "foreman/helpers"
describe "Foreman::Helpers" do
before do
module Foo
class Bar; end
end
end
after do
Object.send(:remove_const, :Foo)
end
subject { o = Object.new; o.extend(Foreman::Helpers); o }
it "should classify words" do
expect(subject.classify("... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/engine_spec.rb | Ruby | mit | 6,149 | main | 3,332 | require "spec_helper"
require "foreman/engine"
class Foreman::Engine::Tester < Foreman::Engine
attr_reader :buffer
def startup
@buffer = ""
end
def output(name, data)
@buffer += "#{name}: #{data}"
end
def shutdown
end
end
describe "Foreman::Engine", :fakefs do
subject do
write_procfile ... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/cli_spec.rb | Ruby | mit | 6,149 | main | 3,600 | require "spec_helper"
require "foreman/cli"
describe "Foreman::CLI", :fakefs do
subject { Foreman::CLI.new }
describe ".foreman" do
before { File.open(".foreman", "w") { |f| f.puts "formation: alpha=2" } }
it "provides default options" do
expect(subject.send(:options)["formation"]).to eq("alpha=2")... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export_spec.rb | Ruby | mit | 6,149 | main | 756 | require "spec_helper"
require "foreman/export"
describe "Foreman::Export" do
subject { Foreman::Export }
describe "with a formatter that doesn't declare the appropriate class" do
it "prints an error" do
expect(subject).to receive(:require).with("foreman/export/invalidformatter")
mock_export_error(... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/process_spec.rb | Ruby | mit | 6,149 | main | 2,241 | require 'spec_helper'
require 'foreman/process'
require 'timeout'
require 'tmpdir'
describe Foreman::Process do
def run(process, options={})
rd, wr = IO.method(:pipe).arity.zero? ? IO.pipe : IO.pipe("BINARY")
process.run(options.merge(:output => wr))
rd.gets
end
describe "#run" do
it "runs the... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/upstart_spec.rb | Ruby | mit | 6,149 | main | 4,501 | require "spec_helper"
require "foreman/engine"
require "foreman/export/upstart"
require "tmpdir"
describe Foreman::Export::Upstart, :fakefs do
let(:procfile) { write_procfile("/tmp/app/Procfile") }
let(:formation) { nil }
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/daemon_spec.rb | Ruby | mit | 6,149 | main | 3,786 | require "spec_helper"
require "foreman/engine"
require "foreman/export/daemon"
require "tmpdir"
describe Foreman::Export::Daemon, :fakefs do
let(:procfile) { write_procfile("/tmp/app/Procfile") }
let(:formation) { nil }
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
l... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/inittab_spec.rb | Ruby | mit | 6,149 | main | 1,241 | require "spec_helper"
require "foreman/engine"
require "foreman/export/inittab"
require "tmpdir"
describe Foreman::Export::Inittab, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:location) { "/tmp/inittab" }
let(:formation) { nil }
let(:engine) { Fore... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/base_spec.rb | Ruby | mit | 6,149 | main | 682 | require "spec_helper"
require "foreman/engine"
require "foreman/export"
describe "Foreman::Export::Base", :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:location) { "/tmp/init" }
let(:engine) { Foreman::Engine.new().load_procfile(procfile) }
let(:subject... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/launchd_spec.rb | Ruby | mit | 6,149 | main | 1,150 | require "spec_helper"
require "foreman/engine"
require "foreman/export/launchd"
require "tmpdir"
describe Foreman::Export::Launchd, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:options) { Hash.new }
let(:engine) { Foreman::Engine.new().load_procfile(pro... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/systemd_spec.rb | Ruby | mit | 6,149 | main | 6,435 | require "spec_helper"
require "foreman/engine"
require "foreman/export/systemd"
require "tmpdir"
describe Foreman::Export::Systemd, :fakefs, :aggregate_failures do
let(:procfile) { write_procfile("/tmp/app/Procfile") }
let(:formation) { nil }
let(:engine) { Foreman::Engine.new(:formation => formation).load_p... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/bluepill_spec.rb | Ruby | mit | 6,149 | main | 1,253 | require "spec_helper"
require "foreman/engine"
require "foreman/export/bluepill"
require "tmpdir"
describe Foreman::Export::Bluepill, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:formation) { nil }
let(:engine) { Foreman::Engine.new(:formation => forma... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/supervisord_spec.rb | Ruby | mit | 6,149 | main | 1,346 | require "spec_helper"
require "foreman/engine"
require "foreman/export/supervisord"
require "tmpdir"
describe Foreman::Export::Supervisord, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:formation) { nil }
let(:engine) { Foreman::Engine.new(:format... |
github | ddollar/foreman | https://github.com/ddollar/foreman | spec/foreman/export/runit_spec.rb | Ruby | mit | 6,149 | main | 1,844 | require "spec_helper"
require "foreman/engine"
require "foreman/export/runit"
require "tmpdir"
describe Foreman::Export::Runit, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile", 'bar=baz') }
let(:engine) { Foreman::Engine.new(:formation => "alpha=2,bravo=1").load_proc... |
github | venmo/synx | https://github.com/venmo/synx | synx.gemspec | Ruby | mit | 6,052 | master | 1,401 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'synx/version'
Gem::Specification.new do |spec|
spec.name = "synx"
spec.version = Synx::VERSION
spec.authors = ["Mark Larsen"]
spec.email = ["mark@venmo.com"]
... |
github | venmo/synx | https://github.com/venmo/synx | lib/synx/project.rb | Ruby | mit | 6,052 | master | 4,130 | require 'fileutils'
require 'xcodeproj'
module Synx
class Project < Xcodeproj::Project
SYNXRONIZE_DIR = File.join(ENV["HOME"], '.synx')
private_constant :SYNXRONIZE_DIR
DEFAULT_EXCLUSIONS = %W(/Libraries /Frameworks /Products /Pods)
private_constant :DEFAULT_EXCLUSIONS
attr_accessor :delayed_g... |
github | venmo/synx | https://github.com/venmo/synx | lib/synx/tabber.rb | Ruby | mit | 6,052 | master | 823 | module Synx
class Tabber
@options = {}
@tabbing = 0
class << self
def increase(n=1)
@tabbing += n
end
def decrease(n=1)
@tabbing -= n
@tabbing = 0 if @tabbing < 0
end
def current
@tabbing
end
def reset
@tabbing = 0
... |
github | venmo/synx | https://github.com/venmo/synx | lib/synx/xcodeproj_ext.rb | Ruby | mit | 6,052 | master | 258 | require "xcodeproj"
require "synx/xcodeproj_ext/project/object/pbx_file_reference"
require "synx/xcodeproj_ext/project/object/pbx_group"
require "synx/xcodeproj_ext/project/object/abstract_object"
require "synx/xcodeproj_ext/project/object/abstract_target" |
github | venmo/synx | https://github.com/venmo/synx | lib/synx/xcodeproj_ext/project/object/abstract_target.rb | Ruby | mit | 6,052 | master | 221 | module Xcodeproj
class Project
module Object
class AbstractTarget
def each_build_settings
build_configurations.each { |bc| yield bc.build_settings }
end
end
end
end
end |
github | venmo/synx | https://github.com/venmo/synx | lib/synx/xcodeproj_ext/project/object/pbx_file_reference.rb | Ruby | mit | 6,052 | master | 2,662 | module Xcodeproj
class Project
module Object
class PBXFileReference
def sync(group)
if should_sync?
if should_move?
FileUtils.mv(real_path.to_s, work_pathname.to_s)
# TODO: move out to abstract_object
self.source_tree = "<group>"
... |
github | venmo/synx | https://github.com/venmo/synx | lib/synx/xcodeproj_ext/project/object/abstract_object.rb | Ruby | mit | 6,052 | master | 1,810 | module Xcodeproj
class Project
module Object
class AbstractObject
def basename
name || path || Pathname(real_path).basename.to_s
end
def referring_groups
referrers.select { |ref| ref.is_a?(Xcodeproj::Project::Object::PBXGroup) }
end
def work_pat... |
github | venmo/synx | https://github.com/venmo/synx | lib/synx/xcodeproj_ext/project/object/pbx_group.rb | Ruby | mit | 6,052 | master | 5,249 | module Xcodeproj
class Project
module Object
class PBXGroup
def sync(group)
ensure_internal_consistency(group) # Make sure we don't belong to any other groups
if excluded_from_sync?
Synx::Tabber.puts "#{basename}/ (excluded)".yellow
else
Synx::T... |
github | venmo/synx | https://github.com/venmo/synx | spec/spec_helper.rb | Ruby | mit | 6,052 | master | 460 | require 'bundler/setup'
require 'synx'
require 'pry'
DUMMY_SYNX_PATH = File.expand_path('../dummy', __FILE__)
DUMMY_SYNX_TEST_PATH = File.expand_path('../test_dummy', __FILE__)
DUMMY_SYNX_TEST_PROJECT_PATH = File.join(DUMMY_SYNX_TEST_PATH, 'dummy.xcodeproj')
FileUtils.rm_rf(DUMMY_SYNX_TEST_PATH)
FileUtils.cp_r(DUMMY_S... |
github | venmo/synx | https://github.com/venmo/synx | spec/synx/tabber_spec.rb | Ruby | mit | 6,052 | master | 2,530 | require 'spec_helper'
describe Synx::Tabber do
before(:each) do
Synx::Tabber.reset
Synx::Tabber.options[:output] = output
end
let(:output) { StringIO.new }
describe "::increase" do
it "should default to increasing tabbing by 1" do
Synx::Tabber.increase
expect(Synx::Tabber.current).to... |
github | venmo/synx | https://github.com/venmo/synx | spec/synx/project_spec.rb | Ruby | mit | 6,052 | master | 9,881 | require 'spec_helper'
require 'fileutils'
require 'pathname'
require 'yaml'
class Hash
# Return a hash that includes everything but the given keys. This is useful for
# limiting a set of parameters to everything but a few known toggles:
#
# @person.update_attributes(params[:person].except(:admin))
#
# If... |
github | venmo/synx | https://github.com/venmo/synx | spec/synx/xcodeproj_ext/project/object/pbx_group_spec.rb | Ruby | mit | 6,052 | master | 868 | require 'spec_helper'
describe Xcodeproj::Project::Object::PBXGroup do
describe "groups_containing_forward_slash" do
before(:all) do
DUMMY_SYNX_TEST_PROJECT.send(:set_options, {})
end
after(:all) do
DUMMY_SYNX_TEST_PROJECT["top group"].remove_from_project
end
it "should return all... |
github | github/markup | https://github.com/github/markup | github-markup.gemspec | Ruby | mit | 6,022 | master | 1,268 | require File.expand_path("../lib/github-markup", __FILE__)
Gem::Specification.new do |s|
s.name = "github-markup"
s.version = GitHub::Markup::VERSION
s.summary = "The code GitHub uses to render README.markup"
s.description = <<~DESC
This gem is used by GitHub to render any fancy mark... |
github | github/markup | https://github.com/github/markup | Rakefile | Ruby | mit | 6,022 | master | 357 | #!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -I lib -r bundler/setup -r github... |
github | github/markup | https://github.com/github/markup | Gemfile | Ruby | mit | 6,022 | master | 609 | source "https://rubygems.org"
gemspec
gem "redcarpet", :platforms => :ruby
gem "kramdown", :platforms => :jruby
gem "RedCloth"
# using a tag version here because 0.18.3 was not published by the author to encourage users to upgrade.
# however we want to bump up to this version since this has a security patch
gem "commo... |
github | github/markup | https://github.com/github/markup | test/markup_test.rb | Ruby | mit | 6,022 | master | 6,044 | # encoding: utf-8
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
require 'github/markup'
require 'minitest/autorun'
require 'html/pipeline'
require 'nokogiri'
require 'nokogiri/diff'
def normalize_html(text)
text.strip
.gsub(/\s\s+/,' ')
.gsub(/\p{Pi}|\p{Pf}|&quot;/u,'"')
.gsub("\u2026... |
github | github/markup | https://github.com/github/markup | lib/github/markup.rb | Ruby | mit | 6,022 | master | 2,557 | begin
require "linguist"
rescue LoadError
# Rely on extensions instead.
end
require "github/markup/command_implementation"
require "github/markup/gem_implementation"
module GitHub
module Markups
# all of supported markups:
MARKUP_ASCIIDOC = :asciidoc
MARKUP_CREOLE = :creole
MARKUP_MARKDOWN = :ma... |
github | github/markup | https://github.com/github/markup | lib/github/markups.rb | Ruby | mit | 6,022 | master | 2,206 | require "github/markup/markdown"
require "github/markup/rdoc"
require "shellwords"
markup_impl(::GitHub::Markups::MARKUP_MARKDOWN, ::GitHub::Markup::Markdown.new)
markup(::GitHub::Markups::MARKUP_TEXTILE, :redcloth, /textile/, ["Textile"]) do |filename, content, options: {}|
RedCloth.new(content).to_html
end
marku... |
github | github/markup | https://github.com/github/markup | lib/github/markup/command_implementation.rb | Ruby | mit | 6,022 | master | 1,338 | require "open3"
require "github/markup/implementation"
module GitHub
module Markup
class CommandError < RuntimeError
end
class CommandImplementation < Implementation
attr_reader :command, :block, :name
def initialize(regexp, languages, command, name, &block)
super(regexp, languages... |
github | github/markup | https://github.com/github/markup | lib/github/markup/markdown.rb | Ruby | mit | 6,022 | master | 1,913 | require "github/markup/implementation"
module GitHub
module Markup
class Markdown < Implementation
MARKDOWN_GEMS = {
"commonmarker" => proc { |content, options: {}|
commonmarker_opts = [:GITHUB_PRE_LANG].concat(options.fetch(:commonmarker_opts, []))
commonmarker_exts = options.f... |
github | github/markup | https://github.com/github/markup | lib/github/markup/gem_implementation.rb | Ruby | mit | 6,022 | master | 636 | require "github/markup/implementation"
module GitHub
module Markup
class GemImplementation < Implementation
attr_reader :gem_name, :renderer
def initialize(regexp, languages, gem_name, &renderer)
super(regexp, languages)
@gem_name = gem_name.to_s
@renderer = renderer
en... |
github | github/markup | https://github.com/github/markup | lib/github/markup/rdoc.rb | Ruby | mit | 6,022 | master | 521 | require "github/markup/implementation"
require "rdoc"
require "rdoc/markup/to_html"
module GitHub
module Markup
class RDoc < Implementation
def initialize
super(/rdoc/, ["RDoc"])
end
def render(filename, content, options: {})
if ::RDoc::VERSION.to_i >= 4
h = ::RDoc::M... |
github | github/markup | https://github.com/github/markup | lib/github/markup/implementation.rb | Ruby | mit | 6,022 | master | 928 | module GitHub
module Markup
class Implementation
attr_reader :regexp
attr_reader :languages
def initialize(regexp, languages)
@regexp = regexp
if defined?(::Linguist)
@languages = languages.map do |l|
lang = Linguist::Language[l]
raise "no matc... |
github | lostisland/faraday | https://github.com/lostisland/faraday | Gemfile | Ruby | mit | 5,928 | main | 725 | # frozen_string_literal: true
source 'https://rubygems.org'
# Even though we don't officially support JRuby, this dependency makes Faraday
# compatible with it, so we're leaving it in for jruby users to use it.
gem 'jruby-openssl', '~> 0.11.0', platforms: :jruby
group :development, :test do
gem 'bake-test-external... |
github | lostisland/faraday | https://github.com/lostisland/faraday | faraday.gemspec | Ruby | mit | 5,928 | main | 1,697 | # frozen_string_literal: true
require_relative 'lib/faraday/version'
Gem::Specification.new do |spec|
spec.name = 'faraday'
spec.version = Faraday::VERSION
spec.summary = 'HTTP/REST API client library.'
spec.authors = ['@technoweenie', '@iMacTia', '@olleolleolle']
spec.email = 'technoweenie@gmail.c... |
github | lostisland/faraday | https://github.com/lostisland/faraday | Rakefile | Ruby | mit | 5,928 | main | 209 | # frozen_string_literal: true
require 'rspec/core/rake_task'
require 'bundler'
Bundler::GemHelper.install_tasks
RSpec::Core::RakeTask.new(:spec) do |task|
task.ruby_opts = %w[-W]
end
task default: :spec |
github | lostisland/faraday | https://github.com/lostisland/faraday | spec/spec_helper.rb | Ruby | mit | 5,928 | main | 5,636 | # frozen_string_literal: true
# This file was generated by the `rspec --init` 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 expl... |
github | lostisland/faraday | https://github.com/lostisland/faraday | spec/faraday_spec.rb | Ruby | mit | 5,928 | main | 1,280 | # frozen_string_literal: true
RSpec.describe Faraday do
it 'has a version number' do
expect(Faraday::VERSION).not_to be nil
end
context 'proxies to default_connection' do
let(:mock_connection) { double('Connection') }
before do
Faraday.default_connection = mock_connection
end
it 'prox... |
github | lostisland/faraday | https://github.com/lostisland/faraday | spec/faraday/error_spec.rb | Ruby | mit | 5,928 | main | 7,749 | # frozen_string_literal: true
RSpec.describe Faraday::Error do
describe '.initialize' do
subject { described_class.new(exception, response) }
let(:response) { nil }
context 'with exception only' do
let(:exception) { RuntimeError.new('test') }
it { expect(subject.wrapped_exception).to eq(exc... |
github | lostisland/faraday | https://github.com/lostisland/faraday | spec/faraday/utils_spec.rb | Ruby | mit | 5,928 | main | 3,337 | # frozen_string_literal: true
RSpec.describe Faraday::Utils do
describe 'headers parsing' do
let(:multi_response_headers) do
"HTTP/1.x 500 OK\r\nContent-Type: text/html; charset=UTF-8\r\n" \
"HTTP/1.x 200 OK\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n"
end
it 'parse headers fo... |
github | lostisland/faraday | https://github.com/lostisland/faraday | spec/faraday/connection_spec.rb | Ruby | mit | 5,928 | main | 26,209 | # frozen_string_literal: true
class CustomEncoder
def encode(params)
params.map { |k, v| "#{k.upcase}-#{v.to_s.upcase}" }.join(',')
end
def decode(params)
params.split(',').to_h { |pair| pair.split('-') }
end
end
shared_examples 'initializer with url' do
context 'with simple url' do
let(:addres... |
github | lostisland/faraday | https://github.com/lostisland/faraday | spec/faraday/middleware_registry_spec.rb | Ruby | mit | 5,928 | main | 1,087 | # frozen_string_literal: true
RSpec.describe Faraday::MiddlewareRegistry do
before do
stub_const('CustomMiddleware', custom_middleware_klass)
end
let(:custom_middleware_klass) { Class.new(Faraday::Middleware) }
let(:dummy) { Class.new { extend Faraday::MiddlewareRegistry } }
after { dummy.unregister_mid... |
github | lostisland/faraday | https://github.com/lostisland/faraday | spec/faraday/middleware_spec.rb | Ruby | mit | 5,928 | main | 8,732 | # frozen_string_literal: true
RSpec.describe Faraday::Middleware do
subject { described_class.new(app) }
let(:app) { double }
describe 'options' do
context 'when options are passed to the middleware' do
subject { described_class.new(app, options) }
let(:options) { { field: 'value' } }
it ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.