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 | MartinJNash/Royce | https://github.com/MartinJNash/Royce | royce.gemspec | Ruby | mit | 209 | master | 851 | $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "royce/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "royce"
s.version = Royce::VERSION
s.authors = ["Martin Nash"]
s.email = ["martin.j.nash@gmail.com"]... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | Rakefile | Ruby | mit | 209 | master | 571 | 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 = 'Royce'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | lib/royce/connector.rb | Ruby | mit | 209 | master | 235 | module Royce
# Connects many roleables and roles
class Connector < ::ActiveRecord::Base
self.table_name = 'royce_connector'
belongs_to :roleable, polymorphic: true
belongs_to :role, class_name: 'Royce::Role'
end
end |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | lib/royce/class_methods.rb | Ruby | mit | 209 | master | 1,129 | module Royce
module ClassMethods
def self.included includer
includer_name = includer.model_name.to_s
includer_pluralized_name = includer_name.underscore.pluralize.to_sym
includer.class_eval do
# Add relations to including class
has_many :role_connectors, as: :roleable, class_na... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | lib/royce/macros.rb | Ruby | mit | 209 | master | 1,109 | module Royce
module Macros
extend ActiveSupport::Concern
module ClassMethods
# How a class opts in to roller
# Pass an array of roles
def royce_roles(roles)
role_strings = roles.map(&:to_s)
confirm_roles_exist role_strings
# Work in singleton class
# Add a... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | lib/royce/methods.rb | Ruby | mit | 209 | master | 1,246 | module Royce
module Methods
# Called when module included in a class
# includer == User
# includer.class == Class
def self.included includer
# With instance eval, we can add instance methods
# Add instance methods like user? admin?
includer.instance_eval do
# Loop through a... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | lib/royce/role.rb | Ruby | mit | 209 | master | 214 | module Royce
# The actual data model
class Role < ::ActiveRecord::Base
self.table_name = 'royce_role'
has_many :connectors, class_name: 'Royce::Connector'
def to_s
name
end
end
end |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | lib/generators/royce/install_generator.rb | Ruby | mit | 209 | master | 535 | require 'rails/generators'
require 'rails/generators/active_record'
module Royce
class InstallGenerator < ::Rails::Generators::Base
include ::Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
desc 'Generates DB migration files for Royce'
def create_migration_file
... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | lib/generators/royce/templates/create_royce.rb | Ruby | mit | 209 | master | 474 | class CreateRoyce < ActiveRecord::Migration
def change
create_table :royce_connector do |t|
t.references :roleable, polymorphic: true, null: false
t.references :role, null: false
t.timestamps
end
add_index :royce_connector, [:roleable_id, :roleable_type]
add_index :royce_connector... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | test/scopes_test.rb | Ruby | mit | 209 | master | 1,831 | require 'test_helper'
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Migration.verbose = false
ActiveRecord::Migration.create_table :employees
ActiveRecord::Migration.create_table :baby_boomers
load "dummy/db/schema.rb"
ActiveRecord::Migrator.up "db/migrate"
def human_r... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | test/test_helper.rb | Ruby | mit | 209 | master | 508 | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
require "minitest/rails"
require "pry"
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| req... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | test/roller_test.rb | Ruby | mit | 209 | master | 3,104 | require 'test_helper'
describe "Basic tests" do
before do
User.delete_all
end
def user
@user ||= User.create
end
it 'can create role' do
role = Royce::Role.create(name: 'some_role')
role.wont_be_nil
end
it 'Can create user' do
User.create.wont_be_nil
end
it 'Creates roles aut... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | test/dummy/scopes_test.rb | Ruby | mit | 209 | master | 1,820 | require 'test_helper'
# ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
# ActiveRecord::Migration.create_table :employees
# ActiveRecord::Migration.create_table :baby_boomers
# load "dummy/db/schema.rb"
# ActiveRecord::Migrator.up "db/migrate"
# def human_roles
# %w( partier rocker... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | test/dummy/db/schema.rb | Ruby | mit | 209 | master | 1,592 | # 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 | MartinJNash/Royce | https://github.com/MartinJNash/Royce | test/dummy/config/application.rb | Ruby | mit | 209 | master | 879 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
require "royce"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/init... |
github | MartinJNash/Royce | https://github.com/MartinJNash/Royce | test/dummy/config/environments/production.rb | Ruby | mit | 209 | master | 3,313 | 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 | alno/irwi | https://github.com/alno/irwi | Rakefile | Ruby | mit | 209 | master | 454 | require 'rspec/core/rake_task'
desc 'Default: run specs.'
task default: :spec
desc "Run specs"
RSpec::Core::RakeTask.new do |t|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
# Put spec opts in a file named .rspec in root
end
desc "Generate code coverage"
RSpec::Core::RakeTask.new(:coverage) ... |
github | alno/irwi | https://github.com/alno/irwi | irwi.gemspec | Ruby | mit | 209 | master | 1,388 | require File.expand_path("../lib/irwi/version", __FILE__)
Gem::Specification.new do |s|
s.name = "irwi"
s.version = Irwi::VERSION::STRING
s.platform = Gem::Platform::RUBY
s.authors = ["Alexey Noskov", "Ravi Bhim"]
s.email = ["alexey.noskov@gmail.com", "ravi.bhim@yahoo.com"]
s.homepage = "http://github.com/... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi.rb | Ruby | mit | 209 | master | 969 | require 'active_support/dependencies'
require 'rails_autolink' if defined?(Rails)
module Irwi
module Support
autoload :TemplateFinder, 'irwi/support/template_finder'
autoload :Autodetector, 'irwi/support/autodetector'
end
module Comparators
autoload :DiffLcs, 'irwi/comparators/diff_lcs'
autoload... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/helpers.rb | Ruby | mit | 209 | master | 386 | module Irwi::Helpers
autoload :WikiPagesHelper, 'irwi/helpers/wiki_pages_helper'
autoload :WikiPageAttachmentsHelper, 'irwi/helpers/wiki_page_attachments_helper'
end
Module.class_eval do
def acts_as_wiki_pages_helper(_config = {})
include Irwi::Helpers::WikiPagesHelper
include Irwi::Helpers::WikiPageAtta... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/config.rb | Ruby | mit | 209 | master | 1,597 | require 'active_support'
class Irwi::Config
attr_accessor :controller_name
attr_accessor :user_class_name
attr_accessor :page_class_name
attr_accessor :page_version_class_name
attr_accessor :page_attachment_class_name
attr_accessor :page_version_foreign_key
# Object using to format content
attr_writer... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/extensions/models.rb | Ruby | mit | 209 | master | 632 | require 'active_record'
module Irwi::Extensions::Models
autoload :WikiPage, 'irwi/extensions/models/wiki_page'
autoload :WikiPageVersion, 'irwi/extensions/models/wiki_page_version'
autoload :WikiPageAttachment, 'irwi/extensions/models/wiki_page_attachment'
end
ActiveRecord::Base.instance_eval do
def acts_as_w... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/extensions/controllers.rb | Ruby | mit | 209 | master | 558 | require 'action_controller'
module Irwi::Extensions::Controllers
autoload :WikiPages, 'irwi/extensions/controllers/wiki_pages'
autoload :WikiPageAttachments, 'irwi/extensions/controllers/wiki_page_attachments'
end
ActionController::Base.instance_eval do
# @param config [Hash] config for controller class
# @op... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/extensions/controllers/wiki_pages.rb | Ruby | mit | 209 | master | 5,131 | module Irwi::Extensions::Controllers::WikiPages
extend ActiveSupport::Concern
module ClassMethods
def page_class
@page_class ||= Irwi.config.page_class
end
def set_page_class(arg)
@page_class = arg
end
end
include Irwi::Extensions::Controllers::WikiPageAttachments
include Irwi::... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/extensions/controllers/wiki_page_attachments.rb | Ruby | mit | 209 | master | 655 | module Irwi::Extensions::Controllers::WikiPageAttachments
def add_attachment
attachment = page_attachment_class.new(permitted_page_attachment_params)
attachment.save!
redirect_to url_for(path: attachment.page.path, action: :edit)
end
def remove_attachment
attachment = page_attachment_class.find(p... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/extensions/models/wiki_page_attachment.rb | Ruby | mit | 209 | master | 263 | module Irwi::Extensions::Models::WikiPageAttachment
extend ActiveSupport::Concern
DEFAULT_PAPERCLIP_OPTIONS = { styles: { medium: "300x300>", thumb: "100x100>" } }.freeze
included do
belongs_to :page, class_name: Irwi.config.page_class_name
end
end |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/extensions/models/wiki_page.rb | Ruby | mit | 209 | master | 1,211 | module Irwi::Extensions::Models::WikiPage
extend ActiveSupport::Concern
module ClassMethods
def find_by_path_or_new(path)
find_by_path(path) || new(path: path, title: CGI.unescape(path))
end
end
# Retrieve number of last version
def last_version_number
last = versions.first
last ? last... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/extensions/models/wiki_page_version.rb | Ruby | mit | 209 | master | 818 | module Irwi::Extensions::Models::WikiPageVersion
extend ActiveSupport::Concern
def next
self.class.first conditions: ["id > ? AND page_id = ?", id, page_id], order: 'id ASC'
end
def previous
self.class.first conditions: ["id < ? AND page_id = ?", id, page_id], order: 'id DESC'
end
private
def ... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/formatters/red_carpet.rb | Ruby | mit | 209 | master | 258 | class Irwi::Formatters::RedCarpet
def initialize
require 'redcarpet'
end
def format(text)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, space_after_headers: true, tables: true)
markdown.render(text)
end
end |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/paginators/kaminari.rb | Ruby | mit | 209 | master | 304 | class Irwi::Paginators::Kaminari
def initialize
require 'kaminari'
end
def paginate(collection, options = {})
collection.page(options[:page])
end
def paginated_section(view, collection, &block)
pager = view.paginate(collection)
pager + view.capture(&block) + pager
end
end |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/paginators/will_paginate.rb | Ruby | mit | 209 | master | 277 | class Irwi::Paginators::WillPaginate
def initialize
require 'will_paginate'
end
def paginate(collection, options = {})
collection.paginate(options)
end
def paginated_section(view, collection, &block)
view.paginated_section(collection, &block)
end
end |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/paginators/none.rb | Ruby | mit | 209 | master | 218 | require 'active_support/core_ext/hash'
class Irwi::Paginators::None
def paginate(collection, _options = {})
collection.all
end
def paginated_section(_view, _collection, &_block)
yield
nil
end
end |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/comparators/base.rb | Ruby | mit | 209 | master | 485 | require 'irwi/comparators/spans/changed_span'
require 'irwi/comparators/spans/not_changed_span'
class Irwi::Comparators::Base
def render_changes(old_text, new_text)
build_changes(old_text, new_text).join('').gsub(/\r?\n/, '<br />')
end
protected
def new_not_changed(value)
Irwi::Comparators::Spans::No... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/comparators/diff_lcs.rb | Ruby | mit | 209 | master | 2,057 | require 'irwi/comparators/base'
class Irwi::Comparators::DiffLcs < Irwi::Comparators::Base
def initialize
super
require 'diff/lcs'
end
def build_changes(old_text, new_text)
old_text ||= ''
new_text ||= ''
# Build symmetric diff sequence
diffs = Diff::LCS.sdiff(old_text.mb_chars, new_te... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/comparators/spans/not_changed_span.rb | Ruby | mit | 209 | master | 227 | class Irwi::Comparators::Spans::NotChangedSpan
attr_accessor :value
def initialize(v)
@value = v
end
def to_s
@value.to_s
end
def action
'='
end
alias old_value value
alias new_value value
end |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/comparators/spans/changed_span.rb | Ruby | mit | 209 | master | 364 | class Irwi::Comparators::Spans::ChangedSpan
attr_accessor :action, :old_value, :new_value
def initialize(act, ov, nv)
@action = act
@old_value = ov
@new_value = nv
end
def to_s
s = ''
s << "<span class=\"removed\">#{@old_value}</span>" if @old_value
s << "<span class=\"added\">#{@new_v... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/support/route_mapper.rb | Ruby | mit | 209 | master | 1,404 | require 'action_dispatch'
module Irwi::Support::RouteMapper
# Defining wiki root mount point
def wiki_root(root, config = {})
opts = {
controller: 'wiki_pages',
root: root
}.merge(config)
Irwi.config.system_pages.each do |page_action, page_path| # Adding routes for system pages
get("... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/support/autodetector.rb | Ruby | mit | 209 | master | 438 | require 'active_support/concern'
module Irwi::Support::Autodetector
extend ActiveSupport::Concern
included do
const_get(:PROVIDERS).each do |fmt|
autoload fmt.classify.to_sym, "#{name.underscore}/#{fmt}"
end
end
module ClassMethods
def autodetect
const_get(:PROVIDERS).each do |f|
... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/support/template_finder.rb | Ruby | mit | 209 | master | 321 | module Irwi::Support::TemplateFinder
def template_dir(template)
dir = respond_to?(:controller_path) ? controller_path : controller.controller_path
dir = 'base_wiki_pages' if Dir.glob("app/views/#{dir}/#{template}.html.*").empty? # Select default if there are no template in resource directory
dir
end
end |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/helpers/wiki_page_attachments_helper.rb | Ruby | mit | 209 | master | 782 | require 'active_record/errors'
module Irwi::Helpers::WikiPageAttachmentsHelper
def wiki_add_page_attachment_path(page)
page = page.path if page.respond_to? :path
url_for(action: 'add_attachment', path: page)
end
def wiki_remove_page_attachment_path(attachment_id)
url_for(action: 'remove_attachment',... |
github | alno/irwi | https://github.com/alno/irwi | lib/irwi/helpers/wiki_pages_helper.rb | Ruby | mit | 209 | master | 3,720 | module Irwi::Helpers::WikiPagesHelper
include Irwi::Support::TemplateFinder
include Irwi::Helpers::WikiPageAttachmentsHelper
# Edit form for wiki page model
def wiki_page_form(config = {}, &block)
form_for(@page, { as: :page, url: url_for(action: :update), html: { class: 'wiki_form', method: :post } }.merg... |
github | alno/irwi | https://github.com/alno/irwi | lib/generators/irwi_wiki_attachments/irwi_wiki_attachments_generator.rb | Ruby | mit | 209 | master | 787 | require 'rails/generators/active_record'
class IrwiWikiAttachmentsGenerator < Rails::Generators::Base
include Rails::Generators::Migration
extend ActiveRecord::Generators::Migration
source_root File.expand_path("../templates", __FILE__)
def generate_attachments
%w(create_wiki_page_attachments).each do |m... |
github | alno/irwi | https://github.com/alno/irwi | lib/generators/irwi_wiki_attachments/templates/models/wiki_page_attachment.rb | Ruby | mit | 209 | master | 487 | require 'paperclip'
class WikiPageAttachment < ActiveRecord::Base
acts_as_wiki_page_attachment do
has_attached_file :wiki_page_attachment, styles: { medium: "300x300>", thumb: "100x100>" }
validates_attachment_presence :wiki_page_attachment, message: " is missing."
validates_attachment_content_type :wiki... |
github | alno/irwi | https://github.com/alno/irwi | lib/generators/irwi_wiki_attachments/templates/migrate/create_wiki_page_attachments.rb | Ruby | mit | 209 | master | 426 | class CreateWikiPageAttachments < ActiveRecord::Migration
def self.up
create_table :wiki_page_attachments do |t|
t.integer :page_id, null: false # Reference to page
t.string :wiki_page_attachment_file_name
t.string :wiki_page_attachment_content_type
t.integer :wiki_page_attachment_fil... |
github | alno/irwi | https://github.com/alno/irwi | lib/generators/irwi_wiki_views/irwi_wiki_views_generator.rb | Ruby | mit | 209 | master | 436 | class IrwiWikiViewsGenerator < Rails::Generators::Base
source_root File.expand_path("../../../../app/views/base_wiki_pages", __FILE__)
def views
empty_directory 'app/views/base_wiki_pages'
Dir.foreach File.expand_path("../../../../app/views/base_wiki_pages", __FILE__) do |file| # Searching for files in ap... |
github | alno/irwi | https://github.com/alno/irwi | lib/generators/irwi_wiki/irwi_wiki_generator.rb | Ruby | mit | 209 | master | 860 | require 'rails/generators/active_record'
class IrwiWikiGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path("../templates", __FILE__)
def generate_wiki
# Controllers
copy_file 'controllers/wiki_pages_controller.rb', 'app/controllers/wiki_pages_controller... |
github | alno/irwi | https://github.com/alno/irwi | lib/generators/irwi_wiki/templates/migrate/create_wiki_pages.rb | Ruby | mit | 209 | master | 901 | class CreateWikiPages < ActiveRecord::Migration
def self.up
create_table :wiki_pages do |t|
t.integer :creator_id
t.integer :updator_id
t.string :path
t.string :title
t.text :content, limit: 268_435_456
t.timestamps
end
add_index :wiki_pages, :creator_id
add_ind... |
github | alno/irwi | https://github.com/alno/irwi | spec/config_spec.rb | Ruby | mit | 209 | master | 2,049 | require "spec_helper"
describe Irwi::Config do
specify "should save selected user_class_name" do
subject.user_class_name = 'MyUserClass'
expect(subject.user_class_name).to eq 'MyUserClass'
end
specify "should select 'User' as user_class_name by default" do
expect(subject.user_class_name).to eq 'User... |
github | alno/irwi | https://github.com/alno/irwi | spec/spec_helper.rb | Ruby | mit | 209 | master | 958 | require 'rubygems'
require 'active_support/test_case'
require 'active_record'
require 'irwi'
require 'irwi/config'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
ActiveRecord::Base.estab... |
github | alno/irwi | https://github.com/alno/irwi | spec/extensions/models/wiki_page_spec.rb | Ruby | mit | 209 | master | 1,497 | require "spec_helper"
require "active_record"
describe Irwi::Extensions::Models::WikiPage do
class AbstractPage < ActiveRecord::Base
def self.columns
c = ActiveRecord::ConnectionAdapters::Column
[
c.new("title", nil, "string", false),
c.new("path", nil, "string", false),
c.n... |
github | alno/irwi | https://github.com/alno/irwi | spec/extensions/controllers/wiki_pages_spec.rb | Ruby | mit | 209 | master | 1,387 | require "spec_helper"
require "action_controller"
describe Irwi::Extensions::Controllers::WikiPages do
class WikiPage; end
class WikiPagesController < ActionController::Base
include Irwi::Extensions::Controllers::WikiPages
private
def current_user
'Some user'
end
end
it { is_expected.... |
github | alno/irwi | https://github.com/alno/irwi | spec/formatters/red_cloth_spec.rb | Ruby | mit | 209 | master | 313 | require "spec_helper"
describe Irwi::Formatters::RedCloth do
specify "should proces bold text" do
expect(subject.format('*Place* ff')).to eq('<p><strong>Place</strong> ff</p>')
end
specify "should proces italic text" do
expect(subject.format('_Mom_ ff')).to eq('<p><em>Mom</em> ff</p>')
end
end |
github | alno/irwi | https://github.com/alno/irwi | spec/comparators/diff_lcs_spec.rb | Ruby | mit | 209 | master | 1,444 | require "spec_helper"
describe Irwi::Comparators::DiffLcs do
specify "should render change for replaced text" do
expect(subject.render_changes('AAA', 'BbB')).to eq('<span class="removed">AAA</span><span class="added">BbB</span>')
end
specify "should render no changes for same text" do
expect(subject.ren... |
github | alno/irwi | https://github.com/alno/irwi | spec/paginators/none_spec.rb | Ruby | mit | 209 | master | 456 | require "spec_helper"
describe Irwi::Paginators::None do
specify "should paginate collection - call find" do
coll = double "Collection"
expect(coll).to receive(:all).and_return("full collection")
expect(subject.paginate(coll, page: 10)).to eq("full collection")
end
specify "should render paginated ... |
github | alno/irwi | https://github.com/alno/irwi | spec/paginators/will_paginate_spec.rb | Ruby | mit | 209 | master | 599 | require "spec_helper"
describe Irwi::Paginators::WillPaginate do
specify "should paginate collection" do
coll = double "Collection"
expect(coll).to receive(:paginate).with(page: 15).and_return("paginated_collection")
expect(subject.paginate(coll, page: 15)).to eq("paginated_collection")
end
specify... |
github | alno/irwi | https://github.com/alno/irwi | spec/helpers/wiki_page_attachments_helper_spec.rb | Ruby | mit | 209 | master | 1,503 | require "spec_helper"
describe Irwi::Helpers::WikiPageAttachmentsHelper do
it { is_expected.not_to be_nil }
context "included in class" do
subject { Object.new }
before(:each) do
Irwi.config.page_attachment_class_name = 'WikiPageAttachment'
subject.send :extend, Irwi::Helpers::WikiPagesHelpe... |
github | alno/irwi | https://github.com/alno/irwi | spec/helpers/wiki_pages_helper_spec.rb | Ruby | mit | 209 | master | 8,141 | require "spec_helper"
class PageAttachment < ActiveRecord::Base
end
describe Irwi::Helpers::WikiPagesHelper do
it { is_expected.not_to be_nil }
context "included in class" do
subject do
ActionView::Base.new.tap do |v|
v.send :extend, ERB::Util
v.send :extend, described_class
end
... |
github | alno/irwi | https://github.com/alno/irwi | spec/support/template_finder_spec.rb | Ruby | mit | 209 | master | 1,000 | require "spec_helper"
describe Irwi::Support::TemplateFinder do
it { is_expected.not_to be_nil }
context "included in class" do
subject { Object.new }
before(:each) do
subject.send :extend, described_class
allow(subject).to receive(:controller_path).and_return('my_controller')
end
s... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | Gemfile | Ruby | mit | 209 | main | 229 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in rails-diff.gemspec
gemspec
gem "simplecov", require: false
gem "standard", "~> 1.0"
gem "rake", "~> 13.0"
gem "rspec", "~> 3.0" |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | rails-diff.gemspec | Ruby | mit | 209 | main | 1,804 | # frozen_string_literal: true
require_relative "lib/rails/diff/version"
Gem::Specification.new do |spec|
spec.name = "rails-diff"
spec.version = Rails::Diff::VERSION
spec.authors = ["Matheus Richard"]
spec.email = ["matheusrichardt@gmail.com"]
spec.summary = "Compare Rails-generated files with the ones in ... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | spec/spec_helper.rb | Ruby | mit | 209 | main | 523 | # frozen_string_literal: true
require "simplecov"
SimpleCov.start do
enable_coverage :branch
add_filter "/spec/"
end
require "rails/diff"
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persiste... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | spec/lib/rails/diff_spec.rb | Ruby | mit | 209 | main | 5,402 | # frozen_string_literal: true
RSpec.describe Rails::Diff do
let(:template_dir) { Dir.mktmpdir }
let(:repo_dir) { Dir.mktmpdir("repo") }
around do |example|
Dir.chdir(repo_dir) { example.run }
ensure
FileUtils.rm_rf(template_dir)
FileUtils.rm_rf(repo_dir)
end
def mock_generator(template_path: ... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | spec/lib/rails/diff/cli_spec.rb | Ruby | mit | 209 | main | 1,681 | # frozen_string_literal: true
# require "spec_helper"
RSpec.describe Rails::Diff::CLI do
describe "#file" do
context "when --fail-on-diff is not specified" do
it "exits successfully" do
allow(Rails::Diff).to receive(:file).with("some_file.rb", kind_of(Hash)).and_return("diff output")
expe... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | spec/lib/rails/diff/rails_app_generator_spec.rb | Ruby | mit | 209 | main | 7,745 | # frozen_string_literal: true
require "rails/diff/rails_app_generator"
RSpec.describe Rails::Diff::RailsAppGenerator do
let(:cache_dir) { Dir.mktmpdir }
let(:work_dir) { Dir.mktmpdir("myapp") }
around do |example|
original_home = ENV["HOME"]
ENV["HOME"] = work_dir
Dir.chdir(work_dir) { example.run ... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | spec/lib/rails/diff/rails_repo_spec.rb | Ruby | mit | 209 | main | 5,786 | # Helper indices for commits:
# @git_repo.commits[0] => 'add railties dir' (initial commit)
# @git_repo.commits[1] => 'commit1'
# @git_repo.commits.last => 'commit2'
require "rails/diff/rails_repo"
require "fileutils"
require "tmpdir"
RSpec.describe Rails::Diff::RailsRepo do
let(:logger) { spy }
let(:cache_... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | spec/integration/rails/diff/file_tracker_spec.rb | Ruby | mit | 209 | main | 2,207 | # frozen_string_literal: true
require "rails/diff/file_tracker"
RSpec.describe Rails::Diff::FileTracker do
let(:temp_dir) { Dir.mktmpdir }
after do
FileUtils.remove_entry(temp_dir)
end
it "tracks newly created files" do
FileUtils.touch("#{temp_dir}/file1.rb")
new_files = described_class.new_fil... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | spec/support/git_repo.rb | Ruby | mit | 209 | main | 1,998 | require "fileutils"
require "tmpdir"
class GitRepo
attr_reader :remote_repo, :commits
# Initializes and creates a bare remote repo and a working repo with main branch
def initialize
@remote_dir = Dir.mktmpdir
@remote_repo = File.join(@remote_dir, "origin.git")
Dir.chdir(@remote_dir) { `git init --ba... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | lib/rails/diff.rb | Ruby | mit | 209 | main | 2,804 | # frozen_string_literal: true
require "rails"
require "difftastic"
require "fileutils"
require_relative "diff/cli"
require_relative "diff/file_tracker"
require_relative "diff/logger"
require_relative "diff/shell"
require_relative "diff/rails_app_generator"
require_relative "diff/rails_repo"
require_relative "diff/vers... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | lib/rails/diff/logger.rb | Ruby | mit | 209 | main | 372 | module Rails
module Diff
module Logger
extend self
def info(message)
puts "\e[1;34minfo:\e[0m\t#{message}"
end
def debug(message)
return unless ENV["DEBUG"]
puts "\e[1;33mdebug:\e[0m\t#{message}"
end
def error(label, message)
warn "\e[1;31m#{... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | lib/rails/diff/rails_app_generator.rb | Ruby | mit | 209 | main | 3,028 | require "digest"
module Rails
module Diff
class RailsAppGenerator
def initialize(ref: nil, new_app_options: nil, no_cache: false, logger: Logger, cache_dir: Rails::Diff::CACHE_DIR, rails_repo: RailsRepo.new(logger:, cache_dir:))
@new_app_options = new_app_options.to_s.split
@rails_repo = ra... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | lib/rails/diff/cli.rb | Ruby | mit | 209 | main | 3,124 | require "thor"
module Rails
module Diff
class CLI < Thor
class_option :no_cache, type: :boolean, desc: "Clear cache before running", aliases: ["--clear-cache"]
class_option :fail_on_diff, type: :boolean, desc: "Fail if there are differences"
class_option :ref, type: :string, desc: "Compare agai... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | lib/rails/diff/file_tracker.rb | Ruby | mit | 209 | main | 854 | # frozen_string_literal: true
module Rails
module Diff
module FileTracker
DEFAULT_EXCLUSIONS = %w[.git tmp log test].freeze
def self.new_files(base_dir, only:, skip: [])
files_before = list_files(base_dir)
yield
files_after = list_files(base_dir, skip:, only:)
files_a... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | lib/rails/diff/shell.rb | Ruby | mit | 209 | main | 450 | # frozen_string_literal: true
require "open3"
module Rails
module Diff
module Shell
extend self
def run!(*cmd, logger:, abort: true)
_, stderr, status = Open3.capture3(*cmd)
logger.debug(cmd.join(" "))
if status.success?
true
elsif abort
logger.er... |
github | MatheusRich/rails-diff | https://github.com/MatheusRich/rails-diff | lib/rails/diff/rails_repo.rb | Ruby | mit | 209 | main | 2,561 | module Rails
module Diff
class RailsRepo
RAILS_REPO = "https://github.com/rails/rails.git"
def initialize(logger:, cache_dir: Rails::Diff::CACHE_DIR, rails_repo: RAILS_REPO)
@logger = logger
@cache_dir = cache_dir
@rails_repo = rails_repo
end
def checkout(ref)
... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | Gemfile | Ruby | mit | 209 | master | 636 | source 'https://rubygems.org'
# Add dependencies required to use your gem here.
# Example:
# gem 'activesupport', '>= 2.3.5'
gem 'awesome_print', '~> 1.9.2', require: false
# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem 'rspec'... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | puts_debuggerer.gemspec | Ruby | mit | 209 | master | 3,124 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: puts_debuggerer 1.0.1 ruby lib
Gem::Specification.new do |s|
s.name = "puts_debuggerer".freeze
s.version = "1.0.1".freeze
s.required_rubygems_version = Gem... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | Rakefile | Ruby | mit | 209 | master | 2,709 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/spec_helper.rb | Ruby | mit | 209 | master | 1,364 | # require 'simplecov'
# require 'simplecov-lcov'
# require 'coveralls' if ENV['TRAVIS']
#
# SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
# formatters = []
# formatters << SimpleCov::Formatter::LcovFormatter
# formatters << Coveralls::SimpleCov::Formatter if ENV['TRAVIS']
# SimpleCov.formatt... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_piecemeal_options__spec.rb | Ruby | mit | 209 | master | 13,592 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with piecemeal options' do
before do
load "awesome_print/core_ext/kern... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_custom_formatter__spec.rb | Ruby | mit | 209 | master | 1,911 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with custom formatter' do
before do
PutsDebuggerer.header = true # kee... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_custom_announcer__spec.rb | Ruby | mit | 209 | master | 1,134 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with custom announcer' do
let(:custom_announcer) {'<PD>'}
before do
... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_rails__spec.rb | Ruby | mit | 209 | master | 2,373 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with rails' do
before do
load "awesome_print/core_ext/kernel.rb"
... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_irb_support__spec.rb | Ruby | mit | 209 | master | 1,775 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'irb support' do
after do
Object.send(:remove_const, :IRB)
end
... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_custom_print_engine__spec.rb | Ruby | mit | 209 | master | 3,305 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with custom print engine' do
let(:expected_object_printout) {
"[\n ... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_wrapper_support_enabled__spec.rb | Ruby | mit | 209 | master | 2,596 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with wrapper support enabled' do
context 'as default wrapper' do
befor... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer_spec.rb | Ruby | mit | 209 | master | 4,699 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
it 'prints file, line number, ruby expression, and evaluated string object; returns ev... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_custom_printer__spec.rb | Ruby | mit | 209 | master | 7,932 | require 'ostruct'
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
before do
now = Time.new(2000, 1, 1, 1, 1, 1, 1)
Time.stub(:... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_header_support_enabled__spec.rb | Ruby | mit | 209 | master | 2,459 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with header support enabled' do
context 'as default header' do
before ... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__exception_cases__spec.rb | Ruby | mit | 209 | master | 1,171 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
before do
$stdout = StringIO.new
PutsDebuggerer.print_engine = :p
end
c... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_footer_support_enabled__spec.rb | Ruby | mit | 209 | master | 2,459 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with footer support enabled' do
context 'as default footer' do
before ... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_run_at_support__spec.rb | Ruby | mit | 209 | master | 17,538 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with run_at specified' do
context 'as an index' do
it 'skips first ... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_caller_backtrace__spec.rb | Ruby | mit | 209 | master | 1,569 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with caller backtrace' do
before do
PutsDebuggerer.caller = true
... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer__with_app_path_provided__spec.rb | Ruby | mit | 209 | master | 834 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe 'PutsDebuggerer' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
context 'with app path provided' do
before do
PutsDebuggerer.app_path = File.e... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/lib/puts_debuggerer/core_ext/kernel__opal__spec.rb | Ruby | mit | 209 | master | 566 | require 'spec_helper'
describe 'Kernel' do
let(:puts_debuggerer_invoker_file) {File.expand_path(File.join(__FILE__, '..', '..', 'support', 'puts_debuggerer_invoker.rb'))}
before :all do
@ruby_engine = RUBY_ENGINE
end
after :all do
RUBY_ENGINE = @ruby_engine
load 'puts_debuggerer/core_ext/kern... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | spec/support/puts_debuggerer_invoker.rb | Ruby | mit | 209 | master | 1,806 | require File.expand_path(File.dirname(__FILE__) + '../../../lib/puts_debuggerer')
# DO NOT MOVE METHODS (LINE NUMBERS ARE BEING TESTED) ADD METHODS AT THE END ONLY
module PutsDebuggererInvoker
# intentional empty line
# intentional empty line
# intentional empty line
# intentional empty line
def self.dynamic... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | lib/puts_debuggerer.rb | Ruby | mit | 209 | master | 17,224 | $LOAD_PATH.unshift(File.expand_path(__dir__)) unless $LOAD_PATH.include?(File.expand_path(__dir__))
require 'puts_debuggerer/core_ext/kernel'
require 'puts_debuggerer/core_ext/logger'
require 'puts_debuggerer/core_ext/logging/logger'
require 'puts_debuggerer/run_determiner'
require 'puts_debuggerer/source_file'
modul... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | lib/puts_debuggerer/run_determiner.rb | Ruby | mit | 209 | master | 3,112 | module PutsDebuggerer
module RunDeterminer
OBJECT_RUN_AT = {}
class << self
attr_reader :run_at_global_number
def run_at_global_number=(value)
@run_at_global_number = value
end
def init_run_at_global_number
@run_at_global_number = 1
end
def increme... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | lib/puts_debuggerer/source_file.rb | Ruby | mit | 209 | master | 1,036 | module PutsDebuggerer
class SourceFile
def initialize(file_path)
@file = File.new(file_path) if file_path && File.exist?(file_path)
end
def source(source_line_count, source_line_number)
@source = ''
return @source if RUBY_ENGINE == 'opal'
# For Opal Ruby compatibility, skip so... |
github | AndyObtiva/puts_debuggerer | https://github.com/AndyObtiva/puts_debuggerer | lib/puts_debuggerer/core_ext/kernel.rb | Ruby | mit | 209 | master | 9,821 | require 'stringio'
module Kernel
# Prints object with bonus info such as file name, line number and source
# expression. Optionally prints out header and footer.
# Lookup PutsDebuggerer attributes for more details about configuration options.
#
# Simply invoke global `pd` method anywhere you'd like to see li... |
github | jesseduffield/lazy_migrate | https://github.com/jesseduffield/lazy_migrate | Guardfile | Ruby | mit | 210 | master | 1,385 | # 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.