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 | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/formatter/ltsv_spec.rb | Ruby | mit | 47 | master | 721 | require "spec_helper"
require "hotdog/formatters"
require "hotdog/formatters/ltsv"
describe "ltsv" do
let(:fmt) {
Hotdog::Formatters::Ltsv.new
}
it "generates ltsv without headers" do
options = {
headers: false,
}
expect(fmt.format([["foo", "aaa", 1], ["bar", "bbb", 2], ["baz", "ccc", 3]],... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/formatter/csv_spec.rb | Ruby | mit | 47 | master | 674 | require "spec_helper"
require "hotdog/formatters"
require "hotdog/formatters/csv"
describe "csv" do
let(:fmt) {
Hotdog::Formatters::Csv.new
}
it "generates csv without headers" do
options = {
headers: false,
}
expect(fmt.format([["foo", "aaa", 1], ["bar", "bbb", 2], ["baz", "ccc", 3]], opt... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/formatter/json_spec.rb | Ruby | mit | 47 | master | 930 | require "spec_helper"
require "hotdog/formatters"
require "hotdog/formatters/json"
describe "json" do
let(:fmt) {
Hotdog::Formatters::Json.new
}
it "generates json without headers" do
options = {
headers: false,
}
expect(fmt.format([["foo", "aaa", 1], ["bar", "bbb", 2], ["baz", "ccc", 3]],... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/formatter/plain_spec.rb | Ruby | mit | 47 | master | 2,110 | require "spec_helper"
require "hotdog/formatters"
require "hotdog/formatters/plain"
describe "plain" do
let(:fmt) {
Hotdog::Formatters::Plain.new
}
it "generates plain (print0) without headers" do
options = {
headers: false,
print0: true,
print1: false,
print2: false,
}
e... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/optparse/down_spec.rb | Ruby | mit | 47 | master | 1,381 | require "spec_helper"
require "hotdog/application"
require "hotdog/commands/down"
describe "option parser for down" do
let(:app) {
Hotdog::Application.new
}
let(:cmd) {
Hotdog::Commands::Down.new(app)
}
before(:each) do
allow(app).to receive(:get_command).with("down") {
cmd
}
end
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/optparse/search_spec.rb | Ruby | mit | 47 | master | 821 | require "spec_helper"
require "hotdog/application"
require "hotdog/commands/search"
describe "option parser for search" do
let(:app) {
Hotdog::Application.new
}
let(:cmd) {
Hotdog::Commands::Search.new(app)
}
before(:each) do
allow(app).to receive(:get_command).with("search") {
cmd
}
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/optparse/ssh_spec.rb | Ruby | mit | 47 | master | 2,317 | require "spec_helper"
require "hotdog/application"
require "hotdog/commands/ssh"
describe "option parser for ssh" do
let(:app) {
Hotdog::Application.new
}
let(:cmd) {
Hotdog::Commands::Ssh.new(app)
}
before(:each) do
allow(app).to receive(:get_command).with("ssh") {
cmd
}
end
it ... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/optparse/hosts_spec.rb | Ruby | mit | 47 | master | 815 | require "spec_helper"
require "hotdog/application"
require "hotdog/commands/hosts"
describe "option parser for hosts" do
let(:app) {
Hotdog::Application.new
}
let(:cmd) {
Hotdog::Commands::Hosts.new(app)
}
before(:each) do
allow(app).to receive(:get_command).with("hosts") {
cmd
}
en... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/optparse/pssh_spec.rb | Ruby | mit | 47 | master | 2,353 | require "spec_helper"
require "hotdog/application"
require "hotdog/commands/pssh"
describe "option parser for pssh" do
let(:app) {
Hotdog::Application.new
}
let(:cmd) {
Hotdog::Commands::Pssh.new(app)
}
before(:each) do
allow(app).to receive(:get_command).with("pssh") {
cmd
}
end
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/optparse/tags_spec.rb | Ruby | mit | 47 | master | 809 | require "spec_helper"
require "hotdog/application"
require "hotdog/commands/tags"
describe "option parser for tags" do
let(:app) {
Hotdog::Application.new
}
let(:cmd) {
Hotdog::Commands::Tags.new(app)
}
before(:each) do
allow(app).to receive(:get_command).with("tags") {
cmd
}
end
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | spec/optparse/up_spec.rb | Ruby | mit | 47 | master | 797 | require "spec_helper"
require "hotdog/application"
require "hotdog/commands/up"
describe "option parser for up" do
let(:app) {
Hotdog::Application.new
}
let(:cmd) {
Hotdog::Commands::Up.new(app)
}
before(:each) do
allow(app).to receive(:get_command).with("up") {
cmd
}
end
it "can... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/sources.rb | Ruby | mit | 47 | master | 2,534 | #!/usr/bin/env ruby
module Hotdog
module Sources
class BaseSource
def initialize(application)
@application = application
@logger = application.logger
@options = application.options
end
attr_reader :application
attr_reader :logger
attr_reader :options
d... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/expression.rb | Ruby | mit | 47 | master | 5,440 | #!/usr/bin/env ruby
require "parslet"
# Monkey patch to prevent `NoMethodError` after some parse error in parselet
module Parslet
class Cause
def cause
self
end
def backtrace
[]
end
end
end
require "hotdog/expression/semantics"
require "hotdog/expression/syntax"
module Hotdog
modu... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands.rb | Ruby | mit | 47 | master | 17,089 | #!/usr/bin/env ruby
require "fileutils"
require "sqlite3"
module Hotdog
module Commands
class BaseCommand
def initialize(application)
@application = application
@source_provider = application.source_provider
@logger = application.logger
@options = application.options
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/application.rb | Ruby | mit | 47 | master | 11,711 | #!/usr/bin/env ruby
require "erb"
require "logger"
require "optparse"
require "shellwords"
require "yaml"
require "hotdog/commands"
require "hotdog/formatters"
require "hotdog/sources"
require "hotdog/version"
module Hotdog
SQLITE_LIMIT_COMPOUND_SELECT = 500 # TODO: get actual value from `sqlite3_limit()`?
# onl... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/formatters.rb | Ruby | mit | 47 | master | 363 | #!/usr/bin/env ruby
module Hotdog
module Formatters
class BaseFormatter
def format(result, options={})
raise(NotImplementedError)
end
private
def prepare(result)
result.map { |row| row.map { |column| column or "<nil>" } }
end
def newline()
"\n"
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/ssh.rb | Ruby | mit | 47 | master | 9,939 | #!/usr/bin/env ruby
require "json"
require "parallel"
require "parslet"
require "shellwords"
require "thread"
require "hotdog/commands/search"
module Hotdog
module Commands
class SshAlike < Search
def define_options(optparse, options={})
default_option(options, :ssh_options, {})
default_op... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/scp.rb | Ruby | mit | 47 | master | 717 | #!/usr/bin/env ruby
require "json"
require "shellwords"
require "hotdog/commands/ssh"
module Hotdog
module Commands
class Scp < SingularSshAlike
def define_options(optparse, options={})
program_name = File.basename($0, '.*')
optparse.banner = "Usage: #{program_name} scp [options] pattern -... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/tag.rb | Ruby | mit | 47 | master | 1,737 | #!/usr/bin/env ruby
module Hotdog
module Commands
class Tag < BaseCommand
def define_options(optparse, options={})
default_option(options, :retry, 5)
default_option(options, :tag_source, "user")
default_option(options, :tags, [])
optparse.on("--retry NUM") do |v|
o... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/version.rb | Ruby | mit | 47 | master | 333 | #!/usr/bin/env ruby
require "rbconfig"
module Hotdog
module Commands
class Version < BaseCommand
def run(args=[], options={})
ruby = File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"])
exit(system(ruby, $0, "--version") ? 0 : 1)
end
end
end
end
# vim:s... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/search.rb | Ruby | mit | 47 | master | 4,161 | #!/usr/bin/env ruby
require "json"
require "parslet"
require "shellwords"
require "hotdog/expression"
module Hotdog
module Commands
class Search < BaseCommand
def define_options(optparse, options={})
optparse.on("-n", "--limit LIMIT", "Limit result set to specified size at most", Integer) do |limi... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/pssh.rb | Ruby | mit | 47 | master | 2,090 | #!/usr/bin/env ruby
require "json"
require "parallel"
require "parslet"
require "shellwords"
require "tempfile"
require "thread"
require "hotdog/commands/ssh"
module Hotdog
module Commands
class Pssh < SshAlike
def define_options(optparse, options={})
super
default_option(options, :show_id... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/untag.rb | Ruby | mit | 47 | master | 2,084 | #!/usr/bin/env ruby
module Hotdog
module Commands
class Untag < BaseCommand
def define_options(optparse, options={})
default_option(options, :retry, 5)
default_option(options, :tag_source, "user")
default_option(options, :tags, [])
optparse.on("--retry NUM") do |v|
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/sftp.rb | Ruby | mit | 47 | master | 501 | #!/usr/bin/env ruby
require "json"
require "shellwords"
require "hotdog/commands/ssh"
module Hotdog
module Commands
class Sftp < SingularSshAlike
private
def build_command_string(host, command=nil, options={})
cmdline = Shellwords.shellsplit(options.fetch(:sftp_command, "sftp")) + build_comm... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/hosts.rb | Ruby | mit | 47 | master | 1,428 | #!/usr/bin/env ruby
module Hotdog
module Commands
class Hosts < BaseCommand
def run(args=[], options={})
if args.empty?
result = execute("SELECT id FROM hosts").to_a.reduce(:+)
show_hosts(result)
else
if args.any? { |host_name| glob?(host_name) }
re... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/down.rb | Ruby | mit | 47 | master | 3,085 | #!/usr/bin/env ruby
module Hotdog
module Commands
class Down < BaseCommand
def define_options(optparse, options={})
default_option(options, :downtime, 86400)
default_option(options, :retry, 5)
default_option(options, :start, Time.new)
optparse.on("--downtime DURATION") do |v... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/tags.rb | Ruby | mit | 47 | master | 1,860 | #!/usr/bin/env ruby
module Hotdog
module Commands
class Tags < BaseCommand
def run(args=[], options={})
if args.empty?
result = execute("SELECT name, value FROM tags").map { |name, value| [join_tag(name, value)] }
show_tags(result)
else
tags = args.map { |tag| ... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/help.rb | Ruby | mit | 47 | master | 1,053 | #!/usr/bin/env ruby
require "rbconfig"
module Hotdog
module Commands
class Help < BaseCommand
def run(args=[], options={})
commands = command_files.map { |file| File.basename(file, ".rb") }.sort.uniq
if "commands" == args.first
STDOUT.puts("hotdog commands are:")
comman... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/commands/up.rb | Ruby | mit | 47 | master | 2,237 | #!/usr/bin/env ruby
module Hotdog
module Commands
class Up < BaseCommand
def define_options(optparse, options={})
default_option(options, :retry, 5)
optparse.on("--retry NUM") do |v|
options[:retry] = v.to_i
end
optparse.on("--retry-delay SECONDS") do |v|
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/formatters/json.rb | Ruby | mit | 47 | master | 489 | #!/usr/bin/env ruby
require "json"
module Hotdog
module Formatters
class Json < BaseFormatter
def format(result, options={})
result = prepare(result)
if options[:headers] and options[:fields]
result.map! do |record|
Hash[options[:fields].zip(record)]
end
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/formatters/text.rb | Ruby | mit | 47 | master | 1,513 | #!/usr/bin/env ruby
module Hotdog
module Formatters
class Text < BaseFormatter
def format(result, options={})
if options[:print0]
sep = "\0"
elsif options[:print1]
sep = newline
elsif options[:print2]
sep = " "
else
sep = " "
e... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/formatters/tsv.rb | Ruby | mit | 47 | master | 395 | #!/usr/bin/env ruby
module Hotdog
module Formatters
class Tsv < BaseFormatter
def format(result, options={})
result = prepare(result)
if options[:headers] and options[:fields]
result.unshift(options[:fields])
end
result.map { |row|
row.join("\t")
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/formatters/csv.rb | Ruby | mit | 47 | master | 431 | #!/usr/bin/env ruby
require "csv"
module Hotdog
module Formatters
class Csv < BaseFormatter
def format(result, options={})
result = prepare(result)
if options[:headers] and options[:fields]
result.unshift(options[:fields])
end
CSV.generate { |csv|
result... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/formatters/yaml.rb | Ruby | mit | 47 | master | 349 | #!/usr/bin/env ruby
require "yaml"
module Hotdog
module Formatters
class Yaml < BaseFormatter
def format(result, options={})
result = prepare(result)
if options[:headers] and options[:fields]
result.unshift(options[:fields])
end
result.to_yaml
end
end
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/formatters/ltsv.rb | Ruby | mit | 47 | master | 537 | #!/usr/bin/env ruby
module Hotdog
module Formatters
class Ltsv < BaseFormatter
def format(result, options={})
result = prepare(result)
if options[:fields]
result.map { |row|
options[:fields].zip(row).map { |(field, column)|
"#{field}:#{column}"
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/sources/datadog.rb | Ruby | mit | 47 | master | 5,808 | #!/usr/bin/env ruby
require "dogapi"
require "multi_json"
require "oj"
require "open-uri"
require "uri"
module Hotdog
module Sources
class Datadog < BaseSource
def initialize(application)
super(application)
options[:endpoint] = ENV.fetch("DATADOG_HOST", "https://app.datadoghq.com")
... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/expression/syntax.rb | Ruby | mit | 47 | master | 7,019 | #!/usr/bin/env ruby
require "parslet"
module Hotdog
module Expression
class ExpressionParser < Parslet::Parser
root(:expression)
rule(:expression) {
( expression0 \
)
}
rule(:expression0) {
( expression1.as(:left) >> spacing.maybe >> binary_op.as(:binary_op) >> sp... |
github | yyuu/hotdog | https://github.com/yyuu/hotdog | lib/hotdog/expression/semantics.rb | Ruby | mit | 47 | master | 36,985 | #!/usr/bin/env ruby
module Hotdog
module Expression
class ExpressionNode
def evaluate(environment, options={})
raise(NotImplementedError.new("must be overridden"))
end
def optimize(options={})
self.dup
end
def compact(options={})
self
end
def d... |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | seo_meta.gemspec | Ruby | mit | 47 | master | 1,056 | Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'seo_meta'
s.authors = ['Philip Arndt']
s.homepage = 'https://github.com/parndt/seo_meta'
s.email = 'gems@p.arndt.io'
s.version = '3.1.0'
s.description = 'SEO Meta t... |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | Rakefile | Ruby | mit | 47 | master | 480 | # -*- encoding: utf-8 -*-
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require 'rubygems'
require 'bundler/setup'
task :default => :spec
task :spec do
%w(5.0 5.1).each do |rails_version|
[
'bundle update',
'bundle exec rspec spec'
].each do |task|
command = [
"BUNDLE_GEM... |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | Gemfile | Ruby | mit | 47 | master | 250 | source 'http://rubygems.org'
gemspec :path => File.expand_path('../', __FILE__)
group :test do
gem 'combustion', '~> 1.3'
RAILS_VERSION = nil unless defined? RAILS_VERSION
gem 'railties', RAILS_VERSION
gem 'activerecord', RAILS_VERSION
end |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | spec/spec_helper.rb | Ruby | mit | 47 | master | 981 | require 'rubygems'
require 'bundler'
def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'
Bundler.require :default, :test
Combustion.initialize! :active_record
require 'rspec'
Rails.backtrace_cleaner.remove_silencers!
Dir[File.expand_path('../support/*.rb', __FILE__)].each... |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | spec/models/seo_meta_spec.rb | Ruby | mit | 47 | master | 1,659 | require 'spec_helper'
module SeoMeta
class DummyForSpec < ActiveRecord::Base
self.table_name = 'seo_meta_dummy_for_specs'
is_seo_meta
end
end
module SeoMeta
describe DummyForSpec do
let(:dummy_for_spec) { DummyForSpec.create }
context 'responds to' do
it 'meta_description' do
exp... |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | db/migrate/20110329222114_create_seo_meta.rb | Ruby | mit | 47 | master | 475 | class CreateSeoMeta < ActiveRecord::Migration[4.2]
def self.up
create_table :seo_meta do |t|
t.integer :seo_meta_id
t.string :seo_meta_type
t.string :browser_title
t.string :meta_keywords
t.text :meta_description
t.timestamps :null => false
end
add_index :seo_meta, :... |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | lib/seo_meta.rb | Ruby | mit | 47 | master | 1,289 | require 'rails'
module SeoMeta
class << self
def attributes
@@attributes ||= {
:browser_title => :string,
:meta_description => :text
}
end
end
class Engine < ::Rails::Engine
engine_name 'seo_meta'
end
autoload :InstanceMethods, File.expand_path('../seo_meta/instance... |
github | parndt/seo_meta | https://github.com/parndt/seo_meta | lib/seo_meta/instance_methods.rb | Ruby | mit | 47 | master | 1,250 | module SeoMeta
module InstanceMethods
class << self
def included(base)
# This has to be introduced using module_eval because it overrides something.
base.module_eval do
def seo_meta
find_seo_meta_tags || build_seo_meta_tags
end
# Allow attributes s... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | Rakefile | Ruby | mit | 47 | master | 590 | $:.unshift(File.expand_path(File.dirname(__FILE__)+"/lib"))
$:.unshift(File.expand_path(File.dirname(__FILE__)))
require 'rake'
require 'rubygems'
require 'rtf'
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
t.verbose = true
end
... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | rtf.gemspec | Ruby | mit | 47 | master | 3,695 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{rtf}
s.version = "0.4.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_v... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf.rb | Ruby | mit | 47 | master | 1,081 | #!/usr/bin/env ruby
require 'stringio'
require 'rtf/font'
require 'rtf/colour'
require 'rtf/style'
require 'rtf/information'
require 'rtf/paper'
require 'rtf/node'
require 'rtf/list'
# This module encapsulates all the classes and definitions relating to the RTF
# library.
module RTF
VERSION="0.5.0"
# This is the... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/list.rb | Ruby | mit | 47 | master | 4,970 | module RTF
class ListTable
def initialize
@templates = []
end
def new_template
@templates.push ListTemplate.new(next_template_id)
@templates.last
end
def to_rtf(indent=0)
return '' if @templates.empty?
prefix = indent > 0 ? ' ' * indent : ''
# List table
... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/paper.rb | Ruby | mit | 47 | master | 2,034 | #!/usr/bin/env ruby
module RTF
# This class represents a definition for a paper size and provides a set
# of class constants for common paper sizes. An instance of the Paper class
# is considered immutable after creation.
class Paper
# Attribute accessor.
attr_reader :name, :width, :height
... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/colour.rb | Ruby | mit | 47 | master | 6,211 | #!/usr/bin/env ruby
require 'stringio'
module RTF
# This class represents a colour within a RTF document.
class Colour
# Attribute accessor.
attr_reader :red, :green, :blue
# This is the constructor for the Colour class.
#
# ==== Parameters
# red:: The intensity setting ... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/font.rb | Ruby | mit | 47 | master | 6,192 | #!/usr/bin/env ruby
require 'stringio'
module RTF
# This class represents a font for use with some RTF content.
class Font
# A declaration for a font family. This family is used for monospaced
# fonts (e.g. Courier New).
MODERN = :modern
# A declaration for a font... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/node.rb | Ruby | mit | 47 | master | 65,978 | #!/usr/bin/env ruby
require 'stringio'
module RTF
# This class represents an element within an RTF document. The class provides
# a base class for more specific node types.
class Node
# Node parent.
attr_accessor :parent
# Constructor for the Node class.
#
# ==== Paramete... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/style.rb | Ruby | mit | 47 | master | 11,561 | #!/usr/bin/env ruby
require 'stringio'
module RTF
# This is a parent class that all style classes will derive from.
class Style
# A definition for a character flow setting.
LEFT_TO_RIGHT = :rtl
# A definition for a character flow setting.
RIGHT_TO_LEFT ... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/information.rb | Ruby | mit | 47 | master | 4,619 | #!/usr/bin/env ruby
require 'stringio'
require 'date'
module RTF
# This class represents an information group for a RTF document.
class Information
# Attribute accessor.
attr_reader :title, :author, :company, :created, :comments
# Attribute mutator.
attr_writer :title, :author, :company,... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | lib/rtf/converters/html.rb | Ruby | mit | 47 | master | 3,499 | require 'nokogiri'
require 'tidy'
module RTF::Converters
class HTML
def initialize(html, options = {})
html = options[:noclean] ? html : clean(html, options[:tidy_options] || {})
@html = Nokogiri::HTML::Document.parse(html)
end
def to_rtf(options = {})
to_rtf_document(options).to_rtf... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | examples/example01.rb | Ruby | mit | 47 | master | 1,464 | # encoding: utf-8
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.dirname(__FILE__)+"/../lib/")
require 'rubygems'
require 'rtf'
include RTF
# Create required styles.
styles = {}
styles['HEADER'] = CharacterStyle.new
styles['HEADER'].bold = true
styles['HEADER'].font_size = 28
styles['NORMAL'] = ParagraphStyle.ne... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | examples/example03.rb | Ruby | mit | 47 | master | 2,180 | #!/usr/bin/env ruby
$LOAD_PATH.unshift(File.dirname(__FILE__)+"/../lib/")
require 'rubygems'
require 'rtf'
include RTF
fonts = [Font.new(Font::ROMAN, 'Times New Roman'),
Font.new(Font::MODERN, 'Courier')]
styles = {}
styles['PS_HEADING'] = ParagraphStyle.new
styles['PS_NORMAL'] =... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | examples/example02.rb | Ruby | mit | 47 | master | 1,407 | #!/usr/bin/env ruby
$LOAD_PATH.unshift(File.dirname(__FILE__)+"/../lib/")
require 'rubygems'
require 'rtf'
include RTF
colours = [Colour.new(0, 0, 0),
Colour.new(255, 255, 255)]
# Create the used styles.
styles = {}
styles['EMPHASISED'] = CharacterStyle.ne... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | examples/example04.rb | Ruby | mit | 47 | master | 1,825 | #!/usr/bin/env ruby
$LOAD_PATH.unshift(File.dirname(__FILE__)+"/../lib/")
require 'rubygems'
require 'rtf'
include RTF
IMAGE_FILE = 'rubyrtf.png'
begin
document = Document.new(Font.new(Font::ROMAN, 'Times New Roman'))
# Add some text to the document and then add the scaled image.
document.paragraph do |p|... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_font_table.rb | Ruby | mit | 47 | master | 3,924 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# FontTable class unit test class.
class FontTableTest < Test::Unit::TestCase
def setup
@fonts = []
@fonts.push(Font.new(Font::MODERN, "Courier New"))
@fonts.push(Font.new(Font::ROMAN, "Arial"))
@fonts.push(Font.new(Font::SWISS... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_paragraph_style.rb | Ruby | mit | 47 | master | 2,483 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class ParagraphStyleTest < Test::Unit::TestCase
def test_basics
style = ParagraphStyle.new
assert(style.is_character_style? == false)
assert(style.is_document_style? == false)
assert(style.... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_table_row_node.rb | Ruby | mit | 47 | master | 2,302 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class TableRowNodeTest < Test::Unit::TestCase
def setup
@table = TableNode.new(nil, 3, 3, 100, 100, 100)
end
def test_basics
rows = []
rows.push(TableRowNode.new(@table, 10))
rows.pus... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_colour.rb | Ruby | mit | 47 | master | 3,927 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Colour class unit test class.
class ColourTest < Test::Unit::TestCase
def test_01
colours = []
colours.push(Colour.new(255, 255, 255))
colours.push(Colour.new(200, 0, 0))
colours.push(Colour.new(0, 150, 0))
colours.push... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/text_node_test.rb | Ruby | mit | 47 | master | 1,763 | # encoding:UTF-8
require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class TextNodeTest < Test::Unit::TestCase
def setup
@node = Node.new(nil)
end
def test01
nodes = []
nodes.push(TextNode.new(@node))
nodes.push(TextNode.new(@node, 'No... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_document_style.rb | Ruby | mit | 47 | master | 2,554 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class DocumentStyleTest < Test::Unit::TestCase
def test_basics
style = DocumentStyle.new
assert(style.is_character_style? == false)
assert(style.is_document_style? == true)
assert(style.is_... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_style.rb | Ruby | mit | 47 | master | 477 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class StyleTest < Test::Unit::TestCase
def test_basics
style = Style.new
assert(style.is_character_style? == false)
assert(style.is_document_style? == false)
assert(style.is_paragraph_style... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_table_cell_node.rb | Ruby | mit | 47 | master | 2,780 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class TableCellNodeTest < Test::Unit::TestCase
def setup
@table = TableNode.new(nil, 3, 3, 100, 100, 100)
@row = TableRowNode.new(@table, 3, 100)
end
def test_basics
cells = []
cell... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_character_style.rb | Ruby | mit | 47 | master | 3,770 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class CharacterStyleTest < Test::Unit::TestCase
def test_basics
style = CharacterStyle.new
assert(style.is_character_style? == true)
assert(style.is_document_style? == false)
assert(style.i... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_command_node.rb | Ruby | mit | 47 | master | 7,166 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class CommandNodeTest < Test::Unit::TestCase
def test_basics
nodes = []
nodes.push(CommandNode.new(nil, 'prefix'))
nodes.push(CommandNode.new(nil, '', 'lalala'))
nodes.push(CommandNode.new(n... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/helper_tests.rb | Ruby | mit | 47 | master | 298 | require 'rubygems'
require 'test/unit'
$LOAD_PATH.unshift(File.dirname(__FILE__)+"/../lib/")
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rtf'
include RTF
class Test::Unit::TestCase
def fixture_file_path(filename)
File.join(File.dirname(__FILE__), "fixtures", filename)
end
end |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_information.rb | Ruby | mit | 47 | master | 5,708 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class InformationTest < Test::Unit::TestCase
def test_01
date = Time.local(1985, 6, 22, 14, 33, 22)
info = []
info.push(Information.new)
info.push(Information.new('Title 1'))
info.push... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_font.rb | Ruby | mit | 47 | master | 1,849 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Font class unit test class.
class FontTest < Test::Unit::TestCase
def test_01
fonts = []
fonts.push(Font.new(Font::MODERN, "Courier New"))
fonts.push(Font.new(Font::ROMAN, "Arial"))
fonts.push(Font.new(Font::SWISS, "Tahoma"))... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_image_node.rb | Ruby | mit | 47 | master | 6,204 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Colour class unit test class.
class ImageNodeTest < Test::Unit::TestCase
def setup
@document = Document.new(Font.new(Font::ROMAN, 'Arial'))
end
def test_basics
image = ImageNode.new(@document, fixture_file_path("bitmap1.bmp"), 1)
... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_container_node.rb | Ruby | mit | 47 | master | 1,711 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class ContainerNodeTest < Test::Unit::TestCase
def test01
nodes = []
nodes.push(ContainerNode.new(nil))
nodes.push(ContainerNode.new(nodes[0]))
assert(nodes[0].size == 0)
assert... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_table_node.rb | Ruby | mit | 47 | master | 3,083 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class TableNodeTest < Test::Unit::TestCase
def setup
@document = Document.new(Font.new(Font::ROMAN, 'Times New Roman'))
@colours = []
@colours << Colour.new(200, 200, 200)
@colours << Colo... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_colour_table.rb | Ruby | mit | 47 | master | 3,966 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# ColourTable class unit test class.
class ColourTableTest < Test::Unit::TestCase
def setup
@colours = [Colour.new(0, 0, 0),
Colour.new(100, 100, 100),
Colour.new(150, 150, 150),
Colour.new(2... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_node.rb | Ruby | mit | 47 | master | 717 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class NodeTest < Test::Unit::TestCase
def test01
nodes = []
nodes.push(Node.new(nil))
nodes.push(Node.new(nodes[0]))
assert(nodes[0].parent == nil)
assert(nodes[1].parent != nil... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_footer_node.rb | Ruby | mit | 47 | master | 798 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class FooterNodeTest < Test::Unit::TestCase
def setup
@document = Document.new(Font.new(Font::ROMAN, 'Arial'))
end
def test_basics
footers = []
footers << FooterNode.new(@document)
f... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_document.rb | Ruby | mit | 47 | master | 3,809 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class DocumentTest < Test::Unit::TestCase
def setup
@fonts = FontTable.new
@fonts << Font.new(Font::ROMAN, 'Arial')
@fonts << Font.new(Font::MODERN, 'Courier')
end
def test_basics
do... |
github | thechrisoshow/rtf | https://github.com/thechrisoshow/rtf | test/test_header_node.rb | Ruby | mit | 47 | master | 800 | require File.expand_path(File.dirname(__FILE__)+'/helper_tests')
# Information class unit test class.
class HeaderNodeTest < Test::Unit::TestCase
def setup
@document = Document.new(Font.new(Font::ROMAN, 'Arial'))
end
def test_basics
headers = []
headers << HeaderNode.new(@document)
h... |
github | bclubb/possessive | https://github.com/bclubb/possessive | possessive.gemspec | Ruby | mit | 47 | master | 1,437 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{possessive}
s.version = "1.0.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :require... |
github | bclubb/possessive | https://github.com/bclubb/possessive | Rakefile | Ruby | mit | 47 | master | 1,500 | require 'rubygems'
require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "possessive"
gem.summary = "Rails plugin that lets you get a possessive form of a string for use on sites"
gem.description = "Rails plugin that lets you get a possessive form of a string for use on sites"
... |
github | bclubb/possessive | https://github.com/bclubb/possessive | lib/possessive.rb | Ruby | mit | 47 | master | 242 | # encoding: utf-8
String.class_eval do
def possessive
return self if self.empty?
self + ('s' == self[-1,1] ? Possessive::APOSTROPHE_CHAR : Possessive::APOSTROPHE_CHAR+"s")
end
end
module Possessive
APOSTROPHE_CHAR = '’'
end |
github | bclubb/possessive | https://github.com/bclubb/possessive | test/test_possessive.rb | Ruby | mit | 47 | master | 382 | # encoding: utf-8
require 'helper'
class TestPossessive < Test::Unit::TestCase
test "Possessive with a normal string" do
assert_equal "Brian’s", "Brian".possessive
end
test "Possessive with a string ending with s" do
assert_equal "Steelers’", "Steelers".possessive
end
test "Possessive with an empt... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | openapi_contracts.gemspec | Ruby | mit | 47 | main | 1,042 | $LOAD_PATH.push File.expand_path('lib', __dir__)
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = 'openapi_contracts'
s.version = ENV.fetch 'VERSION', '0.14.0'
s.authors = ['mkon']
s.email = ['konstantin@munteanu.de']
s.homepage = 'https://githu... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | Gemfile | Ruby | mit | 47 | main | 331 | source 'https://rubygems.org'
gemspec
group :development, :test do
gem 'byebug'
end
if (version = ENV['ACTIVESUPPORT'])
gem 'activesupport', "~> #{version}.0"
end
if (version = ENV['JSON_SCHEMER'])
gem 'json_schemer', "~> #{version}.0"
end
if (version = ENV['ACTIVESUPPORT'])
gem 'activesupport', "~> #{versi... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts_spec.rb | Ruby | mit | 47 | main | 876 | RSpec.describe OpenapiContracts do
include_context 'when using GET /user'
describe '.hash_bury' do
subject { described_class.hash_bury({}, %i(foo bar), 'test') }
it { is_expected.to eq({foo: {bar: 'test'}}) }
end
describe '.hash_bury!' do
subject { {}.tap { |h| described_class.hash_bury!(h, %i(fo... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/spec_helper.rb | Ruby | mit | 47 | main | 349 | if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start do
add_filter '/spec'
end
SimpleCov.minimum_coverage 99
end
require 'rubygems'
require 'bundler'
Bundler.require :default, 'test'
require 'json_spec'
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
FIXTURES_PATH = Pathname.n... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/support/test_response.rb | Ruby | mit | 47 | main | 296 | class TestResponse < Rack::Response
# Rack::Response can not access request
# Make our response behave more like ActionDispatch::Response
attr_accessor :request
end
class TestRequest < Rack::Request
def self.build(path, opts = {})
new Rack::MockRequest.env_for(path, opts)
end
end |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/support/setup_context.rb | Ruby | mit | 47 | main | 3,176 | RSpec.shared_context 'when using GET /user' do
let(:response) do
TestResponse[response_status, response_headers, response_body].tap do |resp|
resp.request = TestRequest.build(path, method:)
end
end
let(:doc) { OpenapiContracts::Doc.parse(FIXTURES_PATH.join('openapi')) }
let(:method) { 'GET' }
le... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/doc_spec.rb | Ruby | mit | 47 | main | 879 | RSpec.describe OpenapiContracts::Doc do
subject(:doc) { described_class.parse(openapi_dir) }
let(:openapi_dir) { FIXTURES_PATH.join('openapi') }
describe '.parse' do
subject(:defined_doc) { described_class.parse(openapi_dir, 'other.openapi.yaml') }
it 'parses default document when not defined' do
... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/match_spec.rb | Ruby | mit | 47 | main | 1,119 | RSpec.describe OpenapiContracts::Match do
subject do
described_class.new(doc, response, options)
end
let(:options) { {} }
before { allow(OpenapiContracts).to receive(:collect_coverage).and_return(true) }
include_context 'when using GET /user'
it { is_expected.to be_valid }
it 'registers the cover... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/payload_parser_spec.rb | Ruby | mit | 47 | main | 1,416 | RSpec.describe OpenapiContracts::PayloadParser do
describe '.parse(media_type, raw_body)' do
subject { described_class.parse(media_type, raw_body) }
context 'when the media-type is application/json' do
let(:media_type) { 'application/json' }
let(:raw_body) { '{"hello":"world"}' }
it 'parse... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/operation_router_spec.rb | Ruby | mit | 47 | main | 1,268 | RSpec.describe OpenapiContracts::OperationRouter do
subject(:router) { described_class.new(doc) }
let(:doc) { OpenapiContracts::Doc.parse(FIXTURES_PATH.join('openapi')) }
describe '#route(path, method)' do
subject { router.route(path, method) }
context 'when routing "GET /messages/acbd1234"' do
l... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/coverage_spec.rb | Ruby | mit | 47 | main | 2,596 | RSpec.describe OpenapiContracts::Coverage do
subject(:coverage) { doc.coverage }
let(:doc) { OpenapiContracts::Doc.parse(openapi_dir) }
let(:openapi_dir) { FIXTURES_PATH.join('openapi') }
describe '.merge_reports' do
subject { described_class.merge_reports(doc, *[file1, file2, file3].map(&:path)) }
l... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/validators/headers_spec.rb | Ruby | mit | 47 | main | 1,163 | RSpec.describe OpenapiContracts::Validators::Headers do
subject { described_class.new(stack, env) }
let(:env) { OpenapiContracts::Env.new(operation:, response:) }
let(:operation) { doc.operation_for(path, method) }
let(:stack) { ->(errors) { errors } }
include_context 'when using GET /user'
context 'when... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/validators/request_body_spec.rb | Ruby | mit | 47 | main | 1,779 | RSpec.describe OpenapiContracts::Validators::RequestBody do
subject { described_class.new(stack, env) }
let(:env) do
OpenapiContracts::Env.new(operation:, response:, request: response.request)
end
let(:operation) { doc.operation_for(path, method) }
let(:stack) { ->(errors) { errors } }
include_context... |
github | mkon/openapi_contracts | https://github.com/mkon/openapi_contracts | spec/openapi_contracts/validators/parameters_spec.rb | Ruby | mit | 47 | main | 3,742 | require 'active_support/core_ext/object/json'
RSpec.describe OpenapiContracts::Validators::Parameters do
subject { described_class.new(stack, env) }
include_context 'when using GET /pets'
let(:env) { OpenapiContracts::Env.new(operation:, request:, response:) }
let(:operation) { doc.operation_for('/pets', met... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.