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 | martijn/xsv | https://github.com/martijn/xsv | test/utf8_happiness_test.rb | Ruby | mit | 230 | main | 794 | require "./test/test_helper"
class Utf8HappinessTest < Minitest::Test
def test_utf8_sheet_names
workbook = Xsv.open("test/files/utf8-sheetnames.xlsx")
assert_equal "ÄËÏÖÜàèìòùâêîôû", workbook.sheets[0].name
assert_equal " ¯\(ツ)/¯ ", workbook.sheets[1].name
assert_equal "☼♔∞♛☆", workbook.sheets[2].na... |
github | martijn/xsv | https://github.com/martijn/xsv | test/helpers_test.rb | Ruby | mit | 230 | main | 332 | require "./test/test_helper"
class HelpersTest < Minitest::Test
include Xsv::Helpers
def test_parse_number_integer
assert_equal 1, parse_number("1")
end
def test_parse_number_float
assert_equal 0.1, parse_number("0.1")
end
def test_parse_number_complex
assert_equal 0.001, parse_number("1E-3"... |
github | martijn/xsv | https://github.com/martijn/xsv | test/sheet_bounds_handler_test.rb | Ruby | mit | 230 | main | 606 | require "./test/test_helper"
class SheetBoundsHandlerTest < Minitest::Test
def setup
@workbook = Xsv.open("test/files/excel2016.xlsx")
@sheet = File.open("test/files/sheet1.xml")
end
def test_sheet_bounds
rows, cols = Xsv::SheetBoundsHandler.get_bounds(@sheet, @workbook)
assert_equal 4, rows
... |
github | martijn/xsv | https://github.com/martijn/xsv | test/sax_parser_test.rb | Ruby | mit | 230 | main | 3,427 | require "./test/test_helper"
class SaxParserTest < Minitest::Test
def test_truncated_document
str = File.open("test/files/sheet1.xml") { |file| file.read(100) }
parser = Class.new(Xsv::SaxParser) do
def start_element(_, _)
end
end
assert_raises Xsv::Error do
parser.new.parse(str)
... |
github | martijn/xsv | https://github.com/martijn/xsv | test/misc_test.rb | Ruby | mit | 230 | main | 670 | require "./test/test_helper"
# Test for miscellaneous files found in the wild
class MiscTest < Minitest::Test
def test_complex_number
@file = Xsv.open("test/files/complex.xlsx")
row = @file.sheets[0][1]
assert_equal 0.001, row[1]
assert_equal 0.01, row[2]
assert_equal 0.1, row[3]
end
def ... |
github | martijn/xsv | https://github.com/martijn/xsv | test/sheet_test.rb | Ruby | mit | 230 | main | 3,923 | require "./test/test_helper"
class SheetTest < Minitest::Test
# Note: Many tests for the sheet class live in the test cases for various file formats
def test_enumerable
@workbook = Xsv.open("test/files/excel2016.xlsx")
first_row = @workbook.sheets[0].first
assert_equal @workbook.sheets[0][0], first_r... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | rust/Vagrantfile | Ruby | mit | 229 | master | 705 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "rust.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | iojs/Vagrantfile | Ruby | mit | 229 | master | 987 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
version = "1.2.0"
hostname = "iojs.box"
locale = "en_GB.UTF.8"
path = "iojs-v#{version}-linux-x64"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | python/Vagrantfile | Ruby | mit | 229 | master | 690 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "python.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | lua/Vagrantfile | Ruby | mit | 229 | master | 703 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
version = "5.2"
hostname = "lua.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "to... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | csharp/Vagrantfile | Ruby | mit | 229 | master | 686 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "csharp.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | php/Vagrantfile | Ruby | mit | 229 | master | 983 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
version = "php5-5.6"
hostname = "php.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline =... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | perl/Vagrantfile | Ruby | mit | 229 | master | 591 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "perl.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | clojure/Vagrantfile | Ruby | mit | 229 | master | 1,441 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "clojure.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | hhvm/Vagrantfile | Ruby | mit | 229 | master | 1,170 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "hhvm.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | ruby/Vagrantfile | Ruby | mit | 229 | master | 1,049 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
version = "2.2.0"
hostname = "ruby.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => ... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | haskell/Vagrantfile | Ruby | mit | 229 | master | 677 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "haskell.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | julia/Vagrantfile | Ruby | mit | 229 | master | 880 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "julia.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | erlang/Vagrantfile | Ruby | mit | 229 | master | 1,130 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "erlang.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | nodejs/Vagrantfile | Ruby | mit | 229 | master | 783 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "nodejs.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | scheme/Vagrantfile | Ruby | mit | 229 | master | 713 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "scheme.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | brainfuck/Vagrantfile | Ruby | mit | 229 | master | 672 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "brainfuck.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | bash/Vagrantfile | Ruby | mit | 229 | master | 591 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "bash.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | elixir/Vagrantfile | Ruby | mit | 229 | master | 1,518 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "elixir.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | racket/Vagrantfile | Ruby | mit | 229 | master | 1,023 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
version = "5.93"
hostname = "racket.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline =>... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | ocaml/Vagrantfile | Ruby | mit | 229 | master | 1,162 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
hostname = "ocaml.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
config.vm.provision :shell, :inline => "touch .hushlogin"
... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | scala/Vagrantfile | Ruby | mit | 229 | master | 1,909 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
version_scala = "2.11.5"
version_sbt = "0.13.7"
hostname = "scala.box"
locale = "en_GB.UTF.8"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "/srv"
# Setup
conf... |
github | adlawson/vagrantfiles | https://github.com/adlawson/vagrantfiles | golang/Vagrantfile | Ruby | mit | 229 | master | 1,555 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
version = "1.4.2"
hostname = "golang.box"
locale = "en_GB.UTF.8"
workspace = "/usr/workspace"
package = "dev"
# Box
config.vm.box = "ubuntu/trusty64"
# Shared folders
config.vm.synced_folder ".", "#{works... |
github | croaky/recipient_interceptor | https://github.com/croaky/recipient_interceptor | recipient_interceptor.gemspec | Ruby | mit | 229 | main | 516 | Gem::Specification.new do |spec|
spec.add_dependency "mail"
spec.authors = ["Dan Croak"]
spec.description = <<-STRING
Avoid emailing your users from non-production environments.
STRING
spec.files = ["lib/recipient_interceptor.rb"]
spec.homepage = "http://github.com/croaky/recipient_interceptor"
spec... |
github | croaky/recipient_interceptor | https://github.com/croaky/recipient_interceptor | spec/recipient_interceptor_spec.rb | Ruby | mit | 229 | main | 3,260 | require File.join(File.dirname(__FILE__), "..", "lib", "recipient_interceptor")
describe RecipientInterceptor do
before do
Mail.defaults do
delivery_method :test
end
module Mail
@@delivery_interceptors = []
end
end
it "overrides to/cc/bcc fields and adds custom headers" do
Mail.... |
github | croaky/recipient_interceptor | https://github.com/croaky/recipient_interceptor | lib/recipient_interceptor.rb | Ruby | mit | 229 | main | 720 | require "mail"
class RecipientInterceptor
def initialize(recipients, opts = {})
@recipients = if recipients.respond_to?(:split)
recipients.split(",")
else
recipients
end
@subject_prefix = opts[:subject_prefix]
end
def delivering_email(msg)
if @subject_prefix.respond_to?(:call)
... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | Rakefile | Ruby | mit | 229 | main | 207 | require "bundler"
require "bundler/setup"
Bundler::GemHelper.install_tasks
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new do |t|
t.rspec_opts = %w[-c]
end
task default: :spec
task test: :spec |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | gyoku.gemspec | Ruby | mit | 229 | main | 780 | $:.push File.expand_path("../lib", __FILE__)
require "gyoku/version"
Gem::Specification.new do |s|
s.name = "gyoku"
s.version = Gyoku::VERSION
s.platform = Gem::Platform::RUBY
s.authors = "Daniel Harrington"
s.email = "me@rubiii.com"
s.homepage = "https://github.com/savonrb/#{s.name}"
s.summary = "Transl... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | lib/gyoku.rb | Ruby | mit | 229 | main | 332 | require "gyoku/version"
require "gyoku/hash"
module Gyoku
# Converts a given Hash +key+ with +options+ into an XML tag.
def self.xml_tag(key, options = {})
XMLKey.create(key, options)
end
# Translates a given +hash+ with +options+ to XML.
def self.xml(hash, options = {})
Hash.to_xml hash.dup, option... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | lib/gyoku/hash.rb | Ruby | mit | 229 | main | 3,904 | require "builder"
require "gyoku/prettifier"
require "gyoku/array"
require "gyoku/xml_key"
require "gyoku/xml_value"
module Gyoku
module Hash
module_function
# Builds XML and prettifies it if +pretty_print+ option is set to +true+
def to_xml(hash, options = {})
xml = build_xml(hash, options)
... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | lib/gyoku/prettifier.rb | Ruby | mit | 229 | main | 701 | require "rexml/document"
module Gyoku
class Prettifier
DEFAULT_INDENT = 2
DEFAULT_COMPACT = true
attr_accessor :indent, :compact
def self.prettify(xml, options = {})
new(options).prettify(xml)
end
def initialize(options = {})
@indent = options[:indent] || DEFAULT_INDENT
@... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | lib/gyoku/xml_value.rb | Ruby | mit | 229 | main | 990 | require "cgi"
require "date"
module Gyoku
module XMLValue
class << self
# xs:date format
XS_DATE_FORMAT = "%Y-%m-%d"
# xs:time format
XS_TIME_FORMAT = "%H:%M:%S"
# xs:dateTime format
XS_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S%Z"
# Converts a given +object+ to an XML valu... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | lib/gyoku/xml_key.rb | Ruby | mit | 229 | main | 2,156 | module Gyoku
module XMLKey
class << self
CAMELCASE = lambda { |key| key.gsub(/\/(.?)/) { |m| "::#{m[-1].upcase}" }.gsub(/(?:^|_)(.)/) { |m| m[-1].upcase } }
LOWER_CAMELCASE = lambda { |key| key[0].chr.downcase + CAMELCASE.call(key)[1..] }
UPCASE = lambda { |key| key.upcase }
FORMULAS = {
... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | lib/gyoku/array.rb | Ruby | mit | 229 | main | 3,259 | module Gyoku
module Array
module_function
NESTED_ELEMENT_NAME = "element"
# Builds XML and prettifies it if +pretty_print+ option is set to +true+
def to_xml(array, key, escape_xml = true, attributes = {}, options = {})
xml = build_xml(array, key, escape_xml, attributes, options)
if opt... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | spec/spec_helper.rb | Ruby | mit | 229 | main | 280 | require "bundler"
Bundler.setup(:default, :development)
unless RUBY_PLATFORM.match?(/java/)
require "simplecov"
require "coveralls"
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start do
add_filter "spec"
end
end
require "gyoku"
require "rspec" |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | spec/gyoku_spec.rb | Ruby | mit | 229 | main | 2,474 | require "spec_helper"
describe Gyoku do
describe ".xml_tag" do
it "translates Symbols to lowerCamelCase by default" do
tag = Gyoku.xml_tag(:user_name)
expect(tag).to eq("userName")
end
it "does not translate Strings" do
tag = Gyoku.xml_tag("user_name")
expect(tag).to eq("user_nam... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | spec/gyoku/array_spec.rb | Ruby | mit | 229 | main | 4,413 | require "spec_helper"
describe Gyoku::Array do
describe ".to_xml" do
it "returns the XML for an Array of Hashes" do
array = [{name: "adam"}, {name: "eve"}]
result = "<user><name>adam</name></user><user><name>eve</name></user>"
expect(to_xml(array, "user")).to eq(result)
end
it "return... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | spec/gyoku/xml_value_spec.rb | Ruby | mit | 229 | main | 2,107 | require "spec_helper"
describe Gyoku::XMLValue do
describe ".create" do
context "for DateTime objects" do
it "returns an xs:dateTime compliant String" do
expect(create(DateTime.new(2012, 3, 22, 16, 22, 33))).to eq("2012-03-22T16:22:33+00:00")
end
end
context "for Date objects" do
... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | spec/gyoku/prettifier_spec.rb | Ruby | mit | 229 | main | 1,199 | require "spec_helper"
describe Gyoku::Prettifier do
describe "#prettify" do
context "when xml is valid" do
let!(:xml) { Gyoku::Hash.build_xml(test: {pretty: "xml"}) }
it "returns prettified xml" do
expect(subject.prettify(xml)).to eql("<test>\n <pretty>xml</pretty>\n</test>")
end
... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | spec/gyoku/xml_key_spec.rb | Ruby | mit | 229 | main | 2,830 | require "spec_helper"
describe Gyoku::XMLKey do
describe ".create" do
it "removes exclamation marks from the end of a String" do
expect(create("value!")).to eq("value")
end
it "removes forward slashes from the end of a String" do
expect(create("self-closing/")).to eq("self-closing")
end
... |
github | savonrb/gyoku | https://github.com/savonrb/gyoku | spec/gyoku/hash_spec.rb | Ruby | mit | 229 | main | 15,393 | require "spec_helper"
describe Gyoku::Hash do
describe ".to_xml" do
describe "returns SOAP request compatible XML" do
it "for a simple Hash" do
expect(to_xml(some: "user")).to eq("<some>user</some>")
end
it "for a nested Hash" do
expect(to_xml(some: {new: "user"})).to eq("<some... |
github | nickhammond/ansible-logrotate | https://github.com/nickhammond/ansible-logrotate | tests/Vagrantfile | Ruby | bsd-3-clause | 229 | master | 642 | # -*- mode: ruby -*-
# vi: set ft=ruby :
@ansible_home = "/home/vagrant/.ansible"
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
# Copy the Ansible playbook over to the guest machine, run rsync-auto to automatically
# pull in the latest changes while a VM is running.
config.vm.synced_fol... |
github | CenturyLinkLabs/building | https://github.com/CenturyLinkLabs/building | building.gemspec | Ruby | mit | 229 | master | 567 | Gem::Specification.new do |s|
s.name = 'building'
s.version = '1.1.2'
s.date = '2014-03-31'
s.summary = "Build a Docker container for any app using Heroku Buildpacks"
s.description = "Build a Docker container for any app using Heroku Buildpacks"
s.authors = ["Lucas Carlson"]
s.em... |
github | CenturyLinkLabs/building | https://github.com/CenturyLinkLabs/building | lib/building.rb | Ruby | mit | 229 | master | 3,679 | require 'yaml'
require 'fileutils'
require 'bundler/setup'
require 'highline/import'
class Building
def self.convert(app_name, tag, options={})
Building.new(app_name, tag, options)
end
def initialize(app_name, tag, options={})
@app_name = app_name
@tag = tag || "latest"
@buildpack_url = options... |
github | erector/erector | https://github.com/erector/erector | clone_rails.rake | Ruby | mit | 229 | master | 1,762 | desc "Clone the rails git repository and configure it for testing."
task(:clone_rails) do
require "erector/rails/rails_version"
rails_root = "#{File.dirname(__FILE__)}/spec/rails_root"
vendor_rails = "#{rails_root}/vendor/rails"
unless File.exists?("#{rails_root}/vendor/rails/.git")
puts "Cloning rails in... |
github | erector/erector | https://github.com/erector/erector | cruise_config.rb | Ruby | mit | 229 | master | 224 | Project.configure do |project|
project.email_notifier.emails = ['alex@stinky.com', 'erector@googlegroups.com']
project.email_notifier.from = 'alexch+erectorci@gmail.com'
project.build_command = "./cruise_build.sh"
end |
github | erector/erector | https://github.com/erector/erector | Rakefile | Ruby | mit | 229 | master | 4,956 | puts "RUBY_VERSION=#{RUBY_VERSION}"
$here = File.dirname(__FILE__)
begin
# fix http://stackoverflow.com/questions/4932881/gemcutter-rake-build-now-throws-undefined-method-write-for-syckemitter
require 'psych' unless RUBY_VERSION =~ /^1\.8/
rescue LoadError
warn "Couldn't find psych; continuing."
end
require "bu... |
github | erector/erector | https://github.com/erector/erector | erector.gemspec | Ruby | mit | 229 | master | 1,445 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'erector/version'
Gem::Specification.new do |spec|
spec.name = "erector"
spec.version = Erector::VERSION
spec.authors = [
"Alex Chaffee",
"Brian Takita",
"Jeff Dean",
"Jim Ki... |
github | erector/erector | https://github.com/erector/erector | Gemfile | Ruby | mit | 229 | master | 337 | source "http://rubygems.org"
gemspec
gem "treetop", ">= 1.2.3"
group :development do
gem "rake", "~>10.0.3"
gem "activesupport", ">=3" # for titleize
gem "rails", "~>3" # for erect spec
gem "rspec", "~>2"
gem "rr"
gem "nokogiri"
gem "haml"
gem "sass"
gem "erubis"
gem "rdoc", "~> 3.4"
gem "wrong... |
github | erector/erector | https://github.com/erector/erector | lib/erector.rb | Ruby | mit | 229 | master | 643 | module Erector
end
require "cgi"
require "yaml"
require "erector/raw_string"
require "erector/dependencies"
require "erector/dependency"
require "erector/externals"
require "erector/output"
require "erector/caching"
require "erector/after_initialize"
require "erector/needs"
require "erector/html"
require "erector/con... |
github | erector/erector | https://github.com/erector/erector | lib/erector/tag.rb | Ruby | mit | 229 | master | 1,793 | module Erector
# Defines a type of tag (not an actual element with attributes and contents)
class Tag
# Pass the self_closing and inline params as symbols, e.g.
#
# Tag.new("i", :inline)
# Tag.new("input", :inline, :self_closing)
#
# @param name the name of the tag, e.g. "div"
# @param... |
github | erector/erector | https://github.com/erector/erector | lib/erector/html_widget.rb | Ruby | mit | 229 | master | 5,223 | require "erector/xml_widget"
module Erector
# A Widget is the center of the Erector universe.
#
# To create a widget, extend Erector::Widget and implement the +content+
# method. Inside this method you may call any of the tag methods like +span+
# or +p+ to emit HTML/XML tags.
#
# You can also define a ... |
github | erector/erector | https://github.com/erector/erector | lib/erector/widgets.rb | Ruby | mit | 229 | master | 220 | require "erector/widgets/environment_badge"
require "erector/widgets/field_table"
require "erector/widgets/form"
require "erector/widgets/external_renderer"
require "erector/widgets/page"
require "erector/widgets/table" |
github | erector/erector | https://github.com/erector/erector | lib/erector/widget.rb | Ruby | mit | 229 | master | 3,279 | require "erector/element"
require "erector/attributes"
require "erector/promise"
require "erector/text"
require "erector/tag"
require "erector/html_widget"
require "erector/needs"
module Erector
# A Widget is the center of the Erector universe.
#
# To create a widget, extend Erector::Widget and implement the +c... |
github | erector/erector | https://github.com/erector/erector | lib/erector/dependency.rb | Ruby | mit | 229 | master | 751 | module Erector
class Dependency
attr_reader :type, :text, :options
def initialize(type, text, options = {})
text = text.read if text.is_a? IO
text = self.class.interpolate(text) if options[:interpolate] # todo: test
@type, @text, @options = type, text, options
end
def self.interpol... |
github | erector/erector | https://github.com/erector/erector | lib/erector/jquery.rb | Ruby | mit | 229 | master | 1,020 | module Erector
module JQuery
# Emits a jQuery script, inside its own script tag, that is to be run on document ready or load.
#
# Usage (from inside a widget method):
# jquery "alert('hi')" :: a jquery ready handler
# jquery "alert('hi')", :id => 'foo' :: a jquery ready handler, with attributes in... |
github | erector/erector | https://github.com/erector/erector | lib/erector/dependencies.rb | Ruby | mit | 229 | master | 613 | module Erector
class Dependencies < Array
def push(*new_dependencies_args)
new_dependencies = new_dependencies_args.select do |new_dependency|
!include?(new_dependency)
end
new_dependencies.each do |dep|
unless dep.is_a? Erector::Dependency
raise "expected Dependency, g... |
github | erector/erector | https://github.com/erector/erector | lib/erector/caching.rb | Ruby | mit | 229 | master | 1,928 | module Erector
class Cache
def initialize
@stores = {}
end
def store_for(klass)
@stores[klass] ||= Hash.new {|h,k| h[k] = {}}
end
def []=(*args)
value = args.pop
klass = args.shift
params = args.first.is_a?(Hash) ? args.first : {}
content_method = args.last.is... |
github | erector/erector | https://github.com/erector/erector | lib/erector/promise.rb | Ruby | mit | 229 | master | 2,949 | require "erector/attributes"
require "erector/text"
module Erector
class Promise
extend Attributes
extend Text
def initialize(output, tag_name, attributes = {}, self_closing = false, newliney = true, &inside_renderer)
raise "bad output: #{output.inspect}" unless output.is_a? Output
raise "fo... |
github | erector/erector | https://github.com/erector/erector | lib/erector/abstract_widget.rb | Ruby | mit | 229 | master | 8,386 | require 'erector/element'
require 'erector/attributes'
require 'erector/text'
require 'erector/convenience'
require 'erector/after_initialize'
require 'erector/output'
module Erector
# Abstract base class for Widget. This pattern allows Widget to include lots
# of nicely organized modules and still have proper se... |
github | erector/erector | https://github.com/erector/erector | lib/erector/version.rb | Ruby | mit | 229 | master | 318 | require 'yaml'
##
# Erector view framework
module Erector
if !Erector.const_defined?(:VERSION)
dir = File.dirname(__FILE__)
version = YAML.load_file(File.expand_path("#{dir}/../../VERSION.yml"))
VERSION = [version[:major], version[:minor], version[:patch], version[:build]].compact.join('.')
end
end |
github | erector/erector | https://github.com/erector/erector | lib/erector/unicode_builder.rb | Ruby | mit | 229 | master | 1,238 | # Note that this class is only used in building erector itself
# (and even then, only needs to be run when there is a new
# UnicodeData.txt file from unicode.org).
class Erector::UnicodeBuilder
def initialize(input, output)
@input = input
@output = output
@first = true
end
def generate()
@outp... |
github | erector/erector | https://github.com/erector/erector | lib/erector/raw_string.rb | Ruby | mit | 229 | master | 217 | module Erector
# A string that has a special type so Erector knows to render it directly, not HTML-escaped
class RawString < String
def html_safe?
true
end
def to_s
self
end
end
end |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails2.rb | Ruby | mit | 229 | master | 1,184 | require "action_controller"
require "erector/rails2/rails_version"
require "erector/rails2/rails_form_builder"
require "erector/rails2/extensions/action_controller"
require "erector/rails2/extensions/rails_helpers"
require "erector/rails2/extensions/rails_widget"
require "erector/rails2/template_handlers/rb_handler"
re... |
github | erector/erector | https://github.com/erector/erector | lib/erector/mixin.rb | Ruby | mit | 229 | master | 556 | module Erector
module Mixin
# Executes the block as if it were the content body of a fresh Erector::Inline,
# and returns the #to_html value. Since it executes inside the new widget it does not
# have access to instance variables of the caller, although it does
# have access to bound variables. Funnil... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails3.rb | Ruby | mit | 229 | master | 7,456 | require "erector/rails/template_handler"
require "erector/rails/railtie"
require "erector/rails/widget_renderer"
require "erector/rails/form_builder"
module Erector
module Rails
class << self
def should_assign?(name, widget_class, is_partial)
(!widget_class.ignore_extra_controller_assigns || widget... |
github | erector/erector | https://github.com/erector/erector | lib/erector/output.rb | Ruby | mit | 229 | master | 3,620 | require 'erector/abstract_widget'
module Erector
class Output
SPACES_PER_INDENT = 2
attr_reader :prettyprint, :widgets, :indentation, :max_length
def initialize(options = {})
@prettyprint = options.fetch(:prettyprint, AbstractWidget.prettyprint_default)
@indentation = options.fetch(:indenta... |
github | erector/erector | https://github.com/erector/erector | lib/erector/attributes.rb | Ruby | mit | 229 | master | 745 | module Erector
module Attributes
def format_attributes(attributes)
if !attributes || attributes.empty?
""
else
format_sorted(sort_attributes(attributes))
end
end
def format_sorted(sorted)
results = ['']
sorted.each do |key, value|
if value
i... |
github | erector/erector | https://github.com/erector/erector | lib/erector/sass.rb | Ruby | mit | 229 | master | 1,058 | module Erector
# Adds sass support to Erector widgets.
#
# Sass is an *optional dependency* of the Erector gem, so
# a call to +sass+ inside a widget will fail unless you have already
# installed the sass gem (e.g. "gem 'sass'" in your code or Gemfile).
#
# Current support is barebones. Please offer sugge... |
github | erector/erector | https://github.com/erector/erector | lib/erector/text.rb | Ruby | mit | 229 | master | 4,229 | require "erector/raw_string"
module Erector
module Text
# Emits text to the output buffer, e.g.
#
# text "my dog smells awful"
# => "my dog smells awful"
#
# If a string is passed in, it will be HTML-escaped. If the
# result of calling methods such as raw is passed in, the HTML will n... |
github | erector/erector | https://github.com/erector/erector | lib/erector/element.rb | Ruby | mit | 229 | master | 3,740 | require 'erector/abstract_widget'
require 'erector/promise'
# todo: unit test
module Erector
module Element
# Internal method used to emit an HTML/XML element, including an open tag,
# attributes (optional, via the default hash), contents (also optional),
# and close tag.
#
# Using the arcane pow... |
github | erector/erector | https://github.com/erector/erector | lib/erector/needs.rb | Ruby | mit | 229 | master | 3,622 | module Erector
module Needs
NO_DUP_CLASSES = [NilClass, FalseClass, TrueClass, 0.class, Float, Symbol].freeze
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
# Class method by which widget classes can declare that they need certain
# parameters. If needed p... |
github | erector/erector | https://github.com/erector/erector | lib/erector/after_initialize.rb | Ruby | mit | 229 | master | 802 | module Erector
module AfterInitialize
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def after_initialize(instance=nil, &blk)
if blk
after_initialize_parts << blk
elsif instance
if superclass.respond_to?(:after_initialize)
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/inline.rb | Ruby | mit | 229 | master | 1,268 | module Erector
def self.inline(*args, &block)
InlineWidget.new(*args, &block)
end
module Inline
# Executes the widget's block (the one that was passed in the
# constructor). Since "self" is pointing to the new widget, the block does
# not naturally have access to parent method methods, so an
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/externals.rb | Ruby | mit | 229 | master | 3,549 | module Erector
# Externals are a mechanism by which a widget can declare page-level
# resources upon which it depends. They are not emitted during the widget's
# normal emiting process. Rather, the Erector::Widget::Page keeps track of
# all the widgets it emits, then goes back and inserts the proper tags for
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/xml_widget.rb | Ruby | mit | 229 | master | 3,613 | require 'erector/abstract_widget'
require 'erector/tag'
require 'erector/needs'
module Erector
# Abstract base class for XML Widgets and HTMLWidget.
# Declares "tags" which define methods that emit tags.
class XMLWidget < AbstractWidget
include Needs
def self.tag_named tag_name, checked = []
@tag... |
github | erector/erector | https://github.com/erector/erector | lib/erector/convenience.rb | Ruby | mit | 229 | master | 3,554 | module Erector
module Convenience
# Render (like to_html) but adding newlines and indentation.
# You may just want to call to_html(:prettyprint => true)
# so you can pass in other rendering options as well.
def to_pretty(options = {})
emit(options.merge(:prettyprint => true))
end
# Rend... |
github | erector/erector | https://github.com/erector/erector | lib/erector/erect/erect.rb | Ruby | mit | 229 | master | 4,894 | require "optparse"
require "erector/erect/erected" # pull this out so we don't recreate the grammar every time
require "fileutils"
module Erector
# "erect" is the erstwhile name of the command-line tool that converts between HTML/ERB and Erector.
# It's invoked via "erector --to-html foo.rb" or "erector --to-ere... |
github | erector/erector | https://github.com/erector/erector | lib/erector/erect/indenting.rb | Ruby | mit | 229 | master | 495 | require 'rubygems'
require 'treetop'
module Erector
class Indenting < Treetop::Runtime::SyntaxNode #:nodoc:
@@indent = 0
def set_indent(x)
@@indent = x
self
end
def indent
[0, @@indent].max
end
def indented(s)
" " * indent + s + "\n"
end
def line(s)
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/erect/erected.rb | Ruby | mit | 229 | master | 1,642 | require 'rubygems'
require 'treetop'
require "#{File.dirname(__FILE__)}/indenting"
Treetop.load("#{File.dirname(__FILE__)}/rhtml.treetop")
module Erector
class Erected
def initialize(in_file, superklass = 'Erector::Widget', method_name = 'content')
@in_file = in_file
@superklass = superklass
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails2/rails_form_builder.rb | Ruby | mit | 229 | master | 629 | module Erector
class RailsFormBuilder
attr_reader :parent, :template
def initialize(object_name, object, template, options, proc)
@template = template
@parent = ActionView::Base.default_form_builder.new(object_name, object, template, options, proc)
end
def method_missing(method_name, *ar... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails2/template_handlers/ert_handler.rb | Ruby | mit | 229 | master | 990 | module ActionView #:nodoc:
module TemplateHandlers #:nodoc:
class ErtTemplate < TemplateHandler
include Compilable
def self.line_offset
2
end
ActionView::Template.instance_eval do
register_template_handler :ert, ActionView::TemplateHandlers::ErtTemplate
end
de... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails2/template_handlers/rb_handler.rb | Ruby | mit | 229 | master | 2,000 | class ActionView::Base
def instance_variables_for_widget_assignment
instance_variables_for_widget_assignment_for(controller)
end
def instance_variables_for_widget_assignment_for(target)
assigns = { }
variables = target.instance_variable_names
variables -= target.protected_instance_variables if ta... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails2/extensions/rails_widget.rb | Ruby | mit | 229 | master | 5,365 | module Erector
module Rails
def self.assigns_for(widget_class, view, local_assigns, is_partial)
assigns = {}
instance_variables = view.instance_variables_for_widget_assignment
if is_partial || widget_class.ignore_extra_controller_assigns
instance_variables = remove_unneeded_assigns(widg... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails2/extensions/rails_helpers.rb | Ruby | mit | 229 | master | 4,714 | module Erector
module Rails
module Helpers
# Set up URL helpers so that both helpers.users_url and users_url can be called.
include ActionController::UrlWriter
def url_for(*args)
parent.url_for(*args)
end
# Wrappers for rails helpers that produce markup. Erector needs to
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails2/extensions/action_controller.rb | Ruby | mit | 229 | master | 570 | ActionController::Base.class_eval do
class_inheritable_accessor :ert_template_base_class
def render_widget(widget_class, assigns=nil, options={})
render options.merge(:text => Erector::Rails.render(widget_class, response.template, assigns, options))
end
def render_with_erector_widget(*options, &block)
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails/form_builder.rb | Ruby | mit | 229 | master | 990 | module Erector
module Rails
class FormBuilder
class_attribute :parent_builder_class
self.parent_builder_class = ActionView::Base.default_form_builder
def self.wrapping(parent_builder_class)
return self if parent_builder_class.nil?
Class.new(self).tap do |klass|
klass.p... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails/template_handler.rb | Ruby | mit | 229 | master | 532 | module Erector
module Rails
class TemplateHandler
def call(template)
require_dependency template.identifier
widget_class_name = "views/#{template.identifier =~ %r(views/([^.]*)(\..*)?\.rb) && $1}".camelize
is_partial = File.basename(template.identifier) =~ /^_/
<<-SRC
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails/railtie.rb | Ruby | mit | 229 | master | 462 | module Erector
class Railtie < ::Rails::Railtie
# config.generators.template_engine :rb
# TODO: automatically add app directory to app.config.autoload_paths,
# so that Views::Foo::Bar autoloads, and 'require "views/foo/bar.html"'
# works. For now, you must add the following to config/application.rb:
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/rails/widget_renderer.rb | Ruby | mit | 229 | master | 236 | require 'action_controller/metal/renderers'
ActionController.add_renderer :widget do |widget, options|
self.content_type ||= options[:content_type] || Mime[:html]
Erector::Rails.render(widget, view_context, {}, false, options)
end |
github | erector/erector | https://github.com/erector/erector | lib/erector/widgets/field_table.rb | Ruby | mit | 229 | master | 3,715 | # A simple HTML table with three columns: label, contents, and (optionally) note.
# Each row is called a field.
# The last row can optionally contain "buttons" (actually any widget will do)
# that are all shown in the 2nd column.
# It's all surrounded with a fieldset element for a title.
#
# In ASCII art, it looks som... |
github | erector/erector | https://github.com/erector/erector | lib/erector/widgets/environment_badge.rb | Ruby | mit | 229 | master | 1,145 | module Erector
module Widgets #:nodoc:
# Displays a colored badge in the upper-left corner
# signifying the environment the app is running in.
# Inspired by Assaf Arkin
# <http://blog.labnotes.org/2009/10/08/using-a-badge-to-distinguish-development-and-production-environments/>
# Erectorized b... |
github | erector/erector | https://github.com/erector/erector | lib/erector/widgets/page.rb | Ruby | mit | 229 | master | 5,194 | # Erector Page base class.
#
# Allows for accumulation of script and style tags (see example below) with
# either external or inline content. External references are 'uniq'd, so it's
# a good idea to declare a js script in all widgets that use it, so you don't
# accidentally lose the script if you remove the one widget... |
github | erector/erector | https://github.com/erector/erector | lib/erector/widgets/external_renderer.rb | Ruby | mit | 229 | master | 1,677 | class ExternalRenderer < Erector::Widget
needs :classes
needs :included_stylesheets => true, :inline_styles => true, :included_scripts => true, :inline_scripts => true
def content
included_stylesheets if @included_stylesheets
inline_styles if @inline_styles
included_scripts if @included_scripts
... |
github | erector/erector | https://github.com/erector/erector | lib/erector/widgets/table.rb | Ruby | mit | 229 | master | 3,114 | module Erector
module Widgets #:nodoc:
# The Table widget provides the ability to render a table from a
# list of objects (one for each row).
#
# Because the default for the column titles utilizes the ActiveSupport
# Inflector#titleize method, this widget requires active_support to be loaded
#... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.