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
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
lib/vimrunner/client.rb
Ruby
mit
241
main
5,971
require "vimrunner/path" require "vimrunner/command" module Vimrunner class Client attr_reader :server def initialize(server) @server = server end # Public: Adds a plugin to Vim's runtime. Initially, Vim is started # without sourcing any plugins to ensure a clean state. This method can be...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
lib/vimrunner/testing.rb
Ruby
mit
241
main
1,807
require 'tmpdir' module Vimrunner # Public: Provides some utility helpers to assist in using Vimrunner for # testing purposes. module Testing # Public: Writes the given string to the file identified by "filename". # # Uses #normalize_string_indent to ensure consistent indentation when given # a...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
lib/vimrunner/errors.rb
Ruby
mit
241
main
393
module Vimrunner class InvalidCommandError < RuntimeError; end class ExecutionError < RuntimeError; end class NoSuitableVimError < RuntimeError def message "No suitable Vim executable could be found for this system." end end class TimeoutError < RuntimeError def message "Timed out wh...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
lib/vimrunner/rspec.rb
Ruby
mit
241
main
1,432
require 'vimrunner' require 'vimrunner/testing' module Vimrunner module RSpec class Configuration attr_accessor :reuse_server def start_vim(&block) @start_vim_method = block end def start_vim_method @start_vim_method || lambda { Vimrunner.start } end end d...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
lib/vimrunner/platform.rb
Ruby
mit
241
main
1,781
require "rbconfig" require "vimrunner/errors" module Vimrunner # Public: The Platform module contains logic for finding a Vim executable # that supports the clientserver functionality on the current system. Its # methods can be used to fetch a Vim path for initializing a Server. # # Examples # # Vimr...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner_spec.rb
Ruby
mit
241
main
1,070
require "spec_helper" require "vimrunner" RSpec.describe Vimrunner do let(:server) { double('server').as_null_object } describe "#start" do before do allow(Vimrunner::Platform).to receive(:vim).and_return("vim") end it "defaults to using the platform vim" do expect(Vimrunner::Server).to r...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/spec_helper.rb
Ruby
mit
241
main
519
require "tmpdir" require "simplecov" SimpleCov.start RSpec.configure do |config| def write_file(filename, contents) dirname = File.dirname(filename) FileUtils.mkdir_p dirname if not File.directory?(dirname) File.open(filename, 'w') { |f| f.write(contents) } end # Execute each example in its own te...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner/server_spec.rb
Ruby
mit
241
main
4,872
require "spec_helper" require "vimrunner/server" require "vimrunner/platform" module Vimrunner RSpec.describe Server do let(:server) { Server.new } describe "#initialize" do it "defaults to using Platform.vim for the executable" do expect(server.executable).to eq(Platform.vim) end ...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner/command_spec.rb
Ruby
mit
241
main
322
require "vimrunner/command" module Vimrunner RSpec.describe Command do it "leaves standard commands untouched" do expect(Command.new("set linenumber").to_s).to eq("set linenumber") end it "escapes single quotes" do expect(Command.new("echo 'foo'").to_s).to eq("echo ''foo''") end end en...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner/errors_spec.rb
Ruby
mit
241
main
757
require "spec_helper" require "vimrunner" require "vimrunner/errors" module Vimrunner RSpec.describe NoSuitableVimError do it "has a useful message" do expect { raise NoSuitableVimError }.to raise_error(/No suitable Vim executable could be found for this system./) end end describe Ti...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner/client_spec.rb
Ruby
mit
241
main
4,812
require "spec_helper" require "vimrunner" module Vimrunner RSpec.describe Client do let!(:client) { Vimrunner.start } after :each do client.kill end it "is instantiated in the current directory" do cwd = FileUtils.getwd expect(client.command(:pwd)).to eq(cwd) end it "can ...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner/path_spec.rb
Ruby
mit
241
main
316
require "vimrunner/path" module Vimrunner RSpec.describe Path do it "leaves standard paths untouched" do expect(Path.new("foo.txt").to_s).to eq("foo.txt") end it "escapes non-standard characters in paths" do expect(Path.new("foo bar!.txt").to_s).to eq('foo\ bar\!.txt') end end end
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner/testing_spec.rb
Ruby
mit
241
main
722
require 'spec_helper' require 'vimrunner' require 'vimrunner/testing' module Vimrunner RSpec.describe Testing do include Testing specify "#normalize_string_indent" do sample = normalize_string_indent(<<-EOF) def foo bar end EOF expect(sample).to eq("def foo\n ba...
github
AndrewRadev/vimrunner
https://github.com/AndrewRadev/vimrunner
spec/vimrunner/platform_spec.rb
Ruby
mit
241
main
2,460
require "spec_helper" require "vimrunner/platform" module Vimrunner RSpec.describe Platform do describe "#vim" do it "raises an error if no suitable vim could be found" do allow(Platform).to receive(:suitable?).and_return(false) expect { Platform.vim }.to raise_error(NoSuitableVimError) ...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
vagrant-gatling-rsync.gemspec
Ruby
mit
241
master
1,036
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'vagrant-gatling-rsync/version' Gem::Specification.new do |spec| spec.name = "vagrant-gatling-rsync" spec.version = VagrantPlugins::GatlingRsync::VERSION spec.authors = ...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
Gemfile
Ruby
mit
241
master
254
source 'https://rubygems.org' # Specify your gem's dependencies in vagrant-gatling-rsync.gemspec gemspec group :development do gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git", :tag => 'v2.2.16' end group :plugins do gemspec end
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
example/vagrant/Vagrantfile
Ruby
mit
241
master
1,507
# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "centos/7" config.vm.provider "docker" do |d, override| d.image = "smerrill/vagrant-ub...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync.rb
Ruby
mit
241
master
852
# This file is required because Vagrant's plugin system expects # an eponymous ruby file matching the rubygem. # # So this gem is called 'vagrant-gatling-rsync' and thus vagrant tries # to require "vagrant-gatling-rsync" require "vagrant-gatling-rsync/plugin" require "pathname" module VagrantPlugins module Gatling...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/config.rb
Ruby
mit
241
master
1,221
require "vagrant" module VagrantPlugins module GatlingRsync class Config < Vagrant.plugin(2, :config) attr_accessor :latency attr_accessor :time_format attr_accessor :rsync_on_startup def initialize @latency = UNSET_VALUE @time_format = UNSET_VALUE @rsync_on_start...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/errors.rb
Ruby
mit
241
master
454
require "vagrant" module VagrantPlugins module GatlingRsync module Errors class VagrantGatlingRsyncError < Vagrant::Errors::VagrantError error_namespace("vagrant_gatling_rsync.errors") end class OSNotSupportedError < VagrantGatlingRsyncError error_key(:os_not_supported) e...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/plugin.rb
Ruby
mit
241
master
1,006
begin require "vagrant" rescue LoadError raise "The Vagrant gatling rsync plugin must be run within Vagrant." end module VagrantPlugins module GatlingRsync class Plugin < Vagrant.plugin(2) name "Gatling Rsync" description <<-DESC Rsync large project directories to your Vagrant VM without us...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/listen/listenosx.rb
Ruby
mit
241
master
1,520
require "rb-fsevent" module VagrantPlugins module GatlingRsync class ListenOSX def initialize(paths, ignores, latency, logger, callback) @paths = paths @ignores = ignores @latency = latency @options = { # We set this to a small value to ensure that we can coalesce ...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/listen/listenwindows.rb
Ruby
mit
241
master
1,205
# @TODO: Note that this is entirely untested and not yet implemented. require "wdm" module VagrantPlugins module GatlingRsync class ListenWindows def initialize(paths, ignores, latency, logger, callback) @paths = paths @ignores = ignores @latency = latency @logger = logger ...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/listen/listenlinux.rb
Ruby
mit
241
master
1,168
require "rb-inotify" module VagrantPlugins module GatlingRsync class ListenLinux def initialize(paths, ignores, latency, logger, callback) @paths = paths @ignores = ignores @latency = latency @logger = logger @callback = callback end def run @log...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/action/startup_rsync.rb
Ruby
mit
241
master
1,336
require "vagrant" module VagrantPlugins module GatlingRsync class StartupRsync include Vagrant::Action::Builtin::MixinSyncedFolders def initialize(app, env) @app = app @gatling_startup_registered = false @rsync_folder_count = 0 end def call(env) folders =...
github
smerrill/vagrant-gatling-rsync
https://github.com/smerrill/vagrant-gatling-rsync
lib/vagrant-gatling-rsync/command/rsync_auto.rb
Ruby
mit
241
master
5,474
require "log4r" require "optparse" require "vagrant" module VagrantPlugins module GatlingRsync class GatlingRsyncAuto < Vagrant.plugin(2, :command) # This is a sanity check to make sure no one is attempting to install # this into an early Vagrant version. if Gem::Version.new(Vagrant::VERSION) ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
Gemfile
Ruby
mit
241
main
826
source "http://rubygems.org" # Declare your gem's dependencies in blogit.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec rails_version = ENV["RAILS_VERSION"] || "default" rails = case rails_version w...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
Appraisals
Ruby
mit
241
main
529
# This is currently broken due to the arel dependency # appraise "rails-head" do # gem "rails", github: "rails/rails" # gem "sass-rails", "~> 5.0.0" # end appraise "rails-4.2" do gem "rails", "~> 4.2.0" gem "sass-rails", "~> 5.0.0" end appraise "rails-4.1" do gem "rails", "~> 4.1.0" gem "sass-rails", "~> ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
blogit.gemspec
Ruby
mit
241
main
2,202
$:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "blogit/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "blogit" s.version = Blogit::VERSION s.authors = ["Bodacious"] s.email = ["bodacious@katanacode.com...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
Guardfile
Ruby
mit
241
main
1,192
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard 'rspec', :version => 2 do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec/" } watch('spec/factories.rb') { "spec/" } watch(%r{^spec/.+_spec\....
github
Bodacious/blogit
https://github.com/Bodacious/blogit
Rakefile
Ruby
mit
241
main
565
#!/usr/bin/env rake $LOAD_PATH.unshift File.expand_path("../lib", __FILE__) require "rubygems" require 'bundler/setup' require 'bundler/gem_tasks' require "blogit/version" require 'rspec/core' require 'rspec/core/rake_task' APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__) load 'rails/tasks/engine....
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/helpers/blogit/application_helper.rb
Ruby
mit
241
main
3,394
module Blogit module ApplicationHelper # Format content using the {Blogit::Configuration#default_parser_class default_parser_class} # # content - A String containing the content to be formatted (defaults: nil) # block - A Proc that returns a String of content to be formatted # # Example...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/helpers/blogit/layout_helper.rb
Ruby
mit
241
main
774
module Blogit module LayoutHelper # Sets or returns the title for a page # # content - The content to include in the HTML title tag. # # Returns a String def title(content=nil) if content content_for(:title, content) else content_for(:title) end end ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/helpers/blogit/posts_helper.rb
Ruby
mit
241
main
1,523
module Blogit module PostsHelper require "blogit/archive" # Renders the comments for a {Post} based on the # {Blogit::Configuration::include_comments} configuration def comments_for_post(post) comment_type = Blogit.configuration.include_comments render(partial: "blogit/comments/#...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/helpers/blogit/comments_helper.rb
Ruby
mit
241
main
571
module Blogit module CommentsHelper # The commenter's name for a Comment. When the Comment has a website, includes an html # link containing their name. Otherwise, just shows the name as a String. # # comment - A {Blogit::Comment} # # Returns a String containing the commenter's name. ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/views/blogit/posts/index.rss.builder
Ruby
mit
241
main
731
xml.instruct! xml.rss "version" => "2.0", "xmlns:dc" => "htt://purl.org/dc/elements/1.1/" do xml.channel do xml.title blogit_conf.rss_feed_title xml.description blogit_conf.rss_feed_description xml.pubDate CGI.rfc1123_date @posts.first.try(:updated_at) xml.link blog_root_url xml.lastBuildDate...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/views/blogit/posts/index.xml.builder
Ruby
mit
241
main
385
xml.instruct! xml.urlset :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' do # Show the blog index in sitemap xml.url do xml.loc posts_url xml.lastmod @posts.maximum(:updated_at).xmlschema end # Include a record for each active post for post in @posts xml.url do xml.loc post_url(pos...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/models/blogit/post.rb
Ruby
mit
241
main
3,612
module Blogit class Post < ActiveRecord::Base require "kaminari" require "acts-as-taggable-on" acts_as_taggable self.paginates_per(Blogit.configuration.posts_per_page) # =============== # = Validations = # =============== validates :title, presence: true, length: { minimum: 10...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/models/blogit/comment.rb
Ruby
mit
241
main
1,659
module Blogit class Comment < ActiveRecord::Base # require custom validators require "validators" include Validators # ================ # = Associations = # ================ belongs_to :post, class_name: "Blogit::Post", foreign_key: "post_id", counter_cache: true, touch: true ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/controllers/blogit/comments_controller.rb
Ruby
mit
241
main
1,754
module Blogit # Handles requests for creating Blogit::Comments class CommentsController < ::Blogit::ApplicationController # Accessor method for the comment being created # # Returns a Blogit::Comment attr_reader :comment # Accessor method for the Post we're adding a Comment to # # Ret...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/controllers/blogit/posts_controller.rb
Ruby
mit
241
main
2,517
module Blogit # Handles requests for viewing Blogit::Posts class PostsController < ::Blogit::ApplicationController # The current Blogit::Post being displayed. # # Returns a Blogit::Post with id from params attr_reader :post # The current Posts being displayed # # Returns ActiveRecord:...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
app/controllers/blogit/application_controller.rb
Ruby
mit
241
main
726
module Blogit # Inherits from the application's controller instead of ActionController::Base class ApplicationController < ::ApplicationController helper Blogit::ApplicationHelper helper Blogit::LayoutHelper helper Blogit::PostsHelper helper Blogit::CommentsHelper helper_method :blogit_co...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/spec_helper.rb
Ruby
mit
241
main
212
require "codeclimate-test-reporter" CodeClimate::TestReporter.start require 'rspec' require "rspec/collection_matchers" require 'pry' require 'timecop' RSpec.configure do |config| config.mock_with :mocha end
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/factories.rb
Ruby
mit
241
main
2,505
FactoryGirl.define do # ================= # = Gem Factories = # ================= factory :post, class: Blogit::Post do title "This is a blog post title" description "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim a...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/blogit_spec.rb
Ruby
mit
241
main
486
require "rails_helper" describe Blogit do it "allows developers to set configurations with a block" do initial_value = Blogit.configuration.current_blogger_method Blogit.configure do |config| config.current_blogger_method = :logged_in_user end user_set_value = Blogit.configuration.current_b...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/rails_helper.rb
Ruby
mit
241
main
495
require 'spec_helper' # This file is copied to spec/ when you run 'rails generate rspec:install' ENV['RAILS_ENV'] = 'test' ENV["DB"] ||= "sqlite" require File.expand_path('../dummy/config/environment', __FILE__) require 'rspec/rails' require 'factory_girl' require 'factories' require 'support/authentication' requi...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/models/blogit/post_spec.rb
Ruby
mit
241
main
5,681
require "rails_helper" describe Blogit::Post do context "should not be valid" do context "if blogger" do let(:blog_post) { Blogit::Post.new } it "is nil" do expect(blog_post).not_to be_valid expect(blog_post.errors[:blogger_id].size).to eq(1) end end contex...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/models/blogit/comment_spec.rb
Ruby
mit
241
main
1,686
require 'rails_helper' describe Comment do describe "should not be valid if it" do let(:comment) { build(:comment) } # nickname is a honey-pot it "has a value for nickname" do comment.nickname = "Gavin" expect(comment).not_to be_valid expect(comment.errors[:nickname].size).to eq(1)...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/support/authentication.rb
Ruby
mit
241
main
258
def mock_login @current_blogger = User.first || create(:user) controller.expects(:current_user).at_least_once.returns(@current_blogger) end def reset_configuration Blogit.configure do |config| config.current_blogger_method = :current_user end end
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/support/helpers/css_matchers.rb
Ruby
mit
241
main
888
require 'rspec/expectations' RSpec::Matchers.define :have_class do |expected_| match do |actual| actual.match(/class\=(?:"|').*(#{expected}).*(?:"|')/) $1.present? end description do "have CSS class \"#{expected}\"" end failure_message do |actual| "expected #{actual} to have CSS cl...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/helpers/blogit/posts_helper_spec.rb
Ruby
mit
241
main
1,440
# -*- coding: utf-8 -*- require "rails_helper" describe Blogit::PostsHelper do describe "comments_for_post" do let(:post) { FactoryGirl.create :post } it "should be empty if comments are not configured" do Blogit.configure do |config| config.include_comments = :no end expect(help...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/helpers/blogit/application_helper_spec.rb
Ruby
mit
241
main
1,000
require "rails_helper" describe Blogit::ApplicationHelper do describe "format_content" do it "should convert markdown text to html if conf is :markdown" do Blogit.configure { |c| c.default_parser = :markdown } expect(helper.format_content("## Hello\n\nWorld")).to match(/<h2>Hello<\/h2>\n\n<p>World<\...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/configuration_spec.rb
Ruby
mit
241
main
3,093
require "rails_helper" describe Blogit::Configuration do let(:blog_configuration) { @blog_configuration = Blogit::Configuration.new } it "should set :include_comments to :active_record" do expect(blog_configuration.include_comments).to eq(:active_record) end it "should set :disqus_shortname to blank" do...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/blogs_spec.rb
Ruby
mit
241
main
344
require "spec_helper" describe Blogit::Blogs do it "should be included in ActiveRecord::Base" do expect(ActiveRecord::Base.included_modules).to include(Blogit::Blogs) end describe :blogs do it "should be a class macro to AR Base" do expect(ActiveRecord::Base.methods).to include(:blogs) en...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/archive/year_spec.rb
Ruby
mit
241
main
810
require 'spec_helper' require 'blogit/archive' require 'injectables/dummy_archiveable' describe Blogit::Archive::Year do describe :to_partial_path do let(:list) { Blogit::Archive::Year.new(2015, []) } it "returns the class name as a path to partial" do expect(list.to_partial_path).to eql("...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/archive/month_spec.rb
Ruby
mit
241
main
372
require 'spec_helper' require 'blogit/archive' require 'injectables/dummy_archiveable' describe Blogit::Archive::Month do describe :to_partial_path do let(:list) { Blogit::Archive::Month.new("June", []) } it "returns the class name as a path to partial" do expect(list.to_partial_path).to e...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/archive/list_spec.rb
Ruby
mit
241
main
1,325
require 'spec_helper' require 'blogit/archive' require 'injectables/dummy_archiveable' describe Blogit::Archive::List do describe :to_partial_path do let(:list) { Blogit::Archive::List.new([]) } it "returns the class name as a path to partial" do expect(list.to_partial_path).to eql("blogit...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/blogit/parsers/textile_parser_spec.rb
Ruby
mit
241
main
372
require "spec_helper" describe Blogit::Parsers::TextileParser do let(:parser) { Blogit::Parsers::TextileParser.new("h2. Some textile\n\np. A paragraph") } let(:desired_output) { "<h2>Some textile</h2>\n<p>A paragraph</p>" } it "should return an html string of content passed when calling parsed" do expe...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/blogit/parsers/markdown_parser_spec.rb
Ruby
mit
241
main
1,944
require "rails_helper" describe Blogit::Parsers::MarkdownParser do let(:parser) { Blogit::Parsers::MarkdownParser.new("## Some textile\n\nA paragraph") } let(:desired_output) { Regexp.new("<h2>Some textile</h2>\n\n<p>A paragraph</p>\n") } it "should return an html string of content passed when calling parsed" ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/lib/blogit/parsers/html_parser_spec.rb
Ruby
mit
241
main
376
require "spec_helper" describe Blogit::Parsers::HtmlParser do let(:parser) { Blogit::Parsers::TextileParser.new("<h2>Some textile</h2>\n<p>A paragraph</p>") } let(:desired_output) { "<h2>Some textile</h2>\n<p>A paragraph</p>" } it "should return an html string of content passed when calling parsed" do ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/config/routes.rb
Ruby
mit
241
main
363
Rails.application.routes.draw do resource :session, :only => [:new, :create, :destroy] mount Blogit::Engine => "/blog" resources :sub_posts, controller: "sub_posts" do collection do get :tagged end end post "sub_posts/:post_id/comments" => "sub_comments#create" resources :users ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/config/application.rb
Ruby
mit
241
main
1,006
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) require "blogit" module Dummy class Application < Rails::Application # Settings in config/env...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/config/environments/production.rb
Ruby
mit
241
main
3,401
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both thread web server...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/config/environments/development.rb
Ruby
mit
241
main
1,210
Dummy::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 ser...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/config/environments/test.rb
Ruby
mit
241
main
1,531
Dummy::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 sui...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/config/initializers/secret_token.rb
Ruby
mit
241
main
872
# Be sure to restart your server when you modify this file. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to diction...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/config/initializers/wrap_parameters.rb
Ruby
mit
241
main
436
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActionController::Base.wrap_parameters format: [:json] # Disab...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/spec/controllers/sub_comments_controller.rb
Ruby
mit
241
main
997
require 'rails_helper' describe SubCommentsController do it "is a subclass of Blogit::CommentsController" do expect(SubCommentsController.superclass).to eq(Blogit::CommentsController) end before do reset_configuration end let(:blog_post) { build :post } describe "POST 'create'" do ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/spec/controllers/sub_posts_controller_spec.rb
Ruby
mit
241
main
1,679
require 'rails_helper' describe SubPostsController do it "is a subclass of Blogit::PostsController" do expect(SubPostsController.superclass).to eq(Blogit::PostsController) end before do reset_configuration end let(:blog_post) { build :post } describe "GET 'index'" do before do ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/app/controllers/sub_posts_controller.rb
Ruby
mit
241
main
403
# Sub-class of Blogit::PostsController for testing calls to super with blocks class SubPostsController < Blogit::PostsController def index super do |posts| posts.update_all(updated_at: Time.now) end end def tagged super do |posts| posts.update_all(updated_at: Time.now) end end ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/app/controllers/people_controller.rb
Ruby
mit
241
main
1,911
class PeopleController < ApplicationController # GET /people # GET /people.json def index @people = Person.all respond_to do |format| format.html # index.html.erb format.json { render json: @people } end end # GET /people/1 # GET /people/1.json def show @person = Person.find(...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/app/controllers/application_controller.rb
Ruby
mit
241
main
397
class ApplicationController < ActionController::Base protect_from_forgery helper_method :current_user def current_user # session[:user_id] = User.first.id @current_user ||= User.find_by_id(session[:user_id]) end def login_required unless current_user flash[:warn] = "You must be l...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/app/controllers/sessions_controller.rb
Ruby
mit
241
main
456
class SessionsController < ApplicationController def new end def create @user = User.authenticate(params[:session]) if @user @current_user = @user session[:user_id] = @user.id redirect_to(root_url, notice: "Successfully logged in!") else render :new end en...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/app/controllers/sub_comments_controller.rb
Ruby
mit
241
main
227
# Sub-class of Blogit::PostsController for testing calls to super with blocks class SubCommentsController < Blogit::CommentsController def create super do |comment| comment.touch(:updated_at) end end end
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/app/controllers/users_controller.rb
Ruby
mit
241
main
1,838
class UsersController < ApplicationController # GET /users # GET /users.json def index @users = User.all respond_to do |format| format.html # index.html.erb format.json { render json: @users } end end # GET /users/1 # GET /users/1.json def show @user = User.find(params[:id]) ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/app/models/user.rb
Ruby
mit
241
main
264
class User < ActiveRecord::Base # this is where the magic happens blogs # Find the User by username and password def self.authenticate(attribute_hash) find_by_username_and_password(attribute_hash[:username], attribute_hash[:password]) end end
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/lib/tasks/dummy.rake
Ruby
mit
241
main
987
namespace :dummy do desc "Sets up the dummy application to the point just before blogit will be installed" task :setup do # If Rails version is 3, use the old rake tasks. # If Rails version is 4, use the new rake tasks. puts `if (echo $RAILS_VERSION | grep '3.\d.\d'); then bundle exec rake acts_as_tagg...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/dummy/db/schema.rb
Ruby
mit
241
main
3,183
# 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
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/controllers/blogit/posts_controller_spec.rb
Ruby
mit
241
main
1,845
require 'rails_helper' describe Blogit::PostsController do before do reset_configuration @routes = Blogit::Engine.routes end let(:blog_post) { build :post } describe "GET 'index'" do let(:posts) { [] } def do_get(page=nil) get :index, page: page end it 'sets posts to Blogit...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
spec/controllers/blogit/comments_controller_spec.rb
Ruby
mit
241
main
1,160
require 'rails_helper' describe Blogit::CommentsController do before do @routes = Blogit::Engine.routes end let(:blog_post) { Blogit::Post.active.first || create(:post, :active) } let(:comment_attributes) { attributes_for(:comment) } describe "POST create" do def do_post(format = :html) ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit.rb
Ruby
mit
241
main
645
# Third-party requirements require "kaminari" require "redcarpet" require "blogit/configuration" require "blogit/blogs" require "blogit/engine" require "blogit/parsers" require "validators" module Blogit autoload :Kaminari, "kaminari" # Exception raised when gem may not be configured properly class Confi...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/validators/absence_validator.rb
Ruby
mit
241
main
494
module Validators # Checks that an attribute is absent. The opposite of Rails's PresenceValidator class AbsenceValidator < ActiveModel::EachValidator # This is a Rails method for custom Validators. Please read {http://api.rubyonrails.org/classes/ActiveModel/Validations/ClassMethods.html#method-i-validates_eac...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/generators/templates/rename_blogit_tables.rb
Ruby
mit
241
main
525
class RenameBlogitTables < ActiveRecord::Migration def change if table_exists?('blog_posts') rename_table('blog_posts', 'blogit_posts') else report_missing_table("blog_posts") end if table_exists?('blog_comments') rename_table('blog_comments', 'blogit_comments') else ...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/generators/templates/blogit.rb
Ruby
mit
241
main
2,162
# These configuration options can be used to customise the behaviour of Blogit Blogit.configure do |config| # What kind of comments do you want to add to your blog ? (:active_record, :disqus or :no) config.include_comments = :active_record # When using disqus comments, what is the shortname of your forum ? co...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/generators/blogit/views_generator.rb
Ruby
mit
241
main
428
module Blogit module Generators class ViewsGenerator < Rails::Generators::Base desc "Copies Blogit views to your application." include Thor::Actions source_root File.expand_path('../../../../app/views', __FILE__) # Copy all of the views from the blogit/app/views/blogit to # app/v...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/generators/blogit/table_name_migration_generator.rb
Ruby
mit
241
main
424
module Blogit module Generators class TableNameMigrationGenerator < Rails::Generators::Base source_root File.expand_path('../../templates', __FILE__) desc "Creates a Blogit initializer in your application's config/initializers dir" def copy_migration_file template "rename_blogit...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/generators/blogit/install_generator.rb
Ruby
mit
241
main
365
module Blogit module Generators class InstallGenerator < Rails::Generators::Base source_root File.expand_path('../../templates', __FILE__) desc "Creates a Blogit initializer in your application's config/initializers dir" def copy_initializer template "blogit.rb", "config/initial...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/blogs.rb
Ruby
mit
241
main
544
module Blogit module Blogs extend ActiveSupport::Concern module ClassMethods # When called within a model (usually User) this creates # a has-many assosciation between the model and {Post} def blogs @blogs = true has_many :blog_posts, :as => "blogger", :class...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/renderers.rb
Ruby
mit
241
main
478
module Blogit::Renderers def self.choose_highlight_renderer case Blogit::configuration.syntax_highlighter when :albino require "blogit/renderers/html_with_albino" Redcarpet::Render::HTMLWithAlbino when :pygments require "blogit/renderers/html_with_pygments" Redcarpet::Render::HTMLW...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/configuration.rb
Ruby
mit
241
main
6,009
module Blogit # This class handles the global configuration options for Blogit. # When you run `rails g blogit:install` this will add an initializer file to # config/initializers/blogit.rb with all of the default configurations applied. # # You can read about each of the individual configuration options b...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/engine.rb
Ruby
mit
241
main
319
module Blogit class Engine < Rails::Engine isolate_namespace Blogit initializer "blogit.extend_active_record" do if defined?(::ActiveRecord::Base) ::ActiveRecord::Base.send(:include, Blogit::Blogs) ::ActiveRecord::Base.send(:include, Validators) end end end end
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/archive/list.rb
Ruby
mit
241
main
1,500
module Blogit module Archive # Public: The main class to be accessed when creating a HTML post archive. class List # Gets/Sets the list of years for this archive object. attr_accessor :years # Gets/Sets the list of _{Archiveable archiveable}_ objects for this Archive List. a...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/archive/archiveable.rb
Ruby
mit
241
main
468
module Blogit module Archive # This class is for documentation only, to define the Archiveable type class Archiveable # Archiveables must respond to :published_at and return a DateTime object. attr_accessor :published_at # Do not use this. # # Raises an excep...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/archive/month.rb
Ruby
mit
241
main
760
module Blogit module Archive # Used internally by {List} when creating a new archive list. class Month attr_reader :month_name alias_method :to_s, :month_name attr_reader :archiveables # Creates a new {Month} object # # month_name - The name o...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/archive/year.rb
Ruby
mit
241
main
848
module Blogit module Archive class Year attr_accessor :year, :months def initialize(year, archiveables) @year = year @months = create_months_from_archiveables(archiveables) end def to_s year end # The name of the partial to load for a {...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/parsers/textile_parser.rb
Ruby
mit
241
main
398
module Blogit module Parsers class TextileParser require "redcloth" # A String containing the content to be parsed attr_reader :content def initialize(content) @content = content end # The parsed content # # Returns an HTML safe String def p...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/parsers/markdown_parser.rb
Ruby
mit
241
main
1,679
class Blogit::Parsers::MarkdownParser require "nokogiri" require "blogit/renderers" # A String containing the content to be parsed attr_reader :content def initialize(content) @content = content end # The parsed content # # Returns an HTML safe String def parsed ensure_pygments_is_instal...
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/parsers/html_parser.rb
Ruby
mit
241
main
208
class Blogit::Parsers::HtmlParser # A String containing the content to be parsed attr_reader :content alias_method :parsed, :content def initialize(content) @content = content end end
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/renderers/html_with_albino.rb
Ruby
mit
241
main
233
# Create a custom renderer that allows highlighting of code blocks class Redcarpet::Render::HTMLWithAlbino < Redcarpet::Render::HTML require "albino" def block_code(code, language) Albino.colorize(code, language) end end
github
Bodacious/blogit
https://github.com/Bodacious/blogit
lib/blogit/renderers/html_with_pygments.rb
Ruby
mit
241
main
246
# Create a custom renderer that allows highlighting of code blocks class Redcarpet::Render::HTMLWithPygments < Redcarpet::Render::HTML require "pygments" def block_code(code, language) Pygments.highlight(code, lexer: language) end end