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 | erector/erector | https://github.com/erector/erector | lib/erector/widgets/form.rb | Ruby | mit | 229 | master | 535 | # todo: make more like http://github.com/justinfrench/formtastic
class Form < Erector::Widget
needs :action, :method => "post"
def content
form :method => form_method, :action => @action do
unless rest_method == form_method
input :type => "hidden", :name => "_method", :value => rest_method
... |
github | erector/erector | https://github.com/erector/erector | web/release_notes.rb | Ruby | mit | 229 | master | 470 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
require "rubygems"
require "bundler"
Bundler.setup
require 'rdoc/markup'
require 'rdoc/markup/to_html'
class ReleaseNotes < Page
def initialize
super(:page_title => "Release Notes")
end
def body_content
notes = File.read("#{Fi... |
github | erector/erector | https://github.com/erector/erector | web/fork_me.rb | Ruby | mit | 229 | master | 502 | # https://github.com/blog/273-github-ribbons
class ForkMe < Erector::Widget
def content
rawtext <<-HTML
<a href="http://github.com/erector/erector"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/30f550e0d38ceb6ef5b81500c64d970b7fb0f028/687474... |
github | erector/erector | https://github.com/erector/erector | web/logo.rb | Ruby | mit | 229 | master | 208 | class Logo < Erector::Widget
def content
div.logo {
a :href => "index.html" do
img.logo :src => 'erector.jpg',
:height => 323,
:width => 287
end
}
end
end |
github | erector/erector | https://github.com/erector/erector | web/faq.rb | Ruby | mit | 229 | master | 8,992 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
require "#{dir}/article"
class Faq < Page
def initialize
super(:page_title => "FAQ")
end
def body_content
widget article
end
def promo
"images/the-mysto-erector.jpg"
end
def article
Article.new(:name => "Erecto... |
github | erector/erector | https://github.com/erector/erector | web/clickable_li.rb | Ruby | mit | 229 | master | 277 | class ClickableLi < Erector::Widget
needs :item, :href, :current => false
def content
classes = ["clickable"]
classes << "current" if @current
li :onclick => "document.location='#{@href}'", :class => classes do
a @item, :href => @href
end
end
end |
github | erector/erector | https://github.com/erector/erector | web/readme.rb | Ruby | mit | 229 | master | 824 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
require "rubygems"
require "bundler"
Bundler.setup
require 'rdoc/markup'
require 'rdoc/markup/to_html'
class Readme < Page
def initialize
super(:page_title => "README")
end
def readme
text = File.read("#{File.dirname(__FILE__)}/... |
github | erector/erector | https://github.com/erector/erector | web/rails.rb | Ruby | mit | 229 | master | 10,721 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
require "#{dir}/article"
require "#{dir}/section"
require "#{dir}/source"
class Rails < Page
include Source
def initialize
super(:page_title => "Erector On Rails")
end
def promo
"images/erectorhudson.jpeg"
end
def body_co... |
github | erector/erector | https://github.com/erector/erector | web/cheatsheet.rb | Ruby | mit | 229 | master | 4,030 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
class Cheatsheet < Page
def initialize
super(:page_title => "Cheatsheet")
end
def promo
"images/1959erector.jpeg"
end
def body_content
h2.clear "Erector API Cheatsheet"
cheats = [
["element('foo')", ... |
github | erector/erector | https://github.com/erector/erector | web/userguide.rb | Ruby | mit | 229 | master | 22,433 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
require "#{dir}/article"
require "#{dir}/section"
require "#{dir}/source"
class Userguide < Page
include Source
def initialize
super(:page_title => "User Guide")
end
def promo
"images/1959erector.jpeg"
end
def body_co... |
github | erector/erector | https://github.com/erector/erector | web/source.rb | Ruby | mit | 229 | master | 285 | # http://shjs.sourceforge.net/doc/documentation.html
module Source
def self.included into
into.external :js, "js/sh_lang.min.js"
into.external :css, "css/sh_style.css"
end
def source_code lang, text
sh_lang = "sh_#{lang}"
pre text, :class => sh_lang
end
end |
github | erector/erector | https://github.com/erector/erector | web/navbar.rb | Ruby | mit | 229 | master | 873 | dir = File.dirname(__FILE__)
require "#{dir}/clickable_li"
class Navbar < Erector::Widget
needs :current_page
def clickable_li(item, href, current = false)
widget ClickableLi, :item => item, :href => href, :current => current
end
def clickable_page page
clickable_li page.display_name, page.href, ... |
github | erector/erector | https://github.com/erector/erector | web/index.rb | Ruby | mit | 229 | master | 1,851 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
require "rubygems"
require "bundler"
Bundler.setup
require 'rdoc/markup'
require 'rdoc/markup/to_html'
class Index < Page
def initialize
super(:page_title => "Home")
end
def body_content
p {
text "Erector is a Builder-li... |
github | erector/erector | https://github.com/erector/erector | web/community.rb | Ruby | mit | 229 | master | 461 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
class Community < Page
def initialize
super(:page_title => "Community")
end
def body_content
ul.clickable do
clickable_li 'Erector Mailing List', "http://googlegroups.com/group/erector"
clickable_li 'Github Repository... |
github | erector/erector | https://github.com/erector/erector | web/example.rb | Ruby | mit | 229 | master | 493 | require 'erector'
here = File.expand_path(File.dirname(__FILE__))
require "#{here}/source"
module Example
def example ruby, html
div.example {
table {
tr {
td.before {
source_code :ruby, ruby
}
td.separator {
span.separator {
text c... |
github | erector/erector | https://github.com/erector/erector | web/page.rb | Ruby | mit | 229 | master | 2,703 | here = File.dirname(__FILE__)
require "#{here}/navbar"
require "#{here}/logo"
require "#{here}/clickable_li"
require "#{here}/promo"
require "#{here}/source"
require "#{here}/example"
require "#{here}/fork_me"
# todo: inherit from Erector::Widgets::Page
class Page < Erector::Widget
needs :page_title
include Sourc... |
github | erector/erector | https://github.com/erector/erector | web/section.rb | Ruby | mit | 229 | master | 563 | dir = File.dirname(__FILE__)
require "#{dir}/source"
class Section < Erector::InlineWidget
include Source # todo: make it not an InlineWidget after all
needs :name, :href => nil, :sections => []
attr_reader :name, :sections
def href
@href || @name.split(':').first.gsub(/[^\w]/, '').downcase
end
# to... |
github | erector/erector | https://github.com/erector/erector | web/developers.rb | Ruby | mit | 229 | master | 4,705 | dir = File.dirname(__FILE__)
require "#{dir}/page"
require "#{dir}/navbar"
class Developers < Page
def initialize
super(:page_title => "For Developers")
end
def promo
"images/be-an-erector-engineer.jpeg"
end
def body_content
h1 "Want to help develop Erector? Here's what to do."
h2 "Clone ... |
github | erector/erector | https://github.com/erector/erector | web/article.rb | Ruby | mit | 229 | master | 1,560 | require 'erector'
here = File.expand_path(File.dirname(__FILE__))
require "#{here}/section"
# todo: move this to Erector::Widgets (aka ErectorSet)
class Article < Erector::Widget
needs :name, :sections => []
def <<(section)
@sections << section
self
end
def add(options, &block)
Section.new(op... |
github | erector/erector | https://github.com/erector/erector | examples/wrapping.rb | Ruby | mit | 229 | master | 520 | # This is an example of the ability to pass a widget in
# to contexts which can also take strings, and have the
# rendered output of the widget appear in that location.
# Understanding this simple example may help with more
# complicated examples like the join and block/widget
# examples in this directory.
require "#... |
github | erector/erector | https://github.com/erector/erector | examples/chunks-via-methods.rb | Ruby | mit | 229 | master | 995 | # One can use methods to create custom view components, in this
# example Chunks and Chunk. Chunks for us are essentially Unordered list wrappers
# with custom styling. A Chunk is a container that has a few
# sections like a Title, and Behaviors plus the body etc.
# Compare with chunks-via-widget.rb.
require "#{Fil... |
github | erector/erector | https://github.com/erector/erector | examples/join-with-dummy-array.rb | Ruby | mit | 229 | master | 1,118 | # See join.rb for the introduction. This is a solution which
# builds up an array (to keep track of which tabs are being
# rendered this time) and then renders the appropriate items
# with separators.
require "#{File.dirname(__FILE__)}/../lib/erector"
class Tabs < Erector::Widget
# note that we are replacing the d... |
github | erector/erector | https://github.com/erector/erector | examples/hello.rb | Ruby | mit | 229 | master | 444 | # This example illustrates basic erector features, including
# rendering HTML and passing in instance variables to a widget.
require "#{File.dirname(__FILE__)}/../lib/erector"
class Hello < Erector::Widget
def content
instruct
html do
head do
title "Hello"
end
body do
text ... |
github | erector/erector | https://github.com/erector/erector | examples/nesting-determines-meaning.rb | Ruby | mit | 229 | master | 1,260 | # This is an example of how, when using the #widget method, you
# can define methods to have different meanings based on what
# they are nested inside of.
# One thing motivating this example is to make it possible to
# have custom "tags" that look identical to built-in tags.
require "#{File.dirname(__FILE__)}/../lib... |
github | erector/erector | https://github.com/erector/erector | examples/join.rb | Ruby | mit | 229 | master | 1,805 | # It is a fairly common situation to have a number of items which
# are to be output with a separator between them, but no separator
# before the first one or after the last. The usual way to do this
# in some non-erector frameworks is to build up an array of rendered
# HTML and then join it (using rendered HTML as th... |
github | erector/erector | https://github.com/erector/erector | examples/chunks-via-widget.rb | Ruby | mit | 229 | master | 1,284 | # The #widget method is for creating custom view components, in this
# example Chunks and Chunk. Chunks for us are essentially Unordered list wrappers
# with custom styling. A Chunk is a container that has a few
# sections like a Title, and Behaviors plus the body etc.
# Compare with chunks-via-method.rb (which, in ... |
github | erector/erector | https://github.com/erector/erector | examples/externals_example.rb | Ruby | mit | 229 | master | 468 | require "#{File.dirname(__FILE__)}/../lib/erector"
class HotSauce < Erector::Widget
external :css, "/css/tapatio.css"
external :css, "/css/salsa_picante.css", :media => "print"
external :js, "/lib/jquery.js"
external :js, "/lib/picante.js"
def content
p :class => "tapatio" do
text "esta salsa es m... |
github | erector/erector | https://github.com/erector/erector | spec/spec_helper.rb | Ruby | mit | 229 | master | 2,805 | $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "rubygems"
require "bundler"
Bundler.setup
require "nokogiri"
require "rr"
require 'tempfile'
require 'ostruct'
require "rspec"
require "rspec/autorun"
require "open3"
require "wrong/adapters/rspec"
include Wrong::D
require "erector"
unless '1.9'.r... |
github | erector/erector | https://github.com/erector/erector | spec/erect/erect_rails_spec.rb | Ruby | mit | 229 | master | 2,882 | require File.expand_path("../../spec_helper", __FILE__)
# backport mktmpdir so this test will work on Ruby 1.8.6
unless Dir.respond_to?(:mktmpdir)
def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil)
case prefix_suffix
when nil
prefix = "d"
suffix = ""
when String
prefix = prefix_suffix
... |
github | erector/erector | https://github.com/erector/erector | spec/erect/erect_spec.rb | Ruby | mit | 229 | master | 5,285 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require "erector/erect/erect"
module Erector
describe Erect do
it "parses an empty command line" do
erect = Erect.new([])
erect.files.should == []
end
it "parses a command line with one filename on it" do
erect =... |
github | erector/erector | https://github.com/erector/erector | spec/erect/erected_spec.rb | Ruby | mit | 229 | master | 4,808 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require "erector/erect/erect"
module Erector
describe Erected do
it "picks the right file name" do
Erected.new("foo.html.erb").filename.should == "foo.rb"
Erected.new("foo.html").filename.should == "foo.rb"
Erected.new("foo.... |
github | erector/erector | https://github.com/erector/erector | spec/erect/rhtml_parser_spec.rb | Ruby | mit | 229 | master | 10,705 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require "erector/erect/erect"
module ParserTestHelper
def assert_evals_to_self(input)
assert_evals_to(input, input)
end
def parse(input)
result = @parser.parse(input)
if result
result.set_indent(0) if result.respond_to? :set... |
github | erector/erector | https://github.com/erector/erector | spec/web/article_spec.rb | Ruby | mit | 229 | master | 6,180 | here = File.dirname(__FILE__)
require File.expand_path("#{here}/../spec_helper")
$: << File.expand_path("#{here}/../../web/")
require "article"
describe Article do
it "requires a name" do
lambda {
Article.new
}.should raise_error(ArgumentError)
a = Article.new(:name => "Foo")
assert { a.insta... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/erect_rails_spec.rb | Ruby | mit | 229 | master | 3,606 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require "erector/rails"
require "rails/version"
# backport mktmpdir so this test will work on Ruby 1.8.6
unless Dir.respond_to?(:mktmpdir)
def Dir.mktmpdir(prefix_suffix=nil, tmpdir=nil)
case prefix_suffix
when nil
prefix = "d"
... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/Gemfile | Ruby | mit | 229 | master | 230 | source 'http://rubygems.org'
gem 'rails', '2.3.11'
gem 'sqlite3', '>=1.3.4'
gem "erector", :path => "../../.."
gem "i18n"
gem "rdoc", "~>3.8"
group :test do
gem 'rspec'
gem 'rr'
gem 'nokogiri'
gem "wrong", ">=0.5.4"
end |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/Rakefile | Ruby | mit | 229 | master | 539 | # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
require "rspe... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/test/test_helper.rb | Ruby | mit | 229 | master | 1,799 | ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test da... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/spec/rails_spec_helper.rb | Ruby | mit | 229 | master | 1,301 | ENV["RAILS_ENV"] ||= "test"
ENV["BUNDLE_GEMFILE"] ||= "#{File.dirname(__FILE__)}/../Gemfile"
here = File.expand_path(File.dirname(__FILE__))
require File.expand_path("#{here}/../config/environment", __FILE__)
require "rspec"
require File.expand_path("#{here}/../../../spec_helper", __FILE__)
Bundler.require(:test)
c... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/spec/rails_widget_spec.rb | Ruby | mit | 229 | master | 1,903 | require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
describe Erector::Rails::WidgetExtensions do
include Erector::Mixin
before(:each) do
@view = ActionView::Base.new
end
def test_render(&block)
Erector::Rails.render(Erector.inline(&block), @view)
end
it "should be set up with... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/spec/render_spec.rb | Ruby | mit | 229 | master | 10,483 | require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
describe ActionController::Base do
class TestController < ActionController::Base
# Let exceptions propagate rather than generating the usual error page.
include ActionController::TestCase::RaiseActionExceptions
# We need this, becau... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/spec/rails_helpers_spec.rb | Ruby | mit | 229 | master | 7,560 | require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
describe Erector::Rails::Helpers do
class RailsHelpersSpecController < ActionController::Base
end
before do
@controller = RailsHelpersSpecController.new
@request = ActionController::TestRequest.new
@response = ActionController::... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/config/routes.rb | Ruby | mit | 229 | master | 1,909 | ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
# ... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/config/boot.rb | Ruby | mit | 229 | master | 2,895 | # Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/config/environment.rb | Ruby | mit | 229 | master | 2,003 | # Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/config/initializers/session_store.rb | Ruby | mit | 229 | master | 801 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Acti... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/config/initializers/cookie_verification_secret.rb | Ruby | mit | 229 | master | 504 | # Be sure to restart your server when you modify this file.
# Your secret key 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 dictionary attac... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/config/initializers/new_rails_defaults.rb | Ruby | mit | 229 | master | 833 | # Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveReco... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/config/environments/test.rb | Ruby | mit | 229 | master | 1,311 | # Settings specified here will take precedence over those in config/environment.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 suite and is wiped
# and recreated between... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/db/seeds.rb | Ruby | mit | 229 | master | 353 | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name =>... |
github | erector/erector | https://github.com/erector/erector | spec/rails2/rails_app/db/schema.rb | Ruby | mit | 229 | master | 766 | # 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 source for your datab... |
github | erector/erector | https://github.com/erector/erector | spec/erector/sass_spec.rb | Ruby | mit | 229 | master | 1,135 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
module CacheSpec
describe Erector::Sass do
include Erector::Mixin
describe 'the #sass method' do
it "renders SCSS by default, since that's what Sass recommends these days" do
erector {sass SAMPLE_SCSS}.should == SAMPLE_CSS
... |
github | erector/erector | https://github.com/erector/erector | spec/erector/externals_spec.rb | Ruby | mit | 229 | master | 7,336 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require 'benchmark'
require 'active_support' # for Symbol#to_proc
module ExternalsSpec
describe "adding dependencies" do
before do
@args = [:what, :ever, :is, :passed]
@result = Erector::Dependency.new :js, '/foo.js'
@result2... |
github | erector/erector | https://github.com/erector/erector | spec/erector/convenience_spec.rb | Ruby | mit | 229 | master | 7,034 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
describe Erector::Convenience do
include Erector::Mixin
let(:tick) { CGI.escapeHTML("'") }
describe "#to_pretty" do
it "calls render with :prettyprint => true" do
widget = Erector.inline do
div "foo"
end
mock(widg... |
github | erector/erector | https://github.com/erector/erector | spec/erector/unicode_builder_spec.rb | Ruby | mit | 229 | master | 2,102 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require File.expand_path("#{File.dirname(__FILE__)}/../../lib/erector/unicode_builder")
describe "build unicode" do
def make_builder(input_string)
@output = ""
Erector::UnicodeBuilder.new(
StringIO.new(input_string),
StringIO.... |
github | erector/erector | https://github.com/erector/erector | spec/erector/jquery_spec.rb | Ruby | mit | 229 | master | 1,168 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
describe Erector::JQuery do
include Erector::Mixin
describe "#jquery" do
def expected(event, *args)
"<script #{'id="foo" ' if args.include? :id}type=\"text/javascript\">\n" +
"// <![CDATA[\n\n" +
"jQuery(do... |
github | erector/erector | https://github.com/erector/erector | spec/erector/needs_spec.rb | Ruby | mit | 229 | master | 4,723 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
describe Erector::Needs do
it "doesn't complain if there aren't any needs declared" do
class Thing1 < Erector::Widget
end
Thing1.new
end
it "allows you to say that you don't want any parameters" do
class Thing2 < Erector::Widge... |
github | erector/erector | https://github.com/erector/erector | spec/erector/output_spec.rb | Ruby | mit | 229 | master | 8,039 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require 'active_support'
module Erector
describe Erector::Output do
before do
@output = Output.new
end
it "accepts a string via the << operator" do
@output.to_s.should == ""
@output << "foo"
@output.to_s.should... |
github | erector/erector | https://github.com/erector/erector | spec/erector/dependency_spec.rb | Ruby | mit | 229 | master | 2,355 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require 'benchmark'
require 'active_support' # for Symbol#to_proc
module DependencySpec
describe Erector::Dependency do
it "can be constructed with type and text" do
x = Erector::Dependency.new(:foo, "abc")
x.type.should == :foo
... |
github | erector/erector | https://github.com/erector/erector | spec/erector/hello_from_readme.rb | Ruby | mit | 229 | master | 293 | here = File.expand_path(File.dirname(__FILE__))
$: << "#{here}/../../lib"
require "erector"
class Hello < Erector::Widget
def content
html do
head do
title "Welcome page"
end
body do
p "Hello, world"
end
end
end
end
puts Hello.new.to_html |
github | erector/erector | https://github.com/erector/erector | spec/erector/promise_spec.rb | Ruby | mit | 229 | master | 4,839 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require "erector/promise"
# a "promise" is my working name for a pointer back into the output stream, so we can rewrite the current tag (or a different one)
module Erector
describe Promise do
before do
@buffer = []
@output = Output.... |
github | erector/erector | https://github.com/erector/erector | spec/erector/inline_spec.rb | Ruby | mit | 229 | master | 2,665 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
describe Erector::Widget do
it "provides access to instance variables from the calling context" do
@var = "yay"
Erector::Widget.new { @var.should == "yay"; @var = "yum" }.to_html
@var.should == "yum"
end
it "provides access to boun... |
github | erector/erector | https://github.com/erector/erector | spec/erector/tag_spec.rb | Ruby | mit | 229 | master | 1,726 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require "erector/tag"
module Erector
describe Tag do
it "takes a name" do
t = Tag.new("foo")
t.name.should == "foo"
end
it "has default values for its options" do
t = Tag.new("foo")
t.self_closing?.should == fal... |
github | erector/erector | https://github.com/erector/erector | spec/erector/mixin_spec.rb | Ruby | mit | 229 | master | 1,595 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require 'benchmark'
module MixinSpec
describe Erector::Mixin do
describe "#erector" do
it "renders its block to a string" do
class Thing
include Erector::Mixin
def name
erector do
... |
github | erector/erector | https://github.com/erector/erector | spec/erector/xml_widget_spec.rb | Ruby | mit | 229 | master | 1,900 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require "erector/xml_widget"
module XmlWidgetSpec
class Rss2Widget < Erector::XMLWidget
tag "rss"
tag "channel"
tag "title"
tag "description"
tag "link"
tag "lastBuildDate"
tag "pubDate"
tag "item"
tag "guid"
... |
github | erector/erector | https://github.com/erector/erector | spec/erector/indentation_spec.rb | Ruby | mit | 229 | master | 5,035 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
describe "indentation" do
include Erector::Mixin
it "can detect newliney tags" do
widget = ::Erector.inline
widget.instance_eval do
@prettyprint = true
end
widget.send(:newliney?, "i").should == false
widget.send(:newli... |
github | erector/erector | https://github.com/erector/erector | spec/erector/widget_spec.rb | Ruby | mit | 229 | master | 8,759 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
require 'benchmark'
module WidgetSpec
describe Erector::Widget do
include Erector::Mixin
describe "#to_html" do
it "invokes #content and returns the string representation of the rendered widget" do
Class.new(Erector::Widget) ... |
github | erector/erector | https://github.com/erector/erector | spec/erector/caching_spec.rb | Ruby | mit | 229 | master | 7,701 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
# todo: figure out why "include Caching" only works when it's on Widget
describe Erector::Cache do
before do
@cache = Erector::Cache.new
end
class Johnny < Erector::Widget
end
class June < Erector::Widget
end
it... |
github | erector/erector | https://github.com/erector/erector | spec/erector/html_spec.rb | Ruby | mit | 229 | master | 16,293 | require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
describe Erector::HTML do
include Erector::Mixin
let(:tick) { CGI.escapeHTML("'") }
describe "#instruct" do
it "when passed no arguments; returns an XML declaration with version 1 and utf-8" do
# version must precede encoding, per X... |
github | erector/erector | https://github.com/erector/erector | spec/erector/hello_from_readme_spec.rb | Ruby | mit | 229 | master | 407 | here = File.expand_path(File.dirname(__FILE__))
require File.expand_path("#{here}/../spec_helper")
describe "Hello World example from README" do
it "works" do
Dir.chdir('/tmp') do
clear_bundler_env
html = `ruby #{File.join(here,'hello_from_readme.rb')} 2>&1`
html.should == "<html><head><title>W... |
github | erector/erector | https://github.com/erector/erector | spec/erector/widgets/table_spec.rb | Ruby | mit | 229 | master | 2,938 | require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
module TableSpec
class DefaultsTestTable < Erector::Widgets::Table
column :first_name
column :last_name
column :email
row_classes :even, :odd
end
class CustomHeadingTable < Erector::Widgets::Table
column :first_name, "Co... |
github | erector/erector | https://github.com/erector/erector | spec/erector/widgets/page_spec.rb | Ruby | mit | 229 | master | 2,050 | require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
describe Erector::Widgets::Page do
it "works" do
Erector::Widgets::Page.new.to_html
end
it "renders body_content" do
Class.new(Erector::Widgets::Page) do
def body_content
text "body_content"
end
end.new.to_ht... |
github | erector/erector | https://github.com/erector/erector | spec/erector/widgets/form_spec.rb | Ruby | mit | 229 | master | 988 | require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
describe Form do
include Erector::Mixin
it "defaults to POST, with no magic hidden method param" do
Form.new(:action => "/foo").to_html.should == "<form action=\"/foo\" method=\"post\"></form>"
end
it "works plainly with GET too" do... |
github | erector/erector | https://github.com/erector/erector | spec/erector/widgets/field_table_spec.rb | Ruby | mit | 229 | master | 5,282 | require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
module Erector
module Widgets
describe FieldTable do
describe "a basic, brittle characterization test, just to get up and running" do
class PasswordForm < Erector::Widget
def content
form :action => "/u... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/Gemfile | Ruby | mit | 229 | master | 201 | source 'http://rubygems.org'
gem 'rails', '~> 3.0.0'
gem 'sqlite3', '>=1.3.4'
gem "erector", :path => "../.."
gem "i18n"
gem "rdoc", "~>3.8"
group :test do
gem 'rspec'
gem "wrong", ">=0.5.4"
end |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/Rakefile | Ruby | mit | 229 | master | 269 | # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
RailsRoot::Application.load_tasks |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/app/controllers/application.rb | Ruby | mit | 229 | master | 261 | # Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
end |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/app/views/layouts/widget_as_layout.rb | Ruby | mit | 229 | master | 204 | class Views::Layouts::WidgetAsLayout < Erector::Widget
def content
content_for(:top) if content_for?(:top)
text @before || "BEFORE"
content_for(:layout)
text @after || "AFTER"
end
end |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/config/routes.rb | Ruby | mit | 229 | master | 1,788 | RailsRoot::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'pro... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/config/application.rb | Ruby | mit | 229 | master | 1,922 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module RailsRoot
class Application < Rails::Application
... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/config/environments/development.rb | Ruby | mit | 229 | master | 872 | RailsRoot::Application.configure do
# Settings specified here will take precedence over those in config/environment.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... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/config/environments/production.rb | Ruby | mit | 229 | master | 1,758 | RailsRoot::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned ... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/config/environments/test.rb | Ruby | mit | 229 | master | 1,539 | RailsRoot::Application.configure do
# Settings specified here will take precedence over those in config/environment.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 tes... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/config/initializers/session_store.rb | Ruby | mit | 229 | master | 414 | # Be sure to restart your server when you modify this file.
RailsRoot::Application.config.session_store :cookie_store, :key => '_rails_root_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with ... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/config/initializers/secret_token.rb | Ruby | mit | 229 | master | 500 | # Be sure to restart your server when you modify this file.
# Your secret key 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 dictionary attac... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/spec/form_builder_spec.rb | Ruby | mit | 229 | master | 877 | require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
describe Erector::Rails::FormBuilder do
describe ".parent_builder_class" do
it "defaults to ActionView::Base.default_form_builder" do
Erector::Rails::FormBuilder.parent_builder_class.should == ActionView::Base.default_form_builder
... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/spec/rails_widget_spec.rb | Ruby | mit | 229 | master | 1,897 | require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
describe Erector::Rails do
include Erector::Mixin
before(:each) do
@view = ActionView::Base.new
end
def test_render(&block)
Erector::Rails.render(Erector.inline(&block), @view)
end
it "should be set up with the same output b... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/spec/render_spec.rb | Ruby | mit | 229 | master | 12,633 | require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
describe ActionController::Base do
class TestController < ActionController::Base
# Let exceptions propagate rather than generating the usual error page.
include ActionController::TestCase::RaiseActionExceptions
# We need this, becau... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/spec/rails_helpers_spec.rb | Ruby | mit | 229 | master | 7,060 | require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
describe Erector::Rails do
before do
@controller = ActionController::Base.new
@controller.request = ActionController::TestRequest.new
@view = ActionView::Base.new
@view.controller = @controller
def @view.... |
github | erector/erector | https://github.com/erector/erector | spec/rails_root/spec/rails_spec_helper.rb | Ruby | mit | 229 | master | 323 | ENV["RAILS_ENV"] ||= "test"
ENV["BUNDLE_GEMFILE"] ||= "#{File.dirname(__FILE__)}/../Gemfile"
here = File.expand_path(File.dirname(__FILE__))
require File.expand_path("#{here}/../../spec_helper", __FILE__)
require File.expand_path("#{here}/../config/environment", __FILE__)
Bundler.require(:test)
require "erector/rail... |
github | joshuay03/dial | https://github.com/joshuay03/dial | dial.gemspec | Ruby | mit | 229 | main | 867 | # frozen_string_literal: true
require_relative "lib/dial/version"
Gem::Specification.new do |spec|
spec.name = "dial"
spec.version = Dial::VERSION
spec.authors = ["Joshua Young"]
spec.email = ["djry1999@gmail.com"]
spec.summary = "A modern profiler for your Rails application"
spec.homepage = "https://git... |
github | joshuay03/dial | https://github.com/joshuay03/dial | Gemfile | Ruby | mit | 229 | main | 602 | # frozen_string_literal: true
source "https://rubygems.org"
gemspec
gem "rake"
gem "minitest"
gem "minitest-mock"
gem "debug"
case ENV["RAILS_VERSION"]
when "7.1"
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.5")
gem "logger"
gem "benchmark"
end
gem "sqlite3", "~> 1.4"
when "7.2"
if Ge... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial.rb | Ruby | mit | 229 | main | 229 | # frozen_string_literal: true
require_relative "dial/constants"
require_relative "dial/util"
require_relative "dial/configuration"
require_relative "dial/storage"
require_relative "dial/railtie"
require_relative "dial/engine" |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/prosopite_composite_logger.rb | Ruby | mit | 229 | main | 905 | # frozen_string_literal: true
require "logger"
module Dial
class ProsopiteCompositeLogger
def initialize dial_logger, existing_logger = nil
@dial_logger = dial_logger
@existing_logger = existing_logger
end
def level
@dial_logger.level
end
def level= value
@dial_logger.l... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/util.rb | Ruby | mit | 229 | main | 401 | # frozen_string_literal: true
require "securerandom"
module Dial
module Util
class << self
def uuid
SecureRandom.uuid_v7
end
def file_name_uuid file_name
file_name.split("_").first
end
def uuid_timestamp uuid
high_bits_hex = uuid.split("-").first(2).join[0... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/configuration.rb | Ruby | mit | 229 | main | 1,094 | # frozen_string_literal: true
module Dial
def self.configure
yield _configuration
end
def self._configuration
@_configuration ||= Configuration.new
end
class Configuration
def initialize
@options = {
enabled: true,
force_param: FORCE_PARAM,
sampling_percentage: ::R... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/railtie.rb | Ruby | mit | 229 | main | 884 | # frozen_string_literal: true
require "rails"
require "active_record"
require "prosopite"
require_relative "middleware"
require_relative "prosopite_logger"
module Dial
class Railtie < ::Rails::Railtie
initializer "dial.setup", after: :load_config_initializers do |app|
app.config.after_initialize do
... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/constants.rb | Ruby | mit | 229 | main | 901 | # frozen_string_literal: true
require "rack"
require "action_dispatch"
require "stringio"
require_relative "version"
module Dial
PROGRAM_ID = Process.getsid Process.pid
HTTP_ACCEPT = "HTTP_ACCEPT"
CONTENT_TYPE = ::Rack::CONTENT_TYPE
CONTENT_TYPE_HTML = "text/html"
CONTENT_LENGTH = ::Rack::CONTENT_LENGTH
... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/middleware.rb | Ruby | mit | 229 | main | 4,921 | # frozen_string_literal: true
require "vernier"
require "prosopite"
require_relative "prosopite"
require_relative "middleware/panel"
require_relative "middleware/ruby_stat"
require_relative "middleware/rails_stat"
module Dial
class Middleware
include RubyStat
include RailsStat
def initialize app
... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/prosopite.rb | Ruby | mit | 229 | main | 1,053 | # frozen_string_literal: true
require "active_support/core_ext/string/filters"
require_relative "prosopite_composite_logger"
module Dial
module Prosopite
def custom_logger= logger
return super logger if @setting_dial_logger
@original_logger = logger
if @dial_logger && @original_logger
... |
github | joshuay03/dial | https://github.com/joshuay03/dial | lib/dial/prosopite_logger.rb | Ruby | mit | 229 | main | 530 | # frozen_string_literal: true
require "logger"
module Dial
class ProsopiteLogger < Logger
def self.log_io
Thread.current[:dial_prosopite_log_io] ||= StringIO.new
end
def initialize
super StringIO.new
end
def add severity, message = nil, progname = nil
return if severity < lev... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.